Commit f651704b authored by Jean-Luc Pons's avatar Jean-Luc Pons

Initial import

parents
.idea/
cmake-build-debug/
bin/
obj/
This diff is collapsed.
/*----- 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);
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)
//
// Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert
//
// 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;
// Attribute data members
public:
Tango::DevString *attr_Errors_read;
// 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);
//--------------------------------------------------------
/**
* 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);
//--------------------------------------------------------
/**
* 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
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="AttributeCombiner" pogoRevision="9.6">
<description description="A class to combine attributes coming from several devices" title="AttributeCombiner" sourcePath="/mntdirect/_segfs/tango/cppserver/calculcation/AttributeCombiner" language="Cpp" filestogenerate="XMI file,Code files,Makefile,CMakeLists,Protected Regions" license="GPL" copyright="Copyright (C): 2018&#xA; European Synchrotron Radiation Facility&#xA; BP 220, Grenoble 38043&#xA; France" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at esrf.fr - pons" author="pons" emailDomain="esrf.fr" classFamily="Calculation" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/>
</description>
<deviceProperties name="AttributeList" description="List of attribute (9 fields per line)&#xA;&#xA;Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert&#xA;&#xA;Name: Attribute Name&#xA;Attribute list: Attribute name list to combine (coma separated)&#xA;Type: Type of Atttribute(s)&#xA;IsRW: Read write flag&#xA;IsSpectrum: true if attribute(s) is(are) a spectrum&#xA;isGrouped: Group all attributes to a single one (scalar only)&#xA;Length: Name of the `ALL` lenght attribute for combined spectrum, `None` otherwise&#xA;Expert: Expert view (true or false)&#xA;Alarm: Set alarm if value are not all equal (true or false) for grouped attribute">
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="AttributeRefList" description="List of reference attribute">
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="DeviceList" description="List of devices">
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device state">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device status">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true"/>
</commands>
<commands name="ResetError" description="Reset Error stack" execMethod="reset_error" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="UpdateSetpoint" description="Update local setpoints from device setpoints" execMethod="update_setpoint" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="EnableDevice" description="Enable device" execMethod="enable_device" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Enable device #i">
<type xsi:type="pogoDsl:ShortType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="DisableDevice" description="Disable device" execMethod="disable_device" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Disable device #i">
<type xsi:type="pogoDsl:ShortType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="Errors" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="2048" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<preferences docHome="./doc_html" makefileHome="/segfs/tango/cppserver/env"/>
<additionalFiles name="AttributeMap" path="/mntdirect/_segfs/tango/cppserver/calculcation/AttributeCombiner/AttributeMap.cpp"/>
</classes>
</pogoDsl:PogoSystem>
This diff is collapsed.
This diff is collapsed.
/*----- PROTECTED REGION ID(AttributeCombinerStateMachine.cpp) ENABLED START -----*/
//=============================================================================
//
// file : AttributeCombinerStateMachine.cpp
//
// description : State machine 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)
//=============================================================================
#include <AttributeCombiner.h>
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::AttributeCombinerStateMachine.cpp
//================================================================
// States | Description
//================================================================
namespace AttributeCombiner_ns
{
//=================================================
// Attributes Allowed Methods
//=================================================
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_Errors_allowed()
* Description : Execution allowed for Errors attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_Errors_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for Errors attribute in read access.
/*----- PROTECTED REGION ID(AttributeCombiner::ErrorsStateAllowed_READ) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::ErrorsStateAllowed_READ
return true;
}
//=================================================
// Commands Allowed Methods
//=================================================
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_ResetError_allowed()
* Description : Execution allowed for ResetError attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_ResetError_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for ResetError command.
/*----- PROTECTED REGION ID(AttributeCombiner::ResetErrorStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::ResetErrorStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_UpdateSetpoint_allowed()
* Description : Execution allowed for UpdateSetpoint attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_UpdateSetpoint_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for UpdateSetpoint command.
/*----- PROTECTED REGION ID(AttributeCombiner::UpdateSetpointStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::UpdateSetpointStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_EnableDevice_allowed()
* Description : Execution allowed for EnableDevice attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_EnableDevice_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for EnableDevice command.
/*----- PROTECTED REGION ID(AttributeCombiner::EnableDeviceStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::EnableDeviceStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_DisableDevice_allowed()
* Description : Execution allowed for DisableDevice attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_DisableDevice_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for DisableDevice command.
/*----- PROTECTED REGION ID(AttributeCombiner::DisableDeviceStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::DisableDeviceStateAllowed
return true;
}
/*----- PROTECTED REGION ID(AttributeCombiner::AttributeCombinerStateAllowed.AdditionalMethods) ENABLED START -----*/
// Additional Methods
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::AttributeCombinerStateAllowed.AdditionalMethods
} // End of namespace
//=============================================================================
//
// file : AttributeMap.cpp
//
// description : Handle relation between attribute and private attribute data for a device
//
// 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/>.
//
// $Author: pons $
//
//
//
//=============================================================================
namespace AttributeCombiner_ns
{
class AttributeMap;
}
#include <AttributeCombiner.h>
using namespace std;
namespace AttributeCombiner_ns
{
// Construct an empty attribute map
AttributeMap::AttributeMap() {
}
// Destruct attribute map
AttributeMap::~AttributeMap() {
clear();
}
// Free allocated resource
void AttributeMap::clear() {
map.clear();
}
// Add a ref attribute
void AttributeMap::addRef(string attName) {
ATTITEM newItem;
newItem.attName = attName;
newItem.grouped = false;
newItem.attNames.clear();
newItem.type = Tango::DEV_DOUBLE;
newItem.rwType = Tango::READ_WRITE;
newItem.setInit = false;
newItem.isSpectrum = true;
newItem.lengthAttName = "";
newItem.isRef = true;
newItem.refData = NULL;
// Look for insertion position
bool found = false;
int i=0;
while(!found && i<(int)map.size()) {
found = map[i].attName.compare(attName) > 0;
if(!found) i++;
}
// Insert
if(found) {
map.insert(map.begin()+i,newItem);
} else {
map.push_back(newItem);
}
}
// Add an attribute
void AttributeMap::add(string attName,vector<std::string> attNames,bool grouped,int type,int rwType,bool isSpectrum,string lgthAttName,bool manageAlarm) {
ATTITEM newItem;
newItem.attName = attName;
newItem.grouped = grouped;
newItem.attNames = attNames;
newItem.type = type;
newItem.rwType = rwType;
newItem.setInit = false;
newItem.isSpectrum = isSpectrum;
newItem.lengthAttName = lgthAttName;
newItem.isRef = false;
newItem.refData = NULL;
newItem.manageAlarm = manageAlarm;
// Look for insertion position
bool found = false;
int i=0;
while(!found && i<(int)map.size()) {
found = map[i].attName.compare(attName) > 0;
if(!found) i++;
}
// Insert
if(found) {
map.insert(map.begin()+i,newItem);
} else {
map.push_back(newItem);
}
}
// Get item according to attribute name
ATTITEM *AttributeMap::get(string attName) {
bool found = false;
int min=0;
int max=map.size()-1;
int mid,comp;
while(!found && min<=max) {
mid = (min+max)/2;
comp = map[mid].attName.compare(attName);
if(comp>0) {
max = mid-1;
} else if(comp<0) {
min = mid+1;
} else {
found = true;