Skip to content
Snippets Groups Projects
Commit 16ba3e24 authored by Xavier ELATTAOUI's avatar Xavier ELATTAOUI
Browse files

renamed PREVAC_VCH01 to PREVAC_VCH

parent b08b4c53
Branches
No related tags found
No related merge requests found
static const char *RcsId = "$Id: PREVAC_VCH01.cpp,v 1.4 2013-06-26 15:15:04 jean_coquet Exp $";
//+=============================================================================
//
// file : PREVAC_VCH01.cpp
//
// description : C++ source for the PREVAC_VCH01 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
// PREVAC_VCH01 are implemented in this file.
//
// project : TANGO Device Server
//
// $Author: jean_coquet $
//
// $Revision: 1.4 $
//
// $Revision: 1.4 $
// $Date: 2013-06-26 15:15:04 $
//
// SVN only:
// $HeadURL: $
//
// CVS only:
// $Source: /segfs/tango/tmp/tango-ds.new/cvsroot/Miscellaneous/PREVAC_VCH01/src/PREVAC_VCH01.cpp,v $
// $Log: not supported by cvs2svn $
// Revision 1.3 2013/05/14 13:53:55 jean_coquet
// ca commence a dialoguer
// petit probleme de lecture du temps
//
// Revision 1.2 2013/05/14 10:20:07 jean_coquet
// premiers tests
// travail en cours
//
// Revision 1.1 2013/01/28 13:17:11 olivierroux
// - initial bug #24391
//
//
// copyleft : Synchrotron SOLEIL
// L'Orme des merisiers - Saint Aubin
// BP48 - 91192 Gif sur Yvette
// FRANCE
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
//===================================================================
//
// The following table gives the correspondence
// between commands and method name.
//
// Command name| Method name
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
// Off | off()
// On | on()
//
//===================================================================
#include <tango.h>
#include <PREVAC_VCH01.h>
#include <PREVAC_VCH01Class.h>
#include <helpers/PogoHelper.h>
namespace PREVAC_VCH01_ns
{
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::PREVAC_VCH01(string &s)
//
// description : constructor for simulated PREVAC_VCH01
//
// in : - cl : Pointer to the DeviceClass object
// - s : Device name
//
//-----------------------------------------------------------------------------
PREVAC_VCH01::PREVAC_VCH01(Tango::DeviceClass *cl,string &s)
:Tango::Device_4Impl(cl,s.c_str())
{
init_device();
}
PREVAC_VCH01::PREVAC_VCH01(Tango::DeviceClass *cl,const char *s)
:Tango::Device_4Impl(cl,s)
{
init_device();
}
PREVAC_VCH01::PREVAC_VCH01(Tango::DeviceClass *cl,const char *s,const char *d)
:Tango::Device_4Impl(cl,s,d)
{
init_device();
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::delete_device()
//
// description : will be called at device destruction or at init command.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::delete_device()
{
// Delete device allocated objects
INFO_STREAM << "PREVAC_VCH01::delete_device() <-" << std::endl;
if (vch01)
delete vch01;
vch01 = 0;
DELETE_SCALAR_ATTRIBUTE(attr_brightness_read);
DELETE_SCALAR_ATTRIBUTE(attr_time_read);
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::init_device()
//
// description : will be called at device initialization.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::init_device()
{
INFO_STREAM << "PREVAC_VCH01::PREVAC_VCH01() create device " << device_name << endl;
// Initialise variables to default values
//--------------------------------------------
this->init_device_done = false;
this->properties_missing = false;
this->status_str.resize (1024);
this->error_str.resize (256);
status_str.clear ();
com_error = 0;
try
{
CREATE_SCALAR_ATTRIBUTE(attr_brightness_read);
CREATE_SCALAR_ATTRIBUTE(attr_time_read);
}
catch(Tango::DevFailed &e )
{
ERROR_STREAM << "PREVAC_VCH01::init_device : OUT_OF_MEMORY (DevFailed) unable to create attribute(s) " << endl;
ERROR_STREAM << e << endl;
this->status_str = "initialization error caught DevFailed creating attributes";
return;
}
catch(std::bad_alloc)
{
ERROR_STREAM << "PREVAC_VCH01::init_device : OUT_OF_MEMORY (bad_alloc) unable to create attribute(s) " << endl;
this->status_str = "initialization error caught bad_alloc creating attributes";
return;
}
catch(...)
{
ERROR_STREAM << "PREVAC_VCH01::init_device : UNKNOW_ERROR unable to create attribute(s) " << endl;
this->status_str = "initialization error caught (...) creating attributes";
return;
}
get_device_property();
if (properties_missing)
return;
try
{
struct prevac::Config conf;
conf.device_address = 0xC8;
conf.device_group = 0x99;
vch01 = new prevac::Vch01Protocol (serialProxy, conf);
}
catch(Tango::DevFailed &e )
{
ERROR_STREAM << "PREVAC_VCH01::init_device : INITIALIZATION_FAILED (DevFailed) unable to create DeviceProxy on <" << serialProxy << ">" << endl;
ERROR_STREAM << e << endl;
this->status_str = "initialization error caught DevFailed creating proxy on <" + serialProxy + ">\n";
return;
}
catch(std::bad_alloc)
{
ERROR_STREAM << "PREVAC_VCH01::init_device : INITIALIZATION_FAILED (bad_alloc) unable to create DeviceProxy on <" << serialProxy << ">" << endl;
this->status_str = "initialization error caught bad_alloc creating attributes\n";
this->status_str += "initialization error caught DevFailed creating proxy on <" + serialProxy + ">\n";
return;
}
catch(...)
{
ERROR_STREAM << "PREVAC_VCH01::init_device : INITIALIZATION_FAILED (...) unable to create DeviceProxy on <" << serialProxy << ">" << endl; this->status_str = "initialization error caught bad_alloc creating attributes";
this->status_str += "initialization error caught (...) creating proxy on <" + serialProxy + ">\n";
return;
}
this->init_device_done = true;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::get_device_property()
//
// description : Read the device properties from database.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::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("SerialProxy"));
// Call database and extract values
//--------------------------------------------
if (Tango::Util::instance()->_UseDb==true)
get_db_device()->get_property(dev_prop);
Tango::DbDatum def_prop, cl_prop;
PREVAC_VCH01Class *ds_class =
(static_cast<PREVAC_VCH01Class *>(get_device_class()));
int i = -1;
// Try to initialize SerialProxy from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> serialProxy;
else {
// Try to initialize SerialProxy from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> serialProxy;
}
// And try to extract SerialProxy value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> serialProxy;
// End of Automatic code generation
//------------------------------------------------------------------
Tango::DbData data_put;
if (dev_prop[0].is_empty() == true || serialProxy.find ("must be defined") != std::string::npos)
{
this->properties_missing = true;
status_str += "SerialProxy property Error [set here the Serial Proxy Dev Name]\n";
ERROR_STREAM << "SerialProxy property Error [set here the Serial Proxy Dev Name]\n";
Tango::DbDatum property("SerialProxy");
property << "must be defined";
data_put.push_back(property);
}
if(!data_put.empty())
get_db_device()->put_property(data_put);
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::always_executed_hook()
//
// description : method always executed before any command is executed
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::always_executed_hook()
{
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::read_attr_hardware
//
// description : Hardware acquisition for attributes.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::read_attr_hardware(vector<long> &attr_list)
{
DEBUG_STREAM << "PREVAC_VCH01::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// Add your own code here
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::read_brightness
//
// description : Extract real attribute values for brightness acquisition result.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::read_brightness(Tango::Attribute &attr)
{
DEBUG_STREAM << "PREVAC_VCH01::read_brightness(Tango::Attribute &attr) entering... "<< endl;
//-
if (!init_device_done || properties_missing)
return;
try
{
*attr_brightness_read = static_cast <Tango::DevShort> (vch01->get_brightness ());
}
catch (Tango::DevFailed &e)
{
ERROR_STREAM << "PREVAC_VCH01::read_brightness caught DevFailed trying to get value desc : "
<< e.errors [0].desc << std::endl;
this->error_str = "Tango Exception trying to read brightness : " + std::string (e.errors [0].desc);
com_error ++;
return;
}
catch (...)
{
ERROR_STREAM << "PREVAC_VCH01::read_brightness caught (...) trying to get value"
<< std::endl;
this->error_str = "(...) exception error trying to read brightness";
com_error ++;
return;
}
attr.set_value (attr_brightness_read);
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::write_brightness
//
// description : Write brightness attribute values to hardware.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::write_brightness(Tango::WAttribute &attr)
{
DEBUG_STREAM << "PREVAC_VCH01::write_brightness(Tango::WAttribute &attr) entering... "<< endl;
if (!init_device_done || properties_missing)
{
Tango::Except::throw_exception ("INITIALIZATION_FAILED",
"device initialization failed (check serial device, cables...)",
"PREVAC_VCH01::write_brightness");
}
attr.get_write_value (attr_brightness_write);
try
{
vch01->set_brightness (attr_brightness_write);
}
catch (Tango::DevFailed &e)
{
ERROR_STREAM << "PREVAC_VCH01::write_brightness caught DevFailed trying to write value desc : "
<< e.errors[0].desc << std::endl;
this->error_str = "Tango Exception trying to write brightness : " + std::string (e.errors[0].desc);
com_error ++;
return;
}
catch (...)
{
ERROR_STREAM << "PREVAC_VCH01::write_brightness caught (...) trying to write value"
<< std::endl;
this->error_str = "(...) exception error trying to write brightness : ";
com_error ++;
return;
}
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::read_time
//
// description : Extract real attribute values for time acquisition result.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::read_time(Tango::Attribute &attr)
{
DEBUG_STREAM << "PREVAC_VCH01::read_time(Tango::Attribute &attr) entering... "<< endl;
if (!init_device_done || properties_missing)
return;
try
{
*attr_time_read = static_cast <Tango::DevShort> (vch01->get_time_mn ());
}
catch (Tango::DevFailed &e)
{
ERROR_STREAM << "PREVAC_VCH01::read_time caught DevFailed trying to get value desc : "
<< e.errors [0].desc << std::endl;
this->error_str = "Tango Exception trying to read remaining time : " + std::string (e.errors [0].desc);
com_error ++;
return;
}
catch (...)
{
ERROR_STREAM << "PREVAC_VCH01::read_brightness caught (...) trying to get value" << std::endl;
this->error_str = "(...) exception error trying to read remaining time";
com_error ++;
return;
}
attr.set_value (attr_time_read);
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::write_time
//
// description : Write time attribute values to hardware.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01::write_time(Tango::WAttribute &attr)
{
DEBUG_STREAM << "PREVAC_VCH01::write_time(Tango::WAttribute &attr) entering... "<< endl;
if (!init_device_done || properties_missing)
{
Tango::Except::throw_exception ("INITIALIZATION_FAILED",
"device initialization failed (check serial device, cables...)",
"PREVAC_VCH01::write_time");
}
attr.get_write_value (attr_time_write);
try
{
vch01->set_time_mn (attr_time_write);
}
catch (Tango::DevFailed &e)
{
ERROR_STREAM << "PREVAC_VCH01::write_time caught DevFailed trying to write value desc : "
<< e.errors[0].desc << std::endl;
this->error_str = "Tango Exception trying to write time : " + std::string (e.errors[0].desc);
com_error ++;
return;
}
catch (...)
{
ERROR_STREAM << "PREVAC_VCH01::write_time caught (...) trying to write value"
<< std::endl;
this->error_str = "(...) exception error trying to write time : ";
com_error ++;
return;
}
}
//+------------------------------------------------------------------
/**
* method: PREVAC_VCH01::off
*
* description: method to execute "Off"
* switches light OFF
*
*
*/
//+------------------------------------------------------------------
void PREVAC_VCH01::off()
{
DEBUG_STREAM << "PREVAC_VCH01::off(): entering... !" << endl;
// Add your own code to control device here
if (!init_device_done || properties_missing)
{ vch01->off ();
Tango::Except::throw_exception ("INITIALIZATION_FAILED",
"device initializarion dfailed (check serial device, cables...)",
"PREVAC_VCH01::off");
}
vch01->off ();
}
//+------------------------------------------------------------------
/**
* method: PREVAC_VCH01::on
*
* description: method to execute "On"
* switches light ON (for argin time at most)
*
* @param argin time of lighting
*
*/
//+------------------------------------------------------------------
void PREVAC_VCH01::on()
{
DEBUG_STREAM << "PREVAC_VCH01::on(): entering... !" << endl;
// Add your own code to control device here
if (!init_device_done || properties_missing)
{
Tango::Except::throw_exception ("INITIALIZATION_FAILED",
"device initializarion dfailed (check serial device, cables...)",
"PREVAC_VCH01::on");
}
if (attr_time_write < 1)
attr_time_write = 1;
if (attr_time_write > 600)
attr_time_write = 600;
if (attr_brightness_write < 1)
attr_brightness_write = 10;
if (attr_brightness_write > 100)
attr_brightness_write = 100;
vch01->on (attr_time_write, attr_brightness_write);
}
//+------------------------------------------------------------------
/**
* method: PREVAC_VCH01::dev_state
*
* description: method to execute "State"
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
*
* @return State Code
*
*/
//+------------------------------------------------------------------
Tango::DevState PREVAC_VCH01::dev_state()
{
DEBUG_STREAM << "PREVAC_VCH01::dev_state(): entering... !" << endl;
// Add your own code to control device here
// Add your own code to control device here
if (!init_device_done || properties_missing)
{
return Tango::FAULT;
}
if (vch01->is_on ())
return Tango::ON;
return Tango::OFF;
}
//+------------------------------------------------------------------
/**
* method: PREVAC_VCH01::dev_status
*
* description: method to execute "Status"
* This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
*
* @return Status description
*
*/
//+------------------------------------------------------------------
Tango::ConstDevString PREVAC_VCH01::dev_status()
{
DEBUG_STREAM << "PREVAC_VCH01::dev_status(): entering... !" << endl;
// Add your own code to control device here
if (!init_device_done || properties_missing)
{
return status_str.c_str ();
}
status_str = "device is up and running\n";
if (vch01->is_on ())
status_str += "LED ON";
else
status_str += "LED OFF";
return status_str.c_str ();
}
} // namespace
//=============================================================================
//
// file : PREVAC_VCH01.h
//
// description : Include for the PREVAC_VCH01 class.
//
// project : PREVAC_VCH01
//
// $Author: jean_coquet $
//
// $Revision: 1.3 $
// $Date: 2013-06-26 15:15:04 $
//
// SVN only:
// $HeadURL: $
//
// CVS only:
// $Source: /segfs/tango/tmp/tango-ds.new/cvsroot/Miscellaneous/PREVAC_VCH01/src/PREVAC_VCH01.h,v $
// $Log: not supported by cvs2svn $
// Revision 1.2 2013/05/14 13:53:55 jean_coquet
// ca commence a dialoguer
// petit probleme de lecture du temps
//
// Revision 1.1 2013/01/28 13:17:11 olivierroux
// - initial bug #24391
//
//
// copyleft : Synchrotron SOLEIL
// L'Orme des merisiers - Saint Aubin
// BP48 - 91192 Gif sur Yvette
// FRANCE
//
//=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _PREVAC_VCH01_H
#define _PREVAC_VCH01_H
#include <tango.h>
#include "VCH01Protocol.h"
//using namespace Tango;
/**
* @author $Author: jean_coquet $
* @version $Revision: 1.3 $
*/
// Add your own constant definitions here.
//-----------------------------------------------
namespace PREVAC_VCH01_ns
{
/**
* Class Description:
* controls the light controller VCH01 from PREVAC
*/
/*
* Device States Description:
*/
class PREVAC_VCH01: public Tango::Device_4Impl
{
public :
// Add your own data members here
//-----------------------------------------
// Here is the Start of the automatic code generation part
//-------------------------------------------------------------
/**
* @name attributes
* Attribute member data.
*/
//@{
Tango::DevShort *attr_brightness_read;
Tango::DevShort attr_brightness_write;
Tango::DevShort *attr_time_read;
Tango::DevShort attr_time_write;
//@}
/**
* @name Device properties
* Device properties member data.
*/
//@{
/**
* name of the Tango Serial line device proxy
*/
string serialProxy;
//@}
/**
* @name Device properties
* Device property member data.
*/
//@{
//@}
/**@name Constructors
* Miscellaneous constructors */
//@{
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device Name
*/
PREVAC_VCH01(Tango::DeviceClass *cl,string &s);
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device Name
*/
PREVAC_VCH01(Tango::DeviceClass *cl,const char *s);
/**
* Constructs a newly allocated Command object.
*
* @param cl Class.
* @param s Device name
* @param d Device description.
*/
PREVAC_VCH01(Tango::DeviceClass *cl,const char *s,const char *d);
//@}
/**@name Destructor
* Only one destructor is defined for this class */
//@{
/**
* The object destructor.
*/
~PREVAC_VCH01() {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 before execution command method.
*/
virtual void always_executed_hook();
//@}
/**
* @name PREVAC_VCH01 methods prototypes
*/
//@{
/**
* Hardware acquisition for attributes.
*/
virtual void read_attr_hardware(vector<long> &attr_list);
/**
* Extract real attribute values for brightness acquisition result.
*/
virtual void read_brightness(Tango::Attribute &attr);
/**
* Write brightness attribute values to hardware.
*/
virtual void write_brightness(Tango::WAttribute &attr);
/**
* Extract real attribute values for time acquisition result.
*/
virtual void read_time(Tango::Attribute &attr);
/**
* Write time attribute values to hardware.
*/
virtual void write_time(Tango::WAttribute &attr);
/**
* Read/Write allowed for brightness attribute.
*/
virtual bool is_brightness_allowed(Tango::AttReqType type);
/**
* Read/Write allowed for time attribute.
*/
virtual bool is_time_allowed(Tango::AttReqType type);
/**
* Execution allowed for Off command.
*/
virtual bool is_Off_allowed(const CORBA::Any &any);
/**
* Execution allowed for On command.
*/
virtual bool is_On_allowed(const CORBA::Any &any);
/**
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
* @return State Code
* @exception DevFailed
*/
virtual Tango::DevState dev_state();
/**
* This command gets the device status (stored in its <i>device_status</i> data member) and returns it to the caller.
* @return Status description
* @exception DevFailed
*/
virtual Tango::ConstDevString dev_status();
/**
* switches light OFF
* @exception DevFailed
*/
void off();
/**
*
* @exception DevFailed
*/
void on();
/**
* 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
//-----------------------------------------
bool properties_missing;
bool init_device_done;
bool communication_error;
std::string status_str;
std::string error_str;
long com_error;
prevac::Vch01Protocol * vch01;
};
} // namespace_ns
#endif // _PREVAC_VCH01_H
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="PREVAC_VCH01" pogoRevision="9.6">
<description description="controls the light controller VCH01 from PREVAC" title="PREVAC_VCH01" sourcePath="/home/experiences/galaxies/com-galaxies/ICA/xe/prevac_vch01/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions,html Pages" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false" descriptionHtmlExists="true">
<inheritances classname="Device_4Impl" sourcePath=""/>
<identification contact="at synchrotron-soleil.fr - jean.coquet" author="jean.coquet" emailDomain="synchrotron-soleil.fr" classFamily="Miscellaneous" siteSpecific="" platform="All Platforms" bus="RS485" manufacturer="PREVAC" reference="VCH01"/>
</description>
<deviceProperties name="SerialProxy" description="name of the Tango Serial line device proxy">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>must be defined</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its &lt;i>device_state&lt;/i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="State Code">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its &lt;i>device_status&lt;/i> data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Status description">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="Off" description="switches light OFF" execMethod="off" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="On" description="" execMethod="on" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="brightness" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Brightness in %" label="Brightness %" unit="%" standardUnit="%" displayUnit="%" format="%3d" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="time" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Write : Time in minutes of lighting \nRead : Time remaining" label="Time (min.)" unit="mn" standardUnit="mn" displayUnit="min." format="%3d" maxValue="600" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<preferences docHome="../doc/doc_html" makefileHome="$(TANGO_HOME)"/>
</classes>
</pogoDsl:PogoSystem>
static const char *ClassId = "$Id: PREVAC_VCH01Class.cpp,v 1.2 2013-06-26 15:15:04 jean_coquet Exp $";
static const char *TagName = "$Name: not supported by cvs2svn $";
static const char *CvsPath = "$Source: /segfs/tango/tmp/tango-ds.new/cvsroot/Miscellaneous/PREVAC_VCH01/src/PREVAC_VCH01Class.cpp,v $";
static const char *SvnPath = "$HeadURL: $";
static const char *HttpServer = "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/";
//+=============================================================================
//
// file : PREVAC_VCH01Class.cpp
//
// description : C++ source for the PREVAC_VCH01Class. A singleton
// class derived from DeviceClass. It implements the
// command list and all properties and methods required
// by the PREVAC_VCH01 once per process.
//
// project : TANGO Device Server
//
// $Author: jean_coquet $
//
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
// Revision 1.1 2013/01/28 13:17:11 olivierroux
// - initial bug #24391
//
//
// copyleft : European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <PREVAC_VCH01.h>
#include <PREVAC_VCH01Class.h>
//+----------------------------------------------------------------------------
/**
* Create PREVAC_VCH01Class singleton and return it in a C function for Python usage
*/
//+----------------------------------------------------------------------------
extern "C" {
#ifdef WIN32
__declspec(dllexport)
#endif
Tango::DeviceClass *_create_PREVAC_VCH01_class(const char *name) {
return PREVAC_VCH01_ns::PREVAC_VCH01Class::init(name);
}
}
namespace PREVAC_VCH01_ns
{
//+----------------------------------------------------------------------------
//
// method : OnCmd::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 executed
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *OnCmd::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "OnCmd::execute(): arrived" << endl;
((static_cast<PREVAC_VCH01 *>(device))->on());
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// method : OffClass::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 executed
// - in_any : The command input data
//
// returns : The command output data (packed in the Any object)
//
//-----------------------------------------------------------------------------
CORBA::Any *OffClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "OffClass::execute(): arrived" << endl;
((static_cast<PREVAC_VCH01 *>(device))->off());
return new CORBA::Any();
}
//
//----------------------------------------------------------------
// Initialize pointer for singleton pattern
//----------------------------------------------------------------
//
PREVAC_VCH01Class *PREVAC_VCH01Class::_instance = NULL;
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::PREVAC_VCH01Class(string &s)
//
// description : constructor for the PREVAC_VCH01Class
//
// in : - s : The class name
//
//-----------------------------------------------------------------------------
PREVAC_VCH01Class::PREVAC_VCH01Class(string &s):DeviceClass(s)
{
cout2 << "Entering PREVAC_VCH01Class constructor" << endl;
set_default_property();
get_class_property();
write_class_property();
cout2 << "Leaving PREVAC_VCH01Class constructor" << endl;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::~PREVAC_VCH01Class()
//
// description : destructor for the PREVAC_VCH01Class
//
//-----------------------------------------------------------------------------
PREVAC_VCH01Class::~PREVAC_VCH01Class()
{
_instance = NULL;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::instance
//
// description : Create the object if not already done. Otherwise, just
// return a pointer to the object
//
// in : - name : The class name
//
//-----------------------------------------------------------------------------
PREVAC_VCH01Class *PREVAC_VCH01Class::init(const char *name)
{
if (_instance == NULL)
{
try
{
string s(name);
_instance = new PREVAC_VCH01Class(s);
}
catch (bad_alloc)
{
throw;
}
}
return _instance;
}
PREVAC_VCH01Class *PREVAC_VCH01Class::instance()
{
if (_instance == NULL)
{
cerr << "Class is not initialised !!" << endl;
exit(-1);
}
return _instance;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::command_factory
//
// description : Create the command object(s) and store them in the
// command list
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01Class::command_factory()
{
command_list.push_back(new OffClass("Off",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
command_list.push_back(new OnCmd("On",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
// add polling if any
for (unsigned int i=0 ; i<command_list.size(); i++)
{
}
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::get_class_property
//
// description : Get the class property for specified name.
//
// in : string name : The property name
//
//+----------------------------------------------------------------------------
Tango::DbDatum PREVAC_VCH01Class::get_class_property(string &prop_name)
{
for (unsigned 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 : PREVAC_VCH01Class::get_default_device_property()
//
// description : Return the default value for device property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum PREVAC_VCH01Class::get_default_device_property(string &prop_name)
{
for (unsigned 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 : PREVAC_VCH01Class::get_default_class_property()
//
// description : Return the default value for class property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum PREVAC_VCH01Class::get_default_class_property(string &prop_name)
{
for (unsigned 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 : PREVAC_VCH01Class::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 PREVAC_VCH01Class::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 PREVAC_VCH01(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: PREVAC_VCH01Class::attribute_factory(vector<Tango::Attr *> &att_list)
//-----------------------------------------------------------------------------
void PREVAC_VCH01Class::attribute_factory(vector<Tango::Attr *> &att_list)
{
// Attribute : brightness
brightnessAttrib *brightness = new brightnessAttrib();
Tango::UserDefaultAttrProp brightness_prop;
brightness_prop.set_label("Brightness %");
brightness_prop.set_unit("%");
brightness_prop.set_standard_unit("%");
brightness_prop.set_display_unit("%");
brightness_prop.set_format("%3d");
brightness_prop.set_description("Brightness in %");
brightness->set_default_properties(brightness_prop);
brightness->set_memorized();
brightness->set_memorized_init(false);
att_list.push_back(brightness);
// Attribute : time
timeAttrib *time = new timeAttrib();
Tango::UserDefaultAttrProp time_prop;
time_prop.set_label("Time (min.)");
time_prop.set_unit("mn");
time_prop.set_standard_unit("mn");
time_prop.set_display_unit("min.");
time_prop.set_format("%3d");
time_prop.set_max_value("600");
time_prop.set_min_value("0");
time_prop.set_description("Write : Time in minutes of lighting \nRead : Time remaining");
time->set_default_properties(time_prop);
time->set_memorized();
time->set_memorized_init(false);
att_list.push_back(time);
// End of Automatic code generation
//-------------------------------------------------------------
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::get_class_property()
//
// description : Read the class properties from database.
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01Class::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 : PREVAC_VCH01Class::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 PREVAC_VCH01Class::set_default_property()
{
string prop_name;
string prop_desc;
string prop_def;
vector<string> vect_data;
// Set Default Class Properties
// Set Default Device Properties
prop_name = "SerialProxy";
prop_desc = "name of the Tango Serial line device proxy";
prop_def = "must be defined";
vect_data.clear();
vect_data.push_back("must be defined");
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);
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01Class::write_class_property
//
// description : Set class description as property in database
//
//-----------------------------------------------------------------------------
void PREVAC_VCH01Class::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("PREVAC_VCH01");
title << str_title;
data.push_back(title);
// Put Description
Tango::DbDatum description("Description");
vector<string> str_desc;
str_desc.push_back("controls the light controller VCH01 from PREVAC");
description << str_desc;
data.push_back(description);
// put cvs or svn location
string filename(classname);
filename += "Class.cpp";
// Create a string with the class ID to
// get the string into the binary
string class_id(ClassId);
// check for cvs information
string src_path(CvsPath);
start = src_path.find("/");
if (start!=string::npos)
{
end = src_path.find(filename);
if (end>start)
{
string strloc = src_path.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);
}
}
// check for svn information
else
{
string src_path(SvnPath);
start = src_path.find("://");
if (start!=string::npos)
{
end = src_path.find(filename);
if (end>start)
{
header = "$HeadURL: ";
start = header.length();
string strloc = src_path.substr(start, (end-start));
Tango::DbDatum svn_loc("svn_location");
svn_loc << strloc;
data.push_back(svn_loc);
}
}
}
// Get CVS or SVN revision tag
// CVS tag
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);
}
// SVN tag
string svnpath(SvnPath);
header = "$HeadURL: ";
start = header.length();
end = svnpath.find(endstr);
if (end!=string::npos && end>start)
{
string strloc = svnpath.substr(start, end-start);
string tagstr ("/tags/");
start = strloc.find(tagstr);
if ( start!=string::npos )
{
start = start + tagstr.length();
end = strloc.find(filename);
string strtag = strloc.substr(start, end-start-1);
Tango::DbDatum svn_tag("svn_tag");
svn_tag << strtag;
data.push_back(svn_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 : PREVAC_VCH01Class.h
//
// description : Include for the PREVAC_VCH01Class root class.
// This class is the singleton class for
// the PREVAC_VCH01 device class.
// It contains all properties and methods which the
// PREVAC_VCH01 requires only once e.g. the commands.
//
// project : TANGO Device Server
//
// $Author: jean_coquet $
//
// $Revision: 1.2 $
// $Date: 2013-06-26 15:15:04 $
//
// SVN only:
// $HeadURL: $
//
// CVS only:
// $Source: /segfs/tango/tmp/tango-ds.new/cvsroot/Miscellaneous/PREVAC_VCH01/src/PREVAC_VCH01Class.h,v $
// $Log: not supported by cvs2svn $
// Revision 1.1 2013/01/28 13:17:11 olivierroux
// - initial bug #24391
//
//
// copyleft : European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
//=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#ifndef _PREVAC_VCH01CLASS_H
#define _PREVAC_VCH01CLASS_H
#include <tango.h>
#include <PREVAC_VCH01.h>
namespace PREVAC_VCH01_ns
{//=====================================
// Define classes for attributes
//=====================================
class timeAttrib: public Tango::Attr
{
public:
timeAttrib():Attr("time", Tango::DEV_SHORT, Tango::READ_WRITE) {};
~timeAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<PREVAC_VCH01 *>(dev))->read_time(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<PREVAC_VCH01 *>(dev))->write_time(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<PREVAC_VCH01 *>(dev))->is_time_allowed(ty);}
};
class brightnessAttrib: public Tango::Attr
{
public:
brightnessAttrib():Attr("brightness", Tango::DEV_SHORT, Tango::READ_WRITE) {};
~brightnessAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<PREVAC_VCH01 *>(dev))->read_brightness(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<PREVAC_VCH01 *>(dev))->write_brightness(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<PREVAC_VCH01 *>(dev))->is_brightness_allowed(ty);}
};
//=========================================
// Define classes for commands
//=========================================
class OnCmd : public Tango::Command
{
public:
OnCmd(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) {};
OnCmd(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~OnCmd() {};
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<PREVAC_VCH01 *>(dev))->is_On_allowed(any);}
};
class OffClass : public Tango::Command
{
public:
OffClass(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) {};
OffClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~OffClass() {};
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<PREVAC_VCH01 *>(dev))->is_Off_allowed(any);}
};
//
// The PREVAC_VCH01Class singleton definition
//
class
#ifdef WIN32
__declspec(dllexport)
#endif
PREVAC_VCH01Class : 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 PREVAC_VCH01Class *init(const char *);
static PREVAC_VCH01Class *instance();
~PREVAC_VCH01Class();
Tango::DbDatum get_class_property(string &);
Tango::DbDatum get_default_device_property(string &);
Tango::DbDatum get_default_class_property(string &);
protected:
PREVAC_VCH01Class(string &);
static PREVAC_VCH01Class *_instance;
void command_factory();
void get_class_property();
void attribute_factory(vector<Tango::Attr *> &);
void write_class_property();
void set_default_property();
string get_cvstag();
string get_cvsroot();
private:
void device_factory(const Tango::DevVarStringArray *);
};
} // namespace PREVAC_VCH01_ns
#endif // _PREVAC_VCH01CLASS_H
static const char *RcsId = "$Id $";
//+=============================================================================
//
// file : PREVAC_VCH01StateMachine.cpp
//
// description : C++ source for the PREVAC_VCH01 and its alowed
// methods for commands and attributes
//
// project : TANGO Device Server
//
// $Author: olivierroux $
//
// $Revision: 1.1 $
// $Date: 2013-01-28 13:17:11 $
//
// SVN only:
// $HeadURL: $
//
// CVS only:
// $Source: /segfs/tango/tmp/tango-ds.new/cvsroot/Miscellaneous/PREVAC_VCH01/src/PREVAC_VCH01StateMachine.cpp,v $
// $Log: not supported by cvs2svn $
//
// copyleft : European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <PREVAC_VCH01.h>
#include <PREVAC_VCH01Class.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 PREVAC_VCH01_ns
{
//=================================================
// Attributes Allowed Methods
//=================================================
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::is_brightness_allowed
//
// description : Read/Write allowed for brightness attribute.
//
//-----------------------------------------------------------------------------
bool PREVAC_VCH01::is_brightness_allowed(Tango::AttReqType type)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::is_time_allowed
//
// description : Read/Write allowed for time attribute.
//
//-----------------------------------------------------------------------------
bool PREVAC_VCH01::is_time_allowed(Tango::AttReqType type)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//=================================================
// Commands Allowed Methods
//=================================================
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::is_Off_allowed
//
// description : Execution allowed for Off command.
//
//-----------------------------------------------------------------------------
bool PREVAC_VCH01::is_Off_allowed(const CORBA::Any &any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
//+----------------------------------------------------------------------------
//
// method : PREVAC_VCH01::is_On_allowed
//
// description : Execution allowed for On command.
//
//-----------------------------------------------------------------------------
bool PREVAC_VCH01::is_On_allowed(const CORBA::Any &any)
{
// End of Generated Code
// Re-Start of Generated Code
return true;
}
} // namespace PREVAC_VCH01_ns
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment