- Reworked the connection object and the IO system

- Reworked the support for TRICS
- Added a second generation motor
This commit is contained in:
koennecke
2009-02-03 08:05:39 +00:00
parent f6d595665e
commit 361ee9ebea
119 changed files with 16455 additions and 3674 deletions

166
conman.h
View File

@ -1,4 +1,3 @@
/*--------------------------------------------------------------------------
C O N N E C T I O N O B J E C T
@ -15,6 +14,10 @@
Mark Koennecke, December 2004
copyright: see copyright.h
substantially for the new asynchronous I/O system
Mark Koennecke, January 2009
----------------------------------------------------------------------------*/
#ifndef SICSCONNECT
#define SICSCONNECT
@ -22,6 +25,7 @@
#include "costa.h"
#include "SCinter.h"
#include "network.h"
#include "asynnet.h"
#include "obdes.h"
#include "commandcontext.h"
#include "dynstring.h"
@ -32,80 +36,57 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
char *pMessage, int iCode);
typedef struct __SConnection {
/* object basics */
pObjectDescriptor pDes;
long lMagic;
long ident;
struct __SConnection *next;
/* I/O control */
/* our socket */
mkChannel *pSock;
/* per connection log files */
FILE *pFiles[MAXLOGFILES];
int iFiles;
int iMacro; /* suppress I/O in macro*/
/* Copy Object Fields*/
pObjectDescriptor pDes; /* must be here */
long lMagic; /* connection object ID */
long ident; /* connection idetification */
struct __SConnection *next; /* pointer for freeConnection managenment */
int sockHandle; /* socket handle */
int iTelnet; /* telnet flag */
int iOutput;
writeFunc write; /* function doing
writing */
int listening; /* for listening to commandlog or other data */
/* execution context */
int eInterrupt;
int iUserRights;
int inUse;
int iGrab; /* grab flag for token*/
int sicsError;
/*
* for I/O Buffering
*/
pDynString data;
writeFunc oldWriteFunc;
/*
stuff supporting the sycamore protocol and a
command context
*/
long iCmdCtr;
int conEventType;
int iMacro; /* suppress I/O in macro */
writeFunc write; /* function doing writing */
int sicsError; /* Tcl interpreter requirement */
pDynString data; /* for I/O buffering */
writeFunc oldWriteFunc; /* saved write function used in I/O buffering */
long iCmdCtr; /* sycamore protocol used */
int conEventType; /* sycamore protocol support */
int conStatus; /* should use status enum ffr */
int iProtocolID;
int contextStack;
/* a FIFO */
pCosta pStack;
/* callback registry */
int iList;
/* Tasking Stuff */
int iEnd;
/* for keeping track of the login
process on a non telnet connection.
Should only be used in SCTaskFunction
*/
int iLogin;
time_t conStart;
int transID; /* transaction ID */
char deviceID[256]; /* transaction device ID */
int iUserRights; /* user rights of the connection */
/* master connection object fields */
int iList; /* callback registry, may go? */
int iEnd; /* flag to end connection task */
int iLogin; /* flag for successful login process */
time_t conStart; /* time when connection was built: used during login */
int iOutput; /* output filter flag */
int listening; /* for listening to commandlog or other data */
int eInterrupt; /* interrupts */
int inUse; /* usage counter for the connection */
int iGrab; /* grab flag for token*/
int iProtocolID; /* ID of the protocol on this connection */
pCosta pStack; /* stack of pending commands */
int contextStack; /* context stack: may go? */
mkChannel *pSock; /* for temporary backwards compatability */
} SConnection;
#include "nserver.h"
/*------------------------------ live & death ----------------------------*/
SConnection *SCreateConnection(SicsInterp *pSics, mkChannel *pSock,
SConnection *SCreateConnection(SicsInterp *pSics, int sockHandle,
int iUserRights);
SConnection *SCCreateDummyConnection(SicsInterp *pSics);
void SCDeleteConnection(void *pVictim);
SConnection *SCCopyConnection(SConnection *pCon);
SConnection *SCfindMaster(SConnection *pCon);
int SCisConnected(SConnection *pCon);
int VerifyConnection(SConnection *pCon);
int SCVerifyConnection(SConnection *self);
/*------------------------------- tasking --------------------------------*/
int SCTaskFunction(void *pCon);
void SCSignalFunction(void *pCon, int iSignal, void *pSigData);
/* ***************************** I/O ************************************** */
int SCAddLogFile(SConnection *self, char *name);
int SCDelLogFile(SConnection *pCon, int iFile);
void SCSetOutputClass(SConnection *self, int iClass);
int SCWrite(SConnection *self, char *pBuffer, int iOut);
int SCPrintf(SConnection *self, int iOut, char *fmt, ...);
@ -126,21 +107,6 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
/*********************** I/O Buffering ***********************************/
int SCStartBuffering(SConnection *pCon);
pDynString SCEndBuffering(SConnection *pCon);
/************************* CallBack *********************************** */
int SCRegister(SConnection *pCon, SicsInterp *pSics,
void *pInter, long lID);
int SCUnregister(SConnection *pCon, void *pInter);
/**
* delete a callback with the given ID
*/
int SCUnregisterID(SConnection *pCon, long ID);
/**
* retrieve the ID of a callback on the callback interface
* given in pData. This, together with SCUnregisterID allows to
* ceanly remove all callbacks on a connection
* returns -1 if no ID can be found.
*/
long SCgetCallbackID(SConnection *pCon, void *pData);
/******************************* Error **************************************/
void SCSetInterrupt(SConnection *self, int eCode);
int SCGetInterrupt(SConnection *self);
@ -156,9 +122,6 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
int SCGetOutClass(SConnection *self);
int SCGetGrab(SConnection *pCon);
int SCActive(SConnection *pCon);
/********************* simulation mode ************************************/
void SCSetSimMode(SConnection *pCon, int value);
int SCinSimMode(SConnection *pCon);
/* **************************** Invocation ******************************** */
int SCInvoke(SConnection *self,SicsInterp *pInter,char *pCommand);
@ -167,6 +130,23 @@ typedef int (*writeFunc)(struct __SConnection *pCon,
int argc, char *argv[]);
int ConSicsAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*------------------------------------------------------------------------*/
int SCDoSockWrite(SConnection *self, char *buffer);
int SCWriteInContext(SConnection *pCon, char *buffer, int code, commandContext cc);
/* ================== =====================================================
* These routines are obsolete and may not even work anymore.
* Mark Koennecke, January 2009
* ==========================================================================*/
void SCWriteToLogFiles(SConnection *self, char *buffer);
long SCTagContext(SConnection *self, char *tagName);
long SCAdvanceContext(SConnection *self, char *tagName);
int SCPushContext(SConnection *pCon, int ID, char *deviceID);
int SCPushContext2(SConnection *pCon, commandContext cc);
int SCPopContext(SConnection *pCon);
commandContext SCGetContext(SConnection *pCon);
/******************************** Store ************************************/
typedef struct SCStore SCStore;
@ -189,18 +169,20 @@ void SCStoreFree(SCStore *conStore);
/* free an SCStore */
void KillFreeConnections(void);
/*------------------------------------------------------------------------*/
int SCVerifyConnection(SConnection *self);
void SCWriteToLogFiles(SConnection *self, char *buffer);
int SCDoSockWrite(SConnection *self, char *buffer);
int SCWriteInContext(SConnection *pCon, char *buffer, int code, commandContext cc);
long SCTagContext(SConnection *self, char *tagName);
long SCAdvanceContext(SConnection *self, char *tagName);
int SCPushContext(SConnection *pCon, int ID, char *deviceID);
int SCPushContext2(SConnection *pCon, commandContext cc);
int SCPopContext(SConnection *pCon);
commandContext SCGetContext(SConnection *pCon);
/************************* CallBack *********************************** */
int SCRegister(SConnection *pCon, SicsInterp *pSics,
void *pInter, long lID);
int SCUnregister(SConnection *pCon, void *pInter);
/**
* delete a callback with the given ID
*/
int SCUnregisterID(SConnection *pCon, long ID);
/**
* retrieve the ID of a callback on the callback interface
* given in pData. This, together with SCUnregisterID allows to
* ceanly remove all callbacks on a connection
* returns -1 if no ID can be found.
*/
long SCgetCallbackID(SConnection *pCon, void *pData);
#endif