You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
IAAT_Detector_Control/IAAT_UVDetectorControlConst...

199 lines
19 KiB

#include <stdlib.h>
#include <sys/time.h>
#ifndef ConstantsHeader
#define ConstantsHeader
// Command-IDs for send-packets
const char SND_CMD_ID_NOP = 0x0; // ( data bytes)
const char SND_CMD_ID_FLOW_NULL = 0x1; // For maintenance (0 data bytes)
const char SND_CMD_ID_FLOW_ACQUIRE = 0x2; // Start data acquisition (0 data bytes)
const char SND_CMD_ID_FLOW_STOP = 0x3; // Stop data acquisition (0 data bytes)
const char SND_CMD_ID_FLOW_RESET = 0x4; // Global reset to all entitys?? (0 data bytes)
const char SND_CMD_ID_FLOW_SLEEP = 0x5; // Enter power saving mode (0 data bytes)
const char SND_CMD_ID_FLOW_WAKEUP = 0x6; // Leave power saving mode (0 data bytes)
const char SND_CMD_ID_FLOW_BASELINE = 0x7; // Determine baseline (0 data bytes)
const char SND_CMD_ID_FPGA_SET_CONFIG = 0x8; // set FPGA config register (2 data bytes)
const char SND_CMD_ID_FPGA_READ_CONFIG = 0x9; // read FPGA config register (1 data bytes)
const char SND_CMD_ID_FPGA_READ_BASELINE = 0xA; // read baseline data (0 data bytes)
const char SND_CMD_ID_BEE_Itp_READ = 0x10; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ipre_READ = 0x11; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Isha_READ = 0x12; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ibuf_READ = 0x13; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Vfp_READ = 0x14; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Vfs_READ = 0x15; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Icomp_READ = 0x16; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ithdelta_READ = 0x17; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ithmain_READ = 0x18; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Vrc_READ = 0x19; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ipipe_READ = 0x1A; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Vd_READ = 0x1B; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Vdcl_READ = 0x1C; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Ivoltbuf_READ = 0x1D; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Isf_READ = 0x1E; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Icurrbuf_READ = 0x1F; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Latency_READ = 0x20; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_ROCtrl_READ = 0x21; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_RclkDiv_READ = 0x22; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_CompCtrl_READ = 0x23; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_CompChTh_READ = 0x24; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_CompMask_READ = 0x25; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_TpSelect_READ = 0x26; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_SEUcounts_READ = 0x27; // Beetle register read request (0 data bytes)
const char SND_CMD_ID_BEE_Itp_WRITE = 0x30; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ipre_WRITE = 0x31; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Isha_WRITE = 0x32; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ibuf_WRITE = 0x33; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Vfp_WRITE = 0x34; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Vfs_WRITE = 0x35; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Icomp_WRITE = 0x36; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ithdelta_WRITE = 0x37; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ithmain_WRITE = 0x38; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Vrc_WRITE = 0x39; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ipipe_WRITE = 0x3A; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Vd_WRITE = 0x3B; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Vdcl_WRITE = 0x3C; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Ivoltbuf_WRITE = 0x3D; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Isf_WRITE = 0x3E; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Icurrbuf_WRITE = 0x3F; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_Latency_WRITE = 0x40; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_ROCtrl_WRITE = 0x41; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_RclkDiv_WRITE = 0x42; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_CompCtrl_WRITE = 0x43; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_CompChTh_WRITE = 0x44; // 128 consecutive writes (1 data bytes)
const char SND_CMD_ID_BEE_CompMask_WRITE = 0x45; // 16 consecutive writes (1 data bytes)
const char SND_CMD_ID_BEE_TpSelect_WRITE = 0x46; // 17 consecutive writes (1 data bytes)
const char SND_CMD_ID_BEE_SEUcounts_WRITE = 0x47; // Beetle register write request (1 data bytes)
const char SND_CMD_ID_BEE_RESET = 0x50; // Beetle reset request (0 data bytes)
const char SND_CMD_ID_BEE_RECONF = 0x51; // Rewrite Beetle reg. fr. RAM (0 data bytes)
const char SND_CMD_ID_EOP = 0x55; // End of packet marker ( data bytes)
const char SND_CMD_ID_BEE_I2CClk_READ = 0x60; // Current I2C period read request (0 data bytes)
const char SND_CMD_ID_BEE_TriggerDur_READ = 0x61; // Current trigger duration request (0 data bytes)
const char SND_CMD_ID_BEE_TriggerDel_READ = 0x62; // Current trigger delay request (0 data bytes)
const char SND_CMD_ID_BEE_I2CClk_WRITE = 0x70; // # of CLK_GLOB periods (2 data bytes)
const char SND_CMD_ID_BEE_TriggerDur_WRITE = 0x71; // # of CLK_Beetle periods (1-16) (1 data bytes)
const char SND_CMD_ID_BEE_TriggerDel_WRITE = 0x72; // # of CLK_Beetle periods (1 data bytes)
const char SND_CMD_ID_STATUS_NULL = 0x80; // For maintenance (0 data bytes)
const char SND_CMD_ID_STATUS_ALL = 0x81; // Burst status info (0 data bytes)
const char SND_CMD_ID_STATUS_COMMANDS = 0x82; // Read # of commands received (0 data bytes)
const char SND_CMD_ID_STATUS_TRIGGERS = 0x83; // Read # of Triggers (0 data bytes)
const char SND_CMD_ID_STATUS_DATAVALID = 0x84; // Read # of DataValid signals (0 data bytes)
const char SND_CMD_ID_STATUS_DAVAUNPROC = 0x85; // Read # of unproc data valid (0 data bytes)
const char SND_CMD_ID_STATUS_DAPACKSEND = 0x86; // Read # of send data packets (0 data bytes)
const char SND_CMD_ID_STATUS_TRIGGER_RATE = 0x87; // Read current rate of triggers/s (0 data bytes)
const char SND_CMD_ID_PARAM_NULL = 0xA0; // For maintenance (0 data bytes)
const char SND_CMD_ID_SOP = 0xAA; // Start of packet marker ( data bytes)
// no. of data bytes per send command (index is command ID)
int SND_CMD_DATA_BYTES[] = { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Command-IDs for receive-packets
const char REC_CMD_ID_NOP = 0x0; // ( data bytes)
const char REC_CMD_ID_FLOW_NULL_ACK = 0x1; // For maintenance (0 data bytes)
const char REC_CMD_ID_FLOW_ACQUIRE_ACK = 0x2; // Acknowledge for acquisition start (0 data bytes)
const char REC_CMD_ID_FLOW_STOP_ACK = 0x3; // Ack for acquisition stop (0 data bytes)
const char REC_CMD_ID_FLOW_RESET_ACK = 0x4; // (0 data bytes)
const char REC_CMD_ID_FLOW_SLEEP_ACK = 0x5; // Ack for power saving mode (0 data bytes)
const char REC_CMD_ID_FLOW_WAKEUP_ACK = 0x6; // Ack for leaving power saving mode (0 data bytes)
const char REC_CMD_ID_FLOW_BASELINE_ACK = 0x7; // Ack for determine baseline (0 data bytes)
const char REC_CMD_ID_FPGA_SET_CONFIG_ACK = 0x8; // Ack for set FPGA config register (0 data bytes)
const char REC_CMD_ID_FPGA_SEND_CONFIG = 0x9; // contents of FPGA config register (2 data bytes)
const char REC_CMD_ID_FPGA_SEND_BASELINE = 0xA; // baseline data of FPGA (256 data bytes)
const char REC_CMD_ID_BEE_Itp_READ = 0x10; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ipre_READ = 0x11; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Isha_READ = 0x12; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ibuf_READ = 0x13; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Vfp_READ = 0x14; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Vfs_READ = 0x15; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Icomp_READ = 0x16; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ithdelta_READ = 0x17; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ithmain_READ = 0x18; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Vrc_READ = 0x19; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ipipe_READ = 0x1A; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Vd_READ = 0x1B; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Vdcl_READ = 0x1C; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Ivoltbuf_READ = 0x1D; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Isf_READ = 0x1E; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Icurrbuf_READ = 0x1F; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Latency_READ = 0x20; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_ROCtrl_READ = 0x21; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_RclkDiv_READ = 0x22; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_CompCtrl_READ = 0x23; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_CompChTh_READ = 0x24; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_CompMask_READ = 0x25; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_TpSelect_READ = 0x26; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_SEUcounts_READ = 0x27; // Beetle register read response (1 data bytes)
const char REC_CMD_ID_BEE_Itp_ACK = 0x30; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ipre_ACK = 0x31; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Isha_ACK = 0x32; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ibuf_ACK = 0x33; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Vfp_ACK = 0x34; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Vfs_ACK = 0x35; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Icomp_ACK = 0x36; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ithdelta_ACK = 0x37; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ithmain_ACK = 0x38; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Vrc_ACK = 0x39; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ipipe_ACK = 0x3A; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Vd_ACK = 0x3B; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Vdcl_ACK = 0x3C; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Ivoltbuf_ACK = 0x3D; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Isf_ACK = 0x3E; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Icurrbuf_ACK = 0x3F; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_Latency_ACK = 0x40; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_ROCtrl_ACK = 0x41; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_RclkDiv_ACK = 0x42; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_CompCtrl_ACK = 0x43; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_CompChTh_ACK = 0x44; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_CompMask_ACK = 0x45; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_TpSelect_ACK = 0x46; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_SEUcounts_ACK = 0x47; // Beetle register write acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_RESET_ACK = 0x50; // Beetle reset acknowledgement (0 data bytes)
const char REC_CMD_ID_BEE_RECONF_ACK = 0x51; // Register rewrite acknowledgement (0 data bytes)
const char REC_CMD_ID_EOP = 0x55; // End of packet marker ( data bytes)
const char REC_CMD_ID_BEE_I2CClk_READ = 0x60; // Current I2C period read response (2 data bytes)
const char REC_CMD_ID_BEE_TriggerDur_READ = 0x61; // Current trigger duration response (1 data bytes)
const char REC_CMD_ID_BEE_TriggerDel_READ = 0x62; // Current trigger delay response (1 data bytes)
const char REC_CMD_ID_BEE_I2CClk_ACK = 0x70; // # of CLK_GLOB periods (0 data bytes)
const char REC_CMD_ID_BEE_TriggerDur_ACK = 0x71; // # of CLK_Beetle periods (1-16) (0 data bytes)
const char REC_CMD_ID_BEE_TriggerDel_ACK = 0x72; // # of CLK_Beetle periods (0 data bytes)
const char REC_CMD_ID_STATUS_NULL_ACK = 0x80; // For maintenance (0 data bytes)
const char REC_CMD_ID_STATUS_ALL = 0x81; // Burst status info (999 = not yet defined) (999 data bytes)
const char REC_CMD_ID_STATUS_COMMANDS = 0x82; // # of received commands (4 data bytes)
const char REC_CMD_ID_STATUS_TRIGGERS = 0x83; // # of received triggers (4 data bytes)
const char REC_CMD_ID_STATUS_DATAVALID = 0x84; // # of DataValid signals (4 data bytes)
const char REC_CMD_ID_STATUS_DAVAUNPROC = 0x85; // # of unproc data valid (4 data bytes)
const char REC_CMD_ID_STATUS_DAPACKSEND = 0x86; // # of send data packets (4 data bytes)
const char REC_CMD_ID_STATUS_TRIGGER_RATE = 0x87; // current triggerrate / s (4 data bytes)
const char REC_CMD_ID_PARAM_NULL_ACK = 0xA0; // For maintenance (0 data bytes)
const char REC_CMD_ID_SOP = 0xAA; // Start of packet marker ( data bytes)
const char REC_CMD_ID_ERROR_NULL = 0xC0; // For maintenance (0 data bytes)
const char REC_CMD_ID_ERROR_FSM_UNDEF = 0xC1; // Undefined error in FSM_MAIN_inst (0 data bytes)
const char REC_CMD_ID_ERROR_UNKNWN_COMM = 0xC2; // Unknown command in FSM_MAIN_inst (1 data bytes)
const char REC_CMD_ID_ERROR_BEEMAN_UNDEF = 0xC3; // Unknown error in BEETLE_MANAGER_inst (0 data bytes)
const char REC_CMD_ID_ERROR_I2C_READ = 0xC4; // I2C read error in BEETLE_MANAGER_inst (1 data bytes)
const char REC_CMD_ID_ERROR_I2C_WRITE = 0xC5; // I2C write error in BEETLE_MANAGER_inst (1 data bytes)
const char REC_CMD_ID_DATA_NULL = 0xF0; // For maintenance and data traffic monitoring (0 data bytes)
const char REC_CMD_ID_DATA_UNPROC = 0xF1; // Unprocessed ADC data packet ((14+2)bit/chn)+NUMSAM+MaxX+MaxY (259 data bytes)
const char REC_CMD_ID_DATA_MAXLOC = 0xF2; // Numbers of strips having maximum charge (3 data bytes)
const char REC_CMD_ID_DATA_EVENT = 0xF3; // Data packet in event format (999 = not yet defined) (999 data bytes)
// no. of data bytes per receive command (index is command ID)
// 999 = not yet defined
int REC_CMD_DATA_BYTES[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 256, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 999, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 259, 3, 999, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// End of imported Code
// ====================================================================
#endif