YANE-Framework 1.1.0
Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes

yane::NetworkedControl::IOInterfaceTCP Class Reference

Class for connecting components in a distributed plant - sensor - controller - actuator setting with a TCP network connection.

Inheritance diagram for yane::NetworkedControl::IOInterfaceTCP:
[legend]
Collaboration diagram for yane::NetworkedControl::IOInterfaceTCP:
[legend]

List of all members.

Public Member Functions

void closeConnection ()
 Function to close the connection to a process.
void connectToModel (yane::Model::Model *model, const char *addr, int port=41923)
 Function to connect to a process.
 IOInterfaceTCP (int seqlengthhint, yane::Utils::DebugMaster *dm=0, yane::Utils::StatisticsMaster *sm=0, int buffersize=8192)
 Constructor.
virtual bool isConnected ()
 Function to return whether network connection has been established.
yane::Model::Modelmodel ()
 Function to return the used class yane::Model::Model pointer.
virtual void readActor (T_ACTORPACKET *response)
 Function to read actuator responds from network connection.
virtual void readInput (T_INPUTPACKET *indata, double *data)
 Function to read sensor input from network connection.
virtual double samplingTime ()
 Function to return the sampling period.
virtual int sequenceLength ()
 Function to return the length of the sent control sequence.
virtual void writeOutput (T_OUTPUTPACKET *outdata, double *data)
 Function to send output from controller to network connection.
virtual ~IOInterfaceTCP ()
 Destructor.

Static Public Attributes

static const int ACTORERRORCODE = 0x2EE878B8
 Actuator error code.
static const int ACTORSUCCESSCODE = 0x7E004BC2
 Actuator success code.
static const int INPUTCODE = 0x9A10092F
 Input error code.
static const int OUTPUTCODE = 0xF02891C2
 Output error code.

Static Protected Member Functions

static void tcp_callback (char *packetdata, int packetlength, void *ptr)
 Callback function to handle incoming data packets.

Protected Attributes

yane::Utils::FIFOBuffer_actorbuffer
 Pointer of the actuator data buffer.
yane::Utils::Semaphore_actorsem
 Pointer of the actuator semaphore.
CtrlClientTCP_client
 Pointer of the TCP network client.
yane::Utils::DebugClient_debugclient
 Pointer of the debug client of class yane::Utils::DebugClient.
yane::Utils::FIFOBuffer_inputbuffer
 Pointer of the sensor data buffer.
yane::Utils::Semaphore_inputsem
 Pointer of the sensor semaphore.
yane::Model::Model_model
 Pointer of the used class yane::Model::Model model.
char * _outputbuffer
 Name of the output buffer.
double _samplingTime
 Sampling period.
int _seqlengthhint
 Indicator of the length of the sensor packet to receive.
int _sequenceLength
 Length of the control sequence.

Constructor & Destructor Documentation

LIB_EXPORT yane::NetworkedControl::IOInterfaceTCP::IOInterfaceTCP ( int  seqlengthhint,
yane::Utils::DebugMaster dm = 0,
yane::Utils::StatisticsMaster sm = 0,
int  buffersize = 8192 
)

Constructor

Parameters:
seqlengthhintLength of the control sequence
dmPointer of the debugmanager of class yane::Utils::DebugMaster
smPointer of the statistics manager of class yane::Utils::StatisticsMaster
buffersizeSize of the buffer for storing control values

Member Function Documentation

LIB_EXPORT void yane::NetworkedControl::IOInterfaceTCP::connectToModel ( yane::Model::Model model,
const char *  addr,
int  port = 41923 
)

Function to cause an internal network client to connect to a process

Parameters:
modelPointer of the model of class yane::Model::Model which shall be connected
addrAddress of the process to connect to
portLocal port to connect the network connection to
LIB_EXPORT bool yane::NetworkedControl::IOInterfaceTCP::isConnected ( ) [virtual]

Function to return whether network connection has been established

Implements yane::NetworkedControl::IOInterface.

LIB_EXPORT yane::Model::Model * yane::NetworkedControl::IOInterface::model ( ) [inherited]

Function to return the used class yane::Model::Model pointer

LIB_EXPORT void yane::NetworkedControl::IOInterfaceTCP::readActor ( T_ACTORPACKET response) [virtual]

Function to read actuator responds from network connection

Parameters:
responseActuator responds packet

Implements yane::NetworkedControl::IOInterface.

LIB_EXPORT void yane::NetworkedControl::IOInterfaceTCP::readInput ( T_INPUTPACKET indata,
double *  data 
) [virtual]

Function to read sensor input from network connection

Parameters:
indataSensor input packet
dataAdditional data information

Implements yane::NetworkedControl::IOInterface.

LIB_EXPORT double yane::NetworkedControl::IOInterfaceTCP::samplingTime ( ) [virtual]

Function to return the sampling period

Implements yane::NetworkedControl::IOInterface.

LIB_EXPORT int yane::NetworkedControl::IOInterfaceTCP::sequenceLength ( ) [virtual]

Function to return the length of the sent control sequence

Implements yane::NetworkedControl::IOInterface.

LIB_EXPORT void yane::NetworkedControl::IOInterfaceTCP::tcp_callback ( char *  packetdata,
int  packetlength,
void *  ptr 
) [static, protected]

Callback function to handle incoming data packets

Parameters:
packetdataIdentifier and data packet of incoming data
packetlengthLength of incoming data
ptrBase pointer of the class yane::NetworkedControl::IOInterfaceTCP network connection handler
LIB_EXPORT void yane::NetworkedControl::IOInterfaceTCP::writeOutput ( T_OUTPUTPACKET outdata,
double *  data 
) [virtual]

Function to send output from controller to network connection

Parameters:
outdataOutput data package
dataAdditional data information

Implements yane::NetworkedControl::IOInterface.