- 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

49
remob.c
View File

@ -45,7 +45,7 @@ typedef struct RemServer {
int taskActive;
int interestActive;
int forwardMessages;
SCStore *conn;
SConnection *conn;
} RemServer;
struct Remob {
@ -156,7 +156,7 @@ static int RemHandle(RemServer *remserver) {
/*-------------------------------------------------------------------------*/
static void RemCopy(RemChannel *rc, SConnection *pCon) {
if (pCon != NULL && rc->line[0] != '\0') {
SCPrintf(pCon, eStatus, " %s", rc->line);
SCPrintf(pCon, eLog, " %s", rc->line);
}
}
/*-------------------------------------------------------------------------*/
@ -260,10 +260,8 @@ static int RemServerTask(void *data) {
if (remserver->forwardMessages) {
/* forward all other messages */
if (SCStoreConnected(remserver->conn)) {
pCon = SCStorePush(remserver->conn);
RemCopy(rc, pCon);
SCStorePop(remserver->conn);
if (SCisConnected(remserver->conn)) {
RemCopy(rc, remserver->conn);
}
}
}
@ -406,7 +404,10 @@ static float RemobGetValue(void *pData, SConnection *pCon) {
assert(remob);
remserver->conn = SCSave(pCon, remserver->conn);
if(remserver->conn != NULL){
SCDeleteConnection(remserver->conn);
}
remserver->conn = SCCopyConnection(pCon);
none = -1.25e6;
value= none;
snprintf(buf, sizeof(buf), "<%s", remob->name);
@ -457,7 +458,10 @@ static int RemobStatus(void *pData, SConnection *pCon) {
assert(remob);
remob->server->conn = SCSave(pCon, remob->server->conn);
if(remob->server->conn != NULL){
SCDeleteConnection(remob->server->conn);
}
remob->server->conn = SCCopyConnection(pCon);
return remob->status;
}
/*---------------------------------------------------------------------------*/
@ -475,10 +479,14 @@ static long RemobRun(void *self, SConnection *pCon, float fNew) {
RemChannel *rc;
int nChan;
remserver = remob->server;
remserver->conn = SCSave(pCon, remserver->conn);
assert(remob);
assert(pCon);
remserver = remob->server;
if(remserver->conn != NULL){
SCDeleteConnection(remserver->conn);
}
remserver->conn = SCCopyConnection(pCon);
rights = SCGetRights(pCon);
nChan = rights <= usUser;
@ -526,6 +534,9 @@ static void KillInfo(void *pData) {
if (self->pName) {
free(self->pName);
}
if(self->pCon){
SCDeleteConnection(self->pCon);
}
free(self);
}
/*------------------- The CallBack function for interest ------------------*/
@ -572,7 +583,10 @@ int RemobAction(SConnection *pCon, SicsInterp *pSics, void *pData,
nChan = (rights <= usUser);
rc = &remserver->rc[nChan];
if (rights >= usUser) {
remserver->conn = SCSave(pCon, remserver->conn);
if(remserver->conn != NULL){
SCDeleteConnection(remserver->conn);
}
remserver->conn = SCCopyConnection(pCon);
}
if (argc == 1) {
iRet = RemTransact(remserver, nChan, pCon, remob->name, ">", NULL);
@ -629,7 +643,7 @@ static void RemobKill(void *self) {
if (remob->pCall) {
DeleteCallBackInterface(remob->pCall);
}
/* kill Descriptor */
if (remob->desc) {
DeleteDescriptor(remob->desc);
@ -664,7 +678,10 @@ int RemServerAction(SConnection *pCon, SicsInterp *pSics, void *pData,
nChan = (rights <= usUser);
rc = &remserver->rc[nChan];
if (nChan) {
remserver->conn = SCSave(pCon, remserver->conn);
if(remserver->conn != NULL){
SCDeleteConnection(remserver->conn);
}
remserver->conn = SCCopyConnection(pCon);
}
if (argc == 1) {
serverport = IFindOption(pSICSOptions,"ServerPort");
@ -680,7 +697,7 @@ int RemServerAction(SConnection *pCon, SicsInterp *pSics, void *pData,
}
}
if (thishostname == NULL) thishostname = "undef";
SCPrintf(pCon, eStatus, "%s = %s:%d %s:%s",
SCPrintf(pCon, eValue, "%s = %s:%d %s:%s",
argv[0], remserver->host, remserver->port, thishostname, serverport);
} else if (argc>2 && strcasecmp(argv[1],"nowait") == 0) {
RemConnect(remserver, nChan);
@ -737,7 +754,9 @@ static void RemServerKill(void *self) {
DeleteDescriptor(remserver->desc);
if (remserver->name) free(remserver->name);
if (remserver->host) free(remserver->host);
SCStoreFree(remserver->conn);
if(remserver->conn != NULL){
SCDeleteConnection(remserver->conn);
}
free(remserver);
}
/*-----------------------------------------------------------------------*/