Beispiel #1
0
/**
* 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;
}
Beispiel #2
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;
}