Commit 767f0723 authored by Ivan Tyagov's avatar Ivan Tyagov

Use a list rather than an individual int variable per I2C slave / relays.

parent d3df07b8
......@@ -28,12 +28,6 @@
##############################################################################
*/
// global relay state - XXX: use a list rather than individual variables
uint8_t I2C_0_RELAYS_STATE = 0; // state of 4 relays at I2C slave 0
uint8_t I2C_1_RELAYS_STATE = 0; // state of 4 relays at I2C slave 1
uint8_t I2C_2_RELAYS_STATE = 0; // state of 4 relays at I2C slave 4
uint8_t I2C_3_RELAYS_STATE = 0; // state of 4 relays at I2C slave 3
// the default addresses of MOD-IOs
static char *DEFAULT_I2C_0_ADDR = "0x58";
......@@ -42,6 +36,7 @@ const int DEFAULT_I2C_SLAVE_ADDR = 0x58;
// the current architecture of LIME2 supports up to 127 MOD-IO I2C slaves
int I2C_SLAVE_ADDR_LIST[127] = {0};
uint8_t I2C_RELAY_STATE_LIST[127] = {0};
// the number of physical relays
const int DEFAULT_RELAY_COUNT = 4;
......
......@@ -369,100 +369,100 @@ static void afterWriteTimeI2C0_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 0, &I2C_0_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 0, &I2C_RELAY_STATE_LIST[0], data);}
static void afterWriteTimeI2C0_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 1, &I2C_0_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 1, &I2C_RELAY_STATE_LIST[0], data);}
static void afterWriteTimeI2C0_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 2, &I2C_0_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 2, &I2C_RELAY_STATE_LIST[0], data);}
static void afterWriteTimeI2C0_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 3, &I2C_0_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[0], 3, &I2C_RELAY_STATE_LIST[0], data);}
// I2C1
static void afterWriteTimeI2C1_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 0, &I2C_1_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 0, &I2C_RELAY_STATE_LIST[1], data);}
static void afterWriteTimeI2C1_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 1, &I2C_1_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 1, &I2C_RELAY_STATE_LIST[1], data);}
static void afterWriteTimeI2C1_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 2, &I2C_1_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 2, &I2C_RELAY_STATE_LIST[1], data);}
static void afterWriteTimeI2C1_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 3, &I2C_1_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[1], 3, &I2C_RELAY_STATE_LIST[1], data);}
// I2C2
static void afterWriteTimeI2C2_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 0, &I2C_2_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 0, &I2C_RELAY_STATE_LIST[2], data);}
static void afterWriteTimeI2C2_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 1, &I2C_2_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 1, &I2C_RELAY_STATE_LIST[2], data);}
static void afterWriteTimeI2C2_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 2, &I2C_2_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 2, &I2C_RELAY_STATE_LIST[2], data);}
static void afterWriteTimeI2C2_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 3, &I2C_2_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[2], 3, &I2C_RELAY_STATE_LIST[2], data);}
// I2C3
static void afterWriteTimeI2C3_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 0, &I2C_3_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 0, &I2C_RELAY_STATE_LIST[3], data);}
static void afterWriteTimeI2C3_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 1, &I2C_3_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 1, &I2C_RELAY_STATE_LIST[3], data);}
static void afterWriteTimeI2C3_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 2, &I2C_3_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 2, &I2C_RELAY_STATE_LIST[3], data);}
static void afterWriteTimeI2C3_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 3, &I2C_3_RELAYS_STATE, data);}
setI2CSlaveRelayState(I2C_SLAVE_ADDR_LIST[3], 3, &I2C_RELAY_STATE_LIST[3], data);}
static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment