AT_64 CAndorSDK3Camera::GetTimeStamp(unsigned char* pBuf) { IInteger* imageSizeBytes = NULL; stringstream ss_logTimeStamp; AT_64 imageSize = 0; try { imageSizeBytes = cameraDevice->GetInteger(L"ImageSizeBytes"); imageSize = imageSizeBytes->Get(); cameraDevice->Release(imageSizeBytes); } catch (exception & e) { string s("[GetTimeStamp] Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(imageSizeBytes); } int i_imageSize = static_cast<int>(imageSize); // Move to end of image. This is assuming reading metadata right to left. unsigned char* puc_metadata = pBuf + i_imageSize; AT_64 i64_timestamp = 0; puc_metadata -= LENGTH_FIELD_SIZE; andoru32 timestampSize = *(reinterpret_cast<andoru32*>(puc_metadata)); puc_metadata -= CID_FIELD_SIZE; andoru32 cid = *(reinterpret_cast<andoru32*>(puc_metadata)); if (CID_FPGA_TICKS == cid) { i64_timestamp = *(reinterpret_cast<AT_64*>(puc_metadata - (timestampSize-CID_FIELD_SIZE))); ss_logTimeStamp << "[GetTimeStamp] found CID, value is: " << i64_timestamp; } else { ss_logTimeStamp << "[GetTimeStamp] No timestamp found in frame: " << thd_->GetImageCounter(); } return i64_timestamp; }
static void name_variable(Symbol *symbol, LString * file_name) { static LString k_orig_name = "orig_name"; if (symbol->get_name() != emptyLString) return; String base_name; String orig_name = get_orig_sym_name(symbol); if (orig_name != emptyString) { base_name = orig_name; } else { base_name = "_"; String source_file_name = condition_file_name(file_name); // add up to 10 characters at the end of the source file name // name Are you KIDDING! base_name += source_file_name.Right(10); base_name += "Tmp"; } // guaranteed to complete because of the IInteger. // Of course it would be faster if we randomized. for (IInteger ii = 0; ; ii++) { String next_name = base_name + ii.to_String(); if (!LString::exists(next_name)) { SymbolTable *st = symbol->get_symbol_table(); suif_assert_message(st != NULL, ("attempt to name unattached symbol")); st->change_name(symbol,next_name); return; } } suif_assert_message(0, ("Could not form a unique name")); }
ConstantLattice::ConstantLattice(IInteger value) : _key(B_CONST), _value(value) { assert(!value.is_undetermined()); assert(!value.is_signless_infinity()); }
void CAndorSDK3Camera::InitialiseDeviceCircularBuffer() { IInteger* imageSizeBytes = NULL; try { imageSizeBytes = cameraDevice->GetInteger(L"ImageSizeBytes"); AT_64 ImageSize = imageSizeBytes->Get(); image_buffers_ = new unsigned char * [NO_CIRCLE_BUFFER_FRAMES]; for (int i = 0; i < NO_CIRCLE_BUFFER_FRAMES; i++) { image_buffers_[i] = new unsigned char[static_cast<int>(ImageSize+7)]; unsigned char* pucAlignedBuffer = reinterpret_cast<unsigned char*>( (reinterpret_cast<unsigned long>( image_buffers_[i] ) + 7 ) & ~0x7); bufferControl->Queue(pucAlignedBuffer, static_cast<int>(ImageSize)); } cameraDevice->Release(imageSizeBytes); } catch (exception & e) { string s("[InitialiseDeviceCircularBuffer] Caught Exception [Live] with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(imageSizeBytes); } }
int CAndorSDK3Camera::SetupCameraForSeqAcquisition(long numImages) { int retCode = DEVICE_OK; bool b_memOkRet = false; IEnum * cycleMode = cameraDevice->GetEnum(L"CycleMode"); if (LONG_MAX != numImages) { cycleMode->Set(L"Fixed"); IInteger * frameCount = cameraDevice->GetInteger(L"FrameCount"); frameCount->Set(numImages); cameraDevice->Release(frameCount); b_memOkRet = InitialiseDeviceCircularBuffer(NUMBER_MDA_BUFFERS); } else { // When using the Micro-Manager GUI, this code is executed when entering live mode cycleMode->Set(L"Continuous"); snapShotController_->setupTriggerModeSilently(); b_memOkRet = InitialiseDeviceCircularBuffer(NUMBER_LIVE_BUFFERS); } if (b_memOkRet) { ResizeImageBuffer(); } else { bufferControl->Flush(); CleanUpDeviceCircularBuffer(); retCode = DEVICE_OUT_OF_MEMORY; } cameraDevice->Release(cycleMode); return retCode; }
void MultiWayGroup::generate_code(StatementList *x, IInteger bound_below, IInteger bound_above) { Expression *low_check = NULL; Expression *high_check = NULL; DataType *bool_type = get_type_builder(_env)->get_boolean_type(); // if there are no more than two entries, build if statements int lab_count = get_label_count(); if (lab_count <= 2) { for (int i=0;i < lab_count; i ++) { MultiWayBranchStatement::case_pair pair = _statement->get_case(i); low_check = create_binary_expression(_env, bool_type, k_is_equal_to, create_var_use(_decision), ie(pair.first)); x->append_statement(create_branch_statement(_env,low_check,pair.second)); } x->append_statement(create_jump_statement(_env,_default_lab)); delete _statement; _statement = 0; return; } if (bound_below.is_undetermined() || (_low_bound > bound_below + 1)) { low_check = create_binary_expression(_env, bool_type, k_is_less_than, create_var_use(_decision), ie(_low_bound)); x->append_statement(create_branch_statement(_env,low_check,_default_lab)); } if (bound_above.is_undetermined() || (_high_bound < bound_above)) { high_check = create_binary_expression(_env, bool_type, k_is_greater_than, create_var_use(_decision), ie(_high_bound)); x->append_statement(create_branch_statement(_env,high_check,_default_lab)); } // in fill the statement so that missing entries are added so as to // complete the table IInteger next_value = _low_bound; while (next_value < _high_bound) { if (!_statement->lookup_case(next_value)) { _statement->insert_case(next_value,_default_lab); } next_value ++; } x->append_statement(_statement); }
static String handle_static_int_constant(CPrintStyleModule *state, const SuifObject *obj) { IntConstant *expr = to<IntConstant>(obj); IInteger v = expr->get_value(); return(v.to_String()); }
/** Create an expression for byte offset of a group field. * */ Expression* NodeBuilder::get_field_offset_exp(FieldSymbol* fsym) { Expression *boffset = fsym->get_bit_offset(); if (!is_kind_of<IntConstant>(boffset)) { trash(fsym); SUIF_THROW(SuifException(String("Field offset not in IntConstant ") + to_id_string(fsym))); } IInteger v = to<IntConstant>(boffset)->get_value(); return int_const(v.div(IInteger(BITSPERBYTE))); }
static String handle_static_mark_statement(CPrintStyleModule *state, const SuifObject *obj) { MarkStatement *stmt = to<MarkStatement>(obj); String return_str; BrickAnnote *br = to<BrickAnnote>(stmt->peek_annote("line")); return_str = "Mark"; if (br != 0) { String file = to<StringBrick>(br->get_brick(1))->get_value(); IInteger line = to<IntegerBrick>(br->get_brick(0))->get_value(); return_str += " "; return_str += file + ":" + line.to_String(); } return(return_str); }
AT_64 CAndorSDK3Camera::GetTimeStamp(unsigned char* pBuf) { #if defined(linux) && defined(_LP64) typedef unsigned int AT_U32; #else typedef unsigned long AT_U32; #endif IInteger* imageSizeBytes = NULL; AT_64 imageSize = 0; try { imageSizeBytes = cameraDevice->GetInteger(L"ImageSizeBytes"); imageSize = imageSizeBytes->Get(); cameraDevice->Release(imageSizeBytes); } catch (exception & e) { string s("[GetTimeStamp] Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(imageSizeBytes); } AT_64 i64_timestamp = 0; bool foundTimestamp = false; AT_U8* puc_metadata = pBuf + static_cast<int>(imageSize); //start at end of buffer do { //move pointer to length field puc_metadata -= LENGTH_FIELD_SIZE; AT_U32 featureSize = *(reinterpret_cast<AT_U32*>(puc_metadata)); //move pointer to Chunk identifier puc_metadata -= CID_FIELD_SIZE; AT_U32 cid = *(reinterpret_cast<AT_U32*>(puc_metadata)); //move pointer to start of data puc_metadata -= (featureSize-CID_FIELD_SIZE); if (CID_FPGA_TICKS == cid) { i64_timestamp = *(reinterpret_cast<AT_64*>(puc_metadata)); foundTimestamp = true; } } while(!foundTimestamp && puc_metadata > pBuf); return i64_timestamp; }
/** * CAndorSDK3Camera constructor. * Setup default all variables and create device properties required to exist * before intialization. In this case, no such properties were required. All * properties will be created in the Initialize() method. * * As a general guideline Micro-Manager devices do not access hardware in the * the constructor. We should do as little as possible in the constructor and * perform most of the initialization in the Initialize() method. */ CAndorSDK3Camera::CAndorSDK3Camera() : CCameraBase<CAndorSDK3Camera> (), deviceManager(NULL), cameraDevice(NULL), bufferControl(NULL), startAcquisitionCommand(NULL), sendSoftwareTrigger(NULL), initialized_(false), b_cameraPresent_(false), number_of_devices_(0), deviceInUseIndex_(0), sequenceStartTime_(0), fpgaTSclockFrequency_(0), timeStamp_(0), defaultExposureTime_(0.0f), pDemoResourceLock_(0), image_buffers_(NULL), numImgBuffersAllocated_(0), currentSeqExposure_(0), keep_trying_(false), stopOnOverflow_(false) { // call the base class method to set-up default error codes/messages InitializeDefaultErrorMessages(); //Add in some others not currently in base impl, will show in CoreLog/Msgbox on error SetErrorText(DEVICE_BUFFER_OVERFLOW, " Circular Buffer Overflow code from MMCore"); SetErrorText(DEVICE_OUT_OF_MEMORY, " Allocation Failure - out of memory"); SetErrorText(DEVICE_SNAP_IMAGE_FAILED, " Snap Image Failure"); #ifdef TESTRESOURCELOCKING pDemoResourceLock_ = new MMThreadLock(); #endif thd_ = new MySequenceThread(this); // Create an atcore++ device manager deviceManager = new TDeviceManager; // Open a system device IDevice * systemDevice = deviceManager->OpenSystemDevice(); IInteger * deviceCount = systemDevice->GetInteger(L"DeviceCount"); SetNumberOfDevicesPresent(static_cast<int>(deviceCount->Get())); systemDevice->Release(deviceCount); IString * swVersion = systemDevice->GetString(L"SoftwareVersion"); currentSoftwareVersion_ = swVersion->Get(); systemDevice->Release(swVersion); deviceManager->CloseDevice(systemDevice); }
void rename_if_collision(SymbolTableObject *sto, SymbolTable *new_st) { LString orig = sto->get_name(); if (orig == emptyLString || !new_st->has_lookup_table_member(orig)) return; for (IInteger serial = 0; ; ++serial) { String suffix; serial.write(suffix, 10); LString trial(orig + suffix); if (!new_st->has_lookup_table_member(trial)) { sto->set_name(trial); return; } } }
void MarkGuardedFors:: do_procedure_definition(ProcedureDefinition *pd) { for (Iter<ForStatement> iter = object_iterator<ForStatement>(pd); iter.is_valid(); iter.next()) { ForStatement *the_for = &iter.current(); if (is_for_statement_guarded(the_for)) continue; IInteger ii = evaluate_for_statement_entry_test(the_for); if (ii.is_undetermined()) return; if (ii == 0) return; if (ii == 1) { set_for_statement_guarded(the_for); } } }
void BitVector::from_i_integer(IInteger new_value) { if (new_value < 0) { from_i_integer(~new_value); *this = invert(); return; } IInteger ii_hex_length = new_value.written_length(16); if (!ii_hex_length.is_c_size_t()) suif_error("out of memory address space"); size_t hex_length = ii_hex_length.c_size_t(); char *buffer = new char[hex_length + 3]; buffer[0] = '0'; buffer[1] = 'x'; new_value.write(&(buffer[2]), 16); read(buffer); delete[] buffer; }
bool CAndorSDK3Camera::InitialiseDeviceCircularBuffer(const unsigned numBuffers) { bool b_ret = false; IInteger* imageSizeBytes = NULL; numImgBuffersAllocated_ = 0; try { imageSizeBytes = cameraDevice->GetInteger(L"ImageSizeBytes"); AT_64 ImageSize = imageSizeBytes->Get(); image_buffers_ = new unsigned char * [numBuffers]; for (unsigned int i = 0; i < numBuffers; i++) { image_buffers_[i] = new unsigned char[static_cast<int>(ImageSize)]; memset(image_buffers_[i], 0, static_cast<int>(ImageSize)); ++numImgBuffersAllocated_; bufferControl->Queue(image_buffers_[i], static_cast<int>(ImageSize)); } cameraDevice->Release(imageSizeBytes); b_ret = true; } catch (bad_alloc & ba) { string s("[InitialiseDeviceCircularBuffer] Caught Bad Allocation with message: "); s += ba.what(); LogMessage(s); b_ret = false; } catch (exception & e) { string s("[InitialiseDeviceCircularBuffer] Caught Exception with message: "); s += e.what(); LogMessage(s); b_ret = false; cameraDevice->Release(imageSizeBytes); } return b_ret; }
/** * CAndorSDK3Camera constructor. * Setup default all variables and create device properties required to exist * before intialization. In this case, no such properties were required. All * properties will be created in the Initialize() method. * * As a general guideline Micro-Manager devices do not access hardware in the * the constructor. We should do as little as possible in the constructor and * perform most of the initialization in the Initialize() method. */ CAndorSDK3Camera::CAndorSDK3Camera() : CCameraBase<CAndorSDK3Camera> (), deviceManager(NULL), systemDevice(NULL), cameraDevice(NULL), cycleMode(NULL), bufferControl(NULL), startAcquisitionCommand(NULL), stopAcquisitionCommand(NULL), sendSoftwareTrigger(NULL), frameCount(NULL), frameRate(NULL), initialized_(false), b_cameraPresent_(false), number_of_devices_(0), sequenceStartTime_(0), fpgaTSclockFrequency_(0), timeStamp_(0), pDemoResourceLock_(0), image_buffers_(NULL), d_frameRate_(0), keep_trying_(false), roiX_(0), roiY_(0) { // call the base class method to set-up default error codes/messages InitializeDefaultErrorMessages(); readoutStartTime_ = GetCurrentMMTime(); #ifdef TESTRESOURCELOCKING pDemoResourceLock_ = new MMThreadLock(); #endif thd_ = new MySequenceThread(this); // Create an atcore++ device manager deviceManager = new TDeviceManager; // Open a system device systemDevice = deviceManager->OpenSystemDevice(); IInteger * deviceCount = systemDevice->GetInteger(L"DeviceCount"); SetNumberOfDevicesPresent(static_cast<int>(deviceCount->Get())); systemDevice->Release(deviceCount); if (GetNumberOfDevicesPresent() > 0) { for (int i = 0; i < GetNumberOfDevicesPresent(); i++) { cameraDevice = deviceManager->OpenDevice(i); IString * cameraFamilyString = cameraDevice->GetString(L"CameraFamily"); std::wstring temp_ws = cameraFamilyString->Get(); cameraDevice->Release(cameraFamilyString); if (temp_ws.compare(L"Andor sCMOS") == 0) { b_cameraPresent_ = true; break; } else { deviceManager->CloseDevice(cameraDevice); } } } if (GetCameraPresent()) { bufferControl = cameraDevice->GetBufferControl(); startAcquisitionCommand = cameraDevice->GetCommand(L"AcquisitionStart"); stopAcquisitionCommand = cameraDevice->GetCommand(L"AcquisitionStop"); cycleMode = cameraDevice->GetEnum(L"CycleMode"); sendSoftwareTrigger = cameraDevice->GetCommand(L"SoftwareTrigger"); frameCount = cameraDevice->GetInteger(L"FrameCount"); frameRate = cameraDevice->GetFloat(L"FrameRate"); snapShotController_ = new SnapShotControl(cameraDevice); } }
/** * CAndorSDK3Camera constructor. * Setup default all variables and create device properties required to exist * before intialization. In this case, no such properties were required. All * properties will be created in the Initialize() method. * * As a general guideline Micro-Manager devices do not access hardware in the * the constructor. We should do as little as possible in the constructor and * perform most of the initialization in the Initialize() method. */ CAndorSDK3Camera::CAndorSDK3Camera() : CCameraBase<CAndorSDK3Camera> (), deviceManager(NULL), systemDevice(NULL), cameraDevice(NULL), cycleMode(NULL), bufferControl(NULL), startAcquisitionCommand(NULL), stopAcquisitionCommand(NULL), sendSoftwareTrigger(NULL), frameCount(NULL), frameRate(NULL), initialized_(false), b_cameraPresent_(false), number_of_devices_(0), sequenceStartTime_(0), fpgaTSclockFrequency_(0), timeStamp_(0), pDemoResourceLock_(0), image_buffers_(NULL), numImgBuffersAllocated_(0), d_frameRate_(0), currentSeqExposure_(0), keep_trying_(false), b_eventsSupported_(false), roiX_(0), roiY_(0) { // call the base class method to set-up default error codes/messages InitializeDefaultErrorMessages(); //Add in some others not currently in base impl, will show in CoreLog/Msgbox on error SetErrorText(DEVICE_BUFFER_OVERFLOW, " Circular Buffer Overflow code from MMCore"); SetErrorText(DEVICE_OUT_OF_MEMORY, " Allocation Failure - out of memory"); SetErrorText(DEVICE_SNAP_IMAGE_FAILED, " Snap Image Failure"); readoutStartTime_ = GetCurrentMMTime(); #ifdef TESTRESOURCELOCKING pDemoResourceLock_ = new MMThreadLock(); #endif thd_ = new MySequenceThread(this); // Create an atcore++ device manager deviceManager = new TDeviceManager; // Open a system device systemDevice = deviceManager->OpenSystemDevice(); IInteger * deviceCount = systemDevice->GetInteger(L"DeviceCount"); SetNumberOfDevicesPresent(static_cast<int>(deviceCount->Get())); systemDevice->Release(deviceCount); if (GetNumberOfDevicesPresent() > 0) { for (int i = 0; i < GetNumberOfDevicesPresent(); i++) { cameraDevice = deviceManager->OpenDevice(i); IString * cameraFamilyString = cameraDevice->GetString(L"CameraFamily"); std::wstring temp_ws = cameraFamilyString->Get(); cameraDevice->Release(cameraFamilyString); if (temp_ws.compare(L"Andor sCMOS") == 0) { b_cameraPresent_ = true; break; } else { deviceManager->CloseDevice(cameraDevice); } } } if (GetCameraPresent()) { bufferControl = cameraDevice->GetBufferControl(); startAcquisitionCommand = cameraDevice->GetCommand(L"AcquisitionStart"); stopAcquisitionCommand = cameraDevice->GetCommand(L"AcquisitionStop"); cycleMode = cameraDevice->GetEnum(L"CycleMode"); sendSoftwareTrigger = cameraDevice->GetCommand(L"SoftwareTrigger"); frameCount = cameraDevice->GetInteger(L"FrameCount"); frameRate = cameraDevice->GetFloat(L"FrameRate"); snapShotController_ = new SnapShotControl(cameraDevice); } }
/** * Intializes the hardware. * Required by the MM::Device API. * Typically we access and initialize hardware at this point. * Device properties are typically created here as well, except * the ones we need to use for defining initialization parameters. * Such pre-initialization properties are created in the constructor. * (This device does not have any pre-initialization properties) */ int CAndorSDK3Camera::Initialize() { if (initialized_) return DEVICE_OK; if (0 == GetNumberOfDevicesPresent()) { initialized_ = false; return DEVICE_NOT_CONNECTED; } PerformReleaseVersionCheck(); // set property list // ----------------- // Name int nRet = CreateProperty(MM::g_Keyword_Name, g_CameraName, MM::String, true); if (DEVICE_OK != nRet) return nRet; // CameraName nRet = CreateProperty(MM::g_Keyword_CameraName, g_CameraDeviceName, MM::String, true); assert(nRet == DEVICE_OK); // Description nRet = CreateProperty(MM::g_Keyword_Description, g_CameraDeviceDescription, MM::String, true); if (DEVICE_OK != nRet) return nRet; // CameraID IString * cameraSerialNumber = cameraDevice->GetString(L"SerialNumber"); std::wstring temp_ws = cameraSerialNumber->Get(); char * p_cameraSerialNumber = new char[temp_ws.size() + 1]; memset(p_cameraSerialNumber, 0, temp_ws.size() + 1); wcstombs(p_cameraSerialNumber, temp_ws.c_str(), temp_ws.size()); cameraDevice->Release(cameraSerialNumber); nRet = CreateProperty(MM::g_Keyword_CameraID, p_cameraSerialNumber, MM::String, true); assert(nRet == DEVICE_OK); delete [] p_cameraSerialNumber; temp_ws.erase(4); bool b_zyla = false; if (0 == temp_ws.compare(L"VSC-") ) { b_zyla = true; } // Properties binning_property = new TEnumProperty(MM::g_Keyword_Binning, cameraDevice->GetEnum(L"AOIBinning"), this, thd_, snapShotController_, false, false); AddAllowedValue(MM::g_Keyword_Binning, g_CameraDefaultBinning); SetProperty(MM::g_Keyword_Binning, g_CameraDefaultBinning); preAmpGain_property = new TEnumProperty(TAndorSDK3Strings::GAIN_TEXT, cameraDevice->GetEnum(L"SimplePreAmpGainControl"), this, thd_, snapShotController_, false, true); electronicShutteringMode_property = new TEnumProperty(TAndorSDK3Strings::ELECTRONIC_SHUTTERING_MODE, cameraDevice->GetEnum(L"ElectronicShutteringMode"), this, thd_, snapShotController_, false, false); temperatureControl_proptery = new TEnumProperty(TAndorSDK3Strings::TEMPERATURE_CONTROL, cameraDevice->GetEnum(L"TemperatureControl"), this, thd_, snapShotController_, b_zyla ? true : false, false); pixelReadoutRate_property = new TEnumProperty(TAndorSDK3Strings::PIXEL_READOUT_RATE, cameraDevice->GetEnum(L"PixelReadoutRateMapper"), this, thd_, snapShotController_, false, false); pixelEncoding_property = new TEnumProperty(TAndorSDK3Strings::PIXEL_ENCODING, cameraDevice->GetEnum(L"PixelEncoding"), this, thd_, snapShotController_, true, false); accumulationLength_property = new TIntegerProperty(TAndorSDK3Strings::ACCUMULATE_COUNT, cameraDevice->GetInteger(L"AccumulateCount"), this, thd_, snapShotController_, false, false); temperatureStatus_property = new TEnumProperty(TAndorSDK3Strings::TEMPERATURE_STATUS, cameraDevice->GetEnum(L"TemperatureStatus"), this, thd_, snapShotController_, true, false); fanSpeed_property = new TEnumProperty(TAndorSDK3Strings::FAN_SPEED, cameraDevice->GetEnum(L"FanSpeed"), this, thd_, snapShotController_, false, false); spuriousNoiseFilter_property = new TBooleanProperty(TAndorSDK3Strings::SPURIOUS_NOISE_FILTER, cameraDevice->GetBool(L"SpuriousNoiseFilter"), this, thd_, snapShotController_, false); sensorCooling_property = new TBooleanProperty(TAndorSDK3Strings::SENSOR_COOLING, cameraDevice->GetBool(L"SensorCooling"), this, thd_, snapShotController_, false); overlap_property = new TBooleanProperty(TAndorSDK3Strings::OVERLAP, cameraDevice->GetBool(L"Overlap"), this, thd_, snapShotController_, false); triggerMode_Enum = cameraDevice->GetEnum(L"TriggerMode"); triggerMode_remapper = new TTriggerRemapper(snapShotController_, triggerMode_Enum); std::map<std::wstring, std::wstring> triggerMode_map; triggerMode_map[L"Software"] = L"Software (Recommended for Live Mode)"; triggerMode_map[L"Internal"] = L"Internal (Recommended for fast acquisitions)"; triggerMode_valueMapper = new TAndorEnumValueMapper( triggerMode_remapper, triggerMode_map); triggerMode_property = new TEnumProperty(TAndorSDK3Strings::TRIGGER_MODE, triggerMode_valueMapper, this, thd_, snapShotController_, false, false); readTemperature_property = new TFloatProperty(TAndorSDK3Strings::SENSOR_TEMPERATURE, cameraDevice->GetFloat(L"SensorTemperature"), this, thd_, snapShotController_, true, false); //frameRate_property = new TFloatProperty(TAndorSDK3Strings::FRAME_RATE, // new TAndorFloatHolder(snapShotController_, frameRate), // this, thd_, snapShotController_, false, true); exposureTime_property = new TFloatProperty(MM::g_Keyword_Exposure, new TAndorFloatValueMapper(cameraDevice->GetFloat(L"ExposureTime"), 1000), this, thd_, snapShotController_, false, false); aoi_property_ = new TAOIProperty(TAndorSDK3Strings::ACQUISITION_AOI, this, cameraDevice, thd_, snapShotController_, false); InitialiseSDK3Defaults(); // synchronize all properties // -------------------------- nRet = UpdateStatus(); if (nRet != DEVICE_OK) return nRet; initialized_ = true; ClearROI(); //MetaData / TimeStamp enable IBool * metadataEnable = NULL; IBool * mdTimeStampEnable = NULL; try { metadataEnable = cameraDevice->GetBool(L"MetadataEnable"); metadataEnable->Set(true); cameraDevice->Release(metadataEnable); } catch (exception & e) { string s("[Initialize] metadataEnable Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(metadataEnable); } try { mdTimeStampEnable = cameraDevice->GetBool(L"MetadataTimestamp"); mdTimeStampEnable->Set(true); cameraDevice->Release(mdTimeStampEnable); } catch (exception & e) { string s("[Initialize] metadataEnable TS Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(mdTimeStampEnable); } //TimestampClockFrequency IInteger* tsClkFrequency = NULL; try { tsClkFrequency = cameraDevice->GetInteger(L"TimestampClockFrequency"); fpgaTSclockFrequency_ = tsClkFrequency->Get(); cameraDevice->Release(tsClkFrequency); } catch (exception & e) { string s("[Initialize] TS Clk Frequency Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(tsClkFrequency); } eventsManager_ = new CEventsManager(cameraDevice); char errorStr[MM::MaxStrLength]; if (false == eventsManager_->Initialise(errorStr) ) { LogMessage(errorStr); } snapShotController_->poiseForSnapShot(); return DEVICE_OK; }
/** * Simple implementation of Sequence Acquisition * A sequence acquisition should run on its own thread and transport new images * coming of the camera into the MMCore circular buffer. */ int CAndorSDK3Camera::StartSequenceAcquisition(long numImages, double interval_ms, bool stopOnOverflow) { int retCode = DEVICE_OK; // The camera's default state is in software trigger mode, poised to make an // acquisition. Stop acquisition so that properties can be set for the // sequence acquisition. Also release the two buffers that were queued to // to take acquisition snapShotController_->leavePoisedMode(); if (IsCapturing()) { retCode = DEVICE_CAMERA_BUSY_ACQUIRING; } else { retCode = GetCoreCallback()->PrepareForAcq(this); } //MetaData / TimeStamp enable IBool * metadataEnable = NULL; IBool * mdTimeStampEnable = NULL; try { metadataEnable = cameraDevice->GetBool(L"MetadataEnable"); metadataEnable->Set(true); cameraDevice->Release(metadataEnable); } catch (exception & e) { string s("[StartSequenceAcquisition] metadataEnable Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(metadataEnable); } try { mdTimeStampEnable = cameraDevice->GetBool(L"MetadataTimestamp"); mdTimeStampEnable->Set(true); cameraDevice->Release(mdTimeStampEnable); } catch (exception & e) { string s("[StartSequenceAcquisition] metadataEnable TS Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(mdTimeStampEnable); } //TimestampClockFrequency IInteger* tsClkFrequency = NULL; try { tsClkFrequency = cameraDevice->GetInteger(L"TimestampClockFrequency"); fpgaTSclockFrequency_ = tsClkFrequency->Get(); cameraDevice->Release(tsClkFrequency); } catch (exception & e) { string s("[StartSequenceAcquisition] TS Clk Frequency Caught Exception with message: "); s += e.what(); LogMessage(s); cameraDevice->Release(tsClkFrequency); } if (DEVICE_OK == retCode) { InitialiseDeviceCircularBuffer(); if (LONG_MAX != numImages) { cycleMode->Set(L"Fixed"); frameCount->Set(numImages); } else { // When using the Micro-Manager GUI, this code is executed when entering live mode cycleMode->Set(L"Continuous"); snapShotController_->setupTriggerModeSilently(); } ResizeImageBuffer(); //// Set the frame rate to that held by the frame rate holder. Check the limits //double held_fr = 0.0; //if (frameRate->IsWritable()) //{ // held_fr = frameRate_floatHolder->Get(); // if (held_fr > frameRate->Max()) // { // held_fr = frameRate->Max(); // frameRate_floatHolder->Set(held_fr); // } // else if (held_fr < frameRate->Min()) // { // held_fr = frameRate->Min(); // frameRate_floatHolder->Set(held_fr); // } // frameRate->Set(held_fr); //} try { startAcquisitionCommand->Do(); if (snapShotController_->isSoftware()) { sendSoftwareTrigger->Do(); } } catch (exception & e) { string s("[StartSequenceAcquisition] Caught Exception [Live] with message: "); s += e.what(); LogMessage(s); return DEVICE_ERR; } keep_trying_ = true; thd_->Start(numImages, interval_ms); stopOnOverflow_ = stopOnOverflow; if (initialized_) { aoi_property_->SetReadOnly(true); } } return retCode; }
bool SuifPrinterModule::parse_and_print(ostream& output, const ObjectWrapper &obj, const LString &name, const String &str, int _indent, int deref = 0) { const Address what = obj.get_address(); const MetaClass *type = obj.get_meta_class(); // ObjectWrapper obj(what, type); //output << "str:deref = " << deref << endl; int l_sep = list_separator; if (str.length() == 0) { return false; } if (deref) _indent -= istep; int str_length = str.length(); bool need_indent = false; bool first_field = true; for (int i = 0; i < str_length; ++i) { if (str[i] != '%') { // If there are less than 2 extra stars don't print anything but the // fields. if (deref < 2) { // Need to check for \n and take care of indentation here switch(str[i]) { case '\n': output << str[i]; if (str[i+1]) { need_indent = true; indent(output, _indent); } break; case '\t': indent(output, istep); break; case '\b': _indent -= istep; break; default: output << str[i]; } } } else { ++i; if (str[i] == '%') { // Double % means print out a '%' output << '%'; } else { // This has to be cleaned up a bit ... //int field_deref = deref?deref-1:0; int field_deref = 0; char buff[256]; int j = 0; char c = str[i++]; if (c == '*') { ++field_deref; while ((c = str[i++]) == '*') ++ field_deref; } while (isalnum(c) || c == '_') { buff[j++] = c; c = str[i++]; } i -= 2; buff[j] = 0; // Now retrieve the particular field and print it. if (!strcmp(buff, "Cl")) { output << type->get_instance_name() << '(' << type->get_meta_class_id() << ") "; } else if (!strcmp(buff, "ii")) { // Deal with printing IInteger IInteger *ii = (IInteger *)what; output << ii->to_String().c_str(); } else if (!strcmp(buff, "i")) { // Deal with printing int output << *(int*)what; } else if (!strcmp(buff, "f")) { // float output << *(float*)what; } else if (!strcmp(buff, "d")) { // double output << *(double*)what; } else if (!strcmp(buff, "c")) { // char output << *(char*)what; } else if (!strcmp(buff, "b")) { // byte output << (int)*(char*)what; } else if (!strcmp(buff, "B")) { // bool output << *(bool*)what; } else if (!strcmp(buff, "ls")) { // Deal with printing LStrings LString str = *(LString*) what; output << str; } else if (!strcmp(buff, "s")) { // Deal with printing Strings String str = *(String*) what; output << str; } else if (!strcmp(buff, "n")) { // Deal with name of field if (!deref) output << name; } else if (!strcmp(buff, "P")) { if (obj.is_null()) output << "NULL"; else { PointerWrapper ptr_obj(obj); ObjectWrapper base_obj = ptr_obj.dereference(); if (ptr_obj.get_meta_class()->is_owning_pointer()) { size_t ref = retrieve_tag(obj.get_object()); output << "t" << ref<< ": "; print2(output, base_obj, emptyLString, _indent+istep, field_deref); } else { print_pointer(output, ptr_obj, emptyLString, _indent, deref); } } } else if (!strcmp(buff, "R")) { // print the ref # if (!what) output << "NULL"; else { // PointerMetaClass *p = (PointerMetaClass*) type; // const Address baseAddr = *(Address*) type; //ObjectWrapper obj(what, type); size_t ref = retrieve_tag(obj); output << "t" << ref<< ": "; } } else if (!strcmp(buff, "LS")) { list_separator = ' '; } else if (!strcmp(buff, "LN")) { list_separator = '\n'; } else if (!strcmp(buff, "LC")) { list_separator = ','; } else if (!strcmp(buff, "ANNOTES")) { // Special CASE for handling ANNOTATIONS AggregateWrapper agg(obj); LString field_name("_annotes"); FieldDescription *f = agg.get_field_description(field_name); if (!f) cerr << type->get_meta_class(what)->get_class_name() << ":No field '" << field_name << "' found to print!!!\n"; else { // Now we need to get the field offset and increment 'what' if (field_deref != 0) cerr << "Extra '*' for %ANNOTES\n"; FieldWrapper field = agg.get_field(field_name); if (need_indent) { indent(output, istep); need_indent = false; } char old_sep = list_separator; list_separator = '\n'; print2(output, field.get_object(), field_name, _indent+istep, 1); list_separator = old_sep; } } else if (j) { // Retrieve the field mentioned // The following cast works as we should reach here only if it // is not an elementary or pointer type. AggregateWrapper agg(obj); char *bf = buff; LString field_name(bf); FieldDescription *f = agg.get_field_description(field_name); if (!f) cerr << type->get_meta_class(what)->get_class_name() << ":No field '" << field_name << "' found to print!!!\n"; else { // Now we need to get the field offset and increment 'what' if (deref) if (!first_field) output << ' '; else first_field = false; FieldWrapper field = agg.get_field(field_name); //char *f_add = (char*)what + f->get_offset(); //indent(output, _indent+istep); if (need_indent) { indent(output, istep); need_indent = false; } if (deref && !field_deref) field_deref = deref - 1; //output << "\tstr:field_deref = " << field_deref << endl; print2(output, field.get_object(), field_name, _indent+istep, field_deref); } } } } } list_separator = l_sep; return true; }