VEXPController.h 3.99 KB
Newer Older
legoc's avatar
legoc committed
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 VEXP_VEXPCONTROLLER_H
#define VEXP_VEXPCONTROLLER_H

#include "controllers/tas/common/TasSettings.h"
#include "controllers/tas/common/Scattering.h"
#include "controllers/tas/common/Sample.h"
#include "controllers/tas/common/IncidentBeam.h"
#include "controllers/tas/common/TasScatteredBeam.h"
legoc's avatar
legoc committed
27
28
29
30
#include <boost/thread/thread.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/mutex.hpp>
#include <memory>
legoc's avatar
legoc committed
31
32
33

namespace vexp {

yannick legoc's avatar
yannick legoc committed
34
35
36
37
38
39
40
41
42
43
44
45
/**
 * The VEXPController is the bridge between Nomad and the vEXP application.
 * It groups the properties needed by vEXP:
 * - Sample properties: as, bs, ... U, B matrices.
 * - Scattering properties: qh, ... qm, ki, kf.
 * - Angle properties: A1...A6.
 * These properties are synchronized with the Nomad controllers.
 *
 * The vEXP application is reading these properties when it synchronizes with Nomad (startup and resync).
 * When the vEXP application requests a calculation of the angles, it sends the property calcvalues.
 * Then the calculation is triggered and calca1...calca6 are calculated by the other Nomad controllers.
 */
legoc's avatar
legoc committed
46
47
48
49
50
51
52
class VEXPController : public ExperimentController {

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

	VEXPController(const std::string& name);
legoc's avatar
legoc committed
53
	VEXPController(const VEXPController& controller);
legoc's avatar
legoc committed
54
55
	virtual ~VEXPController();

legoc's avatar
legoc committed
56
57
58
	void updateUMatrix();
	void updateBMatrix();

ics's avatar
ics committed
59
	void refreshCalcParameters(const std::string& value);
legoc's avatar
legoc committed
60
	void refreshFloat64Property(SimpleProperty<float64>& property, float64 value);
61
	void refreshFloat64PropertyToMoveModel(SimpleProperty<float64>& property, float64 value);
62

ics's avatar
ics committed
63
64
	void updateProperties();

legoc's avatar
legoc committed
65
66
	virtual void postConfiguration();

ics's avatar
ics committed
67
68
	void calculate(float64 ki, float64 kf, float64 qh, float64 qk, float64 ql);

legoc's avatar
legoc committed
69
70
71
72
73
74
75
76
77
78
79
80
	Property<float64> as;
	Property<float64> bs;
	Property<float64> cs;
	Property<float64> aa;
	Property<float64> bb;
	Property<float64> cc;
	Property<float64> ax;
	Property<float64> ay;
	Property<float64> az;
	Property<float64> bx;
	Property<float64> by;
	Property<float64> bz;
legoc's avatar
legoc committed
81

legoc's avatar
legoc committed
82
83
	ArrayProperty<float64> u;
	ArrayProperty<float64> b;
legoc's avatar
legoc committed
84

ics's avatar
ics committed
85
	// Real properties.
legoc's avatar
legoc committed
86
87
88
89
90
91
	Property<float64> qh;
	Property<float64> qk;
	Property<float64> ql;
	Property<float64> en;
	Property<float64> qm;

legoc's avatar
legoc committed
92
93
94
95
96
97
	Property<float64> ki;
	Property<float64> kf;

	Property<float64> a1;
	Property<float64> a2;
	Property<float64> a3;
yannick legoc's avatar
yannick legoc committed
98
	Property<float64> a3p;
legoc's avatar
legoc committed
99
100
101
102
	Property<float64> a4;
	Property<float64> a5;
	Property<float64> a6;

ics's avatar
ics committed
103
104
105
106
107
108
	// JSON String property containing the calculated properties. Use it or the direct properties.
	Property<std::string> calcvalues;

	Property<float64> calca1;
	Property<float64> calca2;
	Property<float64> calca3;
yannick legoc's avatar
yannick legoc committed
109
	Property<float64> calca3p;
ics's avatar
ics committed
110
111
112
113
	Property<float64> calca4;
	Property<float64> calca5;
	Property<float64> calca6;

114
	StatusProperty calculationStatus;
legoc's avatar
legoc committed
115
	Property<std::string> errorMessage;
116
	Property<bool> moveModel;
legoc's avatar
legoc committed
117

legoc's avatar
legoc committed
118
119
120
121
122
	ControllerPtr<tas::TasSettings> tasSettings;
	ControllerPtr<tas::Sample> sample;
	ControllerPtr<tas::Scattering> scattering;
	ControllerPtr<tas::IncidentBeam> incidentBeam;
	ControllerPtr<tas::TasScatteredBeam> scatteredBeam;
legoc's avatar
legoc committed
123
124
125
126

	ControllerPtr<axis::AxisController> a1Controller;
	ControllerPtr<axis::AxisController> a2Controller;
	ControllerPtr<axis::AxisController> a3Controller;
yannick legoc's avatar
yannick legoc committed
127
	ControllerPtr<axis::AxisController> a3pController;
legoc's avatar
legoc committed
128
129
130
	ControllerPtr<axis::AxisController> a4Controller;
	ControllerPtr<axis::AxisController> a5Controller;
	ControllerPtr<axis::AxisController> a6Controller;
legoc's avatar
legoc committed
131
132
133
134
135
};

}

#endif