Newer
Older
// ============================================================================
//
// = CONTEXT
// TANGO Project - NovelecElectrometer Support Library
//
// = FILENAME
// Novelec_MCCE2.cpp
//
// = AUTHOR
// X. Elattaoui
//
// ============================================================================
// ============================================================================
// DEPENDENCIES
// ============================================================================
#include <iostream>
#include <sstream>
#include <string>
#include <Xstring.h>
#include "NovelecProtocol.h"
#include "Novelec_MCCE2.h"
// ============================================================================
// Novelec_MCCE2::Novelec_MCCE2
// ============================================================================
Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, unsigned short address, unsigned short novTypeNumber)
}
// ============================================================================
// Novelec_MCCE2::~Novelec_MCCE2
// ============================================================================
Novelec_MCCE2::~Novelec_MCCE2 (void)
{
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// ============================================================================
// Novelec_MCCE2::init_protocol
// ============================================================================
bool Novelec_MCCE2::init_protocol (void)
{
std::string description("");
bool success = false;
try
{
//- build the keithley Electrometer protocol obj
_electrometerProtocol = new NovelecProtocol(_device_proxy_name, _address, _MCCE2electroTypeNumber);
if(_electrometerProtocol)
success = _electrometerProtocol->build_communicationLink();
}
catch(Tango::DevFailed& df)
{
description = "FAILED to create proxy on : " + _device_proxy_name;
Tango::Except::re_throw_exception (df,
(const char*)"COMMUNICATION_ERROR",
description.c_str(),
(const char*)"Novelec_MCCE2::init_protocol");
}
catch(...)
{
description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...].";
Tango::Except::throw_exception (
(const char*)"COMMUNICATION_ERROR",
description.c_str(),
(const char*)"Novelec_MCCE2::init_protocol");
}
return success;
}
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// ============================================================================
// Novelec_MCCE2::get_ElectroMeterPolarity
// ============================================================================
std::string Novelec_MCCE2::get_ElectroMeterPolarity (void)
{
return _electrometerProtocol->get_polarity();
}
// ============================================================================
// Novelec_MCCE2::set_ElectroMeterPolarity
// ============================================================================
void Novelec_MCCE2::set_ElectroMeterPolarity (std::string polarity)
{
_electrometerProtocol->set_polarity(polarity);
}
// ============================================================================
// Novelec_MCCE2::set_Zero_VonF_function
// ============================================================================
void Novelec_MCCE2::set_Zero_VonF_function (void)
{
_electrometerProtocol->unable_zeroVF_func();
}
// ============================================================================
// Novelec_MCCE2::set_Offset_function
// ============================================================================
void Novelec_MCCE2::set_Offset_ZeroV1_function (void)
{
_electrometerProtocol->unable_offset_zeroV1_func();
}
// ============================================================================
// Novelec_MCCE2::set_Leakage_ZeroV2_function
// ============================================================================
void Novelec_MCCE2::set_Leakage_ZeroV2_function (void)
{
_electrometerProtocol->unable_leakage_zeroV2_func();
}
// ============================================================================
// Novelec_MCCE2::set_Test_function
// ============================================================================
void Novelec_MCCE2::set_Test_function (void)
{
_electrometerProtocol->unable_test_func();
}
// ============================================================================
// Novelec_MCCE2::set_Measure_function
// ============================================================================
void Novelec_MCCE2::set_Measure_function (void)
{
_electrometerProtocol->unable_measure_func();
}
// ============================================================================
// Novelec_MCCE2::mcce_on
// ============================================================================
void Novelec_MCCE2::mcce_on (void)
{
_electrometerProtocol->switch_MCCE2_ON();
}
// ============================================================================
// Novelec_MCCE2::mcce_off
// ============================================================================
void Novelec_MCCE2::mcce_off (void)
{
_electrometerProtocol->switch_MCCE2_OFF();
}
// ============================================================================
// Novelec_MCCE2::electrometer_status
// ============================================================================
std::string Novelec_MCCE2::electrometer_status (void)
{

ELATTAOUI
committed
std::string argout("");
std::string typeStr(" ");
std::string tmp(" ");
short _status = 0;
short _errors = 0;
short _type = 0;
NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol);
if(!_nproto)

ELATTAOUI
committed
throw electrometer::ElectrometerException("BAD_ALLOC",
"Memory allocation failed to query the electrmometer status.",

ELATTAOUI
committed
/***********************************************************************
DISABLED PART TO INCREASE SERIAL PERFORMANCE

ELATTAOUI
committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
//try
//{
// tmp = _nproto->get_electrotype();
// _type = XString<short>::convertFromString(tmp);
//}
//catch(...)
//{
// set_electroState(FAULT);
// throw electrometer::ElectrometerException("INTERNAL_ERROR",
// "Unable to query the electrmometer type.",
// "Novelec_MCCE2::electrometer_status( ).");
//}
//argout = "\n\nINFOS :\n";
//argout += "----------\n";
//switch(_type)
//{
//case 1 : typeStr = "Photovoltaque UHS";
// break;
//case 2 : typeStr = "Photovoltaque HS";
// break;
//case 3 : typeStr = "Photovoltaque MS";
// break;
//case 4 : typeStr = "Photoconducteur HS";
// break;
//case 5 : typeStr = "Photoconducteur MS";
// break;
//default : set_electroState(FAULT);
// argout = "Invalid status string returned !";
// return argout;
//}
//argout += "Novelec type : " + typeStr + "\n";
////- get Electrometer mode :
//argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n";
***********************************************************************/
try
{
//- read novelec status from HW
tmp = _electrometerProtocol->get_raw_status();
//std::cout << "Novelec_MCCE2::electrometer_status -> tmp = \"" << tmp << "\"" << std::endl;
//std::cout << "Novelec_MCCE2::convertFromString -> _status = \"" << _status << "\"" << std::endl;

ELATTAOUI
committed
argout = "Unable to query the electrometer status.";
throw;

ELATTAOUI
committed
return argout;
//throw electrometer::ElectrometerException("COMMUNICATION_ERROR",
// "Unable to query the electrmometer status.",
// "Novelec_MCCE2::electrometer_status( ).");

ELATTAOUI
committed
argout += "\nStatus detail :\n";
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
argout += "------------------------\n";
//- build novelec status
if(_status & 0x10)
argout += "En mesure\n";
else
argout += "Hors mesure\n";
if(_status & 0x20)
argout += "Paramtres par defaut\n";
else
argout += "Ram OK\n";
if(_status & 0x40)
argout += "Paramtre invalide\n";
else
argout += "Paramtre OK\n";
if(_status & 0x80)
{
argout += "ERREUR\n";
set_electroState(ALARM);
}
else
{
argout += "Pas d'erreur\n";
set_electroState(ON);
}
//- error(s) detail(s)
if(_status & 0x80)
{
try
{
//- read novelec error(s) from HW
//std::cout << "Novelec_MCCE2::get_errors ..." << std::endl;
//std::cout << "Novelec_MCCE2::convertFromString -> get_errors = \"" << tmp << "\"" << std::endl;
//std::cout << "Novelec_MCCE2::convertFromString -> convertFromString = \"" << _errors << "\"" << std::endl;
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
}
catch(...)
{
set_electroState(FAULT);
throw electrometer::ElectrometerException("INTERNAL_ERROR",
"Unable to query the electrmometer errors.",
"Novelec_MCCE2::electrometer_status( ).");
}
argout += "\nError(s) detail(s) :\n";
argout += "------------------------\n";
if(_errors & 0x01)
argout += "Paramtre par dfaut\n";
if(_errors & 0x02)
argout += "Erreur srie\n";
if(_errors & 0x04)
argout += "Paramtre invalide\n";
if(_errors & 0x08)
argout += "Electromtre satur\n";
if(_errors & 0x10)
argout += "Electromtre bloqu\n";
if(_errors & 0x20)
argout += "HT < limite basse\n";
if(_errors & 0x40)
argout += "HT > limite haute\n";
if(_errors & 0x80)
argout += "Initialisation\n";
if(_errors & 0x100)
argout += "Dfaut batterie\n";
if(_errors & 0x200)
argout += "Dfaut d'alimentation\n";
if(_errors & 0x400)
argout += "Type d'lectromtre inconnu\n";
if(_errors & 0x800)
argout += "Electromtre dconnect\n";
set_electroState(ALARM);
}
return argout;
}
// ============================================================================
// Novelec_MCCE2::check_range_value
// ============================================================================
short Novelec_MCCE2::check_range_value (const std::string& rgToCheck, const std::string* electroRangeList)
{
for (unsigned int idx = 0; idx < _rangeLimit; idx++)
{
if(electroRangeList[idx].find(rgToCheck) != std::string::npos)
//- value is in the list
return idx;
}
//- new range value not found in the electrometer range list !
return -1;
}