Commit d642c17f authored by Ivan Tyagov's avatar Ivan Tyagov

Remove callbacks.

parent 9cda7eed
...@@ -162,18 +162,6 @@ static void beforeReadTimeI2C0Ain1(UA_Server *server, ...@@ -162,18 +162,6 @@ static void beforeReadTimeI2C0Ain1(UA_Server *server,
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,
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[0], 0x32, data);}
static void beforeReadTimeI2C0Ain3(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[0], 0x33, data);}
// I2C1 // 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,
...@@ -187,18 +175,6 @@ static void beforeReadTimeI2C1Ain1(UA_Server *server, ...@@ -187,18 +175,6 @@ static void beforeReadTimeI2C1Ain1(UA_Server *server,
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,
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[1], 0x32, data);}
static void beforeReadTimeI2C1Ain3(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[1], 0x33, data);}
// I2C2 // I2C2
static void beforeReadTimeI2C2Ain0(UA_Server *server, static void beforeReadTimeI2C2Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
...@@ -212,18 +188,6 @@ static void beforeReadTimeI2C2Ain1(UA_Server *server, ...@@ -212,18 +188,6 @@ static void beforeReadTimeI2C2Ain1(UA_Server *server,
const UA_NumericRange *range, const UA_DataValue *data){ const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[2], 0x31, 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 // I2C3
static void beforeReadTimeI2C3Ain0(UA_Server *server, static void beforeReadTimeI2C3Ain0(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext, const UA_NodeId *sessionId, void *sessionContext,
...@@ -237,18 +201,6 @@ static void beforeReadTimeI2C3Ain1(UA_Server *server, ...@@ -237,18 +201,6 @@ static void beforeReadTimeI2C3Ain1(UA_Server *server,
const UA_NumericRange *range, const UA_DataValue *data){ const UA_NumericRange *range, const UA_DataValue *data){
beforeReadTimeAnalongIn(I2C_SLAVE_ADDR_LIST[3], 0x31, 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,
...@@ -520,7 +472,7 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -520,7 +472,7 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
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 4 out of 127 possible!) // list of relays, digital and analog callbacks for all devices (XXX: for now only 4 out of 127 possible!)
static void (*callables[48]) static void (*callables[40])
(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
...@@ -536,8 +488,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -536,8 +488,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
// analong - IC0 // analong - IC0
beforeReadTimeI2C0Ain0, beforeReadTimeI2C0Ain0,
beforeReadTimeI2C0Ain1, beforeReadTimeI2C0Ain1,
beforeReadTimeI2C0Ain2,
beforeReadTimeI2C0Ain3,
// relays - IC1 // relays - IC1
afterWriteTimeI2C1_0, afterWriteTimeI2C1_0,
...@@ -552,8 +502,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -552,8 +502,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
// analog - IC1 // analog - IC1
beforeReadTimeI2C1Ain0, beforeReadTimeI2C1Ain0,
beforeReadTimeI2C1Ain1, beforeReadTimeI2C1Ain1,
beforeReadTimeI2C1Ain2,
beforeReadTimeI2C1Ain3,
// relays - IC2 // relays - IC2
afterWriteTimeI2C2_0, afterWriteTimeI2C2_0,
...@@ -568,8 +516,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -568,8 +516,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
// analong - IC2 // analong - IC2
beforeReadTimeI2C2Ain0, beforeReadTimeI2C2Ain0,
beforeReadTimeI2C2Ain1, beforeReadTimeI2C2Ain1,
beforeReadTimeI2C2Ain2,
beforeReadTimeI2C2Ain3,
// relays - IC3 // relays - IC3
afterWriteTimeI2C3_0, afterWriteTimeI2C3_0,
...@@ -584,8 +530,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -584,8 +530,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
// analog - IC3 // analog - IC3
beforeReadTimeI2C3Ain0, beforeReadTimeI2C3Ain0,
beforeReadTimeI2C3Ain1, beforeReadTimeI2C3Ain1,
beforeReadTimeI2C3Ain2,
beforeReadTimeI2C3Ain3,
}; };
// set proper callbacks from list of all // set proper callbacks from list of all
...@@ -596,24 +540,26 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) ...@@ -596,24 +540,26 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
UA_NodeId currentNodeId = UA_NODEID_STRING(1, node_id); UA_NodeId currentNodeId = UA_NODEID_STRING(1, node_id);
UA_ValueCallback callback; UA_ValueCallback callback;
callback.onRead = beforeReadTime; callback.onRead = beforeReadTime;
callback.onWrite = callables[device_number * 12 + offset_number]; callback.onWrite = callables[device_number * 10 + offset_number];
UA_Server_setVariableNode_valueCallback(server, currentNodeId, callback); UA_Server_setVariableNode_valueCallback(server, currentNodeId, callback);
// digital inputs // digital inputs
sprintf(node_id, "i2c%d.in%d", device_number, offset_number); sprintf(node_id, "i2c%d.in%d", device_number, offset_number);
UA_NodeId currentNodeId1 = UA_NODEID_STRING(1, node_id); UA_NodeId currentNodeId1 = UA_NODEID_STRING(1, node_id);
UA_ValueCallback callback1; UA_ValueCallback callback1;
callback1.onRead = callables[device_number * 12 + offset_number + 4]; callback1.onRead = callables[device_number * 10 + offset_number + 4];
callback1.onWrite = afterWriteTime; callback1.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId1, callback1); UA_Server_setVariableNode_valueCallback(server, currentNodeId1, callback1);
// analog inputs // analog inputs
sprintf(node_id, "i2c%d.ain%d", device_number, offset_number); if (offset_number < 2) {
UA_NodeId currentNodeId2 = UA_NODEID_STRING(1, node_id); sprintf(node_id, "i2c%d.ain%d", device_number, offset_number);
UA_ValueCallback callback2; UA_NodeId currentNodeId2 = UA_NODEID_STRING(1, node_id);
callback2.onRead = callables[device_number * 12 + offset_number + 8]; UA_ValueCallback callback2;
callback2.onWrite = afterWriteTime; callback2.onRead = callables[device_number * 10 + offset_number + 8];
UA_Server_setVariableNode_valueCallback(server, currentNodeId2, callback2); callback2.onWrite = afterWriteTime;
UA_Server_setVariableNode_valueCallback(server, currentNodeId2, callback2);
}
} }
} }
} }
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