versadac  1
versadac - Scalable Recorder Firmware
am_pvdata.h
1 /*****************************************************************************
2 FILE : am_pvdata.h
3 VERSION : $Id: am_pvdata.h 4938 2006-10-10 14:20:18Z martinto $
4 AUTHOR : Sandra Herring
5 SYSTEM : GNU C++ for Power PC
6 DESCRIPTION : Header file for PV current value and status.
7 *****************************************************************************/
8 
9 #if !defined(__AM_PVDATA_H)
10 #define __AM_PVDATA_H
11 
12 #if !defined(__ENUM_PV_STATUS_H)
13 #include "ENUM_PvStatus.h"
14 #endif
15 
16 extern "C"
17 {
18 #include "stdtypes.h"
19 }
20 
22 {
23  public:
24 
25  uint8 GetValue();
26 
27  void SetValue( uint8 value );
28 
29  void SetPvState( ENUM_PVStatus state );
30 
31  void SetColourB( bool a );
32 
33  void SetZoneB( bool a );
34 
35  void SetVirtualState( bool bVirtual ); // sets whether this is a virtual sample (defaults to no)
36 
37  ENUM_PVStatus GetPvState();
38 
39  bool ZoneB();
40 
41  bool ColourB();
42 
43  bool IsVirtual(); // indicates whether a virtual sample
44 
45  private:
46  uint8 m_value;
47 
48 };
49 
50 
51 /*****************************************************************************
52 CLASS : PvData
53 DESCRIPTION : This class is the basis of the record format used for
54  storing PV's for historical purposes. the rolling buffers
55  provided in the derived classes, will store objects derived
56  from this type.
57 *****************************************************************************/
58 class AM_PVData
59 {
60  public:
61 
62  // although all the items in the status byte may not be required
63  // for historical purposes, may as well store them, unless
64  // space becomes a problem
65  AM_PointStatus status;
66 };
67 
68 static const uint8 POINT_STATUS_PVSTATE_MASK = 0xf;
69 static const uint8 POINT_STATUS_ZONE_MASK = 0x10;
70 static const uint8 POINT_STATUS_COLOUR_MASK = 0x20;
71 static const uint8 POINT_STATUS_VIRTUAL_MASK = 0x40; // indicates that this is a virtual sample
72  // added in to the database to provide an apparent sample
73  // at batch start or end
74 
75 inline uint8 AM_PointStatus::GetValue()
76 {
77  return m_value;
78 }
79 
80 inline void AM_PointStatus::SetPvState( ENUM_PVStatus state )
81 {
82  m_value = (m_value & ~POINT_STATUS_PVSTATE_MASK) | state;
83 }
84 
85 inline void AM_PointStatus::SetValue( uint8 value )
86 {
87  m_value = value;
88 }
89 
90 inline void AM_PointStatus::SetColourB( bool a )
91 {
92  if ( a )
93  {
94  m_value |= POINT_STATUS_COLOUR_MASK;
95  }
96  else
97  {
98  m_value &= ~POINT_STATUS_COLOUR_MASK;
99  }
100 }
101 
102 inline void AM_PointStatus::SetZoneB( bool a )
103 {
104  if ( a )
105  {
106  m_value |= POINT_STATUS_ZONE_MASK;
107  }
108  else
109  {
110  m_value &= ~POINT_STATUS_ZONE_MASK;
111  }
112 }
113 
114 inline ENUM_PVStatus AM_PointStatus::GetPvState()
115 {
116  return (ENUM_PVStatus)(m_value & POINT_STATUS_PVSTATE_MASK);
117 }
118 
119 inline bool AM_PointStatus::ZoneB()
120 {
121  return m_value & POINT_STATUS_ZONE_MASK;
122 }
123 
124 inline bool AM_PointStatus::ColourB()
125 {
126  return m_value & POINT_STATUS_COLOUR_MASK;
127 }
128 
129 inline bool AM_PointStatus::IsVirtual()
130 {
131  return m_value & POINT_STATUS_VIRTUAL_MASK;
132 }
133 
134 #endif
135 
Definition: am_pvdata.h:58
Definition: am_pvdata.h:21