Skip to content
Snippets Groups Projects
Commit c5b5b8e3 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

First import from CVS

parent 6c6bd7bc
No related branches found
No related tags found
No related merge requests found
.nse_depinfo
bin
obj
# Eclipse
.cproject
.project
.settings
NAME_SRV = plcint-esa-srv
CXXFLAGS = -I/usr/include/mysql -L/usr/lib/mysql
LDFLAGS = -lmysqlclient
include ../makefiles/Make-9.3.3.in
use intlkpadres;
CREATE TABLE IF NOT EXISTS description
(
id_description smallint not null,
byte tinyint unsigned not null,
bit tinyint unsigned not null,
name varchar(128) not null,
comment varchar(256),
PRIMARY KEY (id_description)
);
CREATE TABLE IF NOT EXISTS alarm_2010
(
timestamp double not null,
event enum('ALARM','NORMAL','ACKNOWLEDGE','SRV_RESTART') not null,
id_description smallint not null,
INDEX(id_description),
INDEX(timestamp),
INDEX(event)
);
CREATE TABLE IF NOT EXISTS alarm_2011
(
timestamp double not null,
event enum('ALARM','NORMAL','ACKNOWLEDGE','SRV_RESTART') not null,
id_description smallint not null,
INDEX(id_description),
INDEX(timestamp),
INDEX(event)
);
This diff is collapsed.
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcesa/src/ClassFactory.cpp,v 1.1 2010-11-23 11:01:23 graziano 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: graziano $
//
// $Revision: 1.1 $
//
// $Log: ClassFactory.cpp,v $
// Revision 1.1 2010-11-23 11:01:23 graziano
// development
//
//
//
//
// 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 <PLCesallClass.h>
/**
* Create PLCesallClass singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
add_class(PLCesall_ns::PLCesallClass::init("PLCesall"));
}
This diff is collapsed.
This diff is collapsed.
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcesa/src/PLCesallClass.cpp,v 1.2 2017-08-21 08:28:37 graziano Exp $";
static const char *TagName = "$Name: release_22 $";
static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/";
//+=============================================================================
//
// file : PLCesallClass.cpp
//
// description : C++ source for the PLCesallClass. A singleton
// class derived from DeviceClass. It implements the
// command list and all properties and methods required
// by the PLCesall once per process.
//
// project : TANGO Device Server
//
// $Author: graziano $
//
// $Revision: 1.2 $
//
// $Log: PLCesallClass.cpp,v $
// Revision 1.2 2017-08-21 08:28:37 graziano
// tango 9.2.5a
//
// Revision 1.1 2010/11/23 11:01:23 graziano
// development
//
//
//
//
// 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 <PLCesall.h>
#include <PLCesallClass.h>
//+----------------------------------------------------------------------------
/**
* Create PLCesallClass singleton and return it in a C function for Python usage
*/
//+----------------------------------------------------------------------------
extern "C" {
#ifdef WIN32
__declspec(dllexport)
#endif
Tango::DeviceClass *_create_PLCesall_class(const char *name) {
return PLCesall_ns::PLCesallClass::init(name);
}
}
namespace PLCesall_ns
{
//+----------------------------------------------------------------------------
//
// method : UpdateDBDescriptionClass::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 *UpdateDBDescriptionClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "UpdateDBDescriptionClass::execute(): arrived" << endl;
((static_cast<PLCesall *>(device))->update_db_description());
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// method : AcknowledgeClass::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 *AcknowledgeClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "AcknowledgeClass::execute(): arrived" << endl;
const Tango::DevVarShortArray *argin;
extract(in_any, argin);
((static_cast<PLCesall *>(device))->acknowledge(argin));
return new CORBA::Any();
}
//+----------------------------------------------------------------------------
//
// method : Send_cmdClass::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 *Send_cmdClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any)
{
cout2 << "Send_cmdClass::execute(): arrived" << endl;
const Tango::DevVarShortArray *argin;
extract(in_any, argin);
((static_cast<PLCesall *>(device))->send_cmd(argin));
return new CORBA::Any();
}
//
//----------------------------------------------------------------
// Initialize pointer for singleton pattern
//----------------------------------------------------------------
//
PLCesallClass *PLCesallClass::_instance = NULL;
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::PLCesallClass(string &s)
//
// description : constructor for the PLCesallClass
//
// in : - s : The class name
//
//-----------------------------------------------------------------------------
PLCesallClass::PLCesallClass(string &s):DeviceClass(s)
{
cout2 << "Entering PLCesallClass constructor" << endl;
set_default_property();
get_class_property();
write_class_property();
cout2 << "Leaving PLCesallClass constructor" << endl;
}
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::~PLCesallClass()
//
// description : destructor for the PLCesallClass
//
//-----------------------------------------------------------------------------
PLCesallClass::~PLCesallClass()
{
_instance = NULL;
}
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::instance
//
// description : Create the object if not already done. Otherwise, just
// return a pointer to the object
//
// in : - name : The class name
//
//-----------------------------------------------------------------------------
PLCesallClass *PLCesallClass::init(const char *name)
{
if (_instance == NULL)
{
try
{
string s(name);
_instance = new PLCesallClass(s);
}
catch (bad_alloc)
{
throw;
}
}
return _instance;
}
PLCesallClass *PLCesallClass::instance()
{
if (_instance == NULL)
{
cerr << "Class is not initialised !!" << endl;
exit(-1);
}
return _instance;
}
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::command_factory
//
// description : Create the command object(s) and store them in the
// command list
//
//-----------------------------------------------------------------------------
void PLCesallClass::command_factory()
{
command_list.push_back(new Send_cmdClass("Send_cmd",
Tango::DEVVAR_SHORTARRAY, Tango::DEV_VOID,
"Command code, cmd argument",
"",
Tango::OPERATOR));
command_list.push_back(new AcknowledgeClass("Acknowledge",
Tango::DEVVAR_SHORTARRAY, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
command_list.push_back(new UpdateDBDescriptionClass("UpdateDBDescription",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR));
// add polling if any
for (unsigned int i=0 ; i<command_list.size(); i++)
{
}
}
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::get_class_property
//
// description : Get the class property for specified name.
//
// in : string name : The property name
//
//+----------------------------------------------------------------------------
Tango::DbDatum PLCesallClass::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 : PLCesallClass::get_default_device_property()
//
// description : Return the default value for device property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum PLCesallClass::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 : PLCesallClass::get_default_class_property()
//
// description : Return the default value for class property.
//
//-----------------------------------------------------------------------------
Tango::DbDatum PLCesallClass::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 : PLCesallClass::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 PLCesallClass::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 PLCesall(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: PLCesallClass::attribute_factory(vector<Tango::Attr *> &att_list)
//-----------------------------------------------------------------------------
void PLCesallClass::attribute_factory(vector<Tango::Attr *> &att_list)
{
// Attribute : Plc_status
Plc_statusAttrib *plc_status = new Plc_statusAttrib();
att_list.push_back(plc_status);
// Attribute : LogState
LogStateAttrib *log_state = new LogStateAttrib();
att_list.push_back(log_state);
// Attribute : Stat_system
Stat_systemAttrib *stat_system = new Stat_systemAttrib();
att_list.push_back(stat_system);
// Attribute : Alarm_system
Alarm_systemAttrib *alarm_system = new Alarm_systemAttrib();
att_list.push_back(alarm_system);
// Attribute : Db_alarm
Db_alarmAttrib *db_alarm = new Db_alarmAttrib();
att_list.push_back(db_alarm);
// Attribute : Out_system
Out_systemAttrib *out_system = new Out_systemAttrib();
att_list.push_back(out_system);
// Attribute : Real_system
Real_systemAttrib *real_system = new Real_systemAttrib();
att_list.push_back(real_system);
// End of Automatic code generation
//-------------------------------------------------------------
}
//+----------------------------------------------------------------------------
//
// method : PLCesallClass::get_class_property()
//
// description : Read the class properties from database.
//
//-----------------------------------------------------------------------------
void PLCesallClass::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 : PLCesallClass::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 PLCesallClass::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 = "Connect_param";
prop_desc = "PLC connection parameters:\nIP\nport";
prop_def = "";
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);
prop_name = "Remote_ip";
prop_desc = "PLC IP address";
prop_def = "";
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);
prop_name = "Local_port";
prop_desc = "CPU port";
prop_def = "";
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);
prop_name = "Db_param";
prop_desc = "database logging parameters:\nhost\nport\nuser\npw";
prop_def = "";
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);
prop_name = "Data_config";
prop_desc = "Description file, list of attribute names, type, R/W and dimension";
prop_def = "";
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);
prop_name = "Timeout";
prop_desc = "timeout in ms, after this interval data becomes old";
prop_def = "";
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 : PLCesallClass::write_class_property
//
// description : Set class description as property in database
//
//-----------------------------------------------------------------------------
void PLCesallClass::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("plc vacuum low level configurable sever");
title << str_title;
data.push_back(title);
// Put Description
Tango::DbDatum description("Description");
vector<string> str_desc;
str_desc.push_back(" ");
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("TANGO_BASE_CLASS");
inher_datum << inheritance;
data.push_back(inher_datum);
// Call database and and values
//--------------------------------------------
get_db_class()->put_property(data);
}
} // namespace
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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