Commit 2c10d6f2 authored by Ivan Tyagov's avatar Ivan Tyagov

Support up to 4 mod-IOs

parent f4f1f65e
// global relay state - XXX: use a list rather than individual variables // 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_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_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 // the default addresses of MOD-IOs
static char *DEFAULT_I2C_0_ADDR = "0x58"; static char *DEFAULT_I2C_0_ADDR = "0x58";
......
...@@ -117,69 +117,106 @@ static void beforeReadTimeAnalongIn(int addr,uint8_t read_addr, const UA_DataVal ...@@ -117,69 +117,106 @@ static void beforeReadTimeAnalongIn(int addr,uint8_t read_addr, const UA_DataVal
} }
} }
// I2C0
static void beforeReadTimeI2C0Ain0(UA_Server *server, static void beforeReadTimeI2C0Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x30, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x30, data);
}
static void beforeReadTimeI2C0Ain1(UA_Server *server, static void beforeReadTimeI2C0Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x31, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x31, data);
}
static void beforeReadTimeI2C0Ain2(UA_Server *server, static void beforeReadTimeI2C0Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x32, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x32, data);
}
static void beforeReadTimeI2C0Ain3(UA_Server *server, static void beforeReadTimeI2C0Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x33, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[0], 0x33, data);
}
// I2C1
static void beforeReadTimeI2C1Ain0(UA_Server *server, static void beforeReadTimeI2C1Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x30, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x30, data);
}
static void beforeReadTimeI2C1Ain1(UA_Server *server, static void beforeReadTimeI2C1Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x31, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x31, data);
}
static void beforeReadTimeI2C1Ain2(UA_Server *server, static void beforeReadTimeI2C1Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x32, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x32, data);
}
static void beforeReadTimeI2C1Ain3(UA_Server *server, static void beforeReadTimeI2C1Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x33, data);}
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[1], 0x33, data);
} // I2C2
static void beforeReadTimeI2C2Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[2], 0x30, data);}
static void beforeReadTimeI2C2Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[2], 0x31, data);}
static void beforeReadTimeI2C2Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[2], 0x32, data);}
static void beforeReadTimeI2C2Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[2], 0x33, data);}
// I2C3
static void beforeReadTimeI2C3Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[3], 0x30, data);}
static void beforeReadTimeI2C3Ain1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[3], 0x31, data);}
static void beforeReadTimeI2C3Ain2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[3], 0x32, data);}
static void beforeReadTimeI2C3Ain3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[3], 0x33, data);}
// Digital Inputs // Digital Inputs
static void beforeReadTimeDigitalIn(int addr, static void beforeReadTimeDigitalIn(int addr,
...@@ -208,70 +245,107 @@ static void beforeReadTimeDigitalIn(int addr, ...@@ -208,70 +245,107 @@ static void beforeReadTimeDigitalIn(int addr,
} }
} }
// I2C0
static void beforeReadTimeI2C0In0(UA_Server *server, static void beforeReadTimeI2C0In0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 0, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 0, data);
}
static void beforeReadTimeI2C0In1(UA_Server *server, static void beforeReadTimeI2C0In1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 1, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 1, data);
}
static void beforeReadTimeI2C0In2(UA_Server *server, static void beforeReadTimeI2C0In2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 2, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 2, data);
}
static void beforeReadTimeI2C0In3(UA_Server *server, static void beforeReadTimeI2C0In3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 3, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[0], 3, data);
}
// I2C1
static void beforeReadTimeI2C1In0(UA_Server *server, static void beforeReadTimeI2C1In0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 0, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 0, data);
}
static void beforeReadTimeI2C1In1(UA_Server *server, static void beforeReadTimeI2C1In1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 1, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 1, data);
}
static void beforeReadTimeI2C1In2(UA_Server *server, static void beforeReadTimeI2C1In2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 2, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 2, data);
}
static void beforeReadTimeI2C1In3(UA_Server *server, static void beforeReadTimeI2C1In3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext, const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) const UA_NumericRange *range, const UA_DataValue *data){
{ beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 3, data);}
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[1], 3, data);
} // I2C2
static void beforeReadTimeI2C2In0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[2], 0, data);}
static void beforeReadTimeI2C2In1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[2], 1, data);}
static void beforeReadTimeI2C2In2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[2], 2, data);}
static void beforeReadTimeI2C2In3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[2], 3, data);}
// I2C3
static void beforeReadTimeI2C3In0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[3], 0, data);}
static void beforeReadTimeI2C3In1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[3], 1, data);}
static void beforeReadTimeI2C3In2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[3], 2, data);}
static void beforeReadTimeI2C3In3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeid, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeDigitalIn(I2C_SLAVE_ADDR_LIST[3], 3, data);}
// Relays // Relays
static void afterWriteTime(UA_Server *server, static void afterWriteTime(UA_Server *server,
...@@ -310,67 +384,102 @@ static void setI2CSlaveRelayState(int addr, ...@@ -310,67 +384,102 @@ static void setI2CSlaveRelayState(int addr,
static void afterWriteTimeI2C0_0(UA_Server *server, static void afterWriteTimeI2C0_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_0_RELAYS_STATE, data);
}
static void afterWriteTimeI2C0_1(UA_Server *server, static void afterWriteTimeI2C0_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_0_RELAYS_STATE, data);
}
static void afterWriteTimeI2C0_2(UA_Server *server, static void afterWriteTimeI2C0_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_0_RELAYS_STATE, data);
}
static void afterWriteTimeI2C0_3(UA_Server *server, static void afterWriteTimeI2C0_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_0_RELAYS_STATE, data);
}
// I2C1 // I2C1
static void afterWriteTimeI2C1_0(UA_Server *server, static void afterWriteTimeI2C1_0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_1_RELAYS_STATE, data);
}
static void afterWriteTimeI2C1_1(UA_Server *server, static void afterWriteTimeI2C1_1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_1_RELAYS_STATE, data);
}
static void afterWriteTimeI2C1_2(UA_Server *server, static void afterWriteTimeI2C1_2(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_1_RELAYS_STATE, data);
}
static void afterWriteTimeI2C1_3(UA_Server *server, static void afterWriteTimeI2C1_3(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) 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_1_RELAYS_STATE, 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);}
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);}
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);}
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);}
// 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);}
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);}
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);}
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);}
static void addValueCallbackToCurrentTimeVariable(UA_Server *server) static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
{ {
...@@ -378,8 +487,8 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -378,8 +487,8 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
int device_number, offset_number; int device_number, offset_number;
char *node_id = malloc(sizeof(char) * 10); char *node_id = malloc(sizeof(char) * 10);
// list of relays, digital and analog callbacks for all devices (XXX: for now only two, add more!) // list of relays, digital and analog callbacks for all devices (XXX: for now only 4 outof 127 possible!)
static void (*callables[24]) static void (*callables[48])
(UA_Server *server, const UA_NodeId *sessionId, void *sessionContext, (UA_Server *server, const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext, const UA_NumericRange *range, const UA_NodeId *nodeId, void *nodeContext, const UA_NumericRange *range,
const UA_DataValue *data) = {// relays - IC0 const UA_DataValue *data) = {// relays - IC0
...@@ -412,7 +521,40 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -412,7 +521,40 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
beforeReadTimeI2C1Ain0, beforeReadTimeI2C1Ain0,
beforeReadTimeI2C1Ain1, beforeReadTimeI2C1Ain1,
beforeReadTimeI2C1Ain2, beforeReadTimeI2C1Ain2,
beforeReadTimeI2C1Ain3}; beforeReadTimeI2C1Ain3,
// relays - IC2
afterWriteTimeI2C2_0,
afterWriteTimeI2C2_1,
afterWriteTimeI2C2_2,
afterWriteTimeI2C2_3,
// digital - IC2
beforeReadTimeI2C2In0,
beforeReadTimeI2C2In1,
beforeReadTimeI2C2In2,
beforeReadTimeI2C2In3,
// analong - IC2
beforeReadTimeI2C2Ain0,
beforeReadTimeI2C2Ain1,
beforeReadTimeI2C2Ain2,
beforeReadTimeI2C2Ain3,
// relays - IC3
afterWriteTimeI2C3_0,
afterWriteTimeI2C3_1,
afterWriteTimeI2C3_2,
afterWriteTimeI2C3_3,
// digital - IC3
beforeReadTimeI2C3In0,
beforeReadTimeI2C3In1,
beforeReadTimeI2C3In2,
beforeReadTimeI2C3In3,
// analog - IC1
beforeReadTimeI2C3Ain0,
beforeReadTimeI2C3Ain1,
beforeReadTimeI2C3Ain2,
beforeReadTimeI2C3Ain3,
};
// set proper callbacks from list of all // set proper callbacks from list of all
for (device_number = 0; device_number < device_slave_list_length; device_number++){ for (device_number = 0; device_number < device_slave_list_length; device_number++){
......
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