DielectricsRemoteMatlabReq.h 2.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * 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 DIELECTRICS_REMOTEMATLABREQ_H
#define DIELECTRICS_REMOTEMATLABREQ_H

#include <Controller.h>
#include <cameo/cameo.h>

namespace dielectrics {

27
28
class Spectrums;

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*!
 * \brief Test command.
 */
class Test: private controller::Command {

public:
	Test(ExperimentController * c) :
		controller::Command(c, "test", &Test::test, this) {
	}

	virtual void test() = 0;
	void testCommand(bool logging = false) {
		command(logging, true);
	}
};

45
46
class RemoteMatlabReq : public ExperimentController,
									public controller::Start,
47
48
									public controller::Raz,
									public Test {
49
50
51
52
53
54
55
56
57
58
59

public:
	//! Type of controller
	static const std::string TYPE;

	RemoteMatlabReq(const std::string& name);
	RemoteMatlabReq(const RemoteMatlabReq& controller);
	virtual ~RemoteMatlabReq();

	virtual void postConfiguration();

60
61
62
63
64
	virtual void setEnabled(bool all, bool postconf = true);
	virtual void setDisabled(bool all = false);

	void addSpectrumsController(Spectrums * controller);

65
66
	virtual void start();
	virtual void raz();
67
	virtual void test();
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

	void stopRun();

	static const std::string RUN_SPECTRUMS_TEST;
	static const std::string RUN_SPECTRUMS;
	static const std::string RUN_SPECTRUMS_TIME;
	static const std::string RUN_SINGLE_FREQUENCY;

	DynamicProperty<std::string> requestTypeValues;
	Property<std::string> requestType;

	Property<double> fr;
	Property<double> frMin;
	Property<double> frMax;
	Property<int32> nMax;
	Property<double> time;
	Property<std::string> comment;

86
87
88
89
	Property<std::string> serverEndpoint;
	Property<bool> initialized;
	Property<int32> applicationState;

90
91
	ArrayProperty<int32> values;

92
93
94
95
	Property<int32> actualN;
	Property<double> actualTime;
	Property<int32> actualRun;

96
97
98
private:
	bool initApplication();
	void stopApplication();
99
	void subscriberLoop();
100
101
102
103

	static const std::string MATLAB_APPLICATION;
	static const std::string MATLAB_STOP_APPLICATION;
	static const std::string RESPONDER_NAME;
104
	static const std::string PUBLISHER_NAME;
105

106
107
	std::vector<Spectrums *> m_spectrumsControllers;

108
109
110
	std::auto_ptr<cameo::Server> m_server;
	std::auto_ptr<cameo::application::Instance> m_matlabApplication;
	std::auto_ptr<cameo::application::Requester> m_requester;
111
112
	std::auto_ptr<cameo::application::Subscriber> m_subscriber;
	std::auto_ptr<boost::thread> m_subscriberThread;
113
114
115
116
117
};

}

#endif