allow for variable system clock

This commit is contained in:
zimoch
2012-08-14 09:25:28 +00:00
committed by Dirk Zimoch
parent cdbeac4c8c
commit 25eb8981d1
3 changed files with 19 additions and 10 deletions

View File

@@ -23,6 +23,7 @@
#define ANSI
#include "seq.h"
#include "tickLib.h"
#include "sysLib.h"
#include "logLib.h"
/* See seqCom.h for function prototypes (ANSI standard) */
@@ -108,7 +109,7 @@ long seq_pvGet(SS_ID ssId, long pvId)
}
/* Synchronous (-a option): wait for completion (10s timeout) */
sem_status = semTake(pSS->getSemId, 600);
sem_status = semTake(pSS->getSemId, sysClkRateGet()*10);
if (sem_status != OK)
{
logMsg ("semTake error=%d\n", sem_status, 0,0,0,0,0);
@@ -538,7 +539,7 @@ VOID seq_delayInit(SS_ID ssId, long delayId, float delay)
pSS = (SSCB *)ssId;
/* Convert delay time to tics & save */
pSS->delay[delayId] = delay * 60.0;
pSS->delay[delayId] = delay * sysClkRateGet();
ndelay = delayId + 1;
if (ndelay > pSS->numDelays)

View File

@@ -38,6 +38,7 @@
#include "seq.h"
#include "usrLib.h"
#include "tickLib.h"
#include "sysLib.h"
#include "string.h"
/* User functions */
@@ -62,6 +63,7 @@ int tid;
STATE *pST;
int nss, status;
float time;
float clockrate;
char file_name[100];
/* convert (possible) name to task id */
@@ -100,6 +102,7 @@ int tid;
printf("\n");
/* Print state set info */
clockrate=sysClkRateGet();
for (nss = 0, pSS = pSP->pSS; nss < pSP->numSS; nss++, pSS++)
{
printf(" State Set: \"%s\"\n", pSS->pSSName);
@@ -118,7 +121,7 @@ int tid;
pST = pSS->pStates + pSS->prevState;
printf(" Previous state = \"%s\"\n", pST->pStateName);
time = (tickGet() - pSS->timeEntered)/60.0;
time = (tickGet() - pSS->timeEntered)/clockrate;
printf("\tElapsed time since state was entered = %.1f seconds)\n",
time);
#ifdef DEBUG
@@ -157,7 +160,7 @@ char *pStr; /* optional pattern matching string */
return 0;
}
pSP = seqQryFind(tid);
if (tid == NULL)
if (tid == 0)
return 0;
printf("State Program: \"%s\"\n", pSP->pProgName);

View File

@@ -47,6 +47,7 @@
#include "taskwd.h"
#include "logLib.h"
#include "tickLib.h"
#include "sysLib.h"
#include "taskVarLib.h"
/* Function declarations */
@@ -242,9 +243,11 @@ SSCB *pSS;
LOCAL VOID seq_waitConnect(SPROG *pSP, SSCB *pSS)
{
STATUS status;
long _10sec;
long delay;
delay = 600; /* 10, 20, 30, 40, 40,... sec */
_10sec = sysClkRateGet()*10;
delay = _10sec; /* 10, 20, 30, 40, 40,... sec */
while (pSP->connCount < pSP->assignCount)
{
status = semTake(pSS->syncSemId, delay);
@@ -253,8 +256,8 @@ LOCAL VOID seq_waitConnect(SPROG *pSP, SSCB *pSS)
logMsg("%d of %d assigned channels have connected\n",
pSP->connCount, pSP->assignCount, 0,0,0,0);
}
if (delay < 2400)
delay = delay + 600;
if (delay < 4*_10sec)
delay = delay + _10sec;
}
}
/*
@@ -379,7 +382,8 @@ int tid; /* task being deleted */
SPROG *pSP;
SEM_ID cleanupSem;
int status;
int _10sec;
pSP = seqFindProg(tid);
if (pSP == NULL)
return -1; /* not a state program task */
@@ -392,9 +396,10 @@ int tid; /* task being deleted */
(FUNCPTR)seq_cleanup, tid, (int)pSP, (int)cleanupSem, 0,0,0,0,0,0,0);
/* Wait for cleanup task completion */
_10sec = sysClkRateGet()*10;
for (;;)
{
status = semTake(cleanupSem, 600);
status = semTake(cleanupSem, _10sec);
if (status == OK)
break;
logMsg("sprog_delete waiting for seq_cleanup\n", 0,0,0,0,0,0);
@@ -418,7 +423,7 @@ LOCAL long seq_cleanup(int tid, SPROG *pSP, SEM_ID cleanupSem)
#endif /*DEBUG_CLEANUP*/
/* Wait for log semaphore (in case a task is doing a write) */
semTake(pSP->logSemId, 600);
semTake(pSP->logSemId, sysClkRateGet()*10);
/* Remove tasks' watchdog & suspend all state set tasks except self */
#ifdef DEBUG_CLEANUP