Select Git revision
ContinuousAOClass.cpp
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ContinuousAOClass.cpp 22.42 KiB
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/InputOutput/ADLINK/ContinuousAO/src/ContinuousAOClass.cpp,v 1.3 2005-06-15 10:22:17 abeilleg Exp $";
static const char *TagName = "$Name: not supported by cvs2svn $";
static const char *FileName= "$Source: /users/chaize/newsvn/cvsroot/InputOutput/ADLINK/ContinuousAO/src/ContinuousAOClass.cpp,v $";
static const char *HttpServer= "http://controle/DeviceServer/doc/";
static const char *RCSfile = "$RCSfile: ContinuousAOClass.cpp,v $";
//+=============================================================================
//
// file : ContinuousAOClass.cpp
//
// description : C++ source for the ContinuousAOClass. A singleton
// class derived from DeviceClass. It implements the
// command list and all properties and methods required
// by the ContinuousAO once per process.
//
// project : TANGO Device Server
//
// $Author: abeilleg $
//
// $Revision: 1.3 $
//
// $Log: not supported by cvs2svn $
// Revision 1.2 2005/01/20 13:21:51 abeilleg
// following ASL modifications (states management).
//
// Revision 1.1.1.1 2004/12/06 10:20:44 syldup
// initial import
//
//
// copyleft : Synchrotron SOLEIL
// L'Orme des Merisiers
// Saint-Aubin - BP 48/
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
//#include <tango.h>
#include <ContinuousAO.h>
#include <ContinuousAOClass.h>
namespace ContinuousAO
{
//+----------------------------------------------------------------------------
//
// method : StartCmd::StartCmd()
//
// description : constructor for the command of the ContinuousAO.
//
// In : - name : The command name
// - in : The input parameter type
// - out : The output parameter type
// - in_desc : The input parameter description
// - out_desc : The output parameter description
//
//-----------------------------------------------------------------------------
StartCmd::StartCmd( 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)
{
}
//
// Constructor without in/out parameters description
//
StartCmd::StartCmd( const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out)
{
}
//+----------------------------------------------------------------------------
//
// method : StartCmd::is_allowed()
//
// description : method to test whether command is allowed or not in this
// state. In this case, the command is allowed only if
// the device is in ON state
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : boolean - true == is allowed , false == not allowed
//
//-----------------------------------------------------------------------------
bool StartCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : StartCmd::execute()
//
// description : method to trigger the execution of the command.
// PLEASE DO NOT MODIFY this method core without pogo
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *StartCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "DevTemplateCmd::execute(): arrived" << endl;
((static_cast<ContinuousAO *>(device))->start());
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// method : StopCmd::StopCmd()
//
// description : constructor for the command of the ContinuousAO.
//
// In : - name : The command name
// - in : The input parameter type
// - out : The output parameter type
// - in_desc : The input parameter description
// - out_desc : The output parameter description
//
//-----------------------------------------------------------------------------
StopCmd::StopCmd( 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)
{
}
//
// Constructor without in/out parameters description
//
StopCmd::StopCmd( const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out)
{
}
//+----------------------------------------------------------------------------
//
// method : StopCmd::is_allowed()
//
// description : method to test whether command is allowed or not in this
// state. In this case, the command is allowed only if
// the device is in ON state
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : boolean - true == is allowed , false == not allowed
//
//-----------------------------------------------------------------------------
bool StopCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : StopCmd::execute()
//
// description : method to trigger the execution of the command.
// PLEASE DO NOT MODIFY this method core without pogo
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *StopCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "DevTemplateCmd::execute(): arrived" << endl;
((static_cast<ContinuousAO *>(device))->stop());
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// method : SetAOScaledDataCmd::SetAOScaledDataCmd()
//
// description : constructor for the command of the ContinuousAO.
//
// In : - name : The command name
// - in : The input parameter type
// - out : The output parameter type
// - in_desc : The input parameter description
// - out_desc : The output parameter description
//
//-----------------------------------------------------------------------------
SetAOScaledDataCmd::SetAOScaledDataCmd( 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)
{
}
//
// Constructor without in/out parameters description
//
SetAOScaledDataCmd::SetAOScaledDataCmd( const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out)
{
}
//+----------------------------------------------------------------------------
//
// method : SetAOScaledDataCmd::is_allowed()
//
// description : method to test whether command is allowed or not in this
// state. In this case, the command is allowed only if
// the device is in ON state
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : boolean - true == is allowed , false == not allowed
//
//-----------------------------------------------------------------------------
bool SetAOScaledDataCmd::is_allowed(Tango::DeviceImpl *device, const CORBA::Any &in_any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : SetAOScaledDataCmd::execute()
//
// description : method to trigger the execution of the command.
// PLEASE DO NOT MODIFY this method core without pogo
//
// in : - device : The device on which the command must be excuted
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *SetAOScaledDataCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "DevTemplateCmd::execute(): arrived" << endl;
const Tango::DevVarDoubleStringArray *argin;
extract(in_any, argin);
((static_cast<ContinuousAO *>(device))->set_aoscaled_data(argin));
return new CORBA::Any();
}
//
//----------------------------------------------------------------
// Initialize pointer for singleton pattern
//----------------------------------------------------------------
//
ContinuousAOClass *ContinuousAOClass::_instance = NULL;
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::ContinuousAOClass(string &s)
//
// description : constructor for the ContinuousAOClass
//
// in : - s : The class name
//
//-----------------------------------------------------------------------------
ContinuousAOClass::ContinuousAOClass(string &s):DeviceClass(s)
{
cout2 << "Entering ContinuousAOClass constructor" << endl;
write_class_property();
cout2 << "Leaving ContinuousAOClass constructor" << endl;
}
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::~ContinuousAOClass()
//
// description : destructor for the ContinuousAOClass
//
//-----------------------------------------------------------------------------
ContinuousAOClass::~ContinuousAOClass()
{
_instance = NULL;
}
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::instance
//
// description : Create the object if not already done. Otherwise, just
// return a pointer to the object
//
// in : - name : The class name
//
//-----------------------------------------------------------------------------
ContinuousAOClass *ContinuousAOClass::init(const char *name)
{
if (_instance == NULL)
{
try
{
string s(name);
_instance = new ContinuousAOClass(s);
}
catch (bad_alloc)
{
throw;
}
}
return _instance;
}
ContinuousAOClass *ContinuousAOClass::instance()
{
if (_instance == NULL)
{
cerr << "Class is not initialised !!" << endl;
exit(-1);
}
return _instance;
}
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::command_factory
//
// description : Create the command object(s) and store them in the
// command list
//
//-----------------------------------------------------------------------------
void ContinuousAOClass::command_factory()
{
command_list.push_back(new StartCmd("Start",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
command_list.push_back(new StopCmd("Stop",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
command_list.push_back(new SetAOScaledDataCmd("SetAOScaledData",
Tango::DEVVAR_DOUBLESTRINGARRAY, Tango::DEV_VOID,
"The channel number ,in string). The output data in volts ,in double)",
"",
Tango::OPERATOR));
// add polling if any
for (unsigned int i=0 ; i<command_list.size(); i++)
{
}
}
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::device_factory
//
// description : Create the device object(s) and store them in the
// device list
//
// in : Tango::DevVarStringArray *devlist_ptr : The device name list
//
//-----------------------------------------------------------------------------
void ContinuousAOClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
{
for (long i=0 ; i < devlist_ptr->length() ; i++)
{
cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl;
// Create device and add it into the device list
//----------------------------------------------------
device_list.push_back(new ContinuousAO(this, (*devlist_ptr)[i]));
// Export device to the outside world
// Check before id database used.
//---------------------------------------------
if (Tango::Util::_UseDb == true)
export_device(device_list.back());
else
export_device(device_list.back(), (*devlist_ptr)[i]);
}
}
//+----------------------------------------------------------------------------
// Method: ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list)
//-----------------------------------------------------------------------------
void ContinuousAOClass::attribute_factory(vector<Tango::Attr *> &att_list)
{
// Attribute : channel0
Tango::SpectrumAttr *channel0 =
new Tango::SpectrumAttr("channel0", Tango::DEV_DOUBLE, 1000000);
Tango::UserDefaultAttrProp channel0_prop;
channel0_prop.set_label("channel0");
channel0_prop.set_unit("volts");
channel0->set_default_properties(channel0_prop);
att_list.push_back(channel0);
// Attribute : channel1
Tango::SpectrumAttr *channel1 =
new Tango::SpectrumAttr("channel1", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel1_prop;
channel1_prop.set_label("channel1");
channel1_prop.set_unit("volts");
channel1->set_default_properties(channel1_prop);
att_list.push_back(channel1);
// Attribute : channel2
Tango::SpectrumAttr *channel2 =
new Tango::SpectrumAttr("channel2", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel2_prop;
channel2_prop.set_label("channel2");
channel2_prop.set_unit("volts");
channel2->set_default_properties(channel2_prop);
att_list.push_back(channel2);
// Attribute : channel3
Tango::SpectrumAttr *channel3 =
new Tango::SpectrumAttr("channel3", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel3_prop;
channel3_prop.set_label("channel3");
channel3->set_default_properties(channel3_prop);
att_list.push_back(channel3);
// Attribute : channel4
Tango::SpectrumAttr *channel4 =
new Tango::SpectrumAttr("channel4", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel4_prop;
channel4_prop.set_label("channel4");
channel4_prop.set_unit("volts");
channel4->set_default_properties(channel4_prop);
att_list.push_back(channel4);
// Attribute : channel5
Tango::SpectrumAttr *channel5 =
new Tango::SpectrumAttr("channel5", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel5_prop;
channel5_prop.set_label("channel");
channel5_prop.set_unit("volts");
channel5->set_default_properties(channel5_prop);
att_list.push_back(channel5);
// Attribute : channel6
Tango::SpectrumAttr *channel6 =
new Tango::SpectrumAttr("channel6", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel6_prop;
channel6_prop.set_label("channel6");
channel6_prop.set_unit("volts");
channel6->set_default_properties(channel6_prop);
att_list.push_back(channel6);
// Attribute : channel7
Tango::SpectrumAttr *channel7 =
new Tango::SpectrumAttr("channel7", Tango::DEV_DOUBLE, 100000);
Tango::UserDefaultAttrProp channel7_prop;
channel7_prop.set_label("channel7");
channel7_prop.set_unit("volts");
channel7->set_default_properties(channel7_prop);
att_list.push_back(channel7);
// Attribute : errorCounter
Tango::Attr *error_counter =
new Tango::Attr("errorCounter", Tango::DEV_DOUBLE, Tango::READ);
Tango::UserDefaultAttrProp error_counter_prop;
error_counter_prop.set_label("error counter");
error_counter_prop.set_format("%i");
error_counter_prop.set_description("Errors occuring during the waveform generation.");
error_counter->set_default_properties(error_counter_prop);
att_list.push_back(error_counter);
// Attribute : useBoardFifo
Tango::Attr *use_board_fifo =
new Tango::Attr("useBoardFifo", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp use_board_fifo_prop;
use_board_fifo_prop.set_label("use board FIFO");
use_board_fifo_prop.set_description("Set to 1 if data have been loaded in FIFO.\nSet to 0 if data is continuously tranfered through DMA (possible underrun)");
use_board_fifo->set_default_properties(use_board_fifo_prop);
att_list.push_back(use_board_fifo);
// Attribute : channel0Enable
Tango::Attr *channel0_enable =
new Tango::Attr("channel0Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel0_enable_prop;
channel0_enable_prop.set_label("channel0Enable");
channel0_enable_prop.set_description("If equals to 1, data is output on channel 0, otherwise the channel is disable.");
channel0_enable->set_default_properties(channel0_enable_prop);
att_list.push_back(channel0_enable);
// Attribute : channel1Enable
Tango::Attr *channel1_enable =
new Tango::Attr("channel1Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel1_enable_prop;
channel1_enable_prop.set_label("channel1Enable");
channel1_enable_prop.set_description("If equals to 1, data is output on channel 1, otherwise the channel is disable.");
channel1_enable->set_default_properties(channel1_enable_prop);
att_list.push_back(channel1_enable);
// Attribute : channel2Enable
Tango::Attr *channel2_enable =
new Tango::Attr("channel2Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel2_enable_prop;
channel2_enable_prop.set_label("channel2Enable");
channel2_enable_prop.set_description("If equals to 1, data is output on channel 2, otherwise the channel is disable.");
channel2_enable->set_default_properties(channel2_enable_prop);
att_list.push_back(channel2_enable);
// Attribute : channel3Enable
Tango::Attr *channel3_enable =
new Tango::Attr("channel3Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel3_enable_prop;
channel3_enable_prop.set_label("channel3Enable");
channel3_enable_prop.set_description("If equals to 1, data is output on channel 3, otherwise the channel is disable.");
channel3_enable->set_default_properties(channel3_enable_prop);
att_list.push_back(channel3_enable);
// Attribute : channel4Enable
Tango::Attr *channel4_enable =
new Tango::Attr("channel4Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel4_enable_prop;
channel4_enable_prop.set_label("channel4Enable");
channel4_enable_prop.set_description("If equals to 1, data is output on channel 4, otherwise the channel is disable.");
channel4_enable->set_default_properties(channel4_enable_prop);
att_list.push_back(channel4_enable);
// Attribute : channel5Enable
Tango::Attr *channel5_enable =
new Tango::Attr("channel5Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel5_enable_prop;
channel5_enable_prop.set_label("channel5Enable");
channel5_enable_prop.set_description("If equals to 1, data is output on channel 5, otherwise the channel is disable.");
channel5_enable->set_default_properties(channel5_enable_prop);
att_list.push_back(channel5_enable);
// Attribute : channel6Enable
Tango::Attr *channel6_enable =
new Tango::Attr("channel6Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel6_enable_prop;
channel6_enable_prop.set_label("channel6Enable");
channel6_enable_prop.set_description("If equals to 1, data is output on channel 6, otherwise the channel is disable.");
channel6_enable->set_default_properties(channel6_enable_prop);
att_list.push_back(channel6_enable);
// Attribute : channel7Enable
Tango::Attr *channel7_enable =
new Tango::Attr("channel7Enable", Tango::DEV_SHORT, Tango::READ);
Tango::UserDefaultAttrProp channel7_enable_prop;
channel7_enable_prop.set_label("channel7Enable");
channel7_enable_prop.set_description("If equals to 1, data is output on channel 7, otherwise the channel is disable.");
channel7_enable->set_default_properties(channel7_enable_prop);
att_list.push_back(channel7_enable);
}
//+----------------------------------------------------------------------------
//
// method : ContinuousAOClass::write_class_property
//
// description : Set class description as property in database
//
//-----------------------------------------------------------------------------
void ContinuousAOClass::write_class_property()
{
// First time, check if database used
//--------------------------------------------
if (Tango::Util::_UseDb == false)
return;
// Prepeare DbDatum
//--------------------------------------------
Tango::DbDatum title("ProjectTitle");
string str_title("Continuous Anolog Output");
title << str_title;
Tango::DbDatum description("Description");
string str_desc("Perform continuous anolog ouput (waveform generation) on the selected outputs.");
description << str_desc;
// Use the doc_url field to store all information
// on the server version and CVS
string::size_type pos, len;
// 1) Manage module name
// get rid of the $RCSfile: prefix and of Class.cpp suffix
string classname = RCSfile;
pos = classname.find("$RCSfile: ");
len = classname.length();
if (pos != string::npos)
classname= classname.substr(pos+10, len- pos-10);
pos = classname.find ("Class.cpp",0);
if (pos != string::npos)
classname=classname.substr(0,pos);
// 2) Manage version number with SOLEIL CVS rules
// tag name is in the form : release_1_0 ==> transform it to 1.0
//
string version ;
string str_TagName=string(TagName);
pos = str_TagName.find_first_of("_",0);
if (pos != string::npos)
version= str_TagName.substr(pos+1, 3);
pos = version.find_first_of("_",0);
if (pos != string::npos)
version[pos] = '.';
// Store all info in the str_url property
string str_url= "Documentation URL = " + string(HttpServer) + classname +"-" + version + "/index.html" + "\n";
str_url= str_url + " Version CVS Tag = " + string(TagName)+ "\n";
str_url= str_url + " CVS location = " + string(FileName)+ "\n";
Tango::DbDatum doc_url("doc_url");
doc_url << str_url;
// Push everything in DataBase
Tango::DbData data;
data.push_back(title);
data.push_back(description);
data.push_back(doc_url);
// Call database and and values
//--------------------------------------------
get_db_class()->put_property(data);
}
} // namespace