Skip to content
Snippets Groups Projects
Commit 11c4b50e authored by Christian Koernig's avatar Christian Koernig
Browse files

Fixes and added a "Clear Alarm" Tango command

parent b8c6c5a4
No related branches found
No related tags found
No related merge requests found
......@@ -420,8 +420,15 @@ class AmptekPX5(Device):
self.warn_stream("Cannot interpret line '%s'. Will be ignored for configuration loading!"%line.strip())
success = self.interface.SetTextConfiguration( ["RESC=YES"] + self.sort_commands(cmds, vals) )
if not success:
for cmd_str in self.sort_commands(cmds, vals ):
print(cmd_str)
success = self.interface.SetTextConfiguration( [cmd_str] )
if not success:
print("Failed sending command %s"%cmd_str)
self.set_state(tango.DevState.ALARM)
self.error_stream("Failed Setting the text configuration!")
for _,c in self.parameter_dicts.items():
self.load_config_dict(c)
@command(dtype_in=str)
def SaveConfigurationFile(self, filepath):
......@@ -540,7 +547,10 @@ class AmptekPX5(Device):
def GetTecVoltage(self, max_age_ms):
return self.get_status_attribute(max_age_ms, "TecVoltage")
@command
def ClearAlarm(self):
self.set_state(DevState.On)
self.dev_state()
def set_calibrationslope(self, val):
self._calibrationslope = val
......@@ -670,7 +680,7 @@ class AmptekPX5(Device):
"TEC Temp: {detector_temp:.1f}K\n"
"Board Temp: {board_temp:.1f}C\n"
"<<DPP STATUS END>>\n")
status = self.interface.UpdateStatus()
status = self.interface.updateStatus(0)
outstring = template.format( dev_type = status.DeviceType(),
serial_nb = status.SerialNb(),
......
......@@ -247,6 +247,11 @@ bool AmptekHardwareInterface::SetPresetCounts(int c){
* @return false on failure
*/
bool AmptekHardwareInterface::SetTextConfiguration(std::vector<std::string> commands){
std::cout << "Configuration is\n";
for (auto cmd :commands){
std::cout << "\t" << cmd << "\n";
}
std::cout << std::endl;
try{
stringstream cmdstream;
......@@ -258,6 +263,7 @@ bool AmptekHardwareInterface::SetTextConfiguration(std::vector<std::string> comm
// if max packet size (512) would be exceeded when adding this command, send the previous commands and clear the input stringstream
if( streamsize + cmd.size() > 511){
std::cout << "Send " << cmdstream.str() << std::endl;
expectAcknowledge( connection_handler->sendAndReceive( Packet::gernerateSetConfigurationRequest( cmdstream.str() ) ) );
cmdstream = stringstream();
}
......@@ -268,12 +274,18 @@ bool AmptekHardwareInterface::SetTextConfiguration(std::vector<std::string> comm
// if this is the last command in the loop, send the stringstream even if max size is not reached
if( i == commands.size()-1 ){
std::cout << "Send " << cmdstream.str() << std::endl;
expectAcknowledge( connection_handler->sendAndReceive( Packet::gernerateSetConfigurationRequest( cmdstream.str() ) ) );
}
}
}
catch( AmptekException& e){
std::cerr << e.what() << std::endl;
std::cerr << "Failed sending Text Config: " << e.what() << "\n";
std::cerr << "Configuration was\n";
for (auto cmd :commands){
std::cerr << "\t" << cmd << "\n";
}
std::cerr << std::endl;
current_state = ERROR;
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment