예제 #1
0
int RAMPSXYStage::Initialize()
{
  LogMessage("XYStage: initialize");
  RAMPSHub* pHub = static_cast<RAMPSHub*>(GetParentHub());
  if (pHub)
  {
    char hubLabel[MM::MaxStrLength];
    pHub->GetLabel(hubLabel);
    SetParentID(hubLabel); // for backward comp.
  }
  else
    LogMessage(NoHubError);

  if (initialized_)
    return DEVICE_OK;

  // set property list
  // -----------------

  // Name
  int ret = CreateStringProperty(MM::g_Keyword_Name, g_XYStageDeviceName, true);
  if (DEVICE_OK != ret)
    return ret;

  // Description
  ret = CreateStringProperty(MM::g_Keyword_Description, "RAMPS XY stage driver", true);
  if (DEVICE_OK != ret)
    return ret;

  CPropertyAction* pAct = new CPropertyAction (this, &RAMPSXYStage::OnStepSize);
  CreateProperty(g_StepSizeProp, CDeviceUtils::ConvertToString(stepSize_um_), MM::Float, false, pAct);

  // Update lower and upper limits.  These values are cached, so if they change during a session, the adapter will need to be re-initialized
  ret = UpdateStatus();
  if (ret != DEVICE_OK)
    return ret;

  
  initialized_ = true;

  return DEVICE_OK;
}
int CArduinoNeoPixelShutter::Initialize()
{
   CArduinoNeoPixelHub* hub = static_cast<CArduinoNeoPixelHub*>(GetParentHub());
   if (!hub || !hub->IsPortAvailable()) {
      return ERR_NO_PORT_SET;
   }
   char hubLabel[MM::MaxStrLength];
   hub->GetLabel(hubLabel);
   SetParentID(hubLabel); // for backward comp.

   // set property list
   // -----------------
   
   // OnOff
   // ------
   CPropertyAction* pAct = new CPropertyAction (this, &CArduinoNeoPixelShutter::OnOnOff);
   int ret = CreateProperty("OnOff", "1", MM::Integer, false, pAct);
   if (ret != DEVICE_OK)
      return ret;

   pAct = new CPropertyAction (this, &CArduinoNeoPixelShutter::OnIntensity);
   ret = CreateProperty("Intensity", "255", MM::Integer, false, pAct);
   SetPropertyLimits("Intensity", 0, 255);
   if (ret != DEVICE_OK)
      return ret;

   pAct = new CPropertyAction(this, &CArduinoNeoPixelShutter::OnRedBrightness);
   ret = CreateProperty("Red brightness", "255", MM::Integer, false, pAct);
   SetPropertyLimits("Red brightness", 0, 255);
   if (ret != DEVICE_OK)
      return ret;
   pAct = new CPropertyAction(this, &CArduinoNeoPixelShutter::OnGreenBrightness);
   ret = CreateProperty("Green brightness", "255", MM::Integer, false, pAct);
   SetPropertyLimits("Green brightness", 0, 255);
   if (ret != DEVICE_OK)
      return ret;
   pAct = new CPropertyAction(this, &CArduinoNeoPixelShutter::OnBlueBrightness);
   ret = CreateProperty("Blue brightness", "255", MM::Integer, false, pAct);
   SetPropertyLimits("Blue brightness", 0, 255);
   if (ret != DEVICE_OK)
      return ret;
   pAct = new CPropertyAction(this, &CArduinoNeoPixelShutter::OnMulti);
   ret = CreateProperty("Multi", "8", MM::Integer, false, pAct);
   SetPropertyLimits("Multi", 0, 1<<3);
   if (ret != DEVICE_OK)
      return ret;


   // set shutter into the off state
   //WriteToPort(0);
   
   std::vector<std::string> vals;
   vals.push_back("0");
   vals.push_back("1");
   ret = SetAllowedValues("OnOff", vals);
   if (ret != DEVICE_OK)
      return ret;

   ret = UpdateStatus();
   if (ret != DEVICE_OK)
      return ret;

   changedTime_ = GetCurrentMMTime();
   initialized_ = true;

   return DEVICE_OK;
}