versadac  1
versadac - Scalable Recorder Firmware
eiot2srfif.h
1 /*******************************************************************************
2 FILE : eiot2srfif.h
3 VERSION : $Id$
4 AUTHOR : David Cozens
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : This file contains The t2500 FI2 module class
7 
8  Modification for 8Hz execution (for Scalable Recorder)
9 
10 *******************************************************************************/
11 
12 #ifndef __EIOT2SRFIF_H
13 #define __EIOT2SRFIF_H
14 /* The following section is needed by eio_t25sr.c */
15 
16 #include "eiot2srfi2.h"
17 
18 
19 #ifdef __cplusplus
20 
21 /* This section must never be included from C */
22 
23 
24 #include "eio_t25srm.h"
25 #include "rst_ssm.h"
26 #include "led_ssm.h"
27 
29 
30 extern "C" {
31 
32 enum Fi2FastRunStates
33 {
34  EIO_T2500FI2_FAST_STATE_MODULE_NEEDS_RESET,
35  EIO_T2500FI2_FAST_STATE_INITIALISING,
36  EIO_T2500FI2_FAST_STATE_RUNTIME,
37  EIO_T2500FI2_FAST_STATE_DELETE,
38  EIO_T2500FI2_FAST_STATE_SECONDARY,
39  EIO_T2500FI2_FAST_STATE_BECOMING_PRIMARY,
40 };
41 
42 #define FI2_FAST_NUMBER_OF_MESSAGES (EUROTHERM_SPI_MESSAGE_SCHEDULER_NUMBER_OF_SLOTS/EIO_T2500_FAST_MODULE_TICK_INTERLIEVE)
43 
44 class EioT2500FI2FastModule:public EioT2500Module
45 {
46  public:
47  EioT2500FI2FastModule(unsigned char moduleNumber, EioT2500CycleEnum z_expectedCycleNumber);
48  virtual ~EioT2500FI2FastModule();
49 
50  protected:
51  virtual void update62_5mS();
52  virtual void update125mS();
53  virtual void updateFast(unsigned short slot);
54  virtual void updateFastBuffers(unsigned int z_thisSlot);
55  virtual void cycleCompleteFast(unsigned int z_thisSlot);
56 
57  private:
58  void handleModuleError();
59  bool processUpdateMessage(FrequencyInputSpiScheduledMessage *message);
60  void configureUpdateData(int channel);
61  void driveModuleLEDs();
62  /*---------------------------------------------------------------------------
63  FUNCTION : filter
64  DESCRIPTION : This function implements a IIR filter. It is used for
65  filtering frequency.
66 
67  ARGUMENTS : sample - Raw value to include in filter
68  polep - filter pole
69  divisor - divider value to use. It is assumed that this has been checked and is valid!
70 
71  RETURN : New filtered value
72 
73  NOTES :
74 
75  ---------------------------------------------------------------------------*/
76  float filter( float sample, float polep, float divisor)
77  {
78  return polep + ( (sample - polep) / divisor );
79  }
80 
81  Fi2FastRunStates m_state;
82  bool m_messagesScheduled;
83  EioUint16 m_initialisingCount;
84  FrequencyInputSpiScheduledMessage * m_updateMessage[FI2_FAST_NUMBER_OF_MESSAGES];
85  bool m_updateMessageChanged[FI2_NUMBER_OF_CHANNELS][FI2_FAST_NUMBER_OF_MESSAGES];
86  EioFIData m_inputData[FI2_NUMBER_OF_CHANNELS];
87  EioFIConfig m_pointConfig[FI2_NUMBER_OF_CHANNELS];
88  bool m_badConfig[FI2_NUMBER_OF_CHANNELS];
89  bool m_resetFilter[FI2_NUMBER_OF_CHANNELS];
90  EioUint32 m_updatesSinceLastPulse[FI2_NUMBER_OF_CHANNELS];
91  float m_divisor[FI2_NUMBER_OF_CHANNELS];
92  float m_rawFrequency[FI2_NUMBER_OF_CHANNELS];
93  EioUint8 m_ledMask;
94  EioUint8 m_moduleVersion;
95  unsigned char m_debounceCode[FI2_NUMBER_OF_CHANNELS];
96  unsigned char m_supply[FI2_NUMBER_OF_CHANNELS];
97  unsigned char m_threshold[FI2_NUMBER_OF_CHANNELS];
98  unsigned char m_holdoffCount[FI2_NUMBER_OF_CHANNELS];
99  EioFIStatus m_holdoffStatus[FI2_NUMBER_OF_CHANNELS];
100 
101 };
102 } /* extern "C" */
103 #endif /* __cplusplus */
104 #endif /*__EIOT2SRFIF_H */
Definition: eio_t25srm.h:58
Definition: fi_ssm.h:39
Definition: eio_fi.h:52
Definition: eio_fi.h:39