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

moved stop run in another application.

parent dd67f137
......@@ -34,6 +34,7 @@ using namespace cameo;
const std::string FrequencyRemoteMatlabReq::TYPE = "in16_remote_matlab";
const std::string FrequencyRemoteMatlabReq::MATLAB_APPLICATION = "in16-matlab";
const std::string FrequencyRemoteMatlabReq::MATLAB_STOP_APPLICATION = "in16-matlab-stop";
const std::string FrequencyRemoteMatlabReq::RESPONDER_NAME = "in16_frequency_controller";
const std::string FrequencyRemoteMatlabReq::RUN_SPECTRUMS_TEST = "Run Spectrums Test";
......@@ -42,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::Stoppable(this) {
ExperimentController(name), controller::Start(this) {
serverEndpoint.init(this, SAVE, "cameo_server");
initialized.init(this, NOSAVE, "initialized");
......@@ -77,7 +78,7 @@ FrequencyRemoteMatlabReq::FrequencyRemoteMatlabReq(const std::string& name) :
}
FrequencyRemoteMatlabReq::FrequencyRemoteMatlabReq(const FrequencyRemoteMatlabReq& controller) :
ExperimentController(controller), controller::Stoppable(this) {
ExperimentController(controller), controller::Start(this) {
}
FrequencyRemoteMatlabReq::~FrequencyRemoteMatlabReq() {
......@@ -199,33 +200,11 @@ void FrequencyRemoteMatlabReq::start() {
sleep(1);
}
void FrequencyRemoteMatlabReq::stop() {
void FrequencyRemoteMatlabReq::stopRun() {
// Serialize the request.
proto::RunSpectrumsRequest request;
request.set_type(proto::RunSpectrumsRequest_Type_STOP);
request.set_fr(0);
request.set_frmin(0);
request.set_frmax(0);
request.set_nmax(0);
request.set_time(0);
request.set_comment("");
// Send the message.
m_requester->sendBinary(request.SerializeAsString());
cout << getName() << " sent run 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;
auto_ptr<cameo::application::Instance> matlabStopApplication = m_server->start(MATLAB_STOP_APPLICATION);
application::State state = matlabStopApplication->waitFor();
cout << "Matlab stop application terminated with state " << state << endl;
}
}
......@@ -25,7 +25,7 @@
namespace in16 {
class FrequencyRemoteMatlabReq : public ExperimentController,
public controller::Stoppable {
public controller::Start {
public:
//! Type of controller
......@@ -38,7 +38,8 @@ public:
virtual void postConfiguration();
virtual void start();
virtual void stop();
void stopRun();
static const std::string RUN_SPECTRUMS_TEST;
static const std::string RUN_SPECTRUMS;
......@@ -59,6 +60,7 @@ private:
bool initApplication();
static const std::string MATLAB_APPLICATION;
static const std::string MATLAB_STOP_APPLICATION;
static const std::string RESPONDER_NAME;
Property<std::string> serverEndpoint;
......
......@@ -4,6 +4,7 @@
<controller class="in16::RunSpectrumsTest"/>
<controller class="in16::RunSpectrumsTime"/>
<controller class="in16::RunSingleFrequency"/>
<controller class="in16::StopRunSpectrums"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/>
......
......@@ -60,8 +60,6 @@ void RunSpectrums::start() {
}
void RunSpectrums::stop() {
matlabController->stopCommand();
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "StopRunSpectrums.h"
#include "controllers/common/family/Families.h"
namespace in16 {
using namespace std;
using namespace common;
const std::string StopRunSpectrums::TYPE = "in16_run_spectrums_stop";
StopRunSpectrums::StopRunSpectrums(const std::string& name) :
ExperimentController(name), controller::Start(this) {
setFamily(family::ACQUISITION);
matlabController.init(this, "matlab");
}
StopRunSpectrums::~StopRunSpectrums() {
}
void StopRunSpectrums::postConfiguration() {
}
void StopRunSpectrums::start() {
matlabController->stopRun();
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef IN16_STOPRUNSPECTRUMS_H
#define IN16_STOPRUNSPECTRUMS_H
#include <Controller.h>
#include "FrequencyRemoteMatlabReq.h"
namespace in16 {
class StopRunSpectrums : public ExperimentController,
public controller::Start {
public:
//! Type of controller
static const std::string TYPE;
StopRunSpectrums(const std::string& name);
virtual ~StopRunSpectrums();
virtual void postConfiguration();
virtual void start();
ControllerPtr<FrequencyRemoteMatlabReq> matlabController;
};
}
#endif
<plugin>
<controller type="in16_run_spectrums_stop" role="in16_run_spectrums_stop1"/>
<number_of_lines nb_lines="1"/>
</plugin>
<controller_plugin_config type="in16_run_spectrums_stop">
<image key="FREQGEN_CTRL"/>
<settings view="in16_run_spectrums_stopView.xml"/>
<command view="in16_run_spectrums_stopCommandView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="in16_run_spectrums_stop">
</controller>
<plugin>
<controller type="in16_run_spectrums_stop" role="in16_run_spectrums_stop1"/>
</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