Commit e26ebd63 authored by Francis Epaud's avatar Francis Epaud

Added Indice2Devicename, Devicename2Indice and support of USHORT type

parent 8718dd6b
......@@ -54,14 +54,16 @@
// The following table gives the correspondence
// between command and method names.
//
// Command name | Method name
// Command name | Method name
//================================================================
// State | Inherited (no method)
// Status | Inherited (no method)
// ResetError | reset_error
// UpdateSetpoint | update_setpoint
// EnableDevice | enable_device
// DisableDevice | disable_device
// State | Inherited (no method)
// Status | Inherited (no method)
// ResetError | reset_error
// UpdateSetpoint | update_setpoint
// EnableDevice | enable_device
// DisableDevice | disable_device
// Indice2Devicename | indice2_devicename
// Devicename2Indice | devicename2_indice
//================================================================
//================================================================
......@@ -182,7 +184,7 @@ void AttributeCombiner::init_device()
vector<string> values;
dbd[0] >> values;
for(int i=0;i<(int)values.size();i++) {
cout << "Disable" << values[i] << endl;
cout << "Disable: " << values[i] << endl;
deviceGroup->disable(values[i]);
}
......@@ -512,7 +514,7 @@ void AttributeCombiner::enable_device(Tango::DevShort argin)
if(argin<0 || argin>=(short)deviceList.size()) {
Tango::Except::throw_exception(
(const char *) "AttributeCombiner::error_write",
(const char *) "Inbalid device index",
(const char *) "Invalid device index",
(const char *) "AttributeCombiner::disable_device");
}
......@@ -537,7 +539,7 @@ void AttributeCombiner::disable_device(Tango::DevShort argin)
if(argin<0 || argin>=(short)deviceList.size()) {
Tango::Except::throw_exception(
(const char *) "AttributeCombiner::error_write",
(const char *) "Inbalid device index",
(const char *) "Invalid device index",
(const char *) "AttributeCombiner::disable_device");
}
......@@ -547,6 +549,64 @@ void AttributeCombiner::disable_device(Tango::DevShort argin)
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::disable_device
}
//--------------------------------------------------------
/**
* Command Indice2Devicename related method
* Description: Return the devicename associated to the input indice
*
* @param argin indice of device (from 0)
* @returns
*/
//--------------------------------------------------------
Tango::DevString AttributeCombiner::indice2_devicename(Tango::DevShort argin)
{
Tango::DevString argout;
DEBUG_STREAM << "AttributeCombiner::Indice2Devicename() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::indice2_devicename) ENABLED START -----*/
if(argin<0 || argin>=(short)deviceList.size()) {
Tango::Except::throw_exception(
(const char *) "AttributeCombiner::error_write",
(const char *) "Invalid device index",
(const char *) "AttributeCombiner::indice2_devicename");
}
argout = CORBA::string_dup(deviceList[argin].c_str());
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::indice2_devicename
return argout;
}
//--------------------------------------------------------
/**
* Command Devicename2Indice related method
* Description:
*
* @param argin Devicename
* @returns indice of device (from 0) if the devicename is found. -1 otherwise
*/
//--------------------------------------------------------
Tango::DevShort AttributeCombiner::devicename2_indice(Tango::DevString argin)
{
Tango::DevShort argout;
DEBUG_STREAM << "AttributeCombiner::Devicename2Indice() - " << device_name << endl;
/*----- PROTECTED REGION ID(AttributeCombiner::devicename2_indice) ENABLED START -----*/
string devicename = argin;
for (argout=0; argout <(short)deviceList.size(); argout++) {
if (deviceList[argout] == devicename) return argout;
}
argout = -1;
Tango::Except::throw_exception(
(const char *) "AttributeCombiner::error_write",
(const char *) "devicename not found",
(const char *) "AttributeCombiner::disable_device");
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::devicename2_indice
return argout;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::add_dynamic_commands()
* Description : Create the dynamic commands if any
......@@ -638,6 +698,9 @@ void AttributeCombiner::read_dyn_attributes(Tango::Attribute &attr, DynAttribute
case Tango::DEV_BOOLEAN:
READG(attr,item->bVal,item,arl);
break;
case Tango::DEV_USHORT:
READG(attr,item->usVal,item,arl);
break;
case Tango::DEV_SHORT:
READG(attr,item->sVal,item,arl);
break;
......@@ -700,6 +763,10 @@ void AttributeCombiner::write_dyn_attributes(Tango::WAttribute &attr, DynAttribu
WRITEG<Tango::DevBoolean>(attr,item,arl);
break;
case Tango::DEV_USHORT:
WRITEG<Tango::DevUShort>(attr,item,arl);
break;
case Tango::DEV_SHORT:
WRITEG<Tango::DevShort>(attr,item,arl);
break;
......@@ -872,6 +939,13 @@ void AttributeCombiner::read_dynspec_attributes(Tango::Attribute &attr,DynSpectr
READSCALAR<Tango::DevBoolean, Tango::DevDouble>(attr,item,arl,NAN,NAN);
break;
case Tango::DEV_USHORT:
if(item->isSpectrum)
READSPECTRUM<Tango::DevUShort>(attr,item,arl);
else
READSCALAR<Tango::DevUShort, Tango::DevDouble>(attr,item,arl,NAN,NAN);
break;
case Tango::DEV_SHORT:
if(item->isSpectrum)
READSPECTRUM<Tango::DevShort>(attr,item,arl);
......@@ -988,6 +1062,10 @@ void AttributeCombiner::write_dynspec_attributes(Tango::WAttribute &attr,DynSpec
switch (item->type) {
case Tango::DEV_USHORT:
WRITES<Tango::DevDouble,Tango::DevUShort>(attr,item,arl);
break;
case Tango::DEV_SHORT:
WRITES<Tango::DevDouble,Tango::DevShort>(attr,item,arl);
break;
......@@ -1108,6 +1186,8 @@ int AttributeCombiner::ToTangoType(string name,string type) {
return Tango::DEV_LONG;
} else if ( type.compare("DevLong64")==0 ) {
return Tango::DEV_LONG64;
} else if ( type.compare("DevUShort")==0 ) {
return Tango::DEV_USHORT;
} else if ( type.compare("DevShort")==0 ) {
return Tango::DEV_SHORT;
} else if ( type.compare("DevULong")==0 ) {
......@@ -1184,6 +1264,27 @@ 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();
// }
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::namespace_ending
} // namespace
......@@ -247,6 +247,24 @@ public:
*/
virtual void disable_device(Tango::DevShort argin);
virtual bool is_DisableDevice_allowed(const CORBA::Any &any);
/**
* 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);
//--------------------------------------------------------
......
<?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">
<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">
<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>
......@@ -71,6 +71,24 @@
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="Indice2Devicename" description="Return the devicename associated to the input indice" execMethod="indice2_devicename" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="indice of device (from 0)">
<type xsi:type="pogoDsl:ShortType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:StringType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="Devicename2Indice" description="" execMethod="devicename2_indice" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Devicename">
<type xsi:type="pogoDsl:StringType"/>
</argin>
<argout description="indice of device (from 0) if the devicename is found. -1 otherwise">
<type xsi:type="pogoDsl:ShortType"/>
</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"/>
......
......@@ -228,6 +228,44 @@ CORBA::Any *DisableDeviceClass::execute(Tango::DeviceImpl *device, const CORBA::
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : Indice2DevicenameClass::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 *Indice2DevicenameClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
cout2 << "Indice2DevicenameClass::execute(): arrived" << endl;
Tango::DevShort argin;
extract(in_any, argin);
return insert((static_cast<AttributeCombiner *>(device))->indice2_devicename(argin));
}
//--------------------------------------------------------
/**
* method : Devicename2IndiceClass::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 *Devicename2IndiceClass::execute(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
cout2 << "Devicename2IndiceClass::execute(): arrived" << endl;
Tango::DevString argin;
extract(in_any, argin);
return insert((static_cast<AttributeCombiner *>(device))->devicename2_indice(argin));
}
//===================================================================
// Properties management
......@@ -547,6 +585,24 @@ void AttributeCombinerClass::command_factory()
Tango::OPERATOR);
command_list.push_back(pDisableDeviceCmd);
// Command Indice2Devicename
Indice2DevicenameClass *pIndice2DevicenameCmd =
new Indice2DevicenameClass("Indice2Devicename",
Tango::DEV_SHORT, Tango::DEV_STRING,
"indice of device (from 0)",
"",
Tango::OPERATOR);
command_list.push_back(pIndice2DevicenameCmd);
// Command Devicename2Indice
Devicename2IndiceClass *pDevicename2IndiceCmd =
new Devicename2IndiceClass("Devicename2Indice",
Tango::DEV_STRING, Tango::DEV_SHORT,
"Devicename",
"indice of device (from 0) if the devicename is found. -1 otherwise",
Tango::OPERATOR);
command_list.push_back(pDevicename2IndiceCmd);
/*----- PROTECTED REGION ID(AttributeCombinerClass::command_factory_after) ENABLED START -----*/
// Add your own code
......
......@@ -253,6 +253,52 @@ public:
{return (static_cast<AttributeCombiner *>(dev))->is_DisableDevice_allowed(any);}
};
// Command Indice2Devicename class definition
class Indice2DevicenameClass : public Tango::Command
{
public:
Indice2DevicenameClass(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) {};
Indice2DevicenameClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~Indice2DevicenameClass() {};
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_Indice2Devicename_allowed(any);}
};
// Command Devicename2Indice class definition
class Devicename2IndiceClass : public Tango::Command
{
public:
Devicename2IndiceClass(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) {};
Devicename2IndiceClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~Devicename2IndiceClass() {};
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_Devicename2Indice_allowed(any);}
};
/**
* The AttributeCombinerClass singleton definition
......
......@@ -129,6 +129,36 @@ bool AttributeCombiner::is_DisableDevice_allowed(TANGO_UNUSED(const CORBA::Any &
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_Indice2Devicename_allowed()
* Description : Execution allowed for Indice2Devicename attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_Indice2Devicename_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Indice2Devicename command.
/*----- PROTECTED REGION ID(AttributeCombiner::Indice2DevicenameStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::Indice2DevicenameStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : AttributeCombiner::is_Devicename2Indice_allowed()
* Description : Execution allowed for Devicename2Indice attribute
*/
//--------------------------------------------------------
bool AttributeCombiner::is_Devicename2Indice_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for Devicename2Indice command.
/*----- PROTECTED REGION ID(AttributeCombiner::Devicename2IndiceStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // AttributeCombiner::Devicename2IndiceStateAllowed
return true;
}
/*----- PROTECTED REGION ID(AttributeCombiner::AttributeCombinerStateAllowed.AdditionalMethods) ENABLED START -----*/
......
......@@ -49,6 +49,7 @@ typedef struct _ATTITEM {
// Attribute value
Tango::DevBoolean bVal;
Tango::DevUShort usVal;
Tango::DevShort sVal;
Tango::DevLong lVal;
Tango::DevLong64 lVal64;
......
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