#ifndef STPDEFINE_H #define STPDEFINE_H #include #include #define STP_DEBUG #define STP_MANY_PACKETS_DEBUG #define ADC_DEBUG #define CLUSTER_DEBUG #define CONST_HEADER_SIZE 3 #define CONST_REGISTER_HEADER_SIZE 5 #define STP_RECONNECTION_PERIOD 1000 #define DEFAULT_DEST_PORT 7000 #define STP_PING_INTERVAL_MS 1000 #define STP_TIMEOUT_MS 400 #define STP_TIMEOUT_COUNT 2 #define QUEUE_TIMEOUT 400 #define QUEUE_TIMEOUT_COUNT 2 #define DISCOVER_PERIOD 1000 namespace stpProtocol_ns { enum packetType { NOP = 0x00, SYNCReq = 0x01, SYNCAck = 0x02, PING = 0x03, PONG = 0x04, RESET = 0x05, DATA = 0x06 }; enum stpCommand { REG_READ = 0x01, REG_READ_ACK = 0x02, REG_READ_ERROR = 0x03, REG_WRITE = 0x11, REG_WRITE_ACK = 0x12, REG_WRITE_ERROR = 0x13, REQ_ID_SN = 0xFD, REQ_ID = 0xFE, ID = 0xFF }; } namespace ADC_ns { enum ADCState { DISCOVER, CONNECTING, CONNECTED, CONFIGURATION_READING, WAITING_COMMAND, ADC_START_SEND, ADC_STOP_SEND, INIT_FAILED, DISCONNECTED, RUNNING, }; enum channelMode { AC = 0x00, ACDC = 0x01, }; enum bitDepth { BIT16 = 0x0000, BIT24 = 0x0001 }; enum DACMode { SIN, NOISE }; enum SYNCMode { SLAVE, MASTER }; } namespace ADCCluster_ns { enum clusterState { IDLE, CONFIG, RUNNING, FAILED }; } namespace trans_ns { struct couple { uint8_t L; uint8_t H; }; union bytes2word { couple bytes; uint16_t word; }; struct twinCouple { uint8_t LL; uint8_t LH; uint8_t HL; uint8_t HH; }; union bytes2long { twinCouple bytes; uint32_t twinWord; }; union bytes2float { twinCouple bytes; float floatValue; }; union byte2bits { uint8_t byte; struct bit8map { unsigned a0: 1; unsigned a1: 1; unsigned a2: 1; unsigned a3: 1; unsigned a4: 1; unsigned a5: 1; unsigned a6: 1; unsigned a7: 1; } bits; }; } namespace stpClient_ns { enum stpState { DISCONNECTED, CONNECTING, CONNECTED }; enum pingState { IDLE, PENDING }; } namespace ADCQueue_ns { enum queueState { stopped, waiting }; struct cmdItem { stpProtocol_ns::stpCommand cmd; QByteArray * regData; uint16_t regNumber; uint16_t id; bool waiting; }; } #endif // STPDEFINE_H