21 #include "gclib_errors.h" 28 m_ErrorMessage(
"undefined"),
29 m_CurrentWavelength(0),
37 MITK_INFO <<
"[GalilMotor Debug] destroyed that motor";
47 while (std::getline(stream, line))
49 *lines = *lines + line +
"\n";
67 TiXmlElement* root = xmlDoc.FirstChildElement(
"Motor");
70 TiXmlElement* elementNode = root->FirstChildElement(
"Coefficients");
71 TiXmlElement* element = elementNode->FirstChildElement(
"lambda0");
73 element = elementNode->FirstChildElement(
"lambda1");
75 element = elementNode->FirstChildElement(
"lambda2");
77 element = elementNode->FirstChildElement(
"lambda3");
79 element = elementNode->FirstChildElement(
"lambda4");
81 element = elementNode->FirstChildElement(
"lambda5");
83 element = elementNode->FirstChildElement(
"lambda6");
85 element = elementNode->FirstChildElement(
"home");
87 elementNode = root->FirstChildElement(
"Signal");
88 element = elementNode->FirstChildElement(
"Signal-low");
90 element = elementNode->FirstChildElement(
"Signal-default");
92 element = elementNode->FirstChildElement(
"Signal-high");
94 elementNode = root->FirstChildElement(
"Seriell");
95 element = elementNode->FirstChildElement(
"PortNumber");
96 m_ComPort = std::stoi(element->GetText());
97 element = elementNode->FirstChildElement(
"Baud");
103 MITK_ERROR <<
"[GalilMotor Debug] Could not load configuration xml ";
105 std::string openCommand(
"COM" + std::to_string(
m_ComPort) +
" --baud " + std::to_string(
m_BaudRate) +
" --subscribe ALL --direct");
128 double posDouble = 0;
142 std::string positionCommand;
143 if (!isRecalibrating)
150 positionCommand =
"pos=" + std::to_string(posAbs);
156 MITK_INFO <<
"[Galil Debug] after BV: " << m_ReturnCode <<
"";
158 MITK_INFO <<
"[Galil Debug] after empty GProgramDownload: " << m_ReturnCode <<
"";
161 MITK_INFO <<
"[Galil Debug] after sending tune position(" << positionCommand <<
"): " << m_ReturnCode <<
"";
163 std::string galilProgramSTUNE;
165 m_ReturnCode = GProgramDownload(
m_GalilSystem, galilProgramSTUNE.c_str(), 0);
166 MITK_INFO <<
"[Galil Debug] after STUNE progam: " << m_ReturnCode << galilProgramSTUNE;
172 int success, pos = -1;
174 MITK_INFO <<
"[Galil Debug] after asking suc=? = " << m_ReturnCode <<
"; successfulTune = " << success;
176 MITK_INFO <<
"[Galil Debug] after asking pos=? = " << m_ReturnCode <<
"; pos = " << pos;
193 MITK_INFO <<
"[Galil Debug] after BV: " << m_ReturnCode <<
"";
196 MITK_INFO <<
"[Galil Debug] after empty GProgramDownload: " << m_ReturnCode <<
"";
198 std::string positionsCommand(
"#AUTO\n#PARA\nDA pos[0]\npoints = "+std::to_string(wavelengthList.size())+
"\nDM pos[" + std::to_string(wavelengthList.size()) +
"];\n");
200 for (
int wavelengthIterator = 0; wavelengthIterator < wavelengthList.size(); wavelengthIterator++)
202 positionsCommand +=
"pos[" + std::to_string(wavelengthIterator) +
"]=" + std::to_string(this->
GetPositionFromWavelength(wavelengthList[wavelengthIterator])) +
"\n";
204 positionsCommand +=
"EN\n";
206 m_ReturnCode = GProgramDownload(
m_GalilSystem, positionsCommand.c_str(), 0);
207 MITK_INFO <<
"[Galil Debug] after sending positions command(" << positionsCommand <<
"): " << m_ReturnCode <<
"";
212 MITK_INFO <<
"[Galil Debug] after empty GProgramDownload: " << m_ReturnCode <<
"";
214 std::string galilProgramFTUNE;
216 m_ReturnCode = GProgramDownload(
m_GalilSystem, galilProgramFTUNE.c_str(), 0);
217 MITK_INFO <<
"[Galil Debug] after FTUNE progam upload: " << m_ReturnCode <<
"";
225 MITK_INFO <<
"[Galil Debug] cycles = " << count;
227 MITK_INFO <<
"[Galil Debug] pos = " << count;
229 MITK_INFO <<
"[Galil Debug] points = " << count;
243 MITK_INFO <<
"[Galil Debug] after BV: " << m_ReturnCode <<
"";
246 MITK_INFO <<
"[Galil Debug] after empty GProgramDownload: " << m_ReturnCode <<
"";
248 std::string galilProgram;
251 m_ReturnCode = GProgramDownload(
m_GalilSystem, galilProgram.c_str(), 0);
252 MITK_INFO <<
"[Galil Debug] after home GProgramDownloadFile = " << m_ReturnCode <<
"; m_GalilSystem = " <<
m_GalilSystem;
254 m_ReturnCode = GCmd(m_GalilSystem,
"XQ");
257 m_ReturnCode = GCmdI(m_GalilSystem,
"suc=?", &val);
259 MITK_INFO <<
"[Galil Debug] after home execution = " << m_ReturnCode <<
"; m_GalilSystem = " << m_GalilSystem <<
" homed = " << val;
virtual bool OpenConnection(std::string configuration)
virtual bool CloseConnection()
double GetMaxWavelength()
void LoadResorceFile(std::string filename, std::string *lines)
double m_CurrentWavelength
int GetPositionFromWavelength(double wavelength)
bool FastTuneWavelengths(std::vector< double > wavelengthList)
std::string m_XmlOpoConfiguration
Module * GetModule() const
double m_WavelengthToStepCalibration[7]
double GetMinWavelength()
double GetCurrentWavelength()
bool TuneToWavelength(double wavelength, bool isRecalibrating)
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.