void Controller::GenerateDescription() { string str = "CoolLED pE300."; Purge(); Send("XVER"); ReceiveOneLine();//Mainboard version returned str += " Mainboard: v" + buf_string_.substr(8); ReceiveOneLine();//Skip hardware version ReceiveOneLine();//Skip data version ReceiveOneLine();//Pod version returned str += " Pod: v" + buf_string_.substr(8); CreateProperty(MM::g_Keyword_Description, str.c_str(), MM::String, true); }
void Controller::GetUpdate() { MMThreadGuard myLock(lock_); { string propName; Purge(); Send("CSS?"); do { ReceiveOneLine(); } while (0 != buf_string_.compare(0, 3, "CSS", 0, 3)); globalState_ = false; //Record intensities and first LED on for (unsigned int i = 0; i < 3; i++) { //Read the intensity channelIntensities_[i] = atol(buf_string_.substr(6 + i * 6, 3).c_str()); string t = buf_string_.substr(4 + i * 6, 1); channelSelection_[i] = buf_string_.substr(4 + i * 6, 1) == "S" ? 1 : 0; propName = g_Keyword_Intensity; propName.push_back('A' + (char)i); intensityUpdated_[i] = true;; UpdateProperty(propName.c_str()); propName = g_Keyword_Selection; propName.push_back('A' + (char)i); selectionUpdated_[i] = true; UpdateProperty(propName.c_str()); globalState_ |= buf_string_.substr(5 + i * 6, 1) == "N"; globalStateUpdated_ = true; } } }
int Controller::ReadChannelLabels() { buf_tokens_.clear(); string label; Purge(); Send("LAMS"); do { ReceiveOneLine(); buf_tokens_.push_back(buf_string_); } while(! buf_string_.empty()); for (unsigned int i=0;i<buf_tokens_.size();i++) { if (buf_tokens_[i].substr(0,3).compare("LAM")==0) { channelLetters_.push_back(buf_tokens_[i][4]); // Read 4th character string label = buf_tokens_[i].substr(6); StripString(label); channelLabels_.push_back(label); } } if (channelLabels_.size() == 0) return DEVICE_ERR; else return DEVICE_OK; }
int Controller::OnChannelWave(MM::PropertyBase* pProp, MM::ActionType eAct, long channel) { string wavelength; if (eAct == MM::BeforeGet && waveUpdated_[channel]) { pProp->Set(channelWave_[channel].c_str()); waveUpdated_[channel] = false; } else if (eAct == MM::AfterSet) { pProp->Get(wavelength); //LOAD:<wavelength> loads that particular wavelength in the channel stringstream msg; msg << "LOAD:" << wavelength; MMThreadGuard myLock(lock_); Purge(); Send(msg.str()); do { ReceiveOneLine(); } while (buf_string_.size() == 0); } return HandleErrors(); }
void Controller::SetIntensity(long intensity, long index) { stringstream msg; msg << "C" << channelLetters_[index] << "I" << intensity; Purge(); Send(msg.str()); ReceiveOneLine(); }
void Controller::SetIntensity(long intensity, long index) { stringstream msg; msg << "C" << string(1, 'A' + (char)index) << "I" << intensity; { MMThreadGuard myLock(lock_); Purge(); Send(msg.str()); ReceiveOneLine(); } }
///////////////////////////////////////////// // Property Generators ///////////////////////////////////////////// void Controller::GeneratePropertyLockPod() { CPropertyAction* pAct = new CPropertyAction(this, &Controller::OnLockPod); CreateProperty(g_Keyword_PodLock, "0", MM::Integer, false, pAct); AddAllowedValue(g_Keyword_PodLock, "0"); AddAllowedValue(g_Keyword_PodLock, "1"); MMThreadGuard myLock(lock_); Purge(); Send("PORT:P=ON"); ReceiveOneLine(); }
int Controller::OnLockPod(MM::PropertyBase* pProp, MM::ActionType eAct) { if (eAct == MM::AfterSet) { long lockPod; pProp->Get(lockPod); MMThreadGuard myLock(lock_); Purge(); Send(lockPod == 1 ? "PORT:P=OFF" : "PORT:P=ON"); ReceiveOneLine(); } return HandleErrors(); }
void Controller::GetIntensity(long& intensity, long index) { stringstream msg; string ans; msg << "C" << channelLetters_[index] << "?"; Purge(); Send(msg.str()); ReceiveOneLine(); if (! buf_string_.empty()) if (0 == buf_string_.compare(0,2,msg.str(),0,2)) { intensity = atol(buf_string_.substr(2,3).c_str()); } }
int Controller::Initialize() { string strError; ReadGreeting(); Purge(); Send("XMODEL"); ReceiveOneLine();//Mainboard version returned int rlt = (int)buf_string_.find("pE-4000"); if (rlt < 0) { strError = "\r\n\r\nIncompatible device driver!\r\n"; strError += "The driver loaded: CoolLED-pE4000\r\n"; strError += "The device found: "; strError += buf_string_.substr(7); strError += "\r\n\r\n"; strError += "Internal Error Reference: "; SetErrorText(DEVICE_NOT_SUPPORTED, strError.c_str()); return DEVICE_NOT_SUPPORTED; } for (int i = 0; i < 4; i++) { channelIntensities_[i] = 0; channelSelection_[i] = 0; channelWave_[i] = ""; intensityUpdated_[i] = false; selectionUpdated_[i] = false; waveUpdated_[i] = false; } GenerateDescription(); GenerateChannelState(); GenerateChannelSelector(); GeneratePropertyIntensity(); GeneratePropertyState(); GeneratePropertyLockPod(); GetUpdate(); mThread_ = new PollingThread(*this); mThread_->Start(); initialized_ = true; return HandleErrors(); }
void Controller::GetIntensity(long& intensity, long index) { stringstream msg; string ans; msg << "C" << string(1, 'A' + (char)index) << "?"; { MMThreadGuard myLock(lock_); Purge(); Send(msg.str()); ReceiveOneLine(); } if (!buf_string_.empty()) if (0 == buf_string_.compare(0, 2, msg.str(), 0, 2)) { intensity = atol(buf_string_.substr(2, 3).c_str()); } }
int Controller::OnState(MM::PropertyBase* pProp, MM::ActionType eAct) { if (eAct == MM::BeforeGet && globalStateUpdated_) { pProp->Set(globalState_ ? (long)1 : (long)0); globalStateUpdated_ = false; } else if (eAct == MM::AfterSet) { long state; pProp->Get(state); globalState_ = state == 1; MMThreadGuard myLock(lock_); Purge(); Send(state == 1 ? "CSN" : "CSF"); ReceiveOneLine(); } return HandleErrors(); }
void Controller::GetState(long &state) { if (triggerMode_ == OFF) { Purge(); Send("C?"); long stateTmp = 0; for (unsigned int i=1;i<=channelLetters_.size();i++) { ReceiveOneLine(); if (! buf_string_.empty()) if (buf_string_[5]=='N') stateTmp = 1; } state = stateTmp; } else state = state_; }
void Controller::ReadGreeting() { MMThreadGuard myLock(lock_); ReceiveOneLine(); ReceiveOneLine(); }
int Sapphire::Initialize() { LogMessage("Sapphire::Initialize()"); GeneratePowerProperties(); GeneratePropertyState(); GenerateReadOnlyIDProperties(); std::stringstream msg; ReadGreeting(); //disable echo from the controller msg << "E" << "=" << 0; Send(msg.str()); if (ReceiveOneLine() != DEVICE_OK) return ERR_DEVICE_NOT_FOUND; //disable command prompt from controller msg.str(""); msg << ">" << "=" << 0; Send(msg.str()); ReceiveOneLine(); //msg.str(""); //msg << CDRHToken_ << "=" << 0; // Send(msg.str()); // ReceiveOneLine(); // enable control of the laser diode msg.str(""); msg << TECServoToken_ << "=" << 1; Send(msg.str()); ReceiveOneLine(); //disable external 'analogue' control of the laser // enable control of the laser diode //msg.str(""); //msg << externalPowerControlToken_ << "=" << 0; //Send(msg.str()); //ReceiveOneLine(); // query laser for power limits this->initLimits(); double llimit = this->minlp(); double ulimit = this->maxlp(); //if ( 1. > ulimit) // ulimit = 100.; // for off-line test // set the limits as interrogated from the laser controller. SetPropertyLimits(g_Keyword_PowerSetpoint, llimit, ulimit); // milliWatts initialized_ = true; return HandleErrors(); }
void Sapphire::ReadGreeting() { do { ReceiveOneLine(); } while (! buf_string_.empty()); }
void Controller::ReadGreeting() { do { ReceiveOneLine(); } while (! buf_string_.empty()); }