/* * Get value from a queued PV. */ epicsShareFunc boolean seq_pvGetQ(SS_ID ss, CH_ID chId) { PROG *sp = ss->prog; CHAN *ch = sp->chan + chId; void *var = valPtr(ch,ss); EF_ID ev_flag = ch->syncedTo; PVMETA *meta = metaPtr(ch,ss); boolean was_empty; struct getq_cp_arg arg = {ch, var, meta}; if (!ch->queue) { errlogSevPrintf(errlogMajor, "pvGetQ(%s): user error (not queued)\n", ch->varName ); return FALSE; } was_empty = seqQueueGetF(ch->queue, getq_cp, &arg); if (ev_flag) { epicsMutexMustLock(sp->lock); /* If queue is now empty, clear the event flag */ if (seqQueueIsEmpty(ch->queue)) { bitClear(sp->evFlags, ev_flag); } epicsMutexUnlock(sp->lock); } return (!was_empty); }
int evaluatePost(SeqQueue queue) { SeqStack stack; init(&stack); while (!seqQueueIsEmpty(&queue)) { char c = seqDequeue(&queue); if (c > '0' && c < '9') { seqPush(&stack, c); } else { int x = seqPop(&stack) - '0', y = seqPop(&stack) - '0'; switch (c) { case '+': seqPush(&stack, (char) (x + y + '0')); break; case '-': seqPush(&stack, (char) (x - y + '0')); break; case '*': seqPush(&stack, (char) (x * y + '0')); break; case '/': seqPush(&stack, (char) (x / y + '0')); break; } } } return seqPeek(&stack) - '0'; }