00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef POWER_COMM_H
00031 #define POWER_COMM_H
00032
00033 static const unsigned CURRENT_MESSAGE_REVISION = 3;
00034 #define CURRENT_MESSAGE_SIZE (sizeof(PowerMessage))
00035 static const unsigned MINIMUM_MESSAGE_REVISION = 2;
00036 #define REVISION_2_MESSAGE_SIZE (sizeof(MessageHeader) + sizeof(StatusStruct_Rev2))
00037
00038 static const unsigned TRANSITION_MESSAGE_REVISION = 2;
00039 static const unsigned COMMAND_MESSAGE_REVISION = 2;
00040 static const unsigned STATUS_MESSAGE_REVISION = 2;
00041
00042 static const unsigned MESSAGE_ID_POWER = 0;
00043 static const unsigned MESSAGE_ID_COMMAND = 1;
00044 static const unsigned MESSAGE_ID_TRANSITION = 2;
00045 static const unsigned MESSAGE_ID_STATUS = 3;
00046 static const unsigned POWER_PORT = 6801;
00047
00048 enum Master_State { MASTER_NOPOWER, MASTER_STANDBY, MASTER_ON, MASTER_OFF, MASTER_SHUTDOWN };
00049 enum CB_State { STATE_NOPOWER, STATE_STANDBY, STATE_PUMPING, STATE_ON, STATE_DISABLED };
00050 enum CB_Command { NONE = 0, COMMAND_START = 1, COMMAND_STOP = 2, COMMAND_RESET = 3, COMMAND_DISABLE = 4 };
00051
00052 typedef struct
00053 {
00054 unsigned int message_revision;
00055 unsigned int serial_num;
00056 char text[32];
00057 unsigned int message_id;
00058 unsigned int data_length;
00059 } __attribute__((__packed__)) MessageHeader;
00060
00061 typedef struct
00062 {
00063
00064 unsigned char CB0_state;
00065 unsigned char CB1_state;
00066 unsigned char CB2_state;
00067 unsigned char DCDC_state;
00068
00069
00070 float input_voltage;
00071 float input_current;
00072 float DCDC_12V_aux;
00073 float DCDC_12V_cpu0;
00074 float CB0_voltage;
00075 float CB1_voltage;
00076 float CB2_voltage;
00077 float ambient_temp;
00078 unsigned int fan0_speed;
00079 unsigned int fan1_speed;
00080 unsigned int fan2_speed;
00081 unsigned int fan3_speed;
00082 unsigned char CB0_status;
00083 unsigned char CB1_status;
00084 unsigned char CB2_status;
00085 unsigned char estop_button_status;
00086 unsigned char estop_status;
00087 unsigned char pca_rev;
00088 unsigned char pcb_rev;
00089 unsigned char major_rev;
00090 unsigned char minor_rev;
00091 float min_input_voltage;
00092 float max_input_current;
00093 float DCDC_12V_cpu1;
00094 float DCDC_12V_user;
00095 float battery_voltage[4];
00096 } __attribute__((__packed__)) StatusStruct;
00097
00098 typedef struct
00099 {
00100
00101 unsigned char CB0_state;
00102 unsigned char CB1_state;
00103 unsigned char CB2_state;
00104 unsigned char DCDC_state;
00105
00106
00107 float input_voltage;
00108 float input_current;
00109 float DCDC_12V_out_voltage;
00110 float DCDC_19V_out_voltage;
00111 float CB0_voltage;
00112 float CB1_voltage;
00113 float CB2_voltage;
00114 float ambient_temp;
00115 unsigned int fan0_speed;
00116 unsigned int fan1_speed;
00117 unsigned int fan2_speed;
00118 unsigned int fan3_speed;
00119 unsigned char CB0_status;
00120 unsigned char CB1_status;
00121 unsigned char CB2_status;
00122 unsigned char estop_button_status;
00123 unsigned char estop_status;
00124 unsigned char pca_rev;
00125 unsigned char pcb_rev;
00126 unsigned char major_rev;
00127 unsigned char minor_rev;
00128 float min_input_voltage;
00129 float max_input_current;
00130
00131 } __attribute__((__packed__)) StatusStruct_Rev2;
00132
00133 typedef struct
00134 {
00135 MessageHeader header;
00136 StatusStruct status;
00137 } __attribute__((__packed__)) PowerMessage;
00138
00139 #define COMMAND_FLAG_RESET_STATS 0x1 //reset main statistics
00140 #define COMMAND_FLAG_RESET_TRANSITION_STATS 0x2 //reset the transition statistics
00141
00142 typedef struct
00143 {
00144 unsigned char CB0_command;
00145 unsigned char CB1_command;
00146 unsigned char CB2_command;
00147 unsigned char DCDC_command;
00148 unsigned char fan0_command;
00149 unsigned char fan1_command;
00150 unsigned char fan2_command;
00151 unsigned char fan3_command;
00152 unsigned int flags;
00153 } __attribute__((__packed__)) CommandStruct;
00154
00155 typedef struct
00156 {
00157 MessageHeader header;
00158 CommandStruct command;
00159 } __attribute__((__packed__)) CommandMessage;
00160
00161
00162 typedef struct
00163 {
00164 unsigned char stop_count;
00165 unsigned char estop_count;
00166 unsigned char trip_count;
00167 unsigned char fail_18V_count;
00168 unsigned char disable_count;
00169 unsigned char start_count;
00170 unsigned char pump_fail_count;
00171 unsigned char reset_count;
00172 } __attribute__((__packed__)) TransitionCount;
00173
00174 typedef struct
00175 {
00176 MessageHeader header;
00177 TransitionCount cb[3];
00178 } __attribute__((__packed__)) TransitionMessage;
00179
00180
00181 typedef struct
00182 {
00183 MessageHeader header;
00184 int message_to_get;
00185 } __attribute__((__packed__)) GetMessage;
00186
00187 #endif