mrfioc2  2.3.0
devObjLong.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2011 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * mrfioc2 is distributed subject to a Software License Agreement found
5 * in file LICENSE that is included with this distribution.
6 \*************************************************************************/
7 /*
8  * Author: Michael Davidsaver <mdavidsaver@gmail.com>
9  */
10 
11 #include <longinRecord.h>
12 #include <longoutRecord.h>
13 
14 #include "devObj.h"
15 
16 using namespace mrf;
17 
18 /************** longin *************/
19 
20 template<typename T>
21 static long read_li_from_integer(longinRecord* prec)
22 {
23 if (!prec->dpvt) {(void)recGblSetSevr(prec, COMM_ALARM, INVALID_ALARM); return -1; }
24 CurrentRecord cur(prec);
25 try {
26  addr<T> *priv=(addr<T>*)prec->dpvt;
27 
28  {
29  scopedLock<mrf::Object> g(*priv->O);
30  prec->val = priv->P->get();
31  }
32 
33  return 0;
34 }CATCH(S_dev_badArgument)
35 }
36 
37 // li uint32
38 
39 OBJECT_DSET(LIFromUINT32,
40  (&add_record_inp<longinRecord,epicsUInt32>),
41  &del_record_property,
42  &init_record_empty,
43  &read_li_from_integer<epicsUInt32>,
44  NULL);
45 
46 // li uint16
47 
48 OBJECT_DSET(LIFromUINT16,
49  (&add_record_inp<longinRecord,epicsUInt16>),
50  &del_record_property,
51  &init_record_empty,
52  &read_li_from_integer<epicsUInt16>,
53  NULL);
54 
55 // li bool
56 
57 OBJECT_DSET(LIFromBool,
58  (&add_record_inp<longinRecord,bool>),
59  &del_record_property,
60  &init_record_empty,
61  &read_li_from_integer<bool>,
62  NULL);
63 
64 
65 // lo uint32
66 
67 template<typename I>
68 static long write_lo_from_integer(longoutRecord* prec)
69 {
70 if (!prec->dpvt) {(void)recGblSetSevr(prec, COMM_ALARM, INVALID_ALARM); return -1; }
71 CurrentRecord cur(prec);
72 try {
73  addr<I> *priv=(addr<I>*)prec->dpvt;
74 
75  {
76  scopedLock<mrf::Object> g(*priv->O);
77  priv->P->set(prec->val);
78 
79  if(priv->rbv)
80  prec->val = priv->P->get();
81  }
82 
83  return 0;
84 }CATCH(S_dev_badArgument)
85 }
86 
87 
88 OBJECT_DSET(LOFromUINT32,
89  (&add_record_out<longoutRecord,epicsUInt32>),
90  &del_record_property,
91  &init_record_empty,
92  &write_lo_from_integer<epicsUInt32>,
93  NULL);
94 
95 // lo uint16
96 
97 
98 OBJECT_DSET(LOFromUINT16,
99  (&add_record_out<longoutRecord,epicsUInt16>),
100  &del_record_property,
101  &init_record_empty,
102  &write_lo_from_integer<epicsUInt16>,
103  NULL);
104 
105 // lo bool
106 
107 
108 OBJECT_DSET(LOFromBool,
109  (&add_record_out<longoutRecord,bool>),
110  &del_record_property,
111  &init_record_empty,
112  &write_lo_from_integer<bool>,
113  NULL);
114 
115 #include <epicsExport.h>
116 extern "C" {
117  OBJECT_DSET_EXPORT(LIFromUINT32);
118  OBJECT_DSET_EXPORT(LIFromUINT16);
119  OBJECT_DSET_EXPORT(LIFromBool);
120  OBJECT_DSET_EXPORT(LOFromUINT32);
121  OBJECT_DSET_EXPORT(LOFromUINT16);
122  OBJECT_DSET_EXPORT(LOFromBool);
123 }
OBJECT_DSET(LIFromUINT32,(&add_record_inp< longinRecord, epicsUInt32 >), &del_record_property, &init_record_empty, &read_li_from_integer< epicsUInt32 >, NULL)
Definition: devObj.h:97
mrf::Object * O
Definition: devObj.h:90
mrf::auto_ptr< mrf::property< T > > P
Definition: devObj.h:98
#define CATCH(RET)
Definition: devObj.h:31
Definition: flash.cpp:23
int rbv
Definition: devObj.h:89
OBJECT_DSET_EXPORT(LIFromUINT32)