예제 #1
0
void CAndorSDK3Camera::PerformReleaseVersionCheck()
{
   //Release 2 / 2.1 checks
   try
   {
      IString * firmwareVersion = cameraDevice->GetString(L"FirmwareVersion");
      if (firmwareVersion && firmwareVersion->IsImplemented())
      {
         wstring ws = firmwareVersion->Get();
         if (ws == g_RELEASE_2_0_FIRMWARE_VERSION)
         {
            LogMessage("Warning: Release 2.0 Camera firmware detected! Please upgrade your camera to Release 3");
         }
         else if (ws == g_RELEASE_2_1_FIRMWARE_VERSION)
         {
            LogMessage("Warning: Release 2.1 Camera firmware detected! Please upgrade your camera to Release 3");
         }
      }
      cameraDevice->Release(firmwareVersion);
   }
   catch (NotImplementedException & e)
   {
      LogMessage(e.what());
   }
}
예제 #2
0
/**
* 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);
}
예제 #3
0
/**
* 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;

   // 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_, 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();

#ifdef TESTRESOURCELOCKING
   TestResourceLocking(true);
   LogMessage("TestResourceLocking OK",true);
#endif

   snapShotController_->poiseForSnapShot();
   return DEVICE_OK;
}
예제 #4
0
/**
* 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);
   }
}
예제 #5
0
/**
* 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;
   }

   for (int i = 0; i < GetNumberOfDevicesPresent(); i++)
   {
      if (!DEVICE_IN_USE[i])
      {
         try
         {
           cameraDevice = deviceManager->OpenDevice(i);
         }
         catch (exception & e)
         {
            LogMessage(e.what());
            continue;
         }
         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;
            DEVICE_IN_USE[i] = true;
            deviceInUseIndex_ = i;
            break;
         }
         else
         {
            deviceManager->CloseDevice(cameraDevice);
         }
      }
   }

   if (cameraDevice == NULL)
   {
      return DEVICE_NOT_CONNECTED;
   }

   // Description
   int ret = CreateProperty(MM::g_Keyword_Description, g_CameraDeviceDescription, MM::String, true);
   assert(DEVICE_OK == ret);

   //Camera Firmware
   wstring temp_ws = PerformReleaseVersionCheck();
   char * p_cameraInfoString = new char[MAX_CHARS_INFO_STRING];
   memset(p_cameraInfoString, 0, MAX_CHARS_INFO_STRING);
   wcstombs(p_cameraInfoString, temp_ws.c_str(), temp_ws.size());
   ret = CreateProperty(g_Keyword_FirmwareVersion, p_cameraInfoString, MM::String, true);
   assert(DEVICE_OK == ret);
   
   if (GetCameraPresent())
   {
      bufferControl = cameraDevice->GetBufferControl();
      startAcquisitionCommand = cameraDevice->GetCommand(L"AcquisitionStart");
      sendSoftwareTrigger = cameraDevice->GetCommand(L"SoftwareTrigger");
#ifdef linux
      AT_InitialiseUtilityLibrary();
#endif
   }
   else
   {
      return DEVICE_NOT_YET_IMPLEMENTED;
   }

   // CameraID(Serial))
   IString * cameraSerialNumber = cameraDevice->GetString(L"SerialNumber");
   temp_ws = cameraSerialNumber->Get();
   memset(p_cameraInfoString, 0, MAX_CHARS_INFO_STRING);
   wcstombs(p_cameraInfoString, temp_ws.c_str(), temp_ws.size());
   cameraDevice->Release(cameraSerialNumber);
   ret = CreateProperty(MM::g_Keyword_CameraID, p_cameraInfoString, MM::String, true);
   assert(DEVICE_OK == ret);
   wstring cameraSerialCheck(temp_ws);

   // Camera Model
   IString * cameraModel = cameraDevice->GetString(L"CameraModel");
   temp_ws = cameraModel->Get();
   memset(p_cameraInfoString, 0, MAX_CHARS_INFO_STRING);
   wcstombs(p_cameraInfoString, temp_ws.c_str(), temp_ws.size());
   cameraDevice->Release(cameraModel);
   ret = CreateProperty(g_Keyword_CameraModel, p_cameraInfoString, MM::String, true);
   assert(DEVICE_OK == ret);
   wstring cameraModelCheck(temp_ws);

   //Name and Interface type
   IString * cameraInterfaceType = cameraDevice->GetString(L"InterfaceType");
   temp_ws = cameraInterfaceType->Get();
   memset(p_cameraInfoString, 0, MAX_CHARS_INFO_STRING);
   wcstombs(p_cameraInfoString, temp_ws.c_str(), temp_ws.size());
   cameraDevice->Release(cameraInterfaceType);
   
   SetDefaultExpsoure(CalculateDefaultExposure(temp_ws));

   string s_cameraName = GenerateCameraName(DetermineCameraId(cameraSerialCheck), cameraModelCheck) + p_cameraInfoString;
   ret = CreateProperty(MM::g_Keyword_CameraName, s_cameraName.c_str(), MM::String, true);
   assert(DEVICE_OK == ret);

   // Current Software Version running
   memset(p_cameraInfoString, 0, MAX_CHARS_INFO_STRING);
   wcstombs(p_cameraInfoString, currentSoftwareVersion_.c_str(), currentSoftwareVersion_.size());
   ret = CreateProperty(g_Keyword_SoftwareVersion, p_cameraInfoString, MM::String, true);
   assert(DEVICE_OK == ret);

   ret = CreateProperty(g_Keyword_ExtTrigTimeout, "5000", MM::Integer, false);
   assert(DEVICE_OK == ret);

   delete [] p_cameraInfoString;

   InitialiseSDK3Defaults();

   //Create event manager and snapshot controller here

   eventsManager_ = new CEventsManager(cameraDevice);
   snapShotController_ = new SnapShotControl(cameraDevice, eventsManager_);
   callbackManager_ = new CCallBackManager(this, thd_, snapShotController_);

   // Properties
   electronicShutteringMode_property = new TEnumProperty(TAndorSDK3Strings::ELECTRONIC_SHUTTERING_MODE,
                                                         cameraDevice->GetEnum(L"ElectronicShutteringMode"), this, 
                                                         thd_, snapShotController_, false, false);

   preAmpGain_property = new TEnumProperty(TAndorSDK3Strings::GAIN_TEXT, 
                                           cameraDevice->GetEnum(L"SimplePreAmpGainControl"),
                                           this, thd_, snapShotController_, false, true);

   pixelEncoding_property = new TEnumProperty(TAndorSDK3Strings::PIXEL_ENCODING,
                                              cameraDevice->GetEnum(L"PixelEncoding"), this, thd_, 
                                              snapShotController_, true, false);

   binning_property = new TEnumProperty(MM::g_Keyword_Binning, cameraDevice->GetEnum(L"AOIBinning"),
                                        this, thd_, snapShotController_, false, false);
   //To support Rel2.1 cameras if no binning, always have 1x1
   AddAllowedValue(MM::g_Keyword_Binning, g_CameraDefaultBinning);

   aoi_property_ = new TAOIProperty(TAndorSDK3Strings::ACQUISITION_AOI, callbackManager_, false);

   pixelReadoutRate_property = new TEnumProperty(TAndorSDK3Strings::PIXEL_READOUT_RATE,
                                                 cameraDevice->GetEnum(L"PixelReadoutRateMapper"),
                                                 this, thd_, snapShotController_, false, false);

   temperatureControl_property = new TEnumProperty(TAndorSDK3Strings::TEMPERATURE_CONTROL,
                                                   cameraDevice->GetEnum(L"TemperatureControl"), this, thd_, 
                                                   snapShotController_, CIDZyla==DetermineCameraId(cameraSerialCheck), 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"),
                                                       callbackManager_, false);

   sensorCooling_property = new TBooleanProperty(TAndorSDK3Strings::SENSOR_COOLING, 
                                                 cameraDevice->GetBool(L"SensorCooling"), callbackManager_, false);

   rollingShutterGlobalClear_property = new TBooleanProperty(TAndorSDK3Strings::GLOBAL_CLEAR, 
                                                 cameraDevice->GetBool(L"RollingShutterGlobalClear"), callbackManager_, 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"), 
                                                 callbackManager_, true, false);

   overlap_property = new TBooleanProperty(TAndorSDK3Strings::OVERLAP, cameraDevice->GetBool(L"Overlap"),
                                           callbackManager_, false);

   exposureTime_property = new TFloatProperty(MM::g_Keyword_Exposure,
                                       new TAndorFloatValueMapper(cameraDevice->GetFloat(L"ExposureTime"), 1000),
                                       callbackManager_, false, false);
   
   frameRateLimits_property = new TFloatStringProperty(TAndorSDK3Strings::FRAME_RATE_LIMITS, 
                                                 cameraDevice->GetFloat(L"FrameRate"), callbackManager_, true, true);
   
   frameRate_property = new TFloatProperty(TAndorSDK3Strings::FRAME_RATE, 
                                             new TAndorFloatCache(cameraDevice->GetFloat(L"FrameRate")),  
                                             callbackManager_, false, true);
   //Aux TTL
   auxOutSignal_property = new TEnumProperty(TAndorSDK3Strings::AUX_SOURCE, 
                                             cameraDevice->GetEnum(L"AuxiliaryOutSource"), 
                                             this, thd_, snapShotController_, false, false);

   LSPSensorReadoutMode_property = new TEnumProperty("LightScanPlus-SensorReadoutMode", 
                                            cameraDevice->GetEnum(L"SensorReadoutMode"), 
                                            this, thd_, snapShotController_, false, false);

   LSPSequentialPortReadoutMode_property = new TBooleanProperty("LightScanPlus-AlternatingReadoutDirection", 
                                             cameraDevice->GetBool(L"AlternatingReadoutDirection"), 
                                             callbackManager_, false);

   LSPExposedPixelHeight_property = new TIntegerProperty("LightScanPlus-ExposedPixelHeight",
                                             cameraDevice->GetInteger(L"ExposedPixelHeight"), this, thd_, 
                                             snapShotController_, false, false);

   LSPScanSpeedControlEnable_property = new TBooleanProperty("LightScanPlus-ScanSpeedControlEnable", 
                                             cameraDevice->GetBool(L"ScanSpeedControlEnable"),
                                             callbackManager_, false);

   LSPLineScanSpeed_property =  new TFloatProperty("LightScanPlus-LineScanSpeed [lines/sec]", 
                                             cameraDevice->GetFloat(L"LineScanSpeed"),  
                                             callbackManager_, false, false);

   LSPRowReadTime_property = new TFloatProperty("LightScanPlus-RowReadTime", 
                                             cameraDevice->GetFloat(L"RowReadTime"),  
                                             callbackManager_, false, false);

   char errorStr[MM::MaxStrLength];
   if (false == eventsManager_->Initialise(errorStr) )
   {
      LogMessage(errorStr);
   }

   initialized_ = true;
   ResizeImageBuffer();
   try {
      snapShotController_->poiseForSnapShot();
   }
   catch (ComException & e) {
      string s("[Initialize] ComException thrown: ");
      s += e.what();
      LogMessage(s);
      return DEVICE_ERR;
   }
   catch (exception & e)
   {
      string s("[Initialize] Caught Exception with message: ");
      s += e.what();
      LogMessage(s);
      return DEVICE_ERR;
   }
   
   return DEVICE_OK;
}
예제 #6
0
/**
* 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;
}
예제 #7
0
/**
* 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);
   }
}