示例#1
0
bool XYStage::Busy()
{
   // TODO: figure out how to get a busy signal on MF firmware
   if (firmware_ == "MF")
      return false;

   const char * commandX = "NPXm1";
   const char * commandY = "NPYm1";
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  commandX);
   if (ret != DEVICE_OK)
   {
      this->LogMessage("ExecuteCommand failed in XYStage::Busy");
      return false; // error, so say we're not busy
   }

   // first two chars should read 'PN'
   string response;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
   {
      this->LogMessage("GetAnswer failed in XYStage::Busy");
      return false; // error, so say we're not busy
   }

   // Note: if the controller reports that the motors are moving or settling, we'll consider the z-drive to be busy
   if (response.substr(0,2) == "PN") 
   {
      unsigned long status = strtol(response.substr(2,1).c_str(), NULL, 16);
      status &= 0x01;
      if (status != 0)
         return true;
   }

   // Repeat for Y
   ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  commandY);
   if (ret != DEVICE_OK)
   {
      this->LogMessage("ExecuteCommand failed in XYStage::Busy");
      return false; // error, so say we're not busy
   }

   // first two chars should read 'PN'
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
   {
      this->LogMessage("GetAnswer failed in XYStage::Busy");
      return false; // error, so say we're not busy
   }

   // Note: if the controller reports that the motors are moving or settling, we'll consider the z-drive to be busy
   if (response.substr(0,2) == "PN") 
   {
      unsigned long status = strtol(response.substr(2,1).c_str(), NULL, 16);
      status &= 0x01;
      if (status != 0)
         return true;
   }

   return false;
}
示例#2
0
/*
 * Requests current z postion from the controller.  This function does the actual communication
 */
int XYStage::GetPositionSteps(long& stepsX, long& stepsY)
{
   const char* cmdX ="NPXp" ;
   const char* cmdY ="NPYp" ;

   // retrieve x axis
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmdX);
   if (ret != DEVICE_OK)
      return ret;

   string response;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
      return ret;

   if (response.substr(0,2) == "PN") 
   {
      stepsX = strtol(response.substr(2).c_str(), NULL, 16);
   }
   else  
      return ERR_UNEXPECTED_ANSWER;

   // To 'translate' 'negative' numbers according to the Zeiss schema (there must be a more elegant way of doing this:
   long sign = strtol(response.substr(2,1).c_str(), NULL, 16);
   if (sign > 7)  // negative numbers
   {
      stepsX = stepsX - 0xFFFFFF - 1;
   }

   // retrieve y axis
   ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmdY);
   if (ret != DEVICE_OK)
      return ret;

   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
      return ret;

   if (response.substr(0,2) == "PN") 
   {
      stepsY = strtol(response.substr(2).c_str(), NULL, 16);
   }
   else  
      return ERR_UNEXPECTED_ANSWER;

   // To 'translate' 'negative' numbers according to the Zeiss schema (there must be a more elegant way of doing this:
   sign = strtol(response.substr(2,1).c_str(), NULL, 16);
   if (sign > 7)  // negative numbers
   {
      stepsY = stepsY - 0xFFFFFF - 1;
   }

   return DEVICE_OK;
}
示例#3
0
文件: ZStage.cpp 项目: bwagjor/Thesis
/*
 * Requests current z postion from the controller.  This function does the actual communication
 */
int ZStage::GetPositionSteps(long& steps)
{
   const char* cmd ="HPZp" ;
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmd);
   if (ret != DEVICE_OK)
      return ret;

   string response;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
      return ret;

   if (response.substr(0,2) == "PH") 
   {
      steps = strtol(response.substr(2).c_str(), NULL, 16);
   }
   else  
      return ERR_UNEXPECTED_ANSWER;

   // To 'translate' 'negative' numbers according to the Zeiss schema (there must be a more elegant way of doing this:
   long sign = strtol(response.substr(2,1).c_str(), NULL, 16);
   if (sign > 7)  // negative numbers
   {
      steps = steps - 0xFFFFFF - 1;
   }

   return DEVICE_OK;
}
示例#4
0
文件: ZStage.cpp 项目: bwagjor/Thesis
/*
 * Set stage in load sample mode
 */
int ZStage::OnLoadSample(MM::PropertyBase* pProp, MM::ActionType eAct)
{
//1: up
//0: down. but can also return 4.

   if (eAct == MM::BeforeGet)
   {
     const char* cmd = "HPZw";
     int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmd);
     if (ret != DEVICE_OK)
        return ret;

     string response;
     ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
     if (ret != DEVICE_OK)
        return ret;

     if (response.substr(0,2) == "PH") 
     {
        long state = strtol(response.substr(2).c_str(), NULL, 10);
        state=state==0 || state==4;
        pProp->Set(state);
     }
     else
        return ERR_UNEXPECTED_ANSWER;

     return DEVICE_OK;
   }
   else if (eAct == MM::AfterSet)
   {
      long state;
      pProp->Get(state);

     ostringstream cmd;
     cmd << "HPZW" << (!state);
     int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmd.str().c_str());
     if (ret != DEVICE_OK)
        return ret;
     return DEVICE_OK;
   }

   return DEVICE_OK;
}
示例#5
0
int PhotoModule::GetTurretPosition(int& /* position */)
{
   string cmd = "EPPo";
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(), cmd.c_str());
   if (ret != DEVICE_OK)
      return ret;

   string answer;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), answer);
   if (ret != DEVICE_OK)
      return ret;

   // I have no idea how the answer will be formatted.  For now, just log:
   ostringstream log;
   log << "Answer from scope: " << answer;
   this->LogMessage(log.str().c_str());

   return DEVICE_OK;
}
示例#6
0
// TODO: this doesn't work for MCU28
int XYStage::GetXYFirmwareVersion()
{
   // get firmware info
   const char * command = "NPTv0";
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  command);
   if (ret != DEVICE_OK)
      return ret;

   // first two chars should read 'PN'
   string response;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
      return ret;
   if (response.substr(0,2).compare("PN") == 0) 
   {
      xyFirmware_ = response.substr(2);
      firmware_ = response.substr(2,2);
   }
   return DEVICE_OK;
}
示例#7
0
文件: ZStage.cpp 项目: bwagjor/Thesis
int ZStage::GetLowerLimit()
{
   const char* cmd = "HPZl";
   int ret = g_hub.ExecuteCommand(*this, *GetCoreCallback(),  cmd);
   if (ret != DEVICE_OK)
      return ret;

   string response;
   ret = g_hub.GetAnswer(*this, *GetCoreCallback(), response);
   if (ret != DEVICE_OK)
      return ret;

   if (response.substr(0,2) == "PH") 
   {
      long steps = strtol(response.substr(2).c_str(), NULL, 16);
      lowerLimit_ = steps * stepSize_um_; 
   }
   else
      return ERR_UNEXPECTED_ANSWER;

   return DEVICE_OK;
}