Skip to content
Snippets Groups Projects
Commit 19f493cd authored by ELATTAOUI's avatar ELATTAOUI
Browse files

Novelec part : mcce2_off cmd fixed.

parent 5be6c9bc
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,10 @@ protected : ...@@ -116,6 +116,10 @@ protected :
std::string check_and_extract_data (std::string resp_to_check, short command_sent); std::string check_and_extract_data (std::string resp_to_check, short command_sent);
private : private :
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
void is_allowed();
//- if true, parameters cannot be changed ! //- if true, parameters cannot be changed !
bool _is_measure_mode_on; bool _is_measure_mode_on;
//- if true, explicite response mode is enabled //- if true, explicite response mode is enabled
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</parent> </parent>
<groupId>fr.soleil.lib</groupId> <groupId>fr.soleil.lib</groupId>
<artifactId>Electrometers-${aol}-${library}-${mode}</artifactId> <artifactId>Electrometers-${aol}-${library}-${mode}</artifactId>
<version>2.5.0</version> <version>2.5.1</version>
<packaging>nar</packaging> <packaging>nar</packaging>
<name>Electrometers library</name> <name>Electrometers library</name>
<description>Electrometers library</description> <description>Electrometers library</description>
......
...@@ -123,7 +123,8 @@ std::string tmp("no data"); ...@@ -123,7 +123,8 @@ std::string tmp("no data");
//- send cmd to have a explicite response : //- send cmd to have a explicite response :
cmd_to_send << _devAdd << " MEASURE 1 " << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " MEASURE 1 " << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response
//- check only the command response
check_command(tmp); check_command(tmp);
_is_measure_mode_on = true; _is_measure_mode_on = true;
...@@ -142,10 +143,10 @@ std::string tmp("no data"); ...@@ -142,10 +143,10 @@ std::string tmp("no data");
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response //- check only the command response
check_command(tmp); check_command(tmp);
_is_measure_mode_on = false; _is_measure_mode_on = false;
} }
// ============================================================================ // ============================================================================
...@@ -157,6 +158,9 @@ std::stringstream cmd_to_send; ...@@ -157,6 +158,9 @@ std::stringstream cmd_to_send;
std::string argout("no data"); std::string argout("no data");
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command to Novelec device //- send command to Novelec device
cmd_to_send << _devAdd << " READ " << MODE_CMD_NUM << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " READ " << MODE_CMD_NUM << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -215,7 +219,10 @@ std::stringstream cmd_to_send; ...@@ -215,7 +219,10 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 1"); //- PROG 1 -> = PROG FUNCTION std::string cmdNumber(" 1"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data"); std::string tmp("no data");
//- send cmd to have a explicite response : //- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
//- check only the command response //- check only the command response
...@@ -231,6 +238,9 @@ std::stringstream cmd_to_send; ...@@ -231,6 +238,9 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 2"); //- PROG 1 -> = PROG FUNCTION std::string cmdNumber(" 2"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send cmd to have a explicite response : //- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -247,6 +257,9 @@ std::stringstream cmd_to_send; ...@@ -247,6 +257,9 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 3"); //- PROG 1 -> = PROG FUNCTION std::string cmdNumber(" 3"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send cmd to have a explicite response : //- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -263,6 +276,9 @@ std::stringstream cmd_to_send; ...@@ -263,6 +276,9 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 4"); //- PROG 1 -> = PROG FUNCTION std::string cmdNumber(" 4"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send cmd to have a explicite response : //- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -279,6 +295,9 @@ std::stringstream cmd_to_send; ...@@ -279,6 +295,9 @@ std::stringstream cmd_to_send;
std::string cmdNumber(" 5"); //- PROG 1 -> = PROG FUNCTION std::string cmdNumber(" 5"); //- PROG 1 -> = PROG FUNCTION
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send cmd to have a explicite response : //- send cmd to have a explicite response :
cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -320,6 +339,9 @@ void NovelecProtocol::set_range (std::string value) ...@@ -320,6 +339,9 @@ void NovelecProtocol::set_range (std::string value)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command to Novelec device //- send command to Novelec device
cmd_to_send << _devAdd << " PROG " << _rangeParameterNum << " " << value << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG " << _rangeParameterNum << " " << value << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -364,6 +386,9 @@ void NovelecProtocol::set_polarity (std::string newPolarity) ...@@ -364,6 +386,9 @@ void NovelecProtocol::set_polarity (std::string newPolarity)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command to Novelec device //- send command to Novelec device
cmd_to_send << _devAdd << " PROG 2" << " " << newPolarity << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 2" << " " << newPolarity << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -405,6 +430,9 @@ void NovelecProtocol::set_frequency (std::string newFrequency) ...@@ -405,6 +430,9 @@ void NovelecProtocol::set_frequency (std::string newFrequency)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command to Novelec device //- send command to Novelec device
cmd_to_send << _devAdd << " PROG 9" << " " << newFrequency << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 9" << " " << newFrequency << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -448,6 +476,9 @@ void NovelecProtocol::set_gain (std::string newGain) ...@@ -448,6 +476,9 @@ void NovelecProtocol::set_gain (std::string newGain)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command to Novelec device //- send command to Novelec device
cmd_to_send << _devAdd << " PROG 8" << " " << newGain << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " PROG 8" << " " << newGain << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -517,6 +548,9 @@ void NovelecProtocol::local (void) ...@@ -517,6 +548,9 @@ void NovelecProtocol::local (void)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command //- send command
cmd_to_send << _devAdd << " LOCAL" << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " LOCAL" << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -533,6 +567,9 @@ void NovelecProtocol::remote (void) ...@@ -533,6 +567,9 @@ void NovelecProtocol::remote (void)
std::stringstream cmd_to_send; std::stringstream cmd_to_send;
std::string tmp("no data"); std::string tmp("no data");
//- check if the MCCE2 is not in MEASURE mode to get/change any settings
this->is_allowed();
//- send command //- send command
cmd_to_send << _devAdd << " REMOTE" << END_OF_LINE << std::endl; cmd_to_send << _devAdd << " REMOTE" << END_OF_LINE << std::endl;
tmp = _communication_link->write_read(cmd_to_send.str()); tmp = _communication_link->write_read(cmd_to_send.str());
...@@ -575,6 +612,17 @@ std::string tmp("no data"); ...@@ -575,6 +612,17 @@ std::string tmp("no data");
check_command(tmp); check_command(tmp);
} }
// ============================================================================
// NovelecProtocol::is_allowed
// ============================================================================
void NovelecProtocol::is_allowed (void)
{
if(this-> _is_measure_mode_on)
throw electrometer::ElectrometerException("COMMAND_NOT_ALLOWED",
"Cannot change parameter(s) when MEASURE mode enabled : call MCCE2_OFF command.",
"NovelecProtocol::check_command( ).");
}
// ============================================================================ // ============================================================================
// NovelecProtocol::check_command // NovelecProtocol::check_command
// This method read the device response and check and throw an // This method read the device response and check and throw an
...@@ -588,12 +636,6 @@ std::string data; ...@@ -588,12 +636,6 @@ std::string data;
//- A correct response is : //- A correct response is :
// -> "address ACK " : if command well understood // -> "address ACK " : if command well understood
//- An invalid response is: "address NAK ..." //- An invalid response is: "address NAK ..."
if(_is_measure_mode_on)
throw electrometer::ElectrometerException("COMMAND_NOT_ALLOWED",
"Cannot change parameter(s) when MEASURE mode enabled.",
"NovelecProtocol::check_command( ).");
if(response.find("NAK") != std::string::npos) if(response.find("NAK") != std::string::npos)
{ {
throw electrometer::ElectrometerException("COMMAND_NOT_UNDERSTOOD", throw electrometer::ElectrometerException("COMMAND_NOT_UNDERSTOOD",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment