Commit 3fb45f69 authored by Jean-Luc Pons's avatar Jean-Luc Pons

Added DisableAll,EnableAll and CommandList

parent e26ebd63
......@@ -64,6 +64,8 @@
// DisableDevice | disable_device
// Indice2Devicename | indice2_devicename
// Devicename2Indice | devicename2_indice
// DisableAll | disable_all
// EnableAll | enable_all
//================================================================
//================================================================
......@@ -214,6 +216,7 @@ void AttributeCombiner::get_device_property()
dev_prop.push_back(Tango::DbDatum("AttributeList"));
dev_prop.push_back(Tango::DbDatum("AttributeRefList"));
dev_prop.push_back(Tango::DbDatum("DeviceList"));
dev_prop.push_back(Tango::DbDatum("CommandList"));
// is there at least one property to be read ?
if (dev_prop.size()>0)
......@@ -261,6 +264,17 @@ void AttributeCombiner::get_device_property()
// And try to extract DeviceList value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> deviceList;
// Try to initialize CommandList from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> commandList;
else {
// Try to initialize CommandList from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> commandList;
}
// And try to extract CommandList value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> commandList;
}
/*----- PROTECTED REGION ID(AttributeCombiner::get_device_property_after) ENABLED START -----*/
......@@ -607,6 +621,44 @@ Tango::DevShort AttributeCombiner::devicename2_indice(Tango::DevString argin)
return argout;
}
//--------------------------------------------------------
/**
* Command DisableAll related method
* Description:
*
*/
//--------------------------------------------------------
void AttributeCombiner::disable_all()
{
DEBUG_STREAM << "AttributeCombiner::DisableAll() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::disable_all) ENABLED START -----*/
for(int i=0;i<(int)deviceList.size();i++)
deviceGroup->disable(deviceList[i]);
saveDisabledBLM();
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::disable_all
}
//--------------------------------------------------------
/**
* Command EnableAll related method
* Description:
*
*/
//--------------------------------------------------------
void AttributeCombiner::enable_all()
{
DEBUG_STREAM << "AttributeCombiner::EnableAll() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::enable_all) ENABLED START -----*/
for(int i=0;i<(int)deviceList.size();i++)
deviceGroup->enable(deviceList[i]);
saveDisabledBLM();
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::enable_all
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::add_dynamic_commands()
* Description : Create the dynamic commands if any
......@@ -616,8 +668,14 @@ Tango::DevShort AttributeCombiner::devicename2_indice(Tango::DevString argin)
void AttributeCombiner::add_dynamic_commands()
{
/*----- PROTECTED REGION ID(AttributeCombiner::add_dynamic_commands) ENABLED START -----*/
// Add your own code to create and add dynamic commands if any
for(int i=0;i<(int)commandList.size();i++) {
// Create command
DynCommandClass *cmd = new DynCommandClass(commandList[i].c_str(),Tango::DEV_VOID,Tango::DEV_VOID);
add_command(cmd);
}
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::add_dynamic_commands
}
......@@ -1264,26 +1322,12 @@ void AttributeCombiner::addError(int devIdenx,Tango::GroupAttrReply &reply) {
errorStack[devIdenx].errList.erase(errorStack[devIdenx].errList.begin());
}
// //--------------------------------------------------------
// /**
// * Command EnableDevice related method
// * Description: Enable device
// *
// * @param argin Enable device #i
// */
// //--------------------------------------------------------
// void AttributeCombiner::enable_device(Tango::DevShort argin)
// {
// DEBUG_STREAM << "AttributeCombiner::EnableDevice() - " << device_name << endl;
// if(argin<0 || argin>=(short)deviceList.size()) {
// Tango::Except::throw_exception(
// (const char *) "AttributeCombiner::error_write",
// (const char *) "Invalid device index",
// (const char *) "AttributeCombiner::disable_device");
// }
// deviceGroup->enable(deviceList[argin]);
// saveDisabledBLM();
// }
void AttributeCombiner::execute_command(string cmdName) {
deviceGroup->command_inout(cmdName);
}
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::namespace_ending
......
......@@ -96,6 +96,7 @@ public:
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);
virtual void execute_command(string cmdName);
void split(vector<string> &tokens, const string &text, char sep);
void tolower(string &s);
......@@ -112,7 +113,7 @@ public:
public:
// AttributeList: List of attribute (9 fields per line)
//
// Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert
// Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert;Alarm
//
// Name: Attribute Name
// Attribute list: Attribute name list to combine (coma separated)
......@@ -128,6 +129,8 @@ public:
vector<string> attributeRefList;
// DeviceList: List of devices
vector<string> deviceList;
// CommandList: List of global VoidVoid command
vector<string> commandList;
// Attribute data members
public:
......@@ -265,6 +268,20 @@ public:
*/
virtual Tango::DevShort devicename2_indice(Tango::DevString argin);
virtual bool is_Devicename2Indice_allowed(const CORBA::Any &any);
/**
* 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);
//--------------------------------------------------------
......
<?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/_users/epaud/EBS/BPMs/AttributeCombiner" language="Cpp" filestogenerate="XMI file,Code files,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">
<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,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">
<deviceProperties name="AttributeList" description="List of attribute (9 fields per line)&#xA;&#xA;Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert;Alarm&#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>
......@@ -17,6 +17,10 @@
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="CommandList" description="List of global VoidVoid command">
<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"/>
......@@ -89,6 +93,24 @@
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="DisableAll" description="" execMethod="disable_all" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Disable All device">
<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="EnableAll" description="" execMethod="enable_all" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Enable all device">
<type xsi:type="pogoDsl:VoidType"/>
</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"/>
......
......@@ -266,6 +266,42 @@ CORBA::Any *Devicename2IndiceClass::execute(Tango::DeviceImpl *device, const COR
return insert((static_cast<AttributeCombiner *>(device))->devicename2_indice(argin));
}
//--------------------------------------------------------
/**
* method : DisableAllClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *DisableAllClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "DisableAllClass::execute(): arrived" << endl;
((static_cast<AttributeCombiner *>(device))->disable_all());
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : EnableAllClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *EnableAllClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "EnableAllClass::execute(): arrived" << endl;
((static_cast<AttributeCombiner *>(device))->enable_all());
return new CORBA::Any();
}
//===================================================================
// Properties management
......@@ -336,7 +372,7 @@ void AttributeCombinerClass::set_default_property()
// Set Default device Properties
prop_name = "AttributeList";
prop_desc = "List of attribute (9 fields per line)\n\nName;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert\n\nName: Attribute Name\nAttribute list: Attribute name list to combine (coma separated)\nType: Type of Atttribute(s)\nIsRW: Read write flag\nIsSpectrum: true if attribute(s) is(are) a spectrum\nisGrouped: Group all attributes to a single one (scalar only)\nLength: Name of the `ALL` lenght attribute for combined spectrum, `None` otherwise\nExpert: Expert view (true or false)\nAlarm: Set alarm if value are not all equal (true or false) for grouped attribute";
prop_desc = "List of attribute (9 fields per line)\n\nName;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert;Alarm\n\nName: Attribute Name\nAttribute list: Attribute name list to combine (coma separated)\nType: Type of Atttribute(s)\nIsRW: Read write flag\nIsSpectrum: true if attribute(s) is(are) a spectrum\nisGrouped: Group all attributes to a single one (scalar only)\nLength: Name of the `ALL` lenght attribute for combined spectrum, `None` otherwise\nExpert: Expert view (true or false)\nAlarm: Set alarm if value are not all equal (true or false) for grouped attribute";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
......@@ -374,6 +410,19 @@ void AttributeCombinerClass::set_default_property()
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "CommandList";
prop_desc = "List of global VoidVoid command";
prop_def = "";
vect_data.clear();
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
}
//--------------------------------------------------------
......@@ -603,6 +652,24 @@ void AttributeCombinerClass::command_factory()
Tango::OPERATOR);
command_list.push_back(pDevicename2IndiceCmd);
// Command DisableAll
DisableAllClass *pDisableAllCmd =
new DisableAllClass("DisableAll",
Tango::DEV_VOID, Tango::DEV_VOID,
"Disable All device",
"",
Tango::OPERATOR);
command_list.push_back(pDisableAllCmd);
// Command EnableAll
EnableAllClass *pEnableAllCmd =
new EnableAllClass("EnableAll",
Tango::DEV_VOID, Tango::DEV_VOID,
"Enable all device",
"",
Tango::OPERATOR);
command_list.push_back(pEnableAllCmd);
/*----- PROTECTED REGION ID(AttributeCombinerClass::command_factory_after) ENABLED START -----*/
// Add your own code
......
......@@ -139,6 +139,31 @@ public:
};
// Dynamic command
class DynCommandClass : public Tango::Command
{
public:
DynCommandClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
DynCommandClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~DynCommandClass() {};
virtual CORBA::Any *execute(Tango::DeviceImpl *dev,const CORBA::Any &any) {
(static_cast<AttributeCombiner *>(dev))->execute_command(name);
return new CORBA::Any();;
}
};
/*----- PROTECTED REGION END -----*/ // AttributeCombinerClass::classes for dynamic creation
//=========================================
......@@ -299,6 +324,52 @@ public:
{return (static_cast<AttributeCombiner *>(dev))->is_Devicename2Indice_allowed(any);}
};
// Command DisableAll class definition
class DisableAllClass : public Tango::Command
{
public:
DisableAllClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
DisableAllClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~DisableAllClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<AttributeCombiner *>(dev))->is_DisableAll_allowed(any);}
};
// Command EnableAll class definition
class EnableAllClass : public Tango::Command
{
public:
EnableAllClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
EnableAllClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~EnableAllClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<AttributeCombiner *>(dev))->is_EnableAll_allowed(any);}
};
/**
* The AttributeCombinerClass singleton definition
......
......@@ -159,6 +159,36 @@ bool AttributeCombiner::is_Devicename2Indice_allowed(TANGO_UNUSED(const CORBA::A
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_DisableAll_allowed()
* Description : Execution allowed for DisableAll attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_DisableAll_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for DisableAll command.
/*----- PROTECTED REGION ID(AttributeCombiner::DisableAllStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::DisableAllStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_EnableAll_allowed()
* Description : Execution allowed for EnableAll attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_EnableAll_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for EnableAll command.
/*----- PROTECTED REGION ID(AttributeCombiner::EnableAllStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::EnableAllStateAllowed
return true;
}
/*----- PROTECTED REGION ID(AttributeCombiner::AttributeCombinerStateAllowed.AdditionalMethods) ENABLED START -----*/
......
......@@ -9,7 +9,7 @@ Here is the description of the device properties:
**AttributeList** List of attributes (9 fields per line)
Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert<br/>
Name;Attribute list;Type;IsRW;IsSpectrum;IsGrouped;Length;Expert;Alarm<br/>
*Name*: Attribute Name<br/>
*Attribute list*: Attribute name list to combine (coma separated)<br/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment