static void dump() { static int cnt = 1; LstLink(sFacilityCB) *fl; printf("dump: %d\n", cnt++); for (fl = LstFir(&lFacH); fl != LstEnd(&lFacH); fl = LstNex(fl)) printf("%s\n", LstObj(fl)->facnam); printf("dump finished\n\n"); }
static sNode * get_nodes ( pwr_tObjid oid ) { LstLink(sNode) *nl; for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) { if (cdh_ObjidIsEqual(LstObj(nl)->oid, oid)) return LstObj(nl); } return NULL; }
static void scan_timers () { LstLink(sNode) *nl, *nxtnl; plc_sTimer *tp; for (nl = LstFir(&timer_l); nl != LstEnd(&timer_l); nl = nxtnl) { tp = LstObj(nl)->timer; nxtnl = LstNex(nl); if (tp->TimerCount <= 1 || !tp->TimerFlag) { tp->TimerCount = 0; tp->TimerFlag = FALSE; LstRem(nl); LstNul(nl); } else { tp->TimerCount--; } } }
static sTimer * allocTimer ( ) { const int cAllocCount = 100; sTimer *ftp; LstLink(sTimer) *ftl; int i; if (LstEmp(&free_lh)) { ftp = (sTimer *) calloc(cAllocCount, sizeof(sTimer)); for (i=0; i < cAllocCount; i++, ftp++) { LstIns(&LstEnd(free_lh), ftp, ll); } } ftl = LstFir(&free_lh); LstRem(ftl); return LstObj(ftl); }
static void scan_nodes () { LstLink(sNode) *nl; pwr_tStatus sts; pwr_tBoolean Old; pwr_tTime LastUpdate, Timeout, CurrentTime; pwr_tDeltaTime Delta; pwr_tBoolean LinkUp; time_GetTime(&CurrentTime); for (nl = LstFir(&node_l); nl != LstEnd(&node_l); nl = LstNex(nl)) { sNode *np = LstObj(nl); pwr_sClass_NodeLinkSup *o = np->o; LinkUp = 0; sts = gdh_GetSubscriptionOldness (o->SubId, &Old, &LastUpdate, NULL); if (ODD(sts)) { /* IF (CurrentTime < LastUpdate + TimeoutTime) THEN LinkUp */ Delta.tv_sec = o->TimeoutTime; Delta.tv_nsec = 0; time_Aadd(&Timeout, &LastUpdate, &Delta); if (time_Acomp(&CurrentTime, &Timeout) < 0) LinkUp = 1; o->SystemStatus = *np->subvalue; } if (o->LinkUp && !LinkUp) { o->LinkUp = 0; o->DownTime = CurrentTime; o->SystemStatus = PWR__NETTIMEOUT; } else if (!o->LinkUp && LinkUp) { o->LinkUp = 1; o->UpTime = CurrentTime; o->UpCount++; } detect(o, 1, np); } }
void lex_FacNum(int facnum) { LstLink(sFacilityCB) *fl; /* * To do: Check that the facility number is within the valid range * */ /* Insert in ascending order */ for (fl = LstFir(&lFacH); fl != LstEnd(&lFacH); fl = LstNex(fl)) { if (LstObj(fl)->facnum > facnum) { break; } } CurrFac->facnum = facnum; LstIns(fl, CurrFac, FacL); CurrFac = NULL; }
static alimsrv_sSupDataBuf * buildBuffer ( alimsrv_sRequest *rqp, unsigned int *size ) { alimsrv_sSupDataBuf *bp = NULL; alimsrv_sAttrSupList *bap; alimsrv_sSupObjEntry *bsp; sObject *op; sAttribute *ap; sSupObject *sp; LstLink(sAttribute) *al; LstLink(sSupObject) *sl; pwr_tStatus sts; *size = 0; op = tree_Find(&sts, ltp, &rqp->Attribute.Objid); if (op == NULL) return NULL; if (op->attr_c == 0) return NULL; *size = sizeof(alimsrv_sSupDataBuf) - sizeof(alimsrv_sAttrSupList) + op->attr_c * sizeof(alimsrv_sAttrSupList) + (op->sup_c - op->attr_c) * sizeof(alimsrv_sSupObjEntry); bp = (alimsrv_sSupDataBuf *)calloc(1, *size); if (bp == NULL) return NULL; bp->NoOfSupAttr = op->attr_c; bap = bp->AttrSupList; for (al = LstFir(&op->attr_l); al != LstEnd(&op->attr_l); al = LstNex(al)) { ap = LstObj(al); bap->SupAttr = ap->aref; bap->NoOfSupObjs = ap->sup_c; bap->SupClass = ap->cid; bsp = bap->SupList; for (sl = LstFir(&ap->sup_l); sl != LstEnd(&ap->sup_l); sl = LstNex(sl)) { sp = LstObj(sl); bsp->SupObjid = sp->oid; if (ap->cid == pwr_cClass_ASup) { pwr_sClass_ASup *asup = (pwr_sClass_ASup *) sp->p; bsp->SupData.A.EvType = asup->EventType; bsp->SupData.A.EvPrio = asup->EventPriority; bsp->SupData.A.High = asup->High; bsp->SupData.A.Limit = asup->CtrlLimit; bsp->SupData.A.Hyst = asup->Hysteres; bsp->SupData.A.MsgOn = asup->DetectOn; } else if (ap->cid == pwr_cClass_DSup) { pwr_sClass_DSup *dsup = (pwr_sClass_DSup *) sp->p; bsp->SupData.D.EvType = dsup->EventType; bsp->SupData.D.EvPrio = dsup->EventPriority; bsp->SupData.D.CtrlPos = dsup->CtrlPosition; } bsp++; } bap = (void *)bsp; } return bp; }