24 const unsigned char CR = 0xD;
25 const unsigned char LF = 0xA;
29 m_FlashlampRunning(false),
31 m_LaserEmission(false),
39 m_SerialCommunication(nullptr),
40 m_StayAliveMessageThread(),
41 m_SerialCommunicationMutex()
73 MITK_INFO <<
"[Quantel Laser Debug] sending: " << input->c_str();
75 return "SERIALSENDERROR";
79 message = *input +
'\n';
84 std::this_thread::sleep_for(std::chrono::milliseconds(50));
89 if ((returnvalue == 0) || (m.size() != 1))
90 return "SERIALRECEIVEERROR";
92 }
while (m.at(0) !=
LF);
94 std::this_thread::sleep_for(std::chrono::milliseconds(100));
96 MITK_INFO <<
"[Quantel Laser Debug] received: " << answer->c_str();
107 while (std::getline(stream, line))
109 *lines = *lines + line +
"\n";
114 MITK_ERROR <<
"[Quantel Laser Debug] Resource file was not valid";
121 TiXmlDocument xmlDoc;
125 TiXmlElement* root = xmlDoc.FirstChildElement(
"PumpLaser");
128 TiXmlElement* elementNode = root->FirstChildElement(
"Seriell");
129 TiXmlElement* element = elementNode->FirstChildElement(
"PortNumber");
131 element = elementNode->FirstChildElement(
"Baud");
139 MITK_ERROR <<
"[Quantel Laser Debug] Could not load configuration xml ";
160 MITK_ERROR <<
"[Quantel Laser Debug] " <<
"Can not open serial port";
166 std::string *command =
new std::string;
167 std::string answer(
"");
168 command->assign(
"STOP");
205 std::string *command =
new std::string;
206 std::string answer(
"");
207 command->assign(
"STATE");
209 MITK_INFO <<
"[Quantel Laser Debug] get state:" << answer;
210 if (answer ==
"STATE = 0\n")
212 else if(answer ==
"STATE = 1\n")
219 else if(answer ==
"STATE = 2\n")
226 else if(answer ==
"STATE = 3\n")
233 else if(answer ==
"STATE = 4\n")
240 else if (answer ==
"STATE = 5\n")
247 else if (answer ==
"STATE = 6\n")
254 else if (answer ==
"STATE = 7\n")
276 std::this_thread::sleep_for(std::chrono::seconds(2));
277 std::string *command =
new std::string;
278 std::string answer(
"");
279 command->assign(
"STATE");
292 std::string *command =
new std::string;
293 std::string answer(
"");
294 command->assign(
"RUN");
297 if (answer.at(0) ==
'O' && answer.at(1) ==
'K')
306 MITK_ERROR <<
"[Quantel Laser Debug] " <<
"Cannot start flashlamps." <<
" Laser is telling me: " << answer;
311 MITK_INFO <<
"[Quantel Laser Debug] " <<
"Flashlamps are already running";
324 std::string *command =
new std::string;
325 std::string answer(
"");
326 command->assign(
"STOP");
329 if (answer.at(0) ==
'O' && answer.at(1) ==
'K')
337 MITK_ERROR <<
"[Quantel Laser Debug] " <<
"Cannot Stop flashlamps." <<
" Laser is telling me: " << answer;
343 MITK_INFO <<
"[Quantel Laser Debug] " <<
"Flashlamps are not running";
353 std::string *command =
new std::string;
354 std::string answer(
"");
355 command->assign(
"QSW 1");
358 if (answer.at(0) ==
'O' && answer.at(1) ==
'K')
366 MITK_ERROR <<
"[Quantel Laser Debug] " <<
"Cannot start Qswitch." <<
" Laser is telling me: " << answer;
372 MITK_INFO <<
"[Quantel Laser Debug] " <<
"Laser is already emitting";
382 std::string *command =
new std::string;
383 std::string answer(
"");
384 command->assign(
"QSW 0");
387 if (answer.at(0) ==
'O' && answer.at(1) ==
'K')
392 MITK_ERROR <<
"[Quantel Laser Debug] " <<
"Cannot stop Q-switch.";
virtual bool StopQswitching()
virtual bool CloseConnection()
Closes the connection to the device.
virtual bool IsFlashing()
std::string m_DeviceName
Device Name.
DataCollection - Class to facilitate loading/accessing structured data.
mitk::SerialCommunication::Pointer m_SerialCommunication
serial communication interface
void LoadResorceFile(std::string filename, std::string *lines)
virtual bool OpenConnection(std::string configurationFile)
Opens a connection to the device.
virtual bool StopFlashing()
virtual bool StartQswitching()
Module * GetModule() const
DataBits m_DataBits
Number of Data Bits per token.
serial communication interface
PortNumber m_PortNumber
COM Port Number.
BaudRate m_BaudRate
COM Port Baud Rate.
virtual bool IsEmitting()
StopBits m_StopBits
number of stop bits per token
virtual std::string SendAndReceiveLine(const std::string *input, std::string *answer)
std::string m_XmlPumpLaserConfiguration
std::thread m_StayAliveMessageThread
virtual LaserState GetState()
virtual bool StartFlashing()
Parity m_Parity
Parity mode for communication.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.