mrfioc2  2.3.0
devObjMBBDirect.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 <mbbiDirectRecord.h>
12 #include <mbboDirectRecord.h>
13 
14 #include "devObj.h"
15 
16 using namespace mrf;
17 
18 /************** mbbiDirect *************/
19 
20 template<typename T>
21 static long read_mbbidir_from_integer(mbbiDirectRecord* 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->rval = priv->P->get();
31  }
32 
33  return 0;
34 }CATCH(S_dev_badArgument)
35 }
36 
37 // mbbidir uint32
38 
39 OBJECT_DSET(MBBIDirFromUINT32,
40  (&add_record_inp<mbbiDirectRecord,epicsUInt32>),
41  &del_record_property,
42  &init_record_empty,
43  &read_mbbidir_from_integer<epicsUInt32>,
44  NULL);
45 
46 // mbbidir uint16
47 
48 OBJECT_DSET(MBBIDirFromUINT16,
49  (&add_record_inp<mbbiDirectRecord,epicsUInt16>),
50  &del_record_property,
51  &init_record_empty,
52  &read_mbbidir_from_integer<epicsUInt16>,
53  NULL);
54 
55 
56 // mbbodir uint32
57 
58 template<typename I>
59 static long write_mbbodir_from_integer(mbboDirectRecord* prec)
60 {
61 if (!prec->dpvt) {(void)recGblSetSevr(prec, COMM_ALARM, INVALID_ALARM); return -1; }
62 CurrentRecord cur(prec);
63 try {
64  addr<I> *priv=(addr<I>*)prec->dpvt;
65 
66  {
67  scopedLock<mrf::Object> g(*priv->O);
68  priv->P->set(prec->rval);
69 
70  prec->rbv = priv->P->get();
71  }
72 
73  return 0;
74 }CATCH(S_dev_badArgument)
75 }
76 
77 
78 OBJECT_DSET(MBBODirFromUINT32,
79  (&add_record_out<mbboDirectRecord,epicsUInt32>),
80  &del_record_property,
81  &init_record_empty,
82  &write_mbbodir_from_integer<epicsUInt32>,
83  NULL);
84 
85 // mbbodir uint16
86 
87 
88 OBJECT_DSET(MBBODirFromUINT16,
89  (&add_record_out<mbboDirectRecord,epicsUInt16>),
90  &del_record_property,
91  &init_record_empty,
92  &write_mbbodir_from_integer<epicsUInt16>,
93  NULL);
94 
95 #include <epicsExport.h>
96 extern "C" {
97  OBJECT_DSET_EXPORT(MBBIDirFromUINT32);
98  OBJECT_DSET_EXPORT(MBBIDirFromUINT16);
99  OBJECT_DSET_EXPORT(MBBODirFromUINT32);
100  OBJECT_DSET_EXPORT(MBBODirFromUINT16);
101 }
OBJECT_DSET(MBBIDirFromUINT32,(&add_record_inp< mbbiDirectRecord, epicsUInt32 >), &del_record_property, &init_record_empty, &read_mbbidir_from_integer< epicsUInt32 >, NULL)
Definition: devObj.h:97
mrf::Object * O
Definition: devObj.h:90
OBJECT_DSET_EXPORT(MBBIDirFromUINT32)
mrf::auto_ptr< mrf::property< T > > P
Definition: devObj.h:98
#define CATCH(RET)
Definition: devObj.h:31
Definition: flash.cpp:23