Skip to content
Snippets Groups Projects
Commit 27e28adb authored by Lucio Zambon's avatar Lucio Zambon
Browse files

Initial import

parent 868ef43f
No related branches found
No related tags found
No related merge requests found
NAME_SRV = timeri-srv
CXXFLAGS =
LDFLAGS =
include ../makefiles/Make-9.3.3.in
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/timer/src/ClassFactory.cpp,v 1.1.1.1 2013-09-06 09:40:41 zambonl Exp $";
//+=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible to create
// all class singletin for a device server. It is called
// at device server startup
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: ClassFactory.cpp,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <TimerClass.h>
/**
* Create TimerClass singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
add_class(Timer_ns::TimerClass::init("Timer"));
}
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/timer/src/Timer.cpp,v 1.1.1.1 2013-09-06 09:40:41 zambonl Exp $";
//+=============================================================================
//
// file : Timer.cpp
//
// description : C++ source for the Timer and its commands.
// The class is derived from Device. It represents the
// CORBA servant object which will be accessed from the
// network. All commands which can be executed on the
// Timer are implemented in this file.
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: Timer.cpp,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
//===================================================================
//
// The following table gives the correspondance
// between commands and method's name.
//
// Command's name| Method's name
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
// Stop | stop()
// Start | start()
//
//===================================================================
#include <tango.h>
#include <Timer.h>
#include <TimerClass.h>
namespace Timer_ns
{
//+----------------------------------------------------------------------------
//
// method : Timer::Timer(string &s)
//
// description : constructor for simulated Timer
//
// in : - cl : Pointer to the DeviceClass object
// - s : Device name
//
//-----------------------------------------------------------------------------
Timer::Timer(Tango::DeviceClass *cl,string &s)
:TANGO_BASE_CLASS(cl,s.c_str())
{
init_device();
}
Timer::Timer(Tango::DeviceClass *cl,const char *s)
:TANGO_BASE_CLASS(cl,s)
{
init_device();
}
Timer::Timer(Tango::DeviceClass *cl,const char *s,const char *d)
:TANGO_BASE_CLASS(cl,s,d)
{
init_device();
}
/*
* timestamp()
* send a timestamp to standard output
*/
void Timer::timestamp()
{
struct tm *mytime;
time_t myTime_t;
myTime_t = time(NULL);
mytime = localtime(&myTime_t);
strftime(timeLong, 79, "%Y-%m-%d %H:%M:%S ", mytime);
}
//+----------------------------------------------------------------------------
//
// method : supthread::msleep()
//
// description : sleep for some milliseconds
//
//-----------------------------------------------------------------------------
void Timer::msleep(long milliseconds)
{
}
//+----------------------------------------------------------------------------
//
// method : Timer::delete_device()
//
// description : will be called at device destruction or at init command.
//
//-----------------------------------------------------------------------------
void Timer::delete_device()
{
// Delete device's allocated object
}
//+----------------------------------------------------------------------------
//
// method : Timer::init_device()
//
// description : will be called at device initialization.
//
//-----------------------------------------------------------------------------
void Timer::init_device()
{
INFO_STREAM << "Timer::Timer() create device " << device_name << endl;
// Initialise variables to default values
//--------------------------------------------
get_device_property();
// alloc array used for status bits
datab.length(3);
startTime = 0;
}
//+----------------------------------------------------------------------------
//
// method : Timer::get_device_property()
//
// description : Read the device properties from database.
//
//-----------------------------------------------------------------------------
void Timer::get_device_property()
{
// Initialize your default values here (if not done with POGO).
//------------------------------------------------------------------
// Read device properties from database.(Automatic code generation)
//------------------------------------------------------------------
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("SleepTime"));
// Call database and extract values
//--------------------------------------------
if (Tango::Util::instance()->_UseDb==true)
get_db_device()->get_property(dev_prop);
Tango::DbDatum def_prop, cl_prop;
TimerClass *ds_class =
(static_cast<TimerClass *>(get_device_class()));
int i = -1;
// End of Automatic code generation
//------------------------------------------------------------------
}
//+----------------------------------------------------------------------------
//
// method : Timer::always_executed_hook()
//
// description : method always executed before any command is executed
//
//-----------------------------------------------------------------------------
void Timer::always_executed_hook()
{
}
//+----------------------------------------------------------------------------
//
// method : Timer::read_attr_hardware
//
// description : Hardware acquisition for attributes.
//
//-----------------------------------------------------------------------------
void Timer::read_attr_hardware(vector<long> &attr_list)
{
DEBUG_STREAM << "Timer::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// Add your own code here
}
//+----------------------------------------------------------------------------
//
// method : Timer::read_TimeToGo
//
// description : Extract real attribute values for TimeToGo acquisition result.
//
//-----------------------------------------------------------------------------
void Timer::read_TimeToGo(Tango::Attribute &attr)
{
DEBUG_STREAM << "Timer::read_TimeToGo(Tango::Attribute &attr) entering... "<< endl;
long t;
t = 0;
if (startTime > 0) {
t = requiredTime + startTime - time(NULL);
}
attr_l_rd = t>0? t: 0;
attr.set_value(&attr_l_rd);
}
//+----------------------------------------------------------------------------
//
// method : Timer::read_StateFlags
//
// description : Extract real attribute values for StateFlags acquisition result.
//
//-----------------------------------------------------------------------------
void Timer::read_StateFlags(Tango::Attribute &attr)
{
DEBUG_STREAM << "Timer::read_StateFlags(Tango::Attribute &attr) entering... "<< endl;
datab[0] = (bool) (startTime>0);
datab[1] = (bool) (startTime>0? time(NULL) - startTime > requiredTime: 0);
datab[2] = !datab[1];
attr_ab_rd = &datab[0];
attr.set_value(attr_ab_rd, 3, 0, false);
}
//+------------------------------------------------------------------
/**
* method: Timer::stop
*
* description: method to execute "Stop"
* stop and reset timer
*
*
*/
//+------------------------------------------------------------------
void Timer::stop()
{
DEBUG_STREAM << "Timer::stop(): entering... !" << endl;
// Add your own code to control device here
startTime = 0;
timestamp(); cout << timeLong << " timer stopped" << endl;
}
//+------------------------------------------------------------------
/**
* method: Timer::start
*
* description: method to execute "Start"
*
* @param argin time to sleep for
*
*/
//+------------------------------------------------------------------
void Timer::start(Tango::DevDouble argin)
{
DEBUG_STREAM << "Timer::start(): entering... !" << endl;
// Add your own code to control device here
if (argin < 0) {
startTime = 0;
argin = -argin;
}
if (startTime == 0) {
startTime = time(NULL);
requiredTime = argin;
timestamp(); cout << timeLong << " timer started for " << requiredTime << " seconds" << endl;
}
else {
Tango::Except::throw_exception(
(const char *) "timer is already running",
(const char *) "Warning: already started",
(const char *) "Timer::start() warning", Tango::WARN);
return;
}
}
} // namespace
//=============================================================================
//
// file : Timer.h
//
// description : Include for the Timer class.
//
// project : timer
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: Timer.h,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _TIMER_H
#define _TIMER_H
#include <tango.h>
//using namespace Tango;
/**
* @author $Author: zambonl $
* @version $Revision: 1.1.1.1 $
*/
// Add your own constants definitions here.
//-----------------------------------------------
namespace Timer_ns
{
/**
* Class Description:
* this is a timer, designed to sleep for a while, is is usefull for a sequencer
*/
/*
* Device States Description:
*/
class Timer: public TANGO_BASE_CLASS
{
public :
// Add your own data members here
//-----------------------------------------
void msleep(long milliseconds);
char timeLong[80];
void timestamp();
// Here is the Start of the automatic code generation part
//-------------------------------------------------------------
/**
* @name attributes
* Attributs member data.
*/
//@{
Tango::DevLong *attr_TimeToGo_read;
Tango::DevBoolean *attr_StateFlags_read;
//@}
/**
* @name Device properties
* Device properties member data.
*/
//@{
//@}
/**@name Constructors
* Miscellaneous constructors */
//@{
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device Name
*/
Timer(Tango::DeviceClass *cl,string &s);
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device Name
*/
Timer(Tango::DeviceClass *cl,const char *s);
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device name
* @param d Device description.
*/
Timer(Tango::DeviceClass *cl,const char *s,const char *d);
//@}
/**@name Destructor
* Only one desctructor is defined for this class */
//@{
/**
* The object desctructor.
*/
~Timer() {delete_device();};
/**
* will be called at device destruction or at init command.
*/
void delete_device();
//@}
/**@name Miscellaneous methods */
//@{
/**
* Initialize the device
*/
virtual void init_device();
/**
* Always executed method befor execution command method.
*/
virtual void always_executed_hook();
//@}
/**
* @name Timer methods prototypes
*/
//@{
/**
* Hardware acquisition for attributes.
*/
virtual void read_attr_hardware(vector<long> &attr_list);
/**
* Extract real attribute values for TimeToGo acquisition result.
*/
virtual void read_TimeToGo(Tango::Attribute &attr);
/**
* Extract real attribute values for StateFlags acquisition result.
*/
virtual void read_StateFlags(Tango::Attribute &attr);
/**
* Read/Write allowed for TimeToGo attribute.
*/
virtual bool is_TimeToGo_allowed(Tango::AttReqType type);
/**
* Read/Write allowed for StateFlags attribute.
*/
virtual bool is_StateFlags_allowed(Tango::AttReqType type);
/**
* Execution allowed for Stop command.
*/
virtual bool is_Stop_allowed(const CORBA::Any &any);
/**
* Execution allowed for Start command.
*/
virtual bool is_Start_allowed(const CORBA::Any &any);
/**
* stop and reset timer
* @exception DevFailed
*/
void stop();
/**
*
* @param argin time to sleep for
* @exception DevFailed
*/
void start(Tango::DevDouble);
/**
* Read the device properties from database
*/
void get_device_property();
//@}
// Here is the end of the automatic code generation part
//-------------------------------------------------------------
protected :
// Add your own data members here
//-----------------------------------------
Tango::DevBoolean *attr_ab_rd;
Tango::DevVarBooleanArray datab;
Tango::DevLong attr_l_rd;
long startTime, requiredTime;
};
} // namespace_ns
#endif // _TIMER_H
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/timer/src/TimerClass.cpp,v 1.1.1.1 2013-09-06 09:40:41 zambonl Exp $";
static const char *TagName = "$Name: $";
static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/";
//+=============================================================================
//
// file : TimerClass.cpp
//
// description : C++ source for the TimerClass. A singleton
// class derived from DeviceClass. It implements the
// command list and all properties and methods required
// by the Timer once per process.
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: TimerClass.cpp,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <Timer.h>
#include <TimerClass.h>
//+----------------------------------------------------------------------------
/**
* Create TimerClass singleton and return it in a C function for Python usage
*/
//+----------------------------------------------------------------------------
extern "C" {
#ifdef WIN32
__declspec(dllexport)
#endif
Tango::DeviceClass *_create_Timer_class(const char *name) {
return Timer_ns::TimerClass::init(name);
}
}
namespace Timer_ns
{
//+----------------------------------------------------------------------------
//
// method : StartClass::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 *StartClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "StartClass::execute(): arrived" << endl;
Tango::DevDouble argin;
extract(in_any, argin);
((static_cast<Timer *>(device))->start(argin));
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// 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 << "StopCmd::execute(): arrived" << endl;
((static_cast<Timer *>(device))->stop());
return new CORBA::Any();
}
//
//----------------------------------------------------------------
// Initialize pointer for singleton pattern
//----------------------------------------------------------------
//
TimerClass *TimerClass::_instance = NULL;
//+----------------------------------------------------------------------------
//
// method : TimerClass::TimerClass(string &s)
//
// description : constructor for the TimerClass
//
// in : - s : The class name
//
//-----------------------------------------------------------------------------
TimerClass::TimerClass(string &s):DeviceClass(s)
{
cout2 << "Entering TimerClass constructor" << endl;
set_default_property();
write_class_property();
get_class_property();
cout2 << "Leaving TimerClass constructor" << endl;
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::~TimerClass()
//
// description : destructor for the TimerClass
//
//-----------------------------------------------------------------------------
TimerClass::~TimerClass()
{
_instance = NULL;
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::instance
//
// description : Create the object if not already done. Otherwise, just
// return a pointer to the object
//
// in : - name : The class name
//
//-----------------------------------------------------------------------------
TimerClass *TimerClass::init(const char *name)
{
if (_instance == NULL)
{
try
{
string s(name);
_instance = new TimerClass(s);
}
catch (bad_alloc)
{
throw;
}
}
return _instance;
}
TimerClass *TimerClass::instance()
{
if (_instance == NULL)
{
cerr << "Class is not initialised !!" << endl;
exit(-1);
}
return _instance;
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::command_factory
//
// description : Create the command object(s) and store them in the
// command list
//
//-----------------------------------------------------------------------------
void TimerClass::command_factory()
{
command_list.push_back(new StopCmd("Stop",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
command_list.push_back(new StartClass("Start",
Tango::DEV_DOUBLE, Tango::DEV_VOID,
"time to sleep for",
"",
Tango::OPERATOR));
// add polling if any
for (unsigned int i=0 ; i<command_list.size(); i++)
{
}
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::get_class_property
//
// description : Get the class property for specified name.
//
// in : string name : The property name
//
//+----------------------------------------------------------------------------
Tango::DbDatum TimerClass::get_class_property(string &prop_name)
{
for (int i=0 ; i<cl_prop.size() ; i++)
if (cl_prop[i].name == prop_name)
return cl_prop[i];
// if not found, return an empty DbDatum
return Tango::DbDatum(prop_name);
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::get_default_device_property()
//
// description : Return the default value for device property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum TimerClass::get_default_device_property(string &prop_name)
{
for (int i=0 ; i<dev_def_prop.size() ; i++)
if (dev_def_prop[i].name == prop_name)
return dev_def_prop[i];
// if not found, return an empty DbDatum
return Tango::DbDatum(prop_name);
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::get_default_class_property()
//
// description : Return the default value for class property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum TimerClass::get_default_class_property(string &prop_name)
{
for (int i=0 ; i<cl_def_prop.size() ; i++)
if (cl_def_prop[i].name == prop_name)
return cl_def_prop[i];
// if not found, return an empty DbDatum
return Tango::DbDatum(prop_name);
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::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 TimerClass::device_factory(const Tango::DevVarStringArray *devlist_ptr)
{
// Create all devices.(Automatic code generation)
//-------------------------------------------------------------
for (unsigned long i=0 ; i < devlist_ptr->length() ; i++)
{
cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl;
// Create devices and add it into the device list
//----------------------------------------------------
device_list.push_back(new Timer(this, (*devlist_ptr)[i]));
// Export device to the outside world
// Check before if database used.
//---------------------------------------------
if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false))
export_device(device_list.back());
else
export_device(device_list.back(), (*devlist_ptr)[i]);
}
// End of Automatic code generation
//-------------------------------------------------------------
}
//+----------------------------------------------------------------------------
// Method: TimerClass::attribute_factory(vector<Tango::Attr *> &att_list)
//-----------------------------------------------------------------------------
void TimerClass::attribute_factory(vector<Tango::Attr *> &att_list)
{
// Attribute : TimeToGo
TimeToGoAttrib *time_to_go = new TimeToGoAttrib();
att_list.push_back(time_to_go);
// Attribute : StateFlags
StateFlagsAttrib *state_flags = new StateFlagsAttrib();
Tango::UserDefaultAttrProp state_flags_prop;
state_flags_prop.set_description("bit 0: running\nbit 1: finished\nbit 2: not finished");
state_flags->set_default_properties(state_flags_prop);
att_list.push_back(state_flags);
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::get_class_property()
//
// description : Read the class properties from database.
//
//-----------------------------------------------------------------------------
void TimerClass::get_class_property()
{
// Initialize your default values here (if not done with POGO).
//------------------------------------------------------------------
// Read class properties from database.(Automatic code generation)
//------------------------------------------------------------------
// Call database and extract values
//--------------------------------------------
if (Tango::Util::instance()->_UseDb==true)
get_db_class()->get_property(cl_prop);
Tango::DbDatum def_prop;
int i = -1;
// End of Automatic code generation
//------------------------------------------------------------------
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::set_default_property
//
// description: Set default property (class and device) for wizard.
// For each property, add to wizard property name and description
// If default value has been set, add it to wizard property and
// store it in a DbDatum.
//
//-----------------------------------------------------------------------------
void TimerClass::set_default_property()
{
string prop_name;
string prop_desc;
string prop_def;
vector<string> vect_data;
// Set Default Class Properties
// Set Default Device Properties
}
//+----------------------------------------------------------------------------
//
// method : TimerClass::write_class_property
//
// description : Set class description as property in database
//
//-----------------------------------------------------------------------------
void TimerClass::write_class_property()
{
// First time, check if database used
//--------------------------------------------
if (Tango::Util::_UseDb == false)
return;
Tango::DbData data;
string classname = get_name();
string header;
string::size_type start, end;
// Put title
Tango::DbDatum title("ProjectTitle");
string str_title("timer");
title << str_title;
data.push_back(title);
// Put Description
Tango::DbDatum description("Description");
vector<string> str_desc;
str_desc.push_back("this is a timer, designed to sleep for a while, is is usefull for a sequencer");
description << str_desc;
data.push_back(description);
// put cvs location
string rcsId(RcsId);
string filename(classname);
start = rcsId.find("/");
if (start!=string::npos)
{
filename += "Class.cpp";
end = rcsId.find(filename);
if (end>start)
{
string strloc = rcsId.substr(start, end-start);
// Check if specific repository
start = strloc.find("/cvsroot/");
if (start!=string::npos && start>0)
{
string repository = strloc.substr(0, start);
if (repository.find("/segfs/")!=string::npos)
strloc = "ESRF:" + strloc.substr(start, strloc.length()-start);
}
Tango::DbDatum cvs_loc("cvs_location");
cvs_loc << strloc;
data.push_back(cvs_loc);
}
}
// Get CVS tag revision
string tagname(TagName);
header = "$Name: ";
start = header.length();
string endstr(" $");
end = tagname.find(endstr);
if (end!=string::npos && end>start)
{
string strtag = tagname.substr(start, end-start);
Tango::DbDatum cvs_tag("cvs_tag");
cvs_tag << strtag;
data.push_back(cvs_tag);
}
// Get URL location
string httpServ(HttpServer);
if (httpServ.length()>0)
{
Tango::DbDatum db_doc_url("doc_url");
db_doc_url << httpServ;
data.push_back(db_doc_url);
}
// Put inheritance
Tango::DbDatum inher_datum("InheritedFrom");
vector<string> inheritance;
inheritance.push_back("Device_4Impl");
inher_datum << inheritance;
data.push_back(inher_datum);
// Call database and and values
//--------------------------------------------
get_db_class()->put_property(data);
}
} // namespace
//=============================================================================
//
// file : TimerClass.h
//
// description : Include for the TimerClass root class.
// This class is represents the singleton class for
// the Timer device class.
// It contains all properties and methods which the
// Timer requires only once e.g. the commands.
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: TimerClass.h,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _TIMERCLASS_H
#define _TIMERCLASS_H
#include <tango.h>
#include <Timer.h>
namespace Timer_ns
{
//=====================================
// Define classes for attributes
//=====================================
class StateFlagsAttrib: public Tango::SpectrumAttr
{
public:
StateFlagsAttrib():SpectrumAttr("StateFlags", Tango::DEV_BOOLEAN, Tango::READ, 3) {};
~StateFlagsAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<Timer *>(dev))->read_StateFlags(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<Timer *>(dev))->is_StateFlags_allowed(ty);}
};
class TimeToGoAttrib: public Tango::Attr
{
public:
TimeToGoAttrib():Attr("TimeToGo", Tango::DEV_LONG, Tango::READ) {};
~TimeToGoAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<Timer *>(dev))->read_TimeToGo(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<Timer *>(dev))->is_TimeToGo_allowed(ty);}
};
//=========================================
// Define classes for commands
//=========================================
class StartClass : public Tango::Command
{
public:
StartClass(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) {};
StartClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~StartClass() {};
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<Timer *>(dev))->is_Start_allowed(any);}
};
class StopCmd : public Tango::Command
{
public:
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) {};
StopCmd(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~StopCmd() {};
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<Timer *>(dev))->is_Stop_allowed(any);}
};
//
// The TimerClass singleton definition
//
class TimerClass : public Tango::DeviceClass
{
public:
// properties member data
// add your own data members here
//------------------------------------
public:
Tango::DbData cl_prop;
Tango::DbData cl_def_prop;
Tango::DbData dev_def_prop;
// Method prototypes
static TimerClass *init(const char *);
static TimerClass *instance();
~TimerClass();
Tango::DbDatum get_class_property(string &);
Tango::DbDatum get_default_device_property(string &);
Tango::DbDatum get_default_class_property(string &);
protected:
TimerClass(string &);
static TimerClass *_instance;
void command_factory();
void get_class_property();
void attribute_factory(vector<Tango::Attr *> &);
void write_class_property();
void set_default_property();
private:
void device_factory(const Tango::DevVarStringArray *);
};
} // namespace Timer_ns
#endif // _TIMERCLASS_H
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/timer/src/TimerStateMachine.cpp,v 1.1.1.1 2013-09-06 09:40:41 zambonl Exp $";
//+=============================================================================
//
// file : TimerStateMachine.cpp
//
// description : C++ source for the Timer and its alowed.
// method for commands and attributes
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $
//
// $Log: TimerStateMachine.cpp,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <Timer.h>
#include <TimerClass.h>
/*====================================================================
* This file contains the methods to allow commands and attributes
* read or write execution.
*
* If you wand to add your own code, add it between
* the "End/Re-Start of Generated Code" comments.
*
* If you want, you can also add your own methods.
*====================================================================
*/
namespace Timer_ns
{
//=================================================
// Attributes Allowed Methods
//=================================================
//+----------------------------------------------------------------------------
//
// method : Timer::is_TimeToGo_allowed
//
// description : Read/Write allowed for TimeToGo attribute.
//
//-----------------------------------------------------------------------------
bool Timer::is_TimeToGo_allowed(Tango::AttReqType type)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : Timer::is_StateFlags_allowed
//
// description : Read/Write allowed for StateFlags attribute.
//
//-----------------------------------------------------------------------------
bool Timer::is_StateFlags_allowed(Tango::AttReqType type)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//=================================================
// Commands Allowed Methods
//=================================================
//+----------------------------------------------------------------------------
//
// method : Timer::is_Stop_allowed
//
// description : Execution allowed for Stop command.
//
//-----------------------------------------------------------------------------
bool Timer::is_Stop_allowed(const CORBA::Any &any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : Timer::is_Start_allowed
//
// description : Execution allowed for Start command.
//
//-----------------------------------------------------------------------------
bool Timer::is_Start_allowed(const CORBA::Any &any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
} // namespace Timer_ns
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/timer/src/main.cpp,v 1.1.1.1 2013-09-06 09:40:41 zambonl Exp $";
//+=============================================================================
//
// file : main.cpp
//
// description : C++ source for a TANGO device server main.
// The main rule is to initialise (and create) the Tango
// system and to create the DServerClass singleton.
// The main should be the same for every Tango device server.
//
// project : TANGO Device Server
//
// $Author: zambonl $
//
// $Revision: 1.1.1.1 $ $
//
// $Log: main.cpp,v $
// Revision 1.1.1.1 2013-09-06 09:40:41 zambonl
// Prima versione di timer
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
int main(int argc,char *argv[])
{
Tango::Util *tg;
try
{
// Initialise the device server
//----------------------------------------
tg = Tango::Util::init(argc,argv);
// Create the device server singleton
// which will create everything
//----------------------------------------
tg->server_init(false);
// Run the endless loop
//----------------------------------------
cout << "Ready to accept request" << endl;
tg->server_run();
}
catch (bad_alloc)
{
cout << "Can't allocate memory to store device object !!!" << endl;
cout << "Exiting" << endl;
}
catch (CORBA::Exception &e)
{
Tango::Except::print_exception(e);
cout << "Received a CORBA_Exception" << endl;
cout << "Exiting" << endl;
}
tg->server_cleanup();
return(0);
}
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