PSI sics-cvs-psi-2006
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
Use internal connection.
|
||||
Mark Koennecke, July 2002
|
||||
|
||||
changed timeout units in NETRead from us to ms
|
||||
the timing could be optimized (no need for SicsWait
|
||||
when timeout properly choosen (could be in the region of 1 second )
|
||||
M.Zolliker, August 04
|
||||
*/
|
||||
#include "sics.h"
|
||||
#include "network.h"
|
||||
@@ -34,7 +38,7 @@ static void syncLogin(void)
|
||||
connection = NETConnect(hostname, port);
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
NETRead(connection,pBueffel,1020,10*1000);
|
||||
NETRead(connection,pBueffel,1020,10); /* 10 ms M.Z */
|
||||
if(strstr(pBueffel,"OK") != NULL)
|
||||
{
|
||||
break;
|
||||
@@ -60,7 +64,7 @@ static void syncLogin(void)
|
||||
for(i = 0; i < 60; i++)
|
||||
{
|
||||
memset(pRead,0,80);
|
||||
test = NETRead(connection,pRead,70,10*1000);
|
||||
test = NETRead(connection,pRead,70,10); /* 10 ms M.Z. */
|
||||
if(test < 0)
|
||||
{
|
||||
NETClosePort(connection);
|
||||
@@ -164,6 +168,11 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
char pRead[80];
|
||||
int test,i;
|
||||
SConnection *internalCon = NULL;
|
||||
int try;
|
||||
|
||||
try = 2;
|
||||
tryagain:
|
||||
try--;
|
||||
|
||||
/*
|
||||
check for connection
|
||||
@@ -197,9 +206,9 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
NETClosePort(connection);
|
||||
free(connection);
|
||||
connection = NULL;
|
||||
SCWrite(pCon,"ERROR: Failed to contact sync server",eError);
|
||||
SCWrite(pCon,"Try again in order to reconnect before giving up",eWarning);
|
||||
ClearFixedStatus(eEager);
|
||||
if (try > 0) goto tryagain;
|
||||
SCWrite(pCon,"ERROR: Failed to contact main SICS server",eError);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
@@ -212,24 +221,23 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
for(i = 0; i < 60; i++)
|
||||
{
|
||||
pRead[0] = '\0';
|
||||
test = NETRead(connection,pRead,75,20*1000);
|
||||
test = NETRead(connection,pRead,75,20); /* 20 ms M.Z. */
|
||||
if(test < 0)
|
||||
{
|
||||
NETClosePort(connection);
|
||||
free(connection);
|
||||
connection = NULL;
|
||||
SCWrite(pCon,"ERROR: Failed to contact sync server",eError);
|
||||
SCWrite(pCon,
|
||||
"Try again in order to reconnect before giving up",eWarning);
|
||||
ClearFixedStatus(eEager);
|
||||
pServ->simMode = 1;
|
||||
if (try > 0) goto tryagain;
|
||||
SCWrite(pCon,"ERROR: Failed to contact main SICS server",eError);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(test > 0)
|
||||
{
|
||||
strcat(pBueffel,pRead);
|
||||
strncat(pBueffel,pRead, 2047 - strlen(pBueffel));
|
||||
}
|
||||
}
|
||||
if(strstr(pBueffel,"TRANSACTIONFINISHED") != NULL)
|
||||
@@ -250,6 +258,15 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
eWarning);
|
||||
}
|
||||
|
||||
/*
|
||||
* relase the connection, this may be more stable
|
||||
*/
|
||||
NETClosePort(connection);
|
||||
free(connection);
|
||||
connection = NULL;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
now read the backup file and we are done
|
||||
*/
|
||||
@@ -283,6 +300,8 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
tell everybody that we have sync'ed
|
||||
*/
|
||||
ServerWriteGlobal("Simulation Server has SYNCHRONIZED!",eWarning);
|
||||
ServerWriteGlobal("Fixed motors may not have correct positions",
|
||||
eWarning);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user