Beispiel #1
0
//Laser Emission Status
int Stradus::OnLaserOnOff(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 << "?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();
          }

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

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

     return DEVICE_OK;
}
Beispiel #2
0
int Stradus::Shutdown()
{
   if (initialized_)
   {
      LaserOnOff(false);
	  initialized_ = false;
   }
   return DEVICE_OK;
}
int Cobolt::OnLaserOnOff(MM::PropertyBase* pProp, MM::ActionType eAct)
{
    
    std::ostringstream command;
    std::string answer;
    laserOn_ = "Undefined";
    if (eAct == MM::BeforeGet)
    {
        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;
        //fprintf(stderr,"Cobolt::LaserOnOff() %s\n",answer.c_str());
        
        if (answer.at(0) == '0')
            laserOn_ = "Off";
        else if (answer.at(0) == '1')
            laserOn_ = "On";
        else if (answer.at(1) == '0')
            laserOn_ = "Off";
        else if (answer.at(1) == '1')
            laserOn_ = "On";
        
        pProp->Set(laserOn_.c_str());
    }
    else if (eAct == MM::AfterSet)
    {
        pProp->Get(answer);
        if (answer == "Off")
        {
            LaserOnOff(false);
        }
        else
        {
            LaserOnOff(true);
        }
        
    }
    return DEVICE_OK;
}
Beispiel #4
0
int Stradus::SetOpen(bool open)
{
   LaserOnOff((long)open);
   return DEVICE_OK;
}
int Cobolt::Initialize()
{
    CPropertyAction* pAct = new CPropertyAction (this, &Cobolt::OnPowerSetPoint);
    int nRet = CreateProperty("PowerSetpoint", "0.00", MM::Float, false, pAct);
   if (DEVICE_OK != nRet)
        return nRet;
    CreateProperty("Minimum Laser Power", "0", MM::Float, true);
   // CreateProperty("Maximum Laser Power", "60", MM::Float, true);
    pAct = new CPropertyAction (this, &Cobolt::OnPowerSetMax);
    nRet = CreateProperty("Maximum Laser Power", "0", MM::Float, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;

    pAct = new CPropertyAction (this, &Cobolt::OnLaserOnOff);
    nRet = CreateProperty("Laser", "Off", MM::String, false, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    std::vector<std::string> commands;
    commands.push_back("Off");
    commands.push_back("On");
    SetAllowedValues("Laser", commands);
    
    
    pAct = new CPropertyAction (this, &Cobolt::OnHours);
    nRet = CreateProperty("Hours", "0.00", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnCurrent);
    nRet = CreateProperty("Current", "0.00", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnLaserStatus);
    nRet = CreateProperty("LaserStatus", "Off", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnInterlock);
    nRet = CreateProperty("Interlock", "Interlock Open", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnFault);
    nRet = CreateProperty("Fault", "No Fault", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnSerialNumber);
    nRet = CreateProperty("Serial Number", "0", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnVersion);
    nRet = CreateProperty("Version", "0", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    pAct = new CPropertyAction (this, &Cobolt::OnPowerStatus);
    nRet = CreateProperty("OutputPower", "0.00", MM::String, true, pAct);
    if (DEVICE_OK != nRet)
        return nRet;
    
    nRet = UpdateStatus();
    if (nRet != DEVICE_OK)
        return nRet;
    
    LaserOnOff(false);
    
    initialized_ = true;
    return DEVICE_OK;
}
int Cobolt::SetOpen(bool open)
{
    return LaserOnOff((int) open);
}