This is Unofficial EPICS BASE Doxygen Site
epics::pvData::PVAlarm Class Reference

Methods for accessing an alarm structure. More...

#include "pvAlarm.h"

Public Member Functions

 PVAlarm ()
 
bool attach (PVFieldPtr const &pvField)
 
void detach ()
 
bool isAttached ()
 
void get (Alarm &alarm) const
 
bool set (Alarm const &alarm)
 

Detailed Description

Methods for accessing an alarm structure.

An alarm structure has the following fields:

int severity
int status
string message

This class can be attached to an alarm structure field of any PVData object. The methods provide access to the fields in the attached structure, via an instance of class Alarm. This class should not be extended.

Definition at line 37 of file pvAlarm.h.

Constructor & Destructor Documentation

epics::pvData::PVAlarm::PVAlarm ( )
inline

Constructor

Definition at line 43 of file pvAlarm.h.

43 {}

Member Function Documentation

bool epics::pvData::PVAlarm::attach ( PVFieldPtr const &  pvField)

Definition at line 26 of file pvAlarm.cpp.

27 {
28  if(pvField->getField()->getType()!=structure) return false;
29  PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
30  pvSeverity = pvStructure->getSubField<PVInt>("severity");
31  if(pvSeverity.get()==NULL) return false;
32  pvStatus = pvStructure->getSubField<PVInt>("status");
33  if(pvStatus.get()==NULL) {
34  pvSeverity.reset();
35  return false;
36  }
37  pvMessage = pvStructure->getSubField<PVString>("message");
38  if(pvMessage.get()==NULL) {
39  pvSeverity.reset();
40  pvStatus.reset();
41  return false;
42  }
43  return true;
44 }
PVScalarValue< int32 > PVInt
Definition: pvData.h:496
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
#define NULL
Definition: catime.c:38
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
void epics::pvData::PVAlarm::detach ( )

Detach for pvField.

Definition at line 46 of file pvAlarm.cpp.

47 {
48  pvSeverity.reset();
49  pvStatus.reset();
50  pvMessage.reset();
51 }
void epics::pvData::PVAlarm::get ( Alarm alarm) const

copy the alarm structure values to Alarm

Parameters
alarmAn instance of class Alarm
Exceptions
Ifnot attached to a pvField.

Definition at line 59 of file pvAlarm.cpp.

60 {
61  if(pvSeverity.get()==NULL) {
62  throw std::logic_error(notAttached);
63  }
64  alarm.setSeverity(AlarmSeverityFunc::getSeverity(pvSeverity->get()));
65  alarm.setStatus(AlarmStatusFunc::getStatus(pvStatus->get()));
66  alarm.setMessage(pvMessage->get());
67 }
#define NULL
Definition: catime.c:38
static AlarmSeverity getSeverity(int value)
Definition: alarm.cpp:25
static AlarmStatus getStatus(int value)
Definition: alarm.cpp:70
bool epics::pvData::PVAlarm::isAttached ( )

Is the PVAlarm attached to a pvField?

Returns
(false,true) (is not,is) attached to a pvField.

Definition at line 53 of file pvAlarm.cpp.

54 {
55  if(pvSeverity.get()==NULL) return false;
56  return true;
57 }
#define NULL
Definition: catime.c:38
bool epics::pvData::PVAlarm::set ( Alarm const &  alarm)

copy the values from Alarm to the alarm structure.

Parameters
alarmAn instance of class Alarm
Returns
(false,true) if pvField (immutable, mutable)
Exceptions
Ifnot attached to a pvField.

Definition at line 69 of file pvAlarm.cpp.

70 {
71  if(pvSeverity.get()==NULL) {
72  throw std::logic_error(notAttached);
73  }
74  if(pvSeverity->isImmutable() || pvMessage->isImmutable()) return false;
75  Alarm current;
76  get(current);
77  bool returnValue = false;
78  if(current.getSeverity()!=alarm.getSeverity())
79  {
80  pvSeverity->put(alarm.getSeverity());
81  returnValue = true;
82  }
83  if(current.getStatus()!=alarm.getStatus())
84  {
85  pvStatus->put(alarm.getStatus());
86  returnValue = true;
87  }
88  if(current.getMessage()!=alarm.getMessage())
89  {
90  pvMessage->put(alarm.getMessage());
91  returnValue = true;
92  }
93  return returnValue;
94 }
#define NULL
Definition: catime.c:38

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