static BOOL SaveState(FILE *fp, QDPLUS_DIGITIZER *digitizer)
{
QDP_LC *lc;
LNKLST_NODE *crnt;

/* write out digitizer serial number */

    if (fwrite(&digitizer->serialno, sizeof(UINT64), 1, fp) != 1) return FALSE;

/* write out each active HLP */
    
    crnt = listFirstNode(digitizer->lcq.lc);
    while (crnt != NULL) {
        lc = (QDP_LC *) crnt->payload;
        if (lc->hlp != NULL && lc->hlp->nsamp != 0) {
            if (!isiWriteSeqno(fp, &lc->hlp->seqno)) return FALSE;
            if (fwrite(lc->hlp->chn, QDP_CNAME_LEN+1, 1, fp) != 1) return FALSE;
            if (fwrite(lc->hlp->loc, QDP_LNAME_LEN+1, 1, fp) != 1) return FALSE;
            if (fwrite(&lc->hlp->offset, sizeof(INT32), 1, fp) != 1) return FALSE;
        }
        crnt = listNextNode(crnt);
    }

/* flag end of list with undefined sequence number */

    if (!isiWriteSeqno(fp, &ISI_UNDEFINED_SEQNO)) return FALSE;

    return TRUE;
}
BOOL qdplusSaveState(QDPLUS *handle)
{
FILE *fp;
LNKLST_NODE *crnt;
UINT16 dirty = QDPLUS_FLAG_DIRTY;
UINT16 clean = QDPLUS_FLAG_CLEAN;
QDPLUS_DIGITIZER *digitizer;

    if ((fp = OpenStateFile(handle, "wb", NULL)) == NULL) return FALSE;

    if (fwrite(&dirty, sizeof(UINT16), 1, fp) != 1) {
        fclose(fp);
        return FALSE;
    }

    fflush(fp);

    crnt = listFirstNode(handle->list.digitizer);
    while (crnt != NULL) {
        if (!SaveState(fp, (QDPLUS_DIGITIZER *) crnt->payload)) {
            fclose(fp);
            return FALSE;
        }
        crnt = listNextNode(crnt);
    }

    rewind(fp);
    if (fwrite(&clean, sizeof(UINT16), 1, fp) != 1) {
        fclose(fp);
        return FALSE;
    }

    fclose(fp);
    return TRUE;
}
void qdplusPrintState(FILE *fp, QDPLUS *handle)
{
LNKLST_NODE *crnt;
QDPLUS_DIGITIZER *digitizer;

    if (fp == NULL || handle == NULL) return;

    if (handle->par.path.state != NULL) {
        fprintf(fp, "%s\n", handle->par.path.state);
    } else {
        fprintf(fp, "qdplusPrintState called with NULL par.path.state!\n");
    }

    if ((crnt = listFirstNode(handle->list.digitizer)) == NULL) {
        fprintf(fp, "empty file\n");
        return;
    }

    while (crnt != NULL) {
        digitizer = (QDPLUS_DIGITIZER *) crnt->payload;
        fprintf(fp, "S/N %016llX\n", digitizer->serialno);
        PrintState(fp, digitizer->state);
        crnt = listNextNode(crnt);
    }

    fflush(fp);
}
void printttglist()
    {
    char msg[101];
    LNKLST_NODE *node; 

    printf("\nDATA GAP INFO\n");

    node = listFirstNode(messageList);

    if(node==NULL)
        {
        printf("\nNo gaps found\n");
        }
    else
        {
        memset(msg,' ', 101);msg[99]='\n';msg[100]=0;
        memcpy(msg,"Stream",6);
        memcpy(&msg[40],"Gap",3);
        memcpy(&msg[80],"Length",6);
        printf(msg);
        }
    while (node != NULL) 
        {
        printf((char *)node->payload);
        node = listNextNode(node);
        }

    DeleteLists();
    }
Beispiel #5
0
static void trigger_thread(void *args)
{
	SetThreadName("JSRT Trigger");
	for(;;) {
		list_node_t *node;
		pthread_mutex_lock(&jsrt_mutex);
		for(node=listFirstNode(&rt_list); node; node=listNextNode(node))
			JS_TriggerAllOperationCallbacks(node->data);
		pthread_mutex_unlock(&jsrt_mutex);
		SLEEP(100);
	}
}
static void WalkData(QDP_LCQ *lcq)
{
QDP_LC *lc;
LNKLST_NODE *crnt;

    crnt = listFirstNode(lcq->lc);
    while (crnt != NULL) {
        lc = (QDP_LC *) crnt->payload;
        PrintLC(lcq, lc);
        crnt = listNextNode(crnt);
    }
}
Beispiel #7
0
void* DLLCALL msgQueuePeek(msg_queue_t* q, long timeout)
{
	link_list_t*	list = msgQueueReadList(q);

	if(list_wait(list,timeout))
#if defined(LINK_LIST_THREADSAFE)
		listSemPost(list)	/* Replace the semaphore we just cleared */
#endif
		;

	return listNodeData(listFirstNode(list));
}
int utilFlushAllBufferedStream()
	{
	UINT32 count = 0;
	LNKLST_NODE *crnt;
	BufferedStream  *p;

    crnt = listFirstNode(&list);
    while (crnt != NULL) 
		{
		p = (BufferedStream  *)crnt->payload;
		utilFlushBuffer(p);
        crnt = listNextNode(crnt);
		}
	return 0;
	}
static void StateSeqnoLimits(QDPLUS_DIGITIZER *digitizer, ISI_SEQNO *beg, ISI_SEQNO *end)
{
LNKLST_NODE *crnt;
QDPLUS_STATE *state;

    crnt = listFirstNode(digitizer->state);
    while (crnt != NULL) {
        state = (QDPLUS_STATE *) crnt->payload;
        if (isiIsUndefinedSeqno(beg)) *beg = state->seqno;
        if (isiIsUndefinedSeqno(end)) *end = state->seqno;
        if (isiSeqnoLT(&state->seqno, beg)) *beg = state->seqno;
        if (isiSeqnoGT(&state->seqno, end)) *end = state->seqno;
        crnt = listNextNode(crnt);
    }
}
static void PrintState(FILE *fp, LNKLST *head)
{
LNKLST_NODE *crnt;
QDPLUS_STATE *state;

    if (fp == NULL || state == NULL) return;

    crnt = listFirstNode(head);
    while (crnt != NULL) {
        state = (QDPLUS_STATE *) crnt->payload;
        fprintf(fp, "%3s", state->chn);
        fprintf(fp, " %2s", state->loc);
        fprintf(fp, " %08lx%016llx", state->seqno.signature, state->seqno.counter);
        fprintf(fp, " %ld", state->offset);
        fprintf(fp, "\n");
        crnt = listNextNode(crnt);
    }
}
BufferedStream  *utilOpenBufferedStream(char *pFileName)
	{
	int nLen;
	BufferedStream  *p;
	BufferedStream  obf;

	UINT32 count = 0;
	LNKLST_NODE *crnt;

    crnt = listFirstNode(&list);
    while (crnt != NULL) 
		{
		p = (BufferedStream  *)crnt->payload;
		if(strcmp(p->cFileName, pFileName)==0)
			{
			return p;
			}
        crnt = listNextNode(crnt);
		}
	
	nLen = strlen(pFileName);
	if(nLen<sizeof(obf.cFileName)-1)
		STRCPY(obf.cFileName, pFileName);
	else
		{
		strncpy(obf.cFileName, pFileName, sizeof(obf.cFileName)-1);
		obf.cFileName[sizeof(obf.cFileName)-1]=0;
		}

	obf.nBytes=0;
	obf.nTotalBytes=0;

	if(listAppend(&list, &obf, sizeof(obf)))
		{
		crnt = listLastNode(&list);
		p = (BufferedStream  *)crnt->payload;
		return p;
		}
	return NULL;
	}
int ispSendChnLocMap(int sd, char *buffer, IDA *ida, int to)
{
LNKLST_NODE *crnt;
IDA_CHNLOCMAP *entry;
int msglen, status;

    if (ida == NULL) return ISP_OK;
    if (ida->chnlocmap == NULL) return ISP_OK;
    msglen = EncodeChnLocMapName(buffer+4, ida);
    status = isp_send(sd, ISP_CHNMAP, buffer, msglen, to);
    if (status != ISP_OK) return status;

    crnt = listFirstNode(ida->chnlocmap);
    while (crnt != NULL) {
        entry = (IDA_CHNLOCMAP *) crnt->payload;
        status = SendChnLocMapEntry(sd, buffer, entry, to);
        if (status != ISP_OK) return status;
        crnt = listNextNode(crnt);
    }

    return ISP_OK;
}
BOOL qdplusStateSeqnoLimits(QDPLUS *handle, ISI_SEQNO *beg, ISI_SEQNO *end)
{
LNKLST_NODE *crnt;
QDPLUS_DIGITIZER *digitizer;

    if (handle == NULL || beg == NULL || end == NULL) {
        errno = EINVAL;
        return FALSE;
    }

    *beg = ISI_UNDEFINED_SEQNO;
    *end = ISI_UNDEFINED_SEQNO;

    if ((crnt = listFirstNode(handle->list.digitizer)) == NULL) return TRUE;

    while (crnt != NULL) {
        digitizer = (QDPLUS_DIGITIZER *) crnt->payload;
        StateSeqnoLimits(digitizer, beg, end);
        crnt = listNextNode(crnt);
    }

    return TRUE;
}
Beispiel #14
0
BOOL qdpBuildHLP(QDP_LCQ *lcq)
{
QDP_LC *lc;
LNKLST_NODE *crnt;
static char *fid = "qdpBuildHLP";

    if (!lcq->par.rules.valid) {
        qdpLcqWarn(lcq, "%s: WARNING: unexpected invalid rules!  Logic error? (sn=%016llX, addr=%08x)", fid, lcq->meta.combo.fix.sys_num, &lcq->par.rules);
        return TRUE;
    }

    crnt = listFirstNode(lcq->lc);
    while (crnt != NULL) {
        lc = (QDP_LC *) crnt->payload;
        if (lc->hlp == NULL) {
            qdpLcqError(lcq, "%s: ERROR: unexpected NULL hlp!\n", fid);
            return FALSE;
        }
        if (lc->state == QDP_LC_STATE_FULL && !BuildHLP(lcq, lc)) return FALSE;
        crnt = listNextNode(crnt);
    }

    return TRUE;
}
static stream_t *getStream(int nstream)
    {
    stream_t stt, *pstt;

    LNKLST_NODE *node; 
    node = listFirstNode(streamList);

    while (node != NULL) 
        {
        pstt = node->payload;
        if(pstt->nstream==nstream) break;
        node = listNextNode(node);
        }

    if(node==NULL)
        {
        stt.t       = 0.;
        stt.nstream = nstream;
        listAppend(streamList, &stt, sizeof(stt)); 
        node = listLastNode(streamList);
        }

    return (stream_t *)node->payload;
    }
Beispiel #16
0
list_node_t* DLLCALL msgQueueFirstNode(msg_queue_t* q)
{
	return listFirstNode(msgQueueReadList(q));
}