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

Novelec part : mcce2_off cmd fixed.

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