qmca  0.0.20
Public Slots | Signals | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
EpicsDouble Class Reference

#include <epicsdouble.h>

Inheritance diagram for EpicsDouble:
Inheritance graph

Public Slots

void changeValue (dbr_gr_double val)
 
void caput (double val)
 

Signals

void valueChanged (double val)
 
void valueGraphicChanged (dbr_gr_double val)
 
- Signals inherited from EpicsObject
void valueChanged ()
 

Public Member Functions

 EpicsDouble (QString pvName, QObject *parent=0, int debug=0)
 
virtual ~EpicsDouble ()
 
void changeConnection (QString pv)
 
void connected ()
 
double value ()
 
- Public Member Functions inherited from EpicsObject
 EpicsObject (QString pvName, QObject *parent=0, int debug=0)
 
virtual ~EpicsObject ()
 
void changeConnection (QString pv)
 
int count ()
 
QString pvName ()
 
QString toolTip ()
 
virtual void disconnected ()
 
chid channelID ()
 
int debug ()
 
void setDebug (int dbg)
 
void settle (double t)
 
void ca_pend_io (double t)
 

Private Member Functions

virtual caEventCallBackFunc * get_event_handler ()
 

Static Private Member Functions

static void event_handler (struct event_handler_args arg)
 

Private Attributes

dbr_gr_double m_Value
 

Additional Inherited Members

- Static Public Attributes inherited from EpicsObject
static QMutex m_Mutex
 
- Protected Attributes inherited from EpicsObject
chid m_ChannelID
 
evid m_EventID
 
bool m_HasEventHandler
 
int m_Debug
 

Detailed Description

Definition at line 9 of file epicsdouble.h.

Constructor & Destructor Documentation

EpicsDouble::EpicsDouble ( QString  pvName,
QObject *  parent = 0,
int  debug = 0 
)

Definition at line 6 of file epicsdouble.cpp.

References EpicsObject::debug(), and m_Value.

7  : EpicsObject(pvName, parent, dbg)
8 {
9  if (debug()) {
10  printf("EpicsDouble::EpicsDouble(%s)\n", qPrintable(pvName));
11  }
12 
13  m_Value.value = NAN;
14 }
dbr_gr_double m_Value
Definition: epicsdouble.h:35
QString pvName()
Definition: epicsobject.cpp:30
EpicsObject(QString pvName, QObject *parent=0, int debug=0)
Definition: epicsobject.cpp:7
EpicsDouble::~EpicsDouble ( )
virtual

Definition at line 16 of file epicsdouble.cpp.

17 {
18 }

Member Function Documentation

void EpicsDouble::caput ( double  val)
slot
void EpicsDouble::changeConnection ( QString  pv)
void EpicsDouble::changeValue ( dbr_gr_double  val)
slot

Definition at line 63 of file epicsdouble.cpp.

References EpicsObject::channelID(), EpicsObject::debug(), EpicsObject::m_Mutex, m_Value, EpicsObject::valueChanged(), and valueGraphicChanged().

Referenced by event_handler().

64 {
65  if (debug()) {
66  printf("ca_put(%d,%p,%g)\n", DBR_DOUBLE, channelID(), newval);
67  }
68 
69 // ca_put(DBR_DOUBLE, channelID(), &newval);
70 
71  QMutexLocker lock(&m_Mutex);
72 
73  int valchanged=0;
74  int grpchanged=0;
75 
76  if (m_Value.value != newval.value) {
77  valchanged=1;
78  }
79 
80  if ((m_Value.status != newval.status) ||
81  (m_Value.severity != newval.severity) ||
82  (m_Value.precision != newval.precision) ||
83  (m_Value.upper_disp_limit != newval.upper_disp_limit) ||
84  (m_Value.lower_disp_limit != newval.lower_disp_limit) ||
85  (m_Value.upper_warning_limit != newval.upper_warning_limit) ||
86  (m_Value.lower_warning_limit != newval.lower_warning_limit) ||
87  (m_Value.upper_alarm_limit != newval.upper_alarm_limit) ||
88  (m_Value.lower_alarm_limit != newval.lower_alarm_limit) ||
89  (strcmp(m_Value.units,newval.units) != 0)) {
90  grpchanged = 1;
91  }
92 
93  m_Value = newval;
94 
95  if (valchanged) {
96  emit valueChanged(m_Value.value);
97  }
98 
99  if (grpchanged) {
101  }
102 }
dbr_gr_double m_Value
Definition: epicsdouble.h:35
void valueChanged()
static QMutex m_Mutex
Definition: epicsobject.h:42
chid channelID()
Definition: epicsobject.cpp:63
void valueGraphicChanged(dbr_gr_double val)
void EpicsDouble::connected ( )
virtual

Reimplemented from EpicsObject.

Definition at line 20 of file epicsdouble.cpp.

References EpicsObject::debug(), get_event_handler(), EpicsObject::m_ChannelID, EpicsObject::m_EventID, EpicsObject::m_HasEventHandler, and EpicsObject::pvName().

21 {
22  if (!m_HasEventHandler) {
23  SEVCHK(ca_create_subscription(DBR_GR_DOUBLE, 0, m_ChannelID, DBE_VALUE|DBE_ALARM,
24  get_event_handler(), this, &m_EventID), NULL);
25 
27 
28  if (debug()) {
29  printf("Channel %s connected\n", qPrintable(pvName()));
30  }
31  }
32 }
bool m_HasEventHandler
Definition: epicsobject.h:50
QString pvName()
Definition: epicsobject.cpp:30
evid m_EventID
Definition: epicsobject.h:49
virtual caEventCallBackFunc * get_event_handler()
Definition: epicsdouble.cpp:58
chid m_ChannelID
Definition: epicsobject.h:48
void EpicsDouble::event_handler ( struct event_handler_args  arg)
staticprivate

Definition at line 34 of file epicsdouble.cpp.

References changeValue(), and EpicsObject::debug().

Referenced by get_event_handler().

35 {
36  union db_access_val *pb = (union db_access_val *) args.dbr;
37 
38  dbr_gr_double res;
39  memset(&res, 0xff, sizeof(dbr_gr_double));
40 
41  switch (args.type) {
42  case DBR_GR_DOUBLE:
43  res=pb->gdblval;
44  break;
45  default:
46  printf("data type %ld not supported\n", args.type);
47  }
48 
49  EpicsDouble *r = ((EpicsDouble*) args.usr);
50 
51  if (r && r->debug()) {
52  printf("%s Epics Double Event Handler called %ld = %g\n", ca_name(args.chid), args.type, res.value);
53  }
54 
55  ((EpicsDouble*) args.usr) -> changeValue(res);
56 }
void changeValue(dbr_gr_double val)
Definition: epicsdouble.cpp:63
caEventCallBackFunc * EpicsDouble::get_event_handler ( )
privatevirtual

Implements EpicsObject.

Definition at line 58 of file epicsdouble.cpp.

References event_handler().

Referenced by connected().

59 {
61 }
static void event_handler(struct event_handler_args arg)
Definition: epicsdouble.cpp:34
double EpicsDouble::value ( )

Definition at line 110 of file epicsdouble.cpp.

References EpicsObject::m_Mutex, and m_Value.

Referenced by EpicsDoubleDisplay::EpicsDoubleDisplay(), EpicsDoubleLineEdit::EpicsDoubleLineEdit(), and BM12Controller::saveEnergyWindows().

111 {
112  QMutexLocker lock(&m_Mutex);
113 
114  return m_Value.value;
115 }
dbr_gr_double m_Value
Definition: epicsdouble.h:35
static QMutex m_Mutex
Definition: epicsobject.h:42
void EpicsDouble::valueChanged ( double  val)
signal
void EpicsDouble::valueGraphicChanged ( dbr_gr_double  val)
signal

Referenced by changeValue().

Member Data Documentation

dbr_gr_double EpicsDouble::m_Value
private

Definition at line 35 of file epicsdouble.h.

Referenced by changeValue(), EpicsDouble(), and value().


The documentation for this class was generated from the following files: