versadac  1
versadac - Scalable Recorder Firmware
do8_ssm.h
1 /*******************************************************************************
2 FILE : do_f_ssm.h
3 VERSION : $Id: do8_ssm.h 32375 2010-07-07 11:03:01Z richardhi $
4 AUTHOR : Richard Hine
5 SYSTEM : Diab C for PowerPC under vxWorks
6 DESCRIPTION : Scheduled message class for driving any of the upgraded 2500 4 chan digital
7  output modules in a fast mode with error recovery. DO4 and RELAY 4.
8  Note: this is NOT the code which drives the new DO8
9 *******************************************************************************/
10 #ifndef __DO_8_SSM_H
11 #define __DO_8_SSM_H
12 #include "spismsg.h"
13 #include "msg_try.h"
14 #include "id_ssm.h"
15 
16 #define EIO_FAST_MESSAGES_GOOD true
17 #define EIO_FAST_MESSAGES_BAD false
18 
19 #define EIO_DO_8_MODULE_NUMBER_OF_CHANNELS 8
20 
21 /*
22  When enabled this feature provides -
23  1. Outputs 'c' whenever a corrupt reply to a fast update message is received
24  2. Provides ioDoTestCorrupt(module, cycles) which introduces a fixed number of errors
25  into the update message
26 */
27 //#define DO8_CORRUPTION_TEST_FEATURE_ENABLED
28 
29 class DigitalOutput8SpiScheduledMessage:public SpiScheduledMessage
30 {
31  public:
32  DigitalOutput8SpiScheduledMessage(unsigned char device, unsigned char * data, MsgRetryCounter * z_retry_p);
34  void setOnOffState(int z_channel, bool on);
35  void setOutputStates(uint8 z_states);
36  virtual bool wasCommandOk();
37  virtual void sent(); // called every time a message has been sent
38  virtual bool didModRxOk();
39 
40  protected:
41  void setSeed(unsigned char z_seed);
42 
43  private:
44  static unsigned short moduleToDevice(unsigned char module);
45  MsgRetryCounter * retry_p; // pointer to the retries count
46  unsigned char m_seed;
47 
48  static const unsigned char DO8_BIT_REVERSED_IDENT = 0xA8;
49  static const unsigned char DO8_SEED = 0x00;
50 
51  static const int TX_DATA_OFFSET = 0;
52  static const int TX_NOT_DATA_OFFSET = 1;
53 
54  static const int RX_ID_STATUS_OFFSET = 0;
55  static const int RX_DATA_OFFSET = 1;
56 };
57 
59 {
60  public:
61  Relay8SpiScheduledMessage(unsigned char device, unsigned char * data, MsgRetryCounter * z_retry_p);
62  virtual ~Relay8SpiScheduledMessage();
63 
64  virtual bool wasCommandOk();
65  virtual bool didModRxOk();
66 
67  private:
68  static const unsigned char RLY8_STATUS_MOD_RX_OK_MASK = 0xC0; // bits used to indicate module received corrupt message
69  static const unsigned char RLY8_CHECK_DATA_MASK = 0x3F; // mask for bits used to check message being receieved from module is ok
70  static const unsigned char RLY8_CHECK_DATA = 0x3A; // pattern used to check message being receieved from module is ok
71 
72  static const unsigned char RLY8_SEED = 0x55;
73 
74 };
75 
76 #endif /*__DO_8_SSM_H */
77 
Definition: do8_ssm.h:58
Definition: do8_ssm.h:29
Definition: msg_try.h:21