File: new_sim_sensor.h

package info (click to toggle)
openhpi 3.8.0-2.3
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 31,888 kB
  • sloc: ansic: 225,326; cpp: 63,687; java: 16,472; cs: 15,161; python: 11,884; sh: 11,508; makefile: 4,945; perl: 1,529; xml: 36; asm: 13
file content (149 lines) | stat: -rw-r--r-- 5,161 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/** 
 * @file    new_sim_sensor.h
 *
 * The file includes an abstract class for sensor handling:\n
 * NewSimulatorSensor
 * 
 * @author  Lars Wetzel <larswetzel@users.sourceforge.net>
 * @version 0.3
 * @date    2010
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This
 * file and program are licensed under a BSD style license.  See
 * the Copying file included with the OpenHPI distribution for
 * full licensing terms.
 *
 * The new Simulator plugin is adapted from the ipmidirect plugin.
 * Thanks to 
 *     Thomas Kanngieser <thomas.kanngieser@fci.com>
 *     Pierre Sangouard  <psangouard@eso-tech.com>
 *    
 */

#ifndef __NEW_SIM_SENSOR_H__
#define __NEW_SIM_SENSOR_H__


extern "C" {
#include "SaHpi.h"
}


/**
#ifndef __NEW_SIM_EVENT_H__
#include "new_sim_event.h"
#endif
**/

#ifndef __NEW_SIM_RDR_H__
#include "new_sim_rdr.h"
#endif


class  NewSimulatorDomain;

/**
 * @class NewSimulatorSensor
 * 
 * Abstract class for simulating sensors
 * 
 **/
class NewSimulatorSensor : public NewSimulatorRdr {

protected:
  /// Record with the sensor information
  SaHpiSensorRecT        m_sensor_record;
  
  /// Is this sensor enabled
  SaHpiBoolT             m_enabled;
  /// Are events from this sensor enabled
  SaHpiBoolT             m_events_enabled;
  /// Is the reading supported
  SaHpiBoolT             m_read_support;
  /// Events assertion mask
  SaHpiEventStateT       m_assert_mask;
  /// Events deassertion mask
  SaHpiEventStateT       m_deassert_mask;
  
  /// SensorReading values
  SaHpiSensorReadingT    m_read_data;
  /// EventState
  SaHpiEventStateT       m_event_data;
  
  virtual bool gt(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2);
  virtual bool ge(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2);
  virtual bool lt(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2);
  virtual bool le(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2);
  virtual bool eq(const SaHpiSensorReadingT &val1, const SaHpiSensorReadingT &val2);
  virtual bool ltZero(const SaHpiSensorReadingT &val1);
  
public:
  NewSimulatorSensor( NewSimulatorResource *res );
  NewSimulatorSensor( NewSimulatorResource *res,
                      SaHpiRdrT rdr, 
                      SaHpiSensorReadingT data, 
                      SaHpiEventStateT event_state, 
                      SaHpiEventStateT event_amask, 
                      SaHpiEventStateT event_dmask,
                      SaHpiBoolT enabled, 
                      SaHpiBoolT event_enabled);
                      
  virtual ~NewSimulatorSensor();

  /// Return sensor Number
  virtual unsigned int Num() const { return m_sensor_record.Num; }

  /// Return Sensor Type
  SaHpiSensorTypeT       Type() const { return m_sensor_record.Type; }
  /// Return Sensor Event Category
  SaHpiEventCategoryT    EventCategory() const { return m_sensor_record.Category; }
  /// Return if Sensor is enabbled or not 
  SaHpiBoolT             EnableCtrl() const { return m_sensor_record.EnableCtrl; }
  /// Return the event change capability of the sensor
  SaHpiSensorEventCtrlT  EventCtrl() const { return m_sensor_record.EventCtrl; }
  /// Return Sensor Event States
  SaHpiEventStateT       EventStates() const { return m_sensor_record.Events; }
  /// Return Sensor Data Format
  SaHpiSensorDataFormatT DataFormat() const { return m_sensor_record.DataFormat; }
  /// Return Sensor Threshold definitions
  SaHpiSensorThdDefnT    ThresholdDefn() const { return m_sensor_record.ThresholdDefn; }
  /// Return Sensor Oem information
  SaHpiUint32T           Oem() const { return m_sensor_record.Oem; }

  /// Not clear if this function is really needed
  virtual void HandleNew( NewSimulatorDomain *domain );
  /// Not implemented - to be verified if needed
  virtual bool Cmp( const NewSimulatorSensor &s2 ) const;
  
  // create an HPI event from ipmi event
//  virtual SaErrorT CreateEvent( NewSimulatorEvent *event, SaHpiEventT &h );

  /// create and send HPI sensor enable change event
  void CreateEnableChangeEvent();

  // handle all incoming sensor events
//  virtual void HandleEvent( NewSimulatorEvent *event );
  virtual void Dump( NewSimulatorLog &dump ) const;

  /// create an RDR sensor record
  virtual bool CreateRdr( SaHpiRptEntryT &resource, SaHpiRdrT &rdr );

  // Official HPI functions
  /// abstract method for the GetSensorReading command
  virtual SaErrorT GetSensorReading( SaHpiSensorReadingT &data, SaHpiEventStateT &state ) = 0;
  SaErrorT GetEnable( SaHpiBoolT &enable );
  SaErrorT GetEventEnables( SaHpiBoolT &enables );
  SaErrorT GetEventMasks( SaHpiEventStateT &AssertEventMask,
                          SaHpiEventStateT &DeassertEventMask);
  SaErrorT SetEnable( const SaHpiBoolT &enable );
  SaErrorT SetEventEnables( const SaHpiBoolT &enables );
  SaErrorT SetEventMasks( const SaHpiSensorEventMaskActionT &act,
                          SaHpiEventStateT &AssertEventMask,
                          SaHpiEventStateT &DeassertEventMask );

};


#endif