Commit bfcd092a authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Initial commit

parents
.nse_depinfo
bin/
obj/
NAME_SRV = socket2-srv
CXXFLAGS =
LDFLAGS =
include ../Make-9.3.3.in
test: bin/${NAME_SRV}
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(SDKTARGETSYSROOT)/usr/lib $(LOADER) bin/${NAME_SRV} test -v4
/*----- PROTECTED REGION ID(Socket2::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: ClassFactory.cpp,v 1.4 2018-05-09 16:06:06 alessio Exp $";
//=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
//
// project :
//
// 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: alessio $
//
// $Revision: 1.4 $
// $Date: 2018-05-09 16:06:06 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango.h>
#include <Socket2Class.h>
// Add class header files if needed
/**
* Create Socket2 Class singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(Socket2_ns::Socket2Class::init("Socket2"));
}
/*----- PROTECTED REGION END -----*/ // Socket2::ClassFactory.cpp
This diff is collapsed.
/*----- PROTECTED REGION ID(Socket2.h) ENABLED START -----*/
//=============================================================================
//
// file : Socket2.h
//
// description : Include file for the Socket2 class
//
// project :
//
// 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: alessio $
//
// $Revision: 1.11 $
// $Date: 2018-05-09 16:06:06 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#ifndef Socket2_H
#define Socket2_H
#include <tango.h>
#include <netdb.h>
#define BUFFER_SIZE 1000
/*----- PROTECTED REGION END -----*/ // Socket2.h
/**
* Socket2 class description:
*
*/
namespace Socket2_ns
{
/*----- PROTECTED REGION ID(Socket2::Additional Class Declarations) ENABLED START -----*/
// Additional Class Declarations
/*----- PROTECTED REGION END -----*/ // Socket2::Additional Class Declarations
class Socket2 : public TANGO_BASE_CLASS
{
/*----- PROTECTED REGION ID(Socket2::Data Members) ENABLED START -----*/
// Add your own data members
string init_error;
sockaddr_in sa;
socklen_t sa_len;
enum { TCP, UDP } proto;
int fd;
fd_set readfds;
fd_set writefds;
fd_set errorfds;
enum event_type { READ, WRITE };
unsigned char buffer[ BUFFER_SIZE ];
vector< unsigned char > data;
bool connecting;
long long reconnections;
enum { SLEEP, SELECT } multiplexing;
/*----- PROTECTED REGION END -----*/ // Socket2::Data Members
// Device property data members
public:
// Hostname:
string hostname;
// Port:
Tango::DevUShort port;
// Protocol:
string protocol;
// Timeout:
Tango::DevLong timeout;
// IOMultiplexing: Use `sleep` for fixed sleep and `select` for the syscall of the same name
string iOMultiplexing;
bool mandatoryNotDefined;
// Attribute data members
public:
Tango::DevLong *attr_InputLength_read;
Tango::DevLong *attr_OutputLength_read;
Tango::DevLong *attr_Reconnections_read;
// Constructors and destructors
public:
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
Socket2(Tango::DeviceClass *cl,string &s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
Socket2(Tango::DeviceClass *cl,const char *s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device name
* @param d Device description.
*/
Socket2(Tango::DeviceClass *cl,const char *s,const char *d);
/**
* The device object destructor.
*/
~Socket2() {delete_device();};
// Miscellaneous methods
public:
/*
* will be called at device destruction or at init command.
*/
void delete_device();
/*
* Initialize the device
*/
virtual void init_device();
/*
* Read the device properties from database
*/
void get_device_property();
/*
* Always executed method before execution command method.
*/
virtual void always_executed_hook();
/*
* Check if mandatory property has been set
*/
void check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop);
// Attribute methods
public:
//--------------------------------------------------------
/*
* Method : Socket2::read_attr_hardware()
* Description : Hardware acquisition for attributes.
*/
//--------------------------------------------------------
virtual void read_attr_hardware(vector<long> &attr_list);
/**
* Attribute InputLength related methods
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
virtual void read_InputLength(Tango::Attribute &attr);
virtual bool is_InputLength_allowed(Tango::AttReqType type);
/**
* Attribute OutputLength related methods
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
virtual void read_OutputLength(Tango::Attribute &attr);
virtual bool is_OutputLength_allowed(Tango::AttReqType type);
/**
* Attribute Reconnections related methods
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
virtual void read_Reconnections(Tango::Attribute &attr);
virtual bool is_Reconnections_allowed(Tango::AttReqType type);
//--------------------------------------------------------
/**
* Method : Socket2::add_dynamic_attributes()
* Description : Add dynamic attributes if any.
*/
//--------------------------------------------------------
void add_dynamic_attributes();
// Command related methods
public:
/**
* Command Write related method
* Description:
*
* @param argin
*/
virtual void write(const Tango::DevVarCharArray *argin);
virtual bool is_Write_allowed(const CORBA::Any &any);
/**
* Command Read related method
* Description:
*
* @param argin
* @returns
*/
virtual Tango::DevVarCharArray *read(Tango::DevLong argin);
virtual bool is_Read_allowed(const CORBA::Any &any);
/**
* Command ReadUntil related method
* Description:
*
* @param argin
* @returns
*/
virtual Tango::DevVarCharArray *read_until(const Tango::DevVarCharArray *argin);
virtual bool is_ReadUntil_allowed(const CORBA::Any &any);
//--------------------------------------------------------
/**
* Method : Socket2::add_dynamic_commands()
* Description : Add dynamic commands if any.
*/
//--------------------------------------------------------
void add_dynamic_commands();
/*----- PROTECTED REGION ID(Socket2::Additional Method prototypes) ENABLED START -----*/
// Additional Method prototypes
void check_init();
void resolve();
void open();
void close();
void check_connection( );
bool wait_for( event_type et, timeval *tv );
bool wait_for_with_sleep( event_type et, timeval *tv );
bool wait_for_with_select( event_type et, timeval *tv );
int input_queue_length();
int output_queue_length();
bool read( struct timeval *tv );
/*----- PROTECTED REGION END -----*/ // Socket2::Additional Method prototypes
};
/*----- PROTECTED REGION ID(Socket2::Additional Classes Definitions) ENABLED START -----*/
// Additional Classes Definitions
/*----- PROTECTED REGION END -----*/ // Socket2::Additional Classes Definitions
} // End of namespace
#endif // Socket2_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="Socket2" pogoRevision="9.4">
<description description="" title="" sourcePath="/home/alessio/fermi/servers/socket2/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at elettra.eu> - Alessio Igor Bogani &lt;alessio.bogani" author="Alessio Igor Bogani &lt;alessio.bogani" emailDomain="elettra.eu>" classFamily="Communication" siteSpecific="" platform="Unix Like" bus="Socket" manufacturer="none" reference=""/>
</description>
<deviceProperties name="Hostname" mandatory="true" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Port" mandatory="true" description="">
<type xsi:type="pogoDsl:UShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="Protocol" description="">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>TCP</DefaultPropValue>
</deviceProperties>
<deviceProperties name="Timeout" mandatory="true" description="">
<type xsi:type="pogoDsl:IntType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="IOMultiplexing" description="Use `sleep` for fixed sleep and `select` for the syscall of the same name">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<commands name="Write" description="" execMethod="write" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:CharArrayType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="Read" description="" execMethod="read" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:IntType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:CharArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="ReadUntil" description="" execMethod="read_until" displayLevel="OPERATOR" polledPeriod="0">
<argin description="">
<type xsi:type="pogoDsl:CharArrayType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:CharArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<attributes name="InputLength" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:IntType"/>
<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="OutputLength" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:IntType"/>
<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="Reconnections" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:IntType"/>
<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>
<states name="ON" description="Connected">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="Connection failed">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="INIT" description="">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/>
</classes>
</pogoDsl:PogoSystem>
This diff is collapsed.
/*----- PROTECTED REGION ID(Socket2Class.h) ENABLED START -----*/
//=============================================================================
//
// file : Socket2Class.h
//
// description : Include for the Socket2 root class.
// This class is the singleton class for
// the Socket2 device class.
// It contains all properties and methods which the
// Socket2 requires only once e.g. the commands.
//
// project :
//
// 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: alessio $
//
// $Revision: 1.5 $
// $Date: 2018-01-08 10:32:23 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#ifndef Socket2Class_H
#define Socket2Class_H
#include <tango.h>
#include <Socket2.h>
/*----- PROTECTED REGION END -----*/ // Socket2Class.h
namespace Socket2_ns
{
/*----- PROTECTED REGION ID(Socket2Class::classes for dynamic creation) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // Socket2Class::classes for dynamic creation
//=========================================
// Define classes for attributes
//=========================================
// Attribute InputLength class definition
class InputLengthAttrib: public Tango::Attr
{
public:
InputLengthAttrib():Attr("InputLength",
Tango::DEV_LONG, Tango::READ) {};
~InputLengthAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<Socket2 *>(dev))->read_InputLength(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<Socket2 *>(dev))->is_InputLength_allowed(ty);}
};
// Attribute OutputLength class definition
class OutputLengthAttrib: public Tango::Attr
{
public:
OutputLengthAttrib():Attr("OutputLength",
Tango::DEV_LONG, Tango::READ) {};
~OutputLengthAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<Socket2 *>(dev))->read_OutputLength(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<Socket2 *>(dev))->is_OutputLength_allowed(ty);}
};
// Attribute Reconnections class definition
class ReconnectionsAttrib: public Tango::Attr
{
public:
ReconnectionsAttrib():Attr("Reconnections",
Tango::DEV_LONG, Tango::READ) {};
~ReconnectionsAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<Socket2 *>(dev))->read_Reconnections(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<Socket2 *>(dev))->is_Reconnections_allowed(ty);}
};
//=========================================
// Define classes for commands
//=========================================
// Command Write class definition
class WriteClass : public Tango::Command
{
public:
WriteClass(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) {};
WriteClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~WriteClass() {};
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<Socket2 *>(dev))->is_Write_allowed(any);}
};
// Command Read class definition
class ReadClass : public Tango::Command
{
public:
ReadClass(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) {};
ReadClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~ReadClass() {};
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<Socket2 *>(dev))->is_Read_allowed(any);}
};
// Command ReadUntil class definition
class ReadUntilClass : public Tango::Command
{
public:
ReadUntilClass(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) {};
ReadUntilClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~ReadUntilClass() {};
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<Socket2 *>(dev))->is_ReadUntil_allowed(any);}
};