Skip to content
Snippets Groups Projects
Commit 7988eb97 authored by Lorenzo Pivetta's avatar Lorenzo Pivetta
Browse files

Initial import

parent ea81ed09
No related branches found
No related tags found
No related merge requests found
NAME_SRV = plcfastint-srv
MYSQL_INC= `mysql_config --include`
MYSQL_LIB= `mysql_config --libs_r`
CXXFLAGS += $(MYSQL_INC)
LDFLAGS += $(MYSQL_LIB)
include ../makefiles/Make-9.2.2.in
/*----- PROTECTED REGION ID(PLCsocket::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/plcsocket/src/ClassFactory.cpp,v 1.4 2017-02-23 08:42:46 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.4 $
//
// $Log: ClassFactory.cpp,v $
// Revision 1.4 2017-02-23 08:42:46 graziano
// Aggiunta comando disable_interlock_id5
//
// Revision 1.3 2014-04-22 13:02:39 graziano
// new pogo
// added command EnableBPM_11_2
//
// Revision 1.2 2008-04-23 08:26:19 sara
// added queue for logging on db
//
// Revision 1.1.1.1 2007/01/22 11:01:52 sara
// First release of PLC socket server
//
// 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 <PLCsocketClass.h>
/**
* Create PLCsocketClass singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
add_class(PLCsocket_ns::PLCsocketClass::init("PLCsocket"));
}
/*----- PROTECTED REGION END -----*/ // PLCsocket::ClassFactory.cpp
This diff is collapsed.
This diff is collapsed.
<?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="PLCsocket" pogoRevision="9.1">
<description description="" title="PLC interlock server" sourcePath="/home/graziano/fermi/servers/plcsocket/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_4Impl" sourcePath=""/>
<identification contact="at elettra.trieste.it - claudio.scafuri" author="claudio.scafuri" emailDomain="elettra.trieste.it" classFamily="Misc" siteSpecific="" platform="Unix Like" bus="tcp/ip" manufacturer="none" reference=""/>
</description>
<deviceProperties name="Ipaddr" description="ip address of PLC">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Wport" description="">
<type xsi:type="pogoDsl:ShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Rport" description="">
<type xsi:type="pogoDsl:ShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Srv_host" description="ip addr of the server">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Hbeat" description="max time in ms between two read from plc">
<type xsi:type="pogoDsl:ShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Labels" description="list of labels to be written in the panel">
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Logfile" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Db_param" description="contains the parameter string to access logging db:&lt;BR>&#xA;hostname-user-passwd-db_name-port">
<type xsi:type="pogoDsl:StringVectorType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Logging" description="">
<type xsi:type="pogoDsl:ShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Timeadjust" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Ack_policy" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</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="false"/>
</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="false"/>
</commands>
<commands name="Beam_dump" description="" execMethod="beam_dump" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:StringType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="Send_ack" description="" execMethod="send_ack" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:StringType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="Seq_state_rst" description="" execMethod="seq_state_rst" 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="Test_debug" description="" execMethod="test_debug" 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="EnableBPM11_2" description="" execMethod="enable_bpm11_2" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:BooleanType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="DisableInterlockSCW" description="" execMethod="disable_interlock_scw" 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="DisableInterlockID5" description="" execMethod="disable_interlock_id5" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<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="IThreshold" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="Libera3hc" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="BeamDumpPLCA10" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="BeamAbi" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="CallPm" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlIThreshold" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlLibera3hc" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="Seq_state" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="EnableBPM11_2" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="OpenId" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="DiodeDet" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="LiberaSt" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="LiberaNd" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="IlkEnable" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlOpenId" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlDiodeDet" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlLiberaSt" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="AlLiberaNd" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="0">
<dataType xsi:type="pogoDsl:BooleanType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="Seq_num" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="3" maxY="0">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<states name="ON" description="*">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="Severe error occurred">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="UNKNOWN" description="Data timestamp is not coherent">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="ALARM" description="*">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="DISABLE" description="Logging DB connection is not available, the server is not logging">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.2.2/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Device Class Identification:
*
* Class Name : PLCsocket
* Contact : claudio.scafuri@elettra.trieste.it
* Class Family : Misc
* Platform : Unix Like
* Bus : tcp/ip
* Manufacturer : none
* Reference :
*/
/*----- PROTECTED REGION ID(PLCsocket::main.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: main.cpp,v 1.2 2014-04-22 13:02:39 graziano Exp $";
//=============================================================================
//
// file : main.cpp
//
// description : C++ source for the PLCsocket 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 : PLC interlock server
//
// This file is part of Tango device class.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Author: graziano $
//
// $Revision: 1.2 $
// $Date: 2014-04-22 13:02:39 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#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);
}
/*----- PROTECTED REGION END -----*/ // PLCsocket::main.cpp
/*
* plclgthread.cpp
*
* 10.04.06 - SF: first release
*
*
*/
#include "plclgthread.h"
/*
* plclgthread::run()
* Run
*/
void *plclgthread::run_undetached(void *)
{
struct timeval _pre2, _post2;
int pausesec2,pausenano2;
unsigned char buf_local_tstamp[TSTAMP_SIZE];
char buf_tmp[10];
//semaphore management
retval = 0;
id = semget(1000, 1, 0666);
if(id < 0){
DEBUG_STREAM << "plclgthread::lgThread cannot find semaphore" << endl;
}
else{
DEBUG_STREAM << "plclgthread::lgThread found semaphore" << endl;
}
while (!t_PLCsocket->abortflag) {
//log to db elements of the message list
int k=0;
PLCsocket_ns::intlck_libera_t m;
operations[0].sem_num = 0;
operations[0].sem_op = 0;
operations[0].sem_flg = 0;
lock_ops[0].sem_num = 0;
lock_ops[0].sem_op = 1;
lock_ops[0].sem_flg = 0;
unlock_ops[0].sem_num = 0;
unlock_ops[0].sem_op = -1;
unlock_ops[0].sem_flg = 0;
while(!t_PLCsocket->mesg_list.empty()){
retval = semop(id, operations, 1);
m = t_PLCsocket->mesg_list.front();
t_PLCsocket->log_msg(m);
t_PLCsocket->mesg_list.pop_front();
//saving old message
bcopy(&t_PLCsocket->message, &t_PLCsocket->old_message, (sizeof(PLCsocket_ns::intlck_libera)));
t_PLCsocket->message = m;
char locbuf[SRV_BUF_LEN];
bcopy(&t_PLCsocket->message, &locbuf, (sizeof(PLCsocket_ns::intlck_libera)));
//logging on tango debug stream
char tmp_buf[SRV_BUF_LEN];
string x;
for(int j=0;j<(int)(sizeof(PLCsocket_ns::intlck_libera));j++){
memset (tmp_buf, 0, sizeof(tmp_buf) );
sprintf(tmp_buf, "%02X-", locbuf[j]);//change here the format of saved data
x.append(tmp_buf);
}
printf("%s\n",x.c_str());
//////////////////////////////////////////////////////////////////////////disabled
/* if(t_PLCsocket->logging_msg == 1){
char tmp_buf[SRV_BUF_LEN];
string x;
for(int j=0;j<(int)(sizeof(PLCsocket_ns::intlck_libera)/4);j++){
memset (tmp_buf, 0, sizeof(tmp_buf) );
sprintf(tmp_buf, "%02X-", locbuf[j]);//change here the format of saved data
x.append(tmp_buf);
}
DEBUG_STREAM << x << endl;
x.clear();
for(int j=(int)(sizeof(PLCsocket_ns::intlck_libera)/4);j<(int)(sizeof(PLCsocket_ns::intlck_libera)/2);j++){
memset (tmp_buf, 0, sizeof(tmp_buf) );
sprintf(tmp_buf, "%02X-", locbuf[j]);//change here the format of saved data
x.append(tmp_buf);
}
DEBUG_STREAM << x << endl;
x.clear();
for(int j=(int)(sizeof(PLCsocket_ns::intlck_libera)/2);j<(int)(sizeof(PLCsocket_ns::intlck_libera)*3/4);j++){
memset (tmp_buf, 0, sizeof(tmp_buf) );
sprintf(tmp_buf, "%02X-", locbuf[j]);//change here the format of saved data
x.append(tmp_buf);
}
DEBUG_STREAM << x << endl;
x.clear();
for(int j=(int)(sizeof(PLCsocket_ns::intlck_libera)*3/4);j<sizeof(PLCsocket_ns::intlck_libera);j++){
memset (tmp_buf, 0, sizeof(tmp_buf) );
sprintf(tmp_buf, "%02X-", locbuf[j]);//change here the format of saved data
x.append(tmp_buf);
}
DEBUG_STREAM << x << endl;
}*/
///////////////////////////////////////////////////////////////////////////////////
//detects alarmed inputs
if((m.campo_ingressi_1&m.campo_ingressi_2&
m.campo_ingressi_3&m.campo_ingressi_4&
m.campo_ingressi_5) == 0xffff){//no alarm found
;
}
else{
//prepare ack mask and send auto acknowledge
t_PLCsocket->i_answer.ack_1 = 0xffff&(~(m.memo_allarmi_1));
t_PLCsocket->i_answer.ack_2 = 0xffff&(~(m.memo_allarmi_2));
t_PLCsocket->i_answer.ack_3 = 0xffff&(~(m.memo_allarmi_3));
t_PLCsocket->i_answer.ack_4 = 0xffff&(~(m.memo_allarmi_4));
t_PLCsocket->i_answer.ack_5 = 0xffff&(~(m.memo_allarmi_5));
if((t_PLCsocket->ack_policy)==AUTO_ACK)
t_PLCsocket->send_auto_ack();
}
//pushing user events to subscribed clients
//the XOR between old and new monitored signals traces changes
if ((m.mesg_type & CHANGE_MESG) || \
(m.mesg_type & BDCA_MESG) || \
(m.mesg_type & PERIODIC_MESG)) { //if it is NOT a periodic message
t_PLCsocket->push_it();
t_PLCsocket->seq[1] = m.seq_async;
}//changes not monitored from plc, like beam abi
else {
int condition[9];
condition[0] = m.campo_ingressi_1^t_PLCsocket->old_message.campo_ingressi_1;
condition[1] = m.campo_ingressi_2^t_PLCsocket->old_message.campo_ingressi_2;
condition[2] = m.campo_ingressi_3^t_PLCsocket->old_message.campo_ingressi_3;
condition[3] = m.campo_ingressi_4^t_PLCsocket->old_message.campo_ingressi_4;
condition[4] = m.campo_ingressi_5^t_PLCsocket->old_message.campo_ingressi_5;
condition[5]=((m.campo_uscite_2&PLCsocket_ns::maskbits[0])^(t_PLCsocket->old_message.campo_uscite_2&PLCsocket_ns::maskbits[0]));
if((condition[0]|condition[1]|condition[2]|condition[3]|condition[4]|condition[5])!=0x0000){
t_PLCsocket->push_it();
}
}
k++;
}
DEBUG_STREAM << "plclgthread::popped "<< k <<" packets" << endl;
usleep(1000000);//sleep for 1s
}
}
/*
* plclgthread.h
*
* 17.01.07 - SF: heartbeat
*/
#ifndef plclgthread_H
#define plclgthread_H
#include <omnithread.h>
#include <tango.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <signal.h>
#include <netdb.h>
#include "PLCsocket.h"
#define SRV_BUF_LEN 2048
class plclgthread : public omni_thread, public Tango::LogAdapter
{
private:
PLCsocket_ns::PLCsocket::PLCsocket *t_PLCsocket;
public:
plclgthread(PLCsocket_ns::PLCsocket::PLCsocket *s):Tango::LogAdapter(s){ t_PLCsocket = s;};
~plclgthread() {};
void *StartUndetached(){
start_undetached();
}
void *run_undetached(void *);
protected:
struct sembuf operations[1];
struct sembuf lock_ops[1];
struct sembuf unlock_ops[1];
int retval;
int id;
struct timeval _pre2, _post2;
}; /* end class plclgthread() */
#endif
/* EOF */
This diff is collapsed.
/*
* plcsrvthread.h
*
* 17.01.07 - SF: first release
*
*/
#ifndef PLCSRVTHREAD_H
#define PLCSRVTHREAD_H
#include <omnithread.h>
#include <tango.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <signal.h>
#include <netdb.h>
#include <PLCsocket.h>
#define SRV_BUF_LEN 2048
//number of socket accepted by the server
const short MAX_NUM_SOCK=1; ///
class plcsrvthread : public omni_thread, public Tango::LogAdapter{
private:
PLCsocket_ns::PLCsocket::PLCsocket *t_PLCsocket;
public:
plcsrvthread(PLCsocket_ns::PLCsocket::PLCsocket *s):Tango::LogAdapter(s){
t_PLCsocket = s;
};
~plcsrvthread() {
};
void *StartUndetached(){
start_undetached();
}
void *run_undetached(void *);
protected:
int errcount;
struct timeval _pre, _post;
char frame2[SRV_BUF_LEN];
u_short olddata;
u_long first_read;
PLCsocket_ns::tstamp_t time_before;
PLCsocket_ns::intlck_libera local_mesg;
struct sembuf operations[1];
int retval;
int id;
Tango::DeviceProxy *mydevice;
Tango::DeviceAttribute arl;
int cnt, server_started;
struct sockaddr_in myname;
struct sockaddr_in *nptr;
struct sockaddr addr;
char buf[SRV_BUF_LEN];
void Srv_Prepare(void);
uint16_t plc_swap(uint16_t in);
uint32_t plc_swaplong(uint32_t in);
}; /* end class plcsrvthread() */
#endif
/* EOF */
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