Skip to content

Commit

Permalink
revert the order change for some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-momoko committed Aug 29, 2024
1 parent 943b26e commit 1522bfd
Showing 1 changed file with 67 additions and 13 deletions.
80 changes: 67 additions & 13 deletions src/bb/image-io/rt_u3v.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class U3V {
devices_(num_sensor), buffers_(num_sensor), operation_mode_(OperationMode::Came1USB1), frame_cnt_(0), device_idx_(-1), disposed_(false), sim_mode_(sim_mode)
{
init_symbols();
log::debug("U3V:: 23-11-18 : updating obtain and write");
log::debug("U3V:: 24-08-29 : revert the order of AcquisitionStart and create stream as a default");
log::info("Using aravis-{}.{}.{}", arv_get_major_version(), arv_get_minor_version(), arv_get_micro_version());
}

Expand Down Expand Up @@ -877,6 +877,7 @@ class U3VRealCam: public U3V{
log::info("\tFake Device {}::{} : {}", i, "Command", "AcquisitionStart");
}
}else{
bool order_filp = false;
if (num_device < num_sensor_){
log::info("{} device is found; but the num_sensor is set to {}", num_device, num_sensor_);
throw std::runtime_error("Device number is not match, please set num_device again");
Expand Down Expand Up @@ -950,6 +951,7 @@ class U3VRealCam: public U3V{
}
if (is_gendc_){
frame_count_method_ = FrameCountMethod::TYPESPECIFIC3;
order_filp = true;
}
}
log::info("\tDevice/USB {}::{} : {}", i, "frame_count method is ",
Expand Down Expand Up @@ -1067,8 +1069,23 @@ class U3VRealCam: public U3V{
* ion-kit starts the acquisition before stream creation This is a tentative fix only in ion-kit due to hardware issue
* In aravis, the acquisition should be done afterward. Since this maps better with GenAPI, where buffers
* must be pushed to DataStream objectsbefore DataStream acquisition is started.
* refer to https://github.com/AravisProject/aravis/blob/2ebaa8661761ea4bbc4df878aa67b4a9e1a9a3b9/docs/reference/aravis/porting-0.10.md
*/
if (order_filp){
for (auto i=0; i<devices_.size(); ++i) {
arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode");

arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart");
}
}
//start streaming after AcquisitionStart
for (auto i=0; i<devices_.size(); ++i) {
devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_);
Expand All @@ -1080,6 +1097,22 @@ class U3VRealCam: public U3V{
}
}

if (! order_filp){
for (auto i=0; i<devices_.size(); ++i) {
arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode");

arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart");
}
}

for (auto i=0; i<devices_.size(); ++i) {
const size_t buffer_size = 1 * 1024 * 1024 * 1024; // 1GiB for each
auto n = (buffer_size + devices_[i].u3v_payload_size_ - 1) / devices_[i].u3v_payload_size_;
Expand Down Expand Up @@ -1370,6 +1403,7 @@ class U3VGenDC: public U3V{
log::info("\tFake Device {}::{} : {}", i, "Command", "AcquisitionStart");
}
}else{
bool order_filp = false;
if (num_sensor < num_sensor_){
log::info("{} camera is found; but the number is set to {}", num_sensor, num_sensor_);
throw std::runtime_error("Device number is not match, please set num_device again");
Expand Down Expand Up @@ -1449,9 +1483,11 @@ class U3VGenDC: public U3V{
if (strcmp(device_model_name, " ")==0){
is_param_integer_ = true;
frame_count_method_ = FrameCountMethod::TIMESTAMP;
arv_uv_device_set_usb_mode(devices_[i].device_, ARV_UV_USB_MODE_SYNC); //hotfix for v1.0
}
if (is_gendc_){
frame_count_method_ = FrameCountMethod::TYPESPECIFIC3;
order_filp = true;
}
}
log::info("\tDevice/USB {}::{} : {}", i, "frame_count method is ",
Expand Down Expand Up @@ -1539,18 +1575,6 @@ class U3VGenDC: public U3V{
}
log::info("\tDevice/USB {}::{} : {}", i, "OperationMode", operation_mode_in_string);
}

arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode");

arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart");
}

/*
Expand All @@ -1559,7 +1583,21 @@ class U3VGenDC: public U3V{
* must be pushed to DataStream objectsbefore DataStream acquisition is started.
* refer to https://github.com/AravisProject/aravis/blob/2ebaa8661761ea4bbc4df878aa67b4a9e1a9a3b9/docs/reference/aravis/porting-0.10.md
*/
if (order_filp){
for (auto i=0; i<devices_.size(); ++i) {
arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode");

arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart");
}
}
//start streaming after AcquisitionStart
for (auto i=0; i<devices_.size(); ++i) {
devices_[i].stream_ = arv_device_create_stream(devices_[i].device_, nullptr, nullptr, &err_);
Expand All @@ -1571,6 +1609,22 @@ class U3VGenDC: public U3V{
}
}

if (! order_filp){
for (auto i=0; i<devices_.size(); ++i) {
arv_device_set_string_feature_value(devices_[i].device_, "AcquisitionMode", arv_acquisition_mode_to_string(ARV_ACQUISITION_MODE_CONTINUOUS), &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionMode");

arv_device_execute_command(devices_[i].device_, "AcquisitionStart", &err_);
if (err_) {
throw std::runtime_error(err_->message);
}
log::info("\tDevice/USB {}::{} : {}", i, "Command", "AcquisitionStart");
}
}

for (auto i=0; i<devices_.size(); ++i) {
const size_t buffer_size = 1 * 1024 * 1024 * 1024; // 1GiB for each
auto n = (buffer_size + devices_[i].u3v_payload_size_ - 1) / devices_[i].u3v_payload_size_;
Expand Down

0 comments on commit 1522bfd

Please sign in to comment.