~anj/epics-base/process-get

« back to all changes in this revision

Viewing changes to src/std/dev/devLiSoftCallback.c

  • Committer: Andrew Johnson
  • Date: 2010-01-08 23:15:03 UTC
  • Revision ID: anj@aps.anl.gov-20100108231503-97fhp3oih8z8m9kk
Honor MS/MSS/MSI flags and fetches timestamps properly too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "dbDefs.h"
22
22
#include "dbAccess.h"
23
23
#include "dbNotify.h"
 
24
#include "epicsAssert.h"
24
25
#include "recGbl.h"
25
26
#include "recSup.h"
26
27
#include "devSup.h"
28
29
#include "longinRecord.h"
29
30
#include "epicsExport.h"
30
31
 
 
32
 
 
33
#define GET_OPTIONS (DBR_STATUS | DBR_TIME)
 
34
 
31
35
typedef struct notifyInfo {
32
36
    processNotify *ppn;
33
37
    CALLBACK *pcallback;
34
 
    epicsInt32 value;
 
38
    long options;
35
39
    int status;
 
40
    struct {
 
41
        DBRstatus
 
42
        DBRtime
 
43
        epicsInt32 value;
 
44
    } buffer;
36
45
} notifyInfo;
37
46
 
 
47
 
38
48
static void getCallback(processNotify *ppn, notifyGetType type)
39
49
{
40
50
    longinRecord *prec = (longinRecord *)ppn->usrPvt;
41
51
    notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
42
 
    int status = 0;
43
52
    long no_elements = 1;
44
 
    long options = 0;
45
53
 
46
54
    if (ppn->status == notifyCanceled) {
47
55
        printf("devLiSoftCallback::getCallback notifyCanceled\n");
48
56
        return;
49
57
    }
50
58
 
51
 
    switch (type) {
52
 
    case getFieldType:
53
 
        status = dbGetField(ppn->paddr, DBR_LONG, &pnotifyInfo->value,
54
 
                            &options, &no_elements, 0);
55
 
        break;
56
 
    case getType:
57
 
        status = dbGet(ppn->paddr, DBR_LONG, &pnotifyInfo->value,
58
 
                       &options, &no_elements, 0);
59
 
        break;
60
 
    }
61
 
    pnotifyInfo->status = status;
 
59
    assert(type == getFieldType);
 
60
    pnotifyInfo->status = dbGetField(ppn->paddr, DBR_LONG,
 
61
        &pnotifyInfo->buffer, &pnotifyInfo->options, &no_elements, 0);
62
62
}
63
63
 
64
64
static void doneCallback(processNotify *ppn)
99
99
    plink->type = PN_LINK;
100
100
    plink->value.pv_link.precord = pcommon;
101
101
    plink->value.pv_link.pvt = pdbaddr;
102
 
    plink->value.pv_link.pvlMask = 0;
 
102
    plink->value.pv_link.pvlMask &= pvlOptMsMode;   /* Severity flags only */
103
103
 
104
104
    ppn = callocMustSucceed(1, sizeof(*ppn),
105
105
        "devLiSoftCallback::add_record");
114
114
    pnotifyInfo->pcallback = callocMustSucceed(1, sizeof(CALLBACK),
115
115
        "devLiSoftCallback::add_record");
116
116
    pnotifyInfo->ppn = ppn;
 
117
    pnotifyInfo->options = GET_OPTIONS;
117
118
 
118
119
    prec->dpvt = pnotifyInfo;
119
120
    return 0;
125
126
    notifyInfo *pnotifyInfo = (notifyInfo *)prec->dpvt;
126
127
 
127
128
    if (plink->type == CONSTANT) return 0;
128
 
    assert (plink->type == PN_LINK);
 
129
    assert(plink->type == PN_LINK);
129
130
 
130
131
    dbNotifyCancel(pnotifyInfo->ppn);
131
132
    free(pnotifyInfo->ppn);
186
187
        return pnotifyInfo->status;
187
188
    }
188
189
 
189
 
    prec->val = pnotifyInfo->value;
 
190
    prec->val = pnotifyInfo->buffer.value;
190
191
    prec->udf = FALSE;
191
192
 
 
193
    switch (prec->inp.value.pv_link.pvlMask & pvlOptMsMode) {
 
194
        case pvlOptNMS:
 
195
            break;
 
196
        case pvlOptMSI:
 
197
            if (pnotifyInfo->buffer.severity < INVALID_ALARM)
 
198
                break;
 
199
            /* else fall through */
 
200
        case pvlOptMS:
 
201
            recGblSetSevr(prec, LINK_ALARM, pnotifyInfo->buffer.severity);
 
202
            break;
 
203
        case pvlOptMSS:
 
204
            recGblSetSevr(prec, pnotifyInfo->buffer.status,
 
205
                pnotifyInfo->buffer.severity);
 
206
            break;
 
207
    }
 
208
 
192
209
    if (prec->tsel.type == CONSTANT &&
193
210
        prec->tse == epicsTimeEventDeviceTime)
194
 
        prec->time = prec->inp.value.pv_link.precord->time;
 
211
        prec->time = pnotifyInfo->buffer.time;
195
212
    return 0;
196
213
}
197
214