Пример #1
0
int ZStage::SetPositionSteps(long pos)
{
   // First Clear serial port from previous stuff
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   long delta = pos - curSteps_;

   // LIN 01-03-2012 ADDED C COMMAND BELOW. H128 USES C TO SET # STEPS THEN DOES U OR D WITHOUT ARGUMENTS
   std::ostringstream command;
   if (delta >= 0)
      command << "C," << delta; 
   else
      command << "C," << -delta;

   // send command
   ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK)
      return ret;

   // block/wait for acknowledge, or until we time out;
   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
   {
      int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
      return ERR_OFFSET + errNo;
   }

   // LIN 01-03-2012 DIRECTLY SEND "U" OR "D" AS APPROPRIATE
   if (delta >= 0)
      ret = SendSerialCommand(port_.c_str(), "U", "\r");
   else
      ret = SendSerialCommand(port_.c_str(), "D", "\r");

   if (ret != DEVICE_OK)
      return ret;

   // block/wait for acknowledge, or until we time out;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("R") == 0)
   {
      curSteps_ = pos;
      return DEVICE_OK;
   }
   else if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
   {
      int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
      return ERR_OFFSET + errNo;
   }

   return ERR_UNRECOGNIZED_ANSWER;   
}
Пример #2
0
/**
 * Gets and sets the Acceleration of the Prior stage travels
 */
int XYStage::OnAcceleration(MM::PropertyBase* pProp, MM::ActionType eAct) 
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   if (eAct == MM::BeforeGet) 
   {
      // send command
     ret = SendSerialCommand(port_.c_str(), "SRX", "\r"); // LIN 01-01-2012 H128 USES SRX INSTEAD OF SAS
      if (ret != DEVICE_OK)
         return ret;

      // block/wait for acknowledge, or until we time out;
      std::string answer;
      ret = GetSerialAnswer(port_.c_str(), "\r", answer);
      if (ret != DEVICE_OK)
         return ret;

      int acceleration = atoi(answer.c_str());
      if (acceleration < 1 || acceleration > 100) // LIN 01-01-2012 H128 ACCELERATION VALUE MAX 100 NOT 150
         return  ERR_UNRECOGNIZED_ANSWER;

      pProp->Set((long)acceleration);

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

      std::ostringstream os;
      os << "SRX," <<  acceleration; // LIN 01-01-2012 H128 USES SRX,acceleration INSTEAD OF SAS,acceleration

      // send command
      ret = SendSerialCommand(port_.c_str(), os.str().c_str(), "\r");
      if (ret != DEVICE_OK)
         return ret;

      // block/wait for acknowledge, or until we time out;
      std::string answer;
      ret = GetSerialAnswer(port_.c_str(), "\r", answer);
      if (ret != DEVICE_OK)
         return ret;

      if (answer.substr(0,1).compare("0") == 0)
      {
         return DEVICE_OK; // LIN 01-03-2012 note "0" is the correct response from H128
      }
      else if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
      {
         int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
         return ERR_OFFSET + errNo;
      }
      return ERR_UNRECOGNIZED_ANSWER;

   }

   return DEVICE_OK;
}
Пример #3
0
//Gets and sets the Acceleration of the stage travels
int XYStage::OnAcceleration(MM::PropertyBase* pProp, MM::ActionType eAct) 
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   if (eAct == MM::BeforeGet) 
   {
      ret = SendSerialCommand(port_.c_str(), "ACC", "\r");
      if (ret != DEVICE_OK)
         return ret;

      std::string answer;
      ret = GetSerialAnswer(port_.c_str(), "\r", answer);
      if (ret != DEVICE_OK)
         return ret;

      int acceleration = atoi(answer.c_str());

      pProp->Set((long)acceleration);

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

      std::ostringstream os;
      os << "ACC " <<  acceleration;

      ret = SendSerialCommand(port_.c_str(), os.str().c_str(), "\r");
      if (ret != DEVICE_OK)
         return ret;

      std::string answer;
      ret = GetSerialAnswer(port_.c_str(), "\r", answer);
      if (ret != DEVICE_OK)
         return ret;

      if (answer.substr(0,1).compare("A") == 0)
      {
         return DEVICE_OK;
      }
      return ERR_UNRECOGNIZED_ANSWER;

   }

   return DEVICE_OK;
}
Пример #4
0
//Moves stage relative to current position by given number of steps
int XYStage::SetRelativePositionSteps(long x, long y)
{
   MMThreadGuard guard(lock_);

   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   std::ostringstream command;
   command << "rel " << x << " " << y;

   ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("A") == 0)
   {
      return DEVICE_OK;
   }
   return ERR_UNRECOGNIZED_ANSWER;   
}
Пример #5
0
int XYStage::SetOrigin()
// LIN 01-01-2012 H128 USES Z INSTEAD OF PS TO SET ORIGIN AND IT DOES IT FOR ALL 3 AXES
{
   MMThreadGuard guard(lock_);

   // First Clear serial port from previous stuff
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   // send command
   ret = SendSerialCommand(port_.c_str(), "Z", "\r"); // LIN 01-01-2012 CHANGED COMMAND FOR ORIGIN FROM PS TO Z
   if (ret != DEVICE_OK)
      return ret;

   // block/wait for acknowledge, or until we time out;
   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("0") == 0)
   {
      return DEVICE_OK; // LIN 01-03-2012 note "0" is the correct response from H128
   }
   else if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
   {
      int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
      return ERR_OFFSET + errNo;
   }

   return ERR_UNRECOGNIZED_ANSWER; 
}
Пример #6
0
//System Faults or Operating Condition
int Stradus::OnFault(MM::PropertyBase* pProp, MM::ActionType eAct)
{
     std::ostringstream command;
     std::string answer;
     std::vector<std::string> tokens;
     std::string delims="=";
     
     if(eAct==MM::BeforeGet)
     {
        command << "?fd";
        int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
        if (ret != DEVICE_OK) return ret;
        CDeviceUtils::SleepMs(50);
        ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
        ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
        PurgeComPort(port_.c_str());
        if (ret != DEVICE_OK) return ret;

        Stradus::Tokenize(answer, tokens, delims);
        if ( 2 == tokens.size())
        {
		    answer=tokens.at(1).c_str();
        }
        pProp->Set(answer.c_str());
     }
     else
        if(eAct==MM::AfterSet)
        {
            //Read Only, Do Nothing
        }

     return DEVICE_OK;

}
Пример #7
0
int XYStage::SetPositionSteps(long x, long y)
{
   MMThreadGuard guard(lock_);

   // First Clear serial port from previous stuff
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   std::ostringstream command;
   command << "G," << x << "," << y;

   // send command
   ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK)
      return ret;

   // block/wait for acknowledge, or until we time out;
   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("R") == 0)
   {
      return DEVICE_OK; // LIN 01-03-2012 note "R" is the correct response from H128
   }
   else if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
   {
      int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
      return ERR_OFFSET + errNo;
   }

   return ERR_UNRECOGNIZED_ANSWER;   
}
Пример #8
0
int Stradus::GetOpen(bool& open)
{
   long state;
   std::ostringstream command;
   std::string answer;
   std::vector<std::string> tokens;
   std::string delims="=";

   command << "?le";
   int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK) return ret;
   CDeviceUtils::SleepMs(50);
   ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
   ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
   PurgeComPort(port_.c_str());
   if (ret != DEVICE_OK) return ret;

   Stradus::Tokenize(answer, tokens, delims);
   if ( 2 == tokens.size())
   {
   		answer=tokens.at(1).c_str();
   }

   state=atol(answer.c_str());
   if (state==1)
      open = true;
   else if (state==0)
      open = false;

   return DEVICE_OK;
}
// private and expects caller to:
// 1. guard the port
// 2. purge the port
int CArduinoNeoPixelHub::GetControllerVersion(int& version)
{
   int ret = DEVICE_OK;
   version = 0;

  if(!portAvailable_)
    return ERR_NO_PORT_SET;

  std::string answer;

  ret = SendSerialCommand(port_.c_str(), "V", "\r");
  if (ret != DEVICE_OK)
      return ret;

   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK) {
      return ret;
   }

     if (answer != "ArduinoNeoPixelShutter" && answer != "\nArduinoNeoPixelShutter") {
      return ERR_BOARD_NOT_FOUND;
     }
   version = 1; 
   return ret;

}
Пример #10
0
//Moves stage to given absolute z coordinate
int ZStage::SetPositionSteps(long pos)
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   std::ostringstream command;
   command << "absz " << pos;

   ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("A") == 0)
   {
      curSteps_ = pos;
      return DEVICE_OK;
   }

   return ERR_UNRECOGNIZED_ANSWER;   
}
Пример #11
0
int Cobolt::OnFault(MM::PropertyBase* pProp, MM::ActionType /* eAct */)
{
    
    std::ostringstream command;
    std::string answer;
    
    command << "f? ";
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK) return ret;
    
    if (answer.at(0) == '0')
        fault_ = "No Fault";
    else if (answer.at(0) == '1')
        fault_ = "Temperature Fault";
    else if (answer.at(0) == '3')
        fault_ = "Open Interlock";
    else if (answer.at(0) == '4')
        fault_ = "Constant Power Fault";
    
    pProp->Set(fault_.c_str());
    
    return DEVICE_OK;
}
Пример #12
0
int XYStage::Stop()
// LIN 01-01-2012 H128 USES I INSTEAD OF K AS COMMAND FOR STOP
{
   MMThreadGuard guard(lock_);
   int ret = SendSerialCommand(port_.c_str(), "I", "\r"); // LIN 01-01-2012 CHANGED COMMAND FOR STOP FROM K TO I
   if (ret != DEVICE_OK)
      return ret;

   // block/wait for acknowledge, or until we time out;
   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("R") == 0) // LIN 01-03-2012 note "R" is the correct response from H128
   {
      return DEVICE_OK;
   }
   else if (answer.substr(0, 1).compare("E") == 0 && answer.length() > 2) // LIN 01-03-2012 note I don't think the H128 reports E## errors but we can leave this in
   {
      int errNo = atoi(answer.substr(2).c_str()); // LIN 01-03-2012 note here the error number is extracted, atol converts string to short integer
      return ERR_OFFSET + errNo;
   }

   return ERR_UNRECOGNIZED_ANSWER;
}
Пример #13
0
//Reports coordinate the stage is at
int ZStage::GetPositionSteps(long& steps)
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   const char* command="PZ";

   ret = SendSerialCommand(port_.c_str(), command, "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
   {
      return ret;
   }

   if (answer.length() > 2 && answer.substr(0, 1).compare("E") == 0)
   {
      int errNo = atoi(answer.substr(2).c_str());
      return ERR_OFFSET + errNo;
   }
   else if (answer.length() > 0)
   {
      steps = atol(answer.c_str());
      curSteps_ = steps;
      return DEVICE_OK;
   }

   return ERR_UNRECOGNIZED_ANSWER;
}
Пример #14
0
// Checks if stage is busy, returns true if the stage is curently moving false otherwise
// This is effected by XYStage movement
bool ZStage::Busy()
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return false; 

   const char* command = "s";

   ret = SendSerialCommand(port_.c_str(), command, "\r");
   if (ret != DEVICE_OK)
      return false;

   std::string answer="";
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return false;
   
   if (answer.length() >=1)
   {
      int status = atoi(answer.substr(0,1).c_str());
      if (status==0) 
         return false;
      else 
         return true;
   }

   return false;
}
Пример #15
0
// XYStage utility functions
int XYStage::GetPositionStepsSingle(char axis, long& steps)
{
   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   std::stringstream command;
   command << "P" << axis;

   ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
   {
      return ret;
   }

   if (answer.length() > 0)
   {
      steps = atol(answer.c_str());
      return DEVICE_OK;
   }

   return ERR_UNRECOGNIZED_ANSWER;
}
Пример #16
0
int Stradus::LaserOnOff(int onoff)
{
     std::string answer;
     std::ostringstream command;

     if (onoff == 0)
     {
          command << "le=0";
          laserOn_ = "OFF";
     }
     else if (onoff == 1)
     {
          command << "le=1";
          laserOn_ = "ON";
     }
     int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
     if (ret != DEVICE_OK) return ret;
     CDeviceUtils::SleepMs(100);
     ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
     ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
     PurgeComPort(port_.c_str());
     if (ret != DEVICE_OK) return ret;

	 return DEVICE_OK;
}
Пример #17
0
//Peak Power Set/Get (Digital Modulation Only)
int Stradus::OnPulPwr(MM::PropertyBase* pProp, MM::ActionType eAct)
{
     std::string answer;
     std::ostringstream command;

     if (eAct == MM::BeforeGet)
     {
          command << "?pp";
          int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
          if (ret != DEVICE_OK) return ret;
          CDeviceUtils::SleepMs(50);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          PurgeComPort(port_.c_str());
          if (ret != DEVICE_OK) return ret;

          std::vector<std::string> tokens;
          std::string delims="=";

          Stradus::Tokenize(answer, tokens, delims);

          if ( 2 == tokens.size())
		  {
			   answer=tokens.at(1).c_str();
		  }

          pProp->Set(answer.c_str());
     }
     else if (eAct == MM::AfterSet)
     {
          pProp->Get((long&)pulPwr_);
          command << "pp=" << pulPwr_;
          int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
          if (ret != DEVICE_OK) return ret;
          CDeviceUtils::SleepMs(1000);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          PurgeComPort(port_.c_str());
          if (ret != DEVICE_OK) return ret;
     }

   return DEVICE_OK;
}
Пример #18
0
//Sends to corner and sets them postions to 0
int XYStage::Home()
{
   MMThreadGuard guard(lock_);

   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

	// move to corner
   ret = SendSerialCommand(port_.c_str(), "vj 30000 30000 0", "\r");
    if (ret != DEVICE_OK)
      return ret;
	
	std::string answer;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK)
       return ret;

    if (answer.substr(0,1).compare("A") == 0)
    {
		//set x postion to 0
	    ret = SendSerialCommand(port_.c_str(), "px = 0", "\r");
		if (ret != DEVICE_OK)
		   return ret;

		//set y postion to 0
	    ret = SendSerialCommand(port_.c_str(), "py = 0", "\r");
		if (ret != DEVICE_OK)
		   return ret;

	    std::string answer;
	    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
	    if (ret != DEVICE_OK)
		   return ret;

	    if (answer.substr(0,1).compare("A") == 0)
	    {
		  return DEVICE_OK;
        }
	}
   return ERR_UNRECOGNIZED_ANSWER;
}
Пример #19
0
void Sapphire::Send(string cmd)
{

	std::ostringstream messs;
	messs << "Sapphire::Send           " << cmd;
	LogMessage( messs.str().c_str(), true);

   int ret = SendSerialCommand(port_.c_str(), cmd.c_str(), carriage_return);
   if (ret!=DEVICE_OK)
      error_ = DEVICE_SERIAL_COMMAND_FAILED;
}
Пример #20
0
//Zeros XY position
int XYStage::SetOrigin()
{
   MMThreadGuard guard(lock_);

   int ret = ClearPort(*this, *GetCoreCallback(), port_);
   if (ret != DEVICE_OK)
      return ret;

   ret = SendSerialCommand(port_.c_str(), "PX 0", "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("A") == 0)
   {
		ret = ClearPort(*this, *GetCoreCallback(), port_);
	   if (ret != DEVICE_OK)
		  return ret;

	   ret = SendSerialCommand(port_.c_str(), "PY 0", "\r");
	   if (ret != DEVICE_OK)
		  return ret;

	   std::string answer2;
	   ret = GetSerialAnswer(port_.c_str(), "\r", answer2);
	   if (ret != DEVICE_OK)
		  return ret;

	   if (answer2.substr(0,1).compare("A") == 0)
	   {
		  return DEVICE_OK;
	   }
   }
   return ERR_UNRECOGNIZED_ANSWER; 
}
Пример #21
0
//External Power Control
int Stradus::OnEPC(MM::PropertyBase* pProp, MM::ActionType eAct)
{
    std::ostringstream command;
    std::string answer;

    if (eAct == MM::BeforeGet)
     {
          command << "?epc";
          int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
          if (ret != DEVICE_OK) return ret;
          CDeviceUtils::SleepMs(50);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          PurgeComPort(port_.c_str());
          if (ret != DEVICE_OK) return ret;

          std::vector<std::string> tokens;
          std::string delims="=";

          Stradus::Tokenize(answer, tokens, delims);

          if ( 2 == tokens.size())
		  {
			   answer=tokens.at(1).c_str();
		  }

	      if (answer == "0")
               epc_ = "OFF";
          else if (answer == "1")
               epc_ = "ON";

          pProp->Set(epc_.c_str());
     }
     else
          if (eAct == MM::AfterSet)
          {
            pProp->Get(answer);
            if (answer == "OFF")
            {
               epcOnOff(false); //Turn EPC off
            }
            else
                if(answer=="ON")
                {
                    epcOnOff(true); //Turn EPC on
                }
          }


     return DEVICE_OK;
}
Пример #22
0
int Cobolt::GetPowerSetpoint(double& value)
{
    std::ostringstream command;
    std::string answer;
    
    command << "p? ";
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK) return ret;
    value = atof(answer.c_str());
    
    return DEVICE_OK;
}
Пример #23
0
int Cobolt::OnVersion(MM::PropertyBase* pProp, MM::ActionType /* eAct */)
{
    std::ostringstream command;
    
    command << "ver? ";
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", version_);
    if (ret != DEVICE_OK) return ret;
     
    pProp->Set(version_.c_str());
    
    return DEVICE_OK;
}
Пример #24
0
int Cobolt::OnPowerStatus(MM::PropertyBase* pProp, MM::ActionType /* eAct */)
{
    std::string answer;
    std::ostringstream command;
    
    command << "pa? ";
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK) return ret;
    pProp->Set(atof(answer.c_str()));
    
    return DEVICE_OK;
}
Пример #25
0
int FocalPoint::QueryCommand(const char* command, std::string answer)
{
   if (port_ == g_Undefined)
   {
      return ERR_SERIAL_PORT_NOT_OPEN;
   }

   int ret = SendSerialCommand(port_.c_str(), command, "\n");
   if (ret != DEVICE_OK)
      return ret;

   ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);

   return ret;

}
Пример #26
0
int Xcite120PC::ExecuteCommand( const std::string& cmd, char* input, int inputLen, std::string* ret)
// Exedute a command, input, inputlen and ret are 0 by default
// if a pointer to input and a value for inputlen is given, this input is sent to the device
// if a pointer to ret is given, the return value of the device it returned in ret
{
  char* cmd_i;
  
  if (input==NULL) // no input
  {
    cmd_i = new char[cmd.size()+1];
    strcpy(cmd_i,cmd.c_str());
  }
  else  // command with input
  {
    cmd_i = new char[cmd.size() + inputLen + 1];
    strcpy( cmd_i, cmd.c_str() );
    strncat( cmd_i, input, inputLen );
  }
  
  // clear comport
  int s = PurgeComPort( port_.c_str() );
  if (s!=DEVICE_OK)
    return s;

  // send command
  s = SendSerialCommand( port_.c_str(), cmd_i, "\r" );
  if (s!=DEVICE_OK)
    return s;

  delete [] cmd_i;

  // get status
  std::string buff;
  s = GetSerialAnswer( port_.c_str(), "\r", buff );
  if (s!=DEVICE_OK)
    return s;
  if (!buff.compare(g_XciteRetERR))
    return DEVICE_ERR;
  if (buff.compare(g_XciteRetOK) && ret==NULL)
    return DEVICE_NOT_CONNECTED;

  if (ret!=NULL) // read return value
  {
    *ret = buff;
  }
  return DEVICE_OK;
}
Пример #27
0
int Cobolt::SetPowerSetpoint(double requestedPowerSetpoint)
{
    std::string answer;
    std::ostringstream command;
    std::ostringstream setpointString;
	// Check that Requested value is below Max Power otherwise  trim it
	if(requestedPowerSetpoint> maxPower_/1000){
		requestedPowerSetpoint = maxPower_/1000;
	}
	setpointString << requestedPowerSetpoint;
	command << "p " <<setpointString.str();
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK) return ret;
    
    return DEVICE_OK;
}
Пример #28
0
int Cobolt::GetState(int &value)
{
    std::ostringstream command;
    std::string answer;
    
    command << "l? ";
    int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
    if (ret != DEVICE_OK) return ret;
    ret = GetSerialAnswer(port_.c_str(), "\r", answer);
    if (ret != DEVICE_OK) return ret;
    
    if (answer.at(0) == '0')
        value = 0;
    else if (answer.at(0) == '1')
        value = 1;
    
    return DEVICE_OK;
    
}
Пример #29
0
//Stops the current motion. N.B. This will effect ZStage movement
int XYStage::Stop()
{
   MMThreadGuard guard(lock_);

   int ret = SendSerialCommand(port_.c_str(), "STOP", "\r");
   if (ret != DEVICE_OK)
      return ret;

   std::string answer;
   ret = GetSerialAnswer(port_.c_str(), "\r", answer);
   if (ret != DEVICE_OK)
      return ret;

   if (answer.substr(0,1).compare("A") == 0)
   {
      return DEVICE_OK;
   }
   return ERR_UNRECOGNIZED_ANSWER;
}
Пример #30
0
//Digital Modulation On/Off
int Stradus::OnDigMod(MM::PropertyBase* pProp, MM::ActionType eAct)
{
    std::ostringstream command;
    std::string answer;

    if (eAct == MM::BeforeGet)
    {
          command << "?pul";
          int ret = SendSerialCommand(port_.c_str(), command.str().c_str(), "\r");
          if (ret != DEVICE_OK) return ret;
          CDeviceUtils::SleepMs(50);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          ret = GetSerialAnswer(port_.c_str(), "\r\n", answer);
          PurgeComPort(port_.c_str());
          if (ret != DEVICE_OK) return ret;


	      if (answer == "?PUL=0")
               digMod_ = "OFF";
          else if (answer == "?PUL=1")
               digMod_ = "ON";
          pProp->Set(digMod_.c_str());
     }
     else
     {
        if (eAct == MM::AfterSet)
        {
          pProp->Get(answer);
          if (answer == "OFF")
          {
               digModOnOff(false); //Turn laser off
          }
          else
            if(answer == "ON")
            {
               digModOnOff(true); //Turn laser on
            }
        }
     }
     return DEVICE_OK;
}