CameraSetting.cpp 4.85 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
27
/*
 * 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 "CameraSetting.h"

#include "controllers/common/family/Families.h"
#include <boost/lexical_cast.hpp>

using namespace boost;

namespace camera {

const std::string CameraSetting::TYPE = "Camerasetting";
Jerome Locatelli's avatar
Jerome Locatelli committed
28
 const std::string CameraSetting:: BINNING[5] = {"NONE", "1*1","2*2","NONE","4*4"};
29
30
31
32
33
34
35
 const std::string CameraSetting:: MODE[5] = {"ND", "Single","ND","Multi","ND"};

CameraSetting::CameraSetting(const string& name) :
	ExperimentController(name), controller::Start(this) {

	setFamily(family::ACQUISITION, family::SETTING);

Jerome Locatelli's avatar
Jerome Locatelli committed
36
37
38
39
40
	hbinning.init(this, SAVE , "actualhBinning", "wantedhBinning");
	vbinning.init(this, SAVE , "actualvBinning", "wantedvBinning");
//	hflip.init(this, SAVE, "hflip");
//	vflip.init(this, SAVE, "vflip");
//	rotate.init(this, SAVE, "rotate");
41
42
43
	mode.init(this, SAVE, "actualmode", "wantedmode");
	nbKine.init(this, SAVE, "nbKine");
	kineTime.init(this, SAVE, "kineTime");
Jerome Locatelli's avatar
Jerome Locatelli committed
44
45
46
47
48
	modeFVB.init(this, SAVE, "modeFVB");


	stringvbinning.init(this, NOSAVE| SPY, "actualstringvbin", "wantedstringvbin", "vBinn");
	stringhbinning.init(this, NOSAVE| SPY, "actualstringhbin", "wantedstringhbin", "hBinn");
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
	stringmode.init(this, NOSAVE| SPY, "actualstringmode", "wantedstringmode",  "Frame");
	temperature.init(this, SAVE| SPY, "actualtemp", "wantedtemp", "Temp");
	temperature.setUnit("~degree");

	m_CamDriver.init(this, "cammeraDriver");
	detectorController.init(this, "detectorController");
	detectorElement.init(this, "detectorElement");



	registerFunction(TYPE);




}

CameraSetting::~CameraSetting() {
}

void CameraSetting::postConfiguration() {
Jerome Locatelli's avatar
Jerome Locatelli committed
70
71
72
73
	hbinning=m_CamDriver->hbind();
	//stringhbinning=BINNING[hbinning()];
	vbinning=m_CamDriver->vbind();
	//stringvbinning=BINNING[vbinning()];
74
75
76

	mode=m_CamDriver->acqmode();
	temperature=m_CamDriver->actualTemperature();
Jerome Locatelli's avatar
Jerome Locatelli committed
77
	//stringmode=MODE[mode()];
78

Jerome Locatelli's avatar
Jerome Locatelli committed
79
80
	registerRefresher(hbinning, &CameraSetting::refreshBinning, this);
	registerRefresher(vbinning, &CameraSetting::refreshBinning, this);
81
	registerRefresher(mode, &CameraSetting::refreshMode, this);
Jerome Locatelli's avatar
Jerome Locatelli committed
82
83
	registerUpdater(m_CamDriver->hbind, &CameraSetting::updateBinning, this);
	registerUpdater(m_CamDriver->vbind, &CameraSetting::updateBinning, this);
84
85
86
87
88
89
	registerUpdater(m_CamDriver->acqmode, &CameraSetting::updateMode, this);
	registerUpdater(m_CamDriver->actualTemperature, &CameraSetting::updateTemperature, this);

}

void CameraSetting::start() {
Jerome Locatelli's avatar
Jerome Locatelli committed
90
91
92
93
94
95
96
97
98
99
	// Test speed BOB
	//hbinning.setpoint = 1;
	//vbinning.setpoint = 2088;
	if (modeFVB() == true) {
		hbinning.setpoint = 1;
		vbinning.setpoint = 2088;
	}else {
		hbinning.setpoint = 1;
		vbinning.setpoint = 1;
	}
100
101
102



Jerome Locatelli's avatar
Jerome Locatelli committed
103
104
105
106
	int hvalue = hbinning.setpoint();
	m_CamDriver->hbind = hvalue;
	int vvalue = vbinning.setpoint();
	m_CamDriver->vbind = vvalue;
107

Jerome Locatelli's avatar
Jerome Locatelli committed
108
109
110
	m_CamDriver->acqmode = mode.setpoint();
//	m_CamDriver->hflip = hflip();
//	m_CamDriver->vflip = vflip();
111
	m_CamDriver->nbSlicesAcq = nbKine();
Jerome Locatelli's avatar
Jerome Locatelli committed
112
	m_CamDriver->modeFVB = modeFVB();
113
	//m_CamDriver->time = kineTime();
Jerome Locatelli's avatar
Jerome Locatelli committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	if ((vvalue != 0) || (hvalue != 0)) {

		if (modeFVB() == false) {
			cout <<  "modeFVB == false hvalue " << hvalue << endl;
			cout <<  "modeFVB == false vvalue " << vvalue << endl;

			detectorController->detSize = (MAX_XSIZE / hvalue * MAX_YSIZE
					/ vvalue);
			//detectorController->detSize=(MAX_XSIZE *MAX_YSIZE);
			detectorElement->xSize = (MAX_XSIZE / hvalue);
			detectorElement->ySize = (MAX_YSIZE / vvalue);
		} else {
			cout <<  "modeFVB == true " << endl;
			detectorController->detSize = (2088);
			detectorElement->xSize = (2088);
			detectorElement->ySize = (1);
			detectorElement->wSize = (1);
		}
132
133
134

	}

Jerome Locatelli's avatar
Jerome Locatelli committed
135
136
	if (mode() == 3) {
		if ((vvalue != 0) || (hvalue != 0)) {
137

Jerome Locatelli's avatar
Jerome Locatelli committed
138
139
140
141
142
			detectorElement->wSize = nbKine();
			detectorController->detSize = (MAX_XSIZE / hvalue * MAX_YSIZE
					/ vvalue) * nbKine();
			detectorController->wSize = nbKine();
		}
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	}

	m_CamDriver->execute("writeParam");

}


void CameraSetting::refreshBinning(int32 value) {


}

void CameraSetting::refreshMode(int32 value) {


}

void CameraSetting::updateBinning() {
Jerome Locatelli's avatar
Jerome Locatelli committed
161
162
163
164
//	hbinning=m_CamDriver->hbind();
//	stringhbinning=BINNING[hbinning()];
//	vbinning=m_CamDriver->vbind();
//	stringvbinning=BINNING[vbinning()];
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

}

void CameraSetting::updateTemperature() {
	temperature=m_CamDriver->actualTemperature();

}

void CameraSetting::updateMode() {

	mode=m_CamDriver->acqmode();
	stringmode=MODE[mode()];

}

}