Commit be34c738 authored by yannick legoc's avatar yannick legoc
Browse files

implemented stop of the Matlab application as well as added scientific format...

implemented stop of the Matlab application as well as added scientific format to the frequencies (waiting for the input format)
parent a2340503
......@@ -43,7 +43,7 @@ const std::string FrequencyRemoteMatlabReq::RUN_SPECTRUMS_TIME = "Run Spectrums
const std::string FrequencyRemoteMatlabReq::RUN_SINGLE_FREQUENCY = "Run Single Frequency";
FrequencyRemoteMatlabReq::FrequencyRemoteMatlabReq(const std::string& name) :
ExperimentController(name), controller::Start(this) {
ExperimentController(name), controller::Start(this), controller::Raz(this) {
serverEndpoint.init(this, SAVE, "cameo_server");
initialized.init(this, NOSAVE, "initialized");
......@@ -78,18 +78,13 @@ FrequencyRemoteMatlabReq::FrequencyRemoteMatlabReq(const std::string& name) :
}
FrequencyRemoteMatlabReq::FrequencyRemoteMatlabReq(const FrequencyRemoteMatlabReq& controller) :
ExperimentController(controller), controller::Start(this) {
ExperimentController(controller), controller::Start(this), controller::Raz(this) {
}
FrequencyRemoteMatlabReq::~FrequencyRemoteMatlabReq() {
// Stop the remote application.
m_matlabApplication->stop();
// Wait for the termination
application::State state = m_matlabApplication->waitFor();
cout << "Matlab application terminated with state " << application::toString(state) << endl;
// Send a request to stop the remote application.
stopApplication();
}
void FrequencyRemoteMatlabReq::postConfiguration() {
......@@ -147,11 +142,13 @@ bool FrequencyRemoteMatlabReq::initApplication() {
// Application initialized.
initialized = true;
cout << "Matlab application initialized" << endl;
return true;
} catch (...) {
} catch (const std::exception & e) {
// Currently an exception can occur during isAvailable.
cout << "Unexpected exception during matlab connection" << endl;
cout << "Unexpected exception during matlab connection: " << e.what() << endl;
}
return false;
......@@ -159,6 +156,8 @@ bool FrequencyRemoteMatlabReq::initApplication() {
void FrequencyRemoteMatlabReq::start() {
initApplication();
// Serialize the request.
proto::RunSpectrumsRequest request;
......@@ -200,6 +199,15 @@ void FrequencyRemoteMatlabReq::start() {
sleep(1);
}
void FrequencyRemoteMatlabReq::raz() {
// First stop the application.
stopApplication();
// Restart the application.
initialized = false;
}
void FrequencyRemoteMatlabReq::stopRun() {
auto_ptr<cameo::application::Instance> matlabStopApplication = m_server->start(MATLAB_STOP_APPLICATION);
......@@ -207,4 +215,46 @@ void FrequencyRemoteMatlabReq::stopRun() {
cout << "Matlab stop application terminated with state " << state << endl;
}
void FrequencyRemoteMatlabReq::stopApplication() {
if (!initialized()) {
return;
}
// Serialize the request.
proto::RunSpectrumsRequest request;
request.set_fr(0);
request.set_frmin(0);
request.set_frmax(0);
request.set_nmax(0);
request.set_time(0);
request.set_comment("");
request.set_type(proto::RunSpectrumsRequest_Type_STOP);
// Send the message.
m_requester->sendBinary(request.SerializeAsString());
cout << getName() << " sent stop request" << endl;
// Wait for the response synchronously.
// Note that responses can be processed asynchronously if the server is able to.
string data;
m_requester->receiveBinary(data);
proto::FrequencyResponse response;
response.ParseFromString(data);
cout << "received response " << response.responseid() << endl;
// Stop the remote application.
m_matlabApplication->stop();
// Wait for the termination
application::State state = m_matlabApplication->waitFor();
cout << "Matlab application terminated with state " << application::toString(state) << endl;
}
}
......@@ -25,7 +25,8 @@
namespace in16 {
class FrequencyRemoteMatlabReq : public ExperimentController,
public controller::Start {
public controller::Start,
public controller::Raz {
public:
//! Type of controller
......@@ -38,6 +39,7 @@ public:
virtual void postConfiguration();
virtual void start();
virtual void raz();
void stopRun();
......@@ -58,6 +60,7 @@ public:
private:
bool initApplication();
void stopApplication();
static const std::string MATLAB_APPLICATION;
static const std::string MATLAB_STOP_APPLICATION;
......
......@@ -27,7 +27,7 @@ using namespace common;
const std::string RunSpectrums::TYPE = "in16_run_spectrums";
RunSpectrums::RunSpectrums(const std::string& name) :
ExperimentController(name), controller::Stoppable(this) {
ExperimentController(name), controller::Stoppable(this), controller::Raz(this) {
setFamily(family::ACQUISITION);
......@@ -62,4 +62,9 @@ void RunSpectrums::start() {
void RunSpectrums::stop() {
}
void RunSpectrums::raz() {
matlabController->razCommand();
}
}
......@@ -25,7 +25,8 @@
namespace in16 {
class RunSpectrums : public ExperimentController,
public controller::Stoppable {
public controller::Stoppable,
public controller::Raz {
public:
//! Type of controller
......@@ -38,6 +39,7 @@ public:
virtual void start();
virtual void stop();
virtual void raz();
Property<double> fr;
Property<double> frMin;
......
in16_run_single_frequency.frPrefix=Freq.
in16_run_single_frequency.timePrefix=Time
in16_run_single_frequency.commentPrefix=Comment
\ No newline at end of file
in16_run_single_frequency.commentPrefix=Comment
in16_run_single_frequency.razPrefix=Stop application
\ No newline at end of file
......@@ -5,4 +5,8 @@
<property name="comment" type="string" max_length="60">
</property>
<property name="fr" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
</controller>
<plugin>
<controller type="in16_run_single_frequency" role="in16_run_single_frequency1"/>
<table_composite nbColumns="2">
<simple_label prefix="in16_run_single_frequency.frPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="fr"/>
<simple_label prefix="in16_run_single_frequency.timePrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="time"/>
<newLine/>
<simple_label prefix="in16_run_single_frequency.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="comment"/>
</table_composite>
<simple_label prefix="in16_run_single_frequency.frPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="fr"/>
<simple_label prefix="in16_run_single_frequency.timePrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="time"/>
<newLine/>
<simple_label prefix="in16_run_single_frequency.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_single_frequency1" property="comment"/>
<newLine/>
<button role="in16_run_single_frequency1" command="raz" prefix="in16_run_single_frequency.razPrefix"/>
</plugin>
in16_run_spectrums.frMinPrefix=Freq. Min
in16_run_spectrums.frMaxPrefix=Freq. Max
in16_run_spectrums.nMaxPrefix=N Max
in16_run_spectrums.commentPrefix=Comment
\ No newline at end of file
in16_run_spectrums.commentPrefix=Comment
in16_run_spectrums.razPrefix=Stop application
\ No newline at end of file
......@@ -4,5 +4,13 @@
<property name="comment" type="string" max_length="60">
</property>
<property name="frMin" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
<property name="frMax" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
</controller>
<plugin>
<controller type="in16_run_spectrums" role="in16_run_spectrums1"/>
<table_composite nbColumns="2">
<simple_label prefix="in16_run_spectrums.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="frMin"/>
<simple_label prefix="in16_run_spectrums.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="frMax"/>
<simple_label prefix="in16_run_spectrums.nMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="nMax"/>
<newLine/>
<simple_label prefix="in16_run_spectrums.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="comment"/>
</table_composite>
<simple_label prefix="in16_run_spectrums.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="frMin"/>
<simple_label prefix="in16_run_spectrums.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="frMax"/>
<simple_label prefix="in16_run_spectrums.nMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="nMax"/>
<newLine/>
<simple_label prefix="in16_run_spectrums.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums1" property="comment"/>
<newLine/>
<button role="in16_run_spectrums1" command="raz" prefix="in16_run_spectrums.razPrefix"/>
</plugin>
in16_run_spectrums_test.frMinPrefix=Freq. Min
in16_run_spectrums_test.frMaxPrefix=Freq. Max
in16_run_spectrums_test.nMaxPrefix=N Max
in16_run_spectrums_test.commentPrefix=Comment
\ No newline at end of file
in16_run_spectrums_test.commentPrefix=Comment
in16_run_spectrums_test.razPrefix=Stop application
\ No newline at end of file
......@@ -4,5 +4,13 @@
<property name="comment" type="string" max_length="60">
</property>
<property name="frMin" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
<property name="frMax" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
</controller>
<plugin>
<controller type="in16_run_spectrums_test" role="in16_run_spectrums_test1"/>
<table_composite nbColumns="2">
<simple_label prefix="in16_run_spectrums_test.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="frMin"/>
<simple_label prefix="in16_run_spectrums_test.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="frMax"/>
<simple_label prefix="in16_run_spectrums_test.nMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="nMax"/>
<newLine/>
<simple_label prefix="in16_run_spectrums_test.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="comment"/>
</table_composite>
<simple_label prefix="in16_run_spectrums_test.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="frMin"/>
<simple_label prefix="in16_run_spectrums_test.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="frMax"/>
<simple_label prefix="in16_run_spectrums_test.nMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="nMax"/>
<newLine/>
<simple_label prefix="in16_run_spectrums_test.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_test1" property="comment"/>
<newLine/>
<button role="in16_run_spectrums_test1" command="raz" prefix="in16_run_spectrums_test.razPrefix"/>
</plugin>
in16_run_spectrums_time.frMinPrefix=Freq. Min
in16_run_spectrums_time.frMaxPrefix=Freq. Max
in16_run_spectrums_time.timePrefix=Time
in16_run_spectrums_time.commentPrefix=Comment
\ No newline at end of file
in16_run_spectrums_time.commentPrefix=Comment
in16_run_spectrums_time.razPrefix=Stop application
\ No newline at end of file
......@@ -5,4 +5,12 @@
<property name="comment" type="string" max_length="60">
</property>
<property name="frMin" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
<property name="frMax" type="float64" max_length="10">
<scientific_format nb_decimal_places="3"/>
</property>
</controller>
<plugin>
<controller type="in16_run_spectrums_time" role="in16_run_spectrums_time1"/>
<table_composite nbColumns="2">
<simple_label prefix="in16_run_spectrums_time.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="frMin"/>
<simple_label prefix="in16_run_spectrums_time.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="frMax"/>
<simple_label prefix="in16_run_spectrums_time.timePrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="time"/>
<newLine/>
<simple_label prefix="in16_run_spectrums_time.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="comment"/>
</table_composite>
<simple_label prefix="in16_run_spectrums_time.frMinPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="frMin"/>
<simple_label prefix="in16_run_spectrums_time.frMaxPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="frMax"/>
<simple_label prefix="in16_run_spectrums_time.timePrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="time"/>
<newLine/>
<simple_label prefix="in16_run_spectrums_time.commentPrefix" font_size="9" hAlignment="left"/>
<text role="in16_run_spectrums_time1" property="comment"/>
<newLine/>
<button role="in16_run_spectrums_time1" command="raz" prefix="in16_run_spectrums_time.razPrefix"/>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment