AttributeCombiner.h 9.82 KB
Newer Older
Jean-Luc Pons's avatar
Jean-Luc Pons 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*----- PROTECTED REGION ID(AttributeCombiner.h) ENABLED START -----*/
//=============================================================================
//
// file :        AttributeCombiner.h
//
// description : Include file for the AttributeCombiner class
//
// project :     AttributeCombiner
//
// This file is part of Tango device class.
// 
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with Tango.  If not, see <http://www.gnu.org/licenses/>.
// 
//
// Copyright (C): 2018
//                European Synchrotron Radiation Facility
//                BP 220, Grenoble 38043
//                France
//
//=============================================================================
//                This file is generated by POGO
//        (Program Obviously used to Generate tango Object)
//=============================================================================


#ifndef AttributeCombiner_H
#define AttributeCombiner_H

#include <tango.h>

#include <AttributeMap.h>

#define MAXATTRIBUTE 32   // Maximum number of attribute in a definition
#define MAXERROR     5    // Maximum number of error per device
#define MAXVALUELENGTH 100000 // Maximum length of a spectrum attribute

typedef struct {
		vector<string> errList;
} ERRITEM;

/*----- PROTECTED REGION END -----*/	//	AttributeCombiner.h

/**
 *  AttributeCombiner class description:
 *    A class to combine attributes coming from several devices
 */

namespace AttributeCombiner_ns
{
/*----- PROTECTED REGION ID(AttributeCombiner::Additional Class Declarations) ENABLED START -----*/

//	Additional Class Declarations
class DynAttribute;
class DynSpectrumAttribute;
class DynImageAttribute;

/*----- PROTECTED REGION END -----*/	//	AttributeCombiner::Additional Class Declarations

class AttributeCombiner : public TANGO_BASE_CLASS
{

/*----- PROTECTED REGION ID(AttributeCombiner::Data Members) ENABLED START -----*/

//	Add your own data members
public:
		AttributeMap attMap;
		Tango::Group *deviceGroup;
		vector<ERRITEM> errorStack;
		Tango::DeviceProxy *self;

		template<typename inType>
		void READG(Tango::Attribute &attr,inType &value,ATTITEM *item,Tango::GroupAttrReplyList arl[]);
		template<typename T>
		void WRITEG(Tango::WAttribute &attr,ATTITEM *item,Tango::GroupReplyList arl[]);
		template <typename inType,typename outType>
		void READSCALAR(Tango::Attribute &attr,ATTITEM *item,Tango::GroupAttrReplyList arl[],outType invalid,outType disableValue);
		template <typename inType>
		void READSPECTRUM(Tango::Attribute &attr,ATTITEM *item,Tango::GroupAttrReplyList arl[]);
		template <typename inType,typename outType>
		void WRITES(Tango::WAttribute &attr,ATTITEM *item,Tango::GroupReplyList arl[]);

		virtual void read_dyn_attributes(Tango::Attribute &attr,DynAttribute *src);
		virtual void write_dyn_attributes(Tango::WAttribute &attr,DynAttribute *src);
		virtual void read_dynspec_attributes(Tango::Attribute &attr,DynSpectrumAttribute *src);
		virtual void write_dynspec_attributes(Tango::WAttribute &attr,DynSpectrumAttribute *src);
		virtual void read_dynimg_attributes(Tango::Attribute &attr,DynImageAttribute *src);
		virtual void write_dynimg_attributes(Tango::WAttribute &attr,DynImageAttribute *src);
99
    virtual void execute_command(string cmdName);
Jean-Luc Pons's avatar
Jean-Luc Pons committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115

		void split(vector<string> &tokens, const string &text, char sep);
		void tolower(string &s);
		int  ToTangoType(string name,string type);
		void addError(int devIndex,Tango::GroupAttrReply &reply);
		Tango::WAttribute &getAtt(string name);
		bool isNumber(std::string value);
		void saveDisabledBLM();
    bool isDisalbed(int idx);

/*----- PROTECTED REGION END -----*/	//	AttributeCombiner::Data Members

//	Device property data members
public:
	//	AttributeList:	List of attribute (9 fields per line)
	//  
116
	//  Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert;Alarm
Jean-Luc Pons's avatar
Jean-Luc Pons committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
	//  
	//  Name: Attribute Name
	//  Attribute list: Attribute name list to combine (coma separated)
	//  Type: Type of Atttribute(s)
	//  IsRW: Read write flag
	//  IsSpectrum: true if attribute(s) is(are) a spectrum
	//  isGrouped: Group all attributes to a single one (scalar only)
	//  Length: Name of the `ALL` lenght attribute for combined spectrum, `None` otherwise
	//  Expert: Expert view (true or false)
	//  Alarm: Set alarm if value are not all equal (true or false) for grouped attribute
	vector<string>	attributeList;
	//	AttributeRefList:	List of reference attribute
	vector<string>	attributeRefList;
	//	DeviceList:	List of devices
	vector<string>	deviceList;
132
133
	//	CommandList:	List of global VoidVoid command
	vector<string>	commandList;
134
135
	//	Timeout:	Timeout value of grouped call
	Tango::DevLong	timeout;
Jean-Luc Pons's avatar
Jean-Luc Pons committed
136
137
138
139

//	Attribute data members
public:
	Tango::DevString	*attr_Errors_read;
140
	Tango::DevString	*attr_DeviceList_read;
Jean-Luc Pons's avatar
Jean-Luc Pons committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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

//	Constructors and destructors
public:
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	AttributeCombiner(Tango::DeviceClass *cl,string &s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device Name
	 */
	AttributeCombiner(Tango::DeviceClass *cl,const char *s);
	/**
	 * Constructs a newly device object.
	 *
	 *	@param cl	Class.
	 *	@param s 	Device name
	 *	@param d	Device description.
	 */
	AttributeCombiner(Tango::DeviceClass *cl,const char *s,const char *d);
	/**
	 * The device object destructor.
	 */
	~AttributeCombiner() {delete_device();};


//	Miscellaneous methods
public:
	/*
	 *	will be called at device destruction or at init command.
	 */
	void delete_device();
	/*
	 *	Initialize the device
	 */
	virtual void init_device();
	/*
	 *	Read the device properties from database
	 */
	void get_device_property();
	/*
	 *	Always executed method before execution command method.
	 */
	virtual void always_executed_hook();


//	Attribute methods
public:
	//--------------------------------------------------------
	/*
	 *	Method      : AttributeCombiner::read_attr_hardware()
	 *	Description : Hardware acquisition for attributes.
	 */
	//--------------------------------------------------------
	virtual void read_attr_hardware(vector<long> &attr_list);

/**
 *	Attribute Errors related methods
 *	Description: 
 *
 *	Data type:	Tango::DevString
 *	Attr type:	Spectrum max = 2048
 */
	virtual void read_Errors(Tango::Attribute &attr);
	virtual bool is_Errors_allowed(Tango::AttReqType type);
211
212
213
214
215
216
217
218
219
/**
 *	Attribute DeviceList related methods
 *	Description: 
 *
 *	Data type:	Tango::DevString
 *	Attr type:	Spectrum max = 4096
 */
	virtual void read_DeviceList(Tango::Attribute &attr);
	virtual bool is_DeviceList_allowed(Tango::AttReqType type);
Jean-Luc Pons's avatar
Jean-Luc Pons committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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


	//--------------------------------------------------------
	/**
	 *	Method      : AttributeCombiner::add_dynamic_attributes()
	 *	Description : Add dynamic attributes if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_attributes();




//	Command related methods
public:
	/**
	 *	Command ResetError related method
	 *	Description: Reset Error stack
	 *
	 */
	virtual void reset_error();
	virtual bool is_ResetError_allowed(const CORBA::Any &any);
	/**
	 *	Command UpdateSetpoint related method
	 *	Description: Update local setpoints from device setpoints
	 *
	 */
	virtual void update_setpoint();
	virtual bool is_UpdateSetpoint_allowed(const CORBA::Any &any);
	/**
	 *	Command EnableDevice related method
	 *	Description: Enable device
	 *
	 *	@param argin Enable device #i
	 */
	virtual void enable_device(Tango::DevShort argin);
	virtual bool is_EnableDevice_allowed(const CORBA::Any &any);
	/**
	 *	Command DisableDevice related method
	 *	Description: Disable device
	 *
	 *	@param argin Disable device #i
	 */
	virtual void disable_device(Tango::DevShort argin);
	virtual bool is_DisableDevice_allowed(const CORBA::Any &any);
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
	/**
	 *	Command Indice2Devicename related method
	 *	Description: Return the devicename associated to the input indice
	 *
	 *	@param argin indice of device (from 0)
	 *	@returns 
	 */
	virtual Tango::DevString indice2_devicename(Tango::DevShort argin);
	virtual bool is_Indice2Devicename_allowed(const CORBA::Any &any);
	/**
	 *	Command Devicename2Indice related method
	 *	Description: 
	 *
	 *	@param argin Devicename
	 *	@returns indice of device (from 0) if the devicename is found. -1 otherwise
	 */
	virtual Tango::DevShort devicename2_indice(Tango::DevString argin);
	virtual bool is_Devicename2Indice_allowed(const CORBA::Any &any);
283
284
285
286
287
288
289
290
291
292
293
294
295
296
	/**
	 *	Command DisableAll related method
	 *	Description: 
	 *
	 */
	virtual void disable_all();
	virtual bool is_DisableAll_allowed(const CORBA::Any &any);
	/**
	 *	Command EnableAll related method
	 *	Description: 
	 *
	 */
	virtual void enable_all();
	virtual bool is_EnableAll_allowed(const CORBA::Any &any);
Jean-Luc Pons's avatar
Jean-Luc Pons committed
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322


	//--------------------------------------------------------
	/**
	 *	Method      : AttributeCombiner::add_dynamic_commands()
	 *	Description : Add dynamic commands if any.
	 */
	//--------------------------------------------------------
	void add_dynamic_commands();

/*----- PROTECTED REGION ID(AttributeCombiner::Additional Method prototypes) ENABLED START -----*/

//	Additional Method prototypes

/*----- PROTECTED REGION END -----*/	//	AttributeCombiner::Additional Method prototypes
};

/*----- PROTECTED REGION ID(AttributeCombiner::Additional Classes Definitions) ENABLED START -----*/

//	Additional Classes Definitions

/*----- PROTECTED REGION END -----*/	//	AttributeCombiner::Additional Classes Definitions

}	//	End of namespace

#endif   //	AttributeCombiner_H