versadac  1
versadac - Scalable Recorder Firmware
do16_ssm.h
1 /*******************************************************************************
2 FILE : do16_ssm.h
3 VERSION : $Id$
4 AUTHOR : David Cozens
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : Scheduled message for the update of DO16 modules
7 *******************************************************************************/
8 #ifndef __DO_16_SSM_H
9 #define __DO_16_SSM_H
10 #include "spismsg.h"
11 #include "msg_try.h"
12 #include "id_ssm.h"
13 
14 #define EIO_FAST_MESSAGES_GOOD true
15 #define EIO_FAST_MESSAGES_BAD false
16 
17 #define EIO_DO_16_MODULE_NUMBER_OF_CHANNELS 16
18 
19 /*
20  When enabled this feature provides -
21  1. Outputs 'c' whenever a corrupt reply to a fast update message is received
22  2. Provides ioDoTestCorrupt(module, cycles) which introduces a fixed number of errors
23  into the update message
24 */
25 //#define DO16_CORRUPTION_TEST_FEATURE_ENABLED
26 
27 class DigitalOutput16SpiScheduledMessage:public SpiScheduledMessage
28 {
29  public:
30  DigitalOutput16SpiScheduledMessage(unsigned char device, unsigned char * data, MsgRetryCounter * z_retry_p);
32  void setOnOffState(int z_channel, bool on);
33  void setOutputStates(uint16 z_states);
34  // for now we do not include a check on the recieved data bytes.
35  // we probably should check the RX data bytes but need to restructure the calls to
36  // setOnOffState to do this.
37  bool wasCommandOk() {return( (*getRxPtr()==DO16_IDENT) &&
38  ((*(getRxPtr()+DO16_RX_STATUS_BYTE_OFFSET) | DO16_STATUS_OVERTEMP_MASK | DO16_STATUS_MOD_RX_OK_MASK) == 0xff)
39  );};
40  bool isModuleHealthy(){return (*(getRxPtr()+DO16_RX_STATUS_BYTE_OFFSET)&DO16_STATUS_OVERTEMP_MASK)==DO16_STATUS_OVERTEMP_MASK;};
41  bool didModRxOk() {return((*(getRxPtr()+DO16_RX_STATUS_BYTE_OFFSET))&DO16_STATUS_MOD_RX_OK_MASK) != 0;};
42  virtual void sent(); // called every time a message has been sent
43 
44  private:
45  static unsigned short moduleToDevice(unsigned char module);
46  MsgRetryCounter * retry_p; // pointer to the retries count
47 
48  static const unsigned char DO16_DATA_CODE = 0x55;
49  static const unsigned char DO16_IDENT = 0x68;
50 
51  static const unsigned char DO16_STATUS_OVERTEMP_MASK = 0x80;
52  static const unsigned char DO16_STATUS_MOD_RX_OK_MASK = 0x40;
53 
54  static const int DO16_RX_ID_BYTE_OFFSET = 0x00;
55  static const int DO16_RX_STATUS_BYTE_OFFSET = 0x01;
56  static const int DO16_RX_DATA1_BYTE_OFFSET = 0x02;
57  static const int DO16_RX_DATA2_BYTE_OFFSET = 0x03;
58 
59  static const int DO16_TX_DATA1_BYTE_OFFSET = 0x00;
60  static const int DO16_TX_DATA2_BYTE_OFFSET = 0x01;
61  static const int DO16_TX_NOTDATA1_BYTE_OFFSET = 0x02;
62  static const int DO16_TX_NOTDATA2_BYTE_OFFSET = 0x03;
63 };
64 
65 
66 #endif /*__DO_16_SSM_H */
67 
Definition: do16_ssm.h:27
Definition: msg_try.h:21