-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathregDevInt64.c
104 lines (85 loc) · 2.72 KB
/
regDevInt64.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <dbAccess.h>
#include <dbEvent.h>
#include "regDevSup.h"
/* int64in ***********************************************************/
#include <int64inRecord.h>
long regDevInitRecordInt64in(int64inRecord *);
long regDevReadInt64in(int64inRecord *);
struct devsup regDevInt64in =
{
5,
NULL,
NULL,
regDevInitRecordInt64in,
regDevGetInIntInfo,
regDevReadInt64in
};
epicsExportAddress(dset, regDevInt64in);
long regDevInitRecordInt64in(int64inRecord* record)
{
regDevCommonInit(record, inp, TYPE_INT|TYPE_BCD);
return S_dev_success;
}
long regDevReadInt64in(int64inRecord* record)
{
int status;
status = regDevReadNumber((dbCommon*)record, &record->val, NULL);
if (status == ASYNC_COMPLETION) return S_dev_success;
if (status) return status;
return S_dev_success;
}
/* int64out **********************************************************/
#include <int64outRecord.h>
long regDevInitRecordInt64out(int64outRecord *);
long regDevWriteInt64out(int64outRecord *);
long regDevUpdateInt64out(int64outRecord *);
struct devsup regDevInt64out =
{
5,
NULL,
NULL,
regDevInitRecordInt64out,
regDevGetOutIntInfo,
regDevWriteInt64out
};
epicsExportAddress(dset, regDevInt64out);
long regDevInitRecordInt64out(int64outRecord* record)
{
regDevCommonInit(record, out, TYPE_INT|TYPE_BCD);
status = regDevInstallUpdateFunction((dbCommon*)record, regDevUpdateInt64out);
if (status) return status;
if (priv->rboffset == DONT_INIT) return S_dev_success;
return regDevReadNumber((dbCommon*)record, &record->val, NULL);
}
/* DELTA calculates the absolute difference between its arguments */
#define DELTA(last, val) ((last) > (val) ? (last) - (val) : (val) - (last))
long regDevUpdateInt64out(int64outRecord* record)
{
int status;
unsigned short monitor_mask;
status = regDevReadNumber((dbCommon*)record, &record->val, NULL);
if (status == ASYNC_COMPLETION) return S_dev_success;
monitor_mask = recGblResetAlarms(record);
if (DELTA(record->mlst, record->val) > record->mdel)
{
monitor_mask |= DBE_VALUE;
record->mlst = record->val;
}
if (DELTA(record->alst, record->val) > record->adel)
{
monitor_mask |= DBE_LOG;
record->alst = record->val;
}
if (monitor_mask)
db_post_events(record, &record->val, monitor_mask);
return status;
}
long regDevWriteInt64out(int64outRecord* record)
{
int status;
regDevCheckAsyncWriteResult(record);
regDevDebugLog(DBG_OUT, "%s: val=%lld (0x%llx)\n", record->name, (long long)record->val, (long long)record->val);
status = regDevWriteNumber((dbCommon*)record, record->val, 0.0);
if (status == ASYNC_COMPLETION) return S_dev_success;
return status;
}