Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
osie
Commits
56dd3ffd
Commit
56dd3ffd
authored
Apr 24, 2024
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support the maximal amount of Analon Ins (2).
parent
cc96c967
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
71 deletions
+19
-71
coupler/mod_io_opc_ua.h
coupler/mod_io_opc_ua.h
+19
-71
No files found.
coupler/mod_io_opc_ua.h
View file @
56dd3ffd
...
@@ -113,10 +113,12 @@ static void addVariable(UA_Server *server)
...
@@ -113,10 +113,12 @@ static void addVariable(UA_Server *server)
sprintf
(
node_id
,
"i2c%d.in%d"
,
i
,
n
);
sprintf
(
node_id
,
"i2c%d.in%d"
,
i
,
n
);
sprintf
(
node_title
,
"I2C%d / Digital Input %d"
,
i
,
n
);
sprintf
(
node_title
,
"I2C%d / Digital Input %d"
,
i
,
n
);
addBooleanVariableReadNode
(
server
,
node_id
,
node_title
);
addBooleanVariableReadNode
(
server
,
node_id
,
node_title
);
// add analog in
// add analog in (board has only 2 thus do not all all)
sprintf
(
node_id
,
"i2c%d.ain%d"
,
i
,
n
);
if
(
n
<
2
)
{
sprintf
(
node_title
,
"I2C%d / Analog Input %d"
,
i
,
n
);
sprintf
(
node_id
,
"i2c%d.ain%d"
,
i
,
n
);
addUIntegerVariableReadNode
(
server
,
node_id
,
node_title
);
sprintf
(
node_title
,
"I2C%d / Analog Input %d"
,
i
,
n
);
addUIntegerVariableReadNode
(
server
,
node_id
,
node_title
);
}
}
}
}
}
}
}
...
@@ -160,18 +162,6 @@ static void beforeReadTimeI2C0Ain1(UA_Server *server,
...
@@ -160,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
,
...
@@ -185,18 +175,6 @@ static void beforeReadTimeI2C1Ain1(UA_Server *server,
...
@@ -185,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
,
...
@@ -210,18 +188,6 @@ static void beforeReadTimeI2C2Ain1(UA_Server *server,
...
@@ -210,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
,
...
@@ -235,18 +201,6 @@ static void beforeReadTimeI2C3Ain1(UA_Server *server,
...
@@ -235,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
,
...
@@ -517,8 +471,8 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -517,8 +471,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 4 outof 127 possible!)
// list of relays, digital and analog callbacks for all devices (XXX: for now only 4 out
of 127 possible!)
static
void
(
*
callables
[
4
8
])
static
void
(
*
callables
[
4
0
])
(
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
...
@@ -534,8 +488,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -534,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
,
...
@@ -550,8 +502,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -550,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
,
...
@@ -566,8 +516,6 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -566,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
,
...
@@ -579,11 +527,9 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -579,11 +527,9 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
beforeReadTimeI2C3In1
,
beforeReadTimeI2C3In1
,
beforeReadTimeI2C3In2
,
beforeReadTimeI2C3In2
,
beforeReadTimeI2C3In3
,
beforeReadTimeI2C3In3
,
// analog - IC
1
// analog - IC
3
beforeReadTimeI2C3Ain0
,
beforeReadTimeI2C3Ain0
,
beforeReadTimeI2C3Ain1
,
beforeReadTimeI2C3Ain1
,
beforeReadTimeI2C3Ain2
,
beforeReadTimeI2C3Ain3
,
};
};
// set proper callbacks from list of all
// set proper callbacks from list of all
...
@@ -594,24 +540,26 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server)
...
@@ -594,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
*
1
2
+
offset_number
];
callback
.
onWrite
=
callables
[
device_number
*
1
0
+
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
*
1
2
+
offset_number
+
4
];
callback1
.
onRead
=
callables
[
device_number
*
1
0
+
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
);
}
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment