Commit db52601f authored by Balakrishna Balakrishna's avatar Balakrishna Balakrishna

Merge branch 'master' into feature/coupler_opcua_integration

parents 90e5051e 4b21b84c
<?xml version='1.0' encoding='utf-8'?>
<BeremizRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" URI_location="LOCAL://">
<TargetType/>
</BeremizRoot>
<?xml version='1.0' encoding='utf-8'?>
<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="1" Name="opcua_0-coupler1"/>
<?xml version='1.0' encoding='utf-8'?>
<OPCUAClient xmlns:xsd="http://www.w3.org/2001/XMLSchema" Server_URI="opc.tcp://192.168.0.45:4840"/>
input,I2C0 / Relay 0,1,str,i2c0.relay0,Int32,0
input,I2C0 / Relay 1,1,str,i2c0.relay1,Int32,1
input,I2C0 / Relay 2,1,str,i2c0.relay2,Int32,2
input,I2C0 / Relay 3,1,str,i2c0.relay3,Int32,3
input,I2C1 / Relay 0,1,str,i2c1.relay0,Int32,4
input,I2C1 / Relay 1,1,str,i2c1.relay1,Int32,5
input,I2C1 / Relay 2,1,str,i2c1.relay2,Int32,6
input,I2C1 / Relay 3,1,str,i2c1.relay3,Int32,7
output,I2C0 / Relay 0,1,str,i2c0.relay0,Int32,0
output,I2C0 / Relay 1,1,str,i2c0.relay1,Int32,1
output,I2C0 / Relay 2,1,str,i2c0.relay2,Int32,2
output,I2C0 / Relay 3,1,str,i2c0.relay3,Int32,3
output,I2C1 / Relay 0,1,str,i2c1.relay0,Int32,4
output,I2C1 / Relay 1,1,str,i2c1.relay1,Int32,5
output,I2C1 / Relay 2,1,str,i2c1.relay2,Int32,6
output,I2C1 / Relay 3,1,str,i2c1.relay3,Int32,7
<?xml version='1.0' encoding='utf-8'?>
<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="0" Name="opcua_1-coupler0"/>
<?xml version='1.0' encoding='utf-8'?>
<OPCUAClient xmlns:xsd="http://www.w3.org/2001/XMLSchema" Server_URI="opc.tcp://192.168.0.73:4840"/>
input,I2C0 / Relay 0,1,str,i2c0.relay0,Int32,0
input,I2C0 / Relay 1,1,str,i2c0.relay1,Int32,1
input,I2C0 / Relay 2,1,str,i2c0.relay2,Int32,2
input,I2C0 / Relay 3,1,str,i2c0.relay3,Int32,3
input,I2C1 / Relay 0,1,str,i2c1.relay0,Int32,4
input,I2C1 / Relay 1,1,str,i2c1.relay1,Int32,5
input,I2C1 / Relay 2,1,str,i2c1.relay2,Int32,6
input,I2C1 / Relay 3,1,str,i2c1.relay3,Int32,7
output,I2C0 / Relay 0,1,str,i2c0.relay0,Int32,0
output,I2C0 / Relay 1,1,str,i2c0.relay1,Int32,1
output,I2C0 / Relay 2,1,str,i2c0.relay2,Int32,2
output,I2C0 / Relay 3,1,str,i2c0.relay3,Int32,3
output,I2C1 / Relay 0,1,str,i2c1.relay0,Int32,4
output,I2C1 / Relay 1,1,str,i2c1.relay1,Int32,5
output,I2C1 / Relay 2,1,str,i2c1.relay2,Int32,6
output,I2C1 / Relay 3,1,str,i2c1.relay3,Int32,7
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Unknown" productName="Unnamed" productVersion="1" creationDateTime="2021-05-14T14:33:11"/>
<contentHeader name="Counter (OSIE)" modificationDateTime="2022-01-25T16:13:36">
<coordinateInfo>
<fbd>
<scaling x="0" y="0"/>
</fbd>
<ld>
<scaling x="0" y="0"/>
</ld>
<sfc>
<scaling x="0" y="0"/>
</sfc>
</coordinateInfo>
</contentHeader>
<types>
<dataTypes/>
<pous>
<pou name="plc_prg" pouType="program">
<interface>
<localVars>
<variable name="CounterST0">
<type>
<derived name="CounterST"/>
</type>
</variable>
</localVars>
</interface>
<body>
<FBD>
<comment localId="1" height="143" width="201">
<position x="566" y="75"/>
<content>
<xhtml:p><![CDATA[This PLC program is used in automated testing of beremiz' runtime / coupler integration]]></xhtml:p>
</content>
</comment>
<block localId="2" typeName="CounterST" instanceName="CounterST0" executionOrderId="0" height="109" width="99">
<position x="288" y="192"/>
<inputVariables>
<variable formalParameter="Reset">
<connectionPointIn>
<relPosition x="0" y="42"/>
</connectionPointIn>
</variable>
</inputVariables>
<inOutVariables/>
<outputVariables>
<variable formalParameter="Out1">
<connectionPointOut>
<relPosition x="99" y="42"/>
</connectionPointOut>
</variable>
<variable formalParameter="Out0">
<connectionPointOut>
<relPosition x="99" y="86"/>
</connectionPointOut>
</variable>
</outputVariables>
</block>
</FBD>
</body>
</pou>
<pou name="CounterST" pouType="functionBlock">
<interface>
<outputVars>
<variable name="Out0">
<type>
<INT/>
</type>
</variable>
</outputVars>
<localVars>
<variable name="Cnt0">
<type>
<INT/>
</type>
</variable>
</localVars>
<externalVars>
<variable name="Coupler0_Relay0">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler0_Relay1">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler0_Relay2">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler0_Relay3">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler1_Relay0">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler1_Relay1">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler1_Relay2">
<type>
<DINT/>
</type>
</variable>
<variable name="Coupler1_Relay3">
<type>
<DINT/>
</type>
</variable>
</externalVars>
</interface>
<body>
<ST>
<xhtml:p><![CDATA[Cnt0 := Cnt0 + 1;
Coupler0_Relay0 := Coupler0_Relay0 + 1;
Coupler1_Relay0 := Coupler0_Relay0;
Out0 := Cnt0;]]></xhtml:p>
</ST>
</body>
</pou>
</pous>
</types>
<instances>
<configurations>
<configuration name="config">
<resource name="resource1">
<task name="task0" priority="0" interval="T#20ms">
<pouInstance name="instance0" typeName="plc_prg"/>
</task>
</resource>
<globalVars>
<variable name="Coupler0_Relay0" address="%QD1.0">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 0 at coupler 0]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler0_Relay1" address="%QD1.1">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 1 at coupler 0]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler0_Relay2" address="%QD1.2">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 2 at coupler 0]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler0_Relay3" address="%QD1.3">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 3 at coupler 0]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler1_Relay0" address="%QD0.0">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 0 at coupler 1]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler1_Relay1" address="%QD0.1">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 1 at coupler 1]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler1_Relay2" address="%QD0.2">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 2 at coupler 1]]></xhtml:p>
</documentation>
</variable>
<variable name="Coupler1_Relay3" address="%QD0.3">
<type>
<DINT/>
</type>
<initialValue>
<simpleValue value="0"/>
</initialValue>
<documentation>
<xhtml:p><![CDATA[OPC-UA relay 3 at coupler 1]]></xhtml:p>
</documentation>
</variable>
</globalVars>
</configuration>
</configurations>
</instances>
</project>
THis folder contains various CAD files used for 3d printing of the coupler and its MOD-IO enclosure.
\ No newline at end of file
THis folder contains various CAD files used for 3d printing of the coupler (Lime2) and its MOD-IO enclosure.
......@@ -18,4 +18,8 @@ $ cp ~/open62541/build/open62541.* ~/osie/coupler/opc-ua-server/
### Building your OPC UA server (Cross compilation to ARM architecture from Ubuntu)
$ arm-linux-gnueabihf-gcc open62541.c server.c -o server
\ No newline at end of file
$ arm-linux-gnueabihf-gcc open62541.c server.c -o server
### If one wants to run coupler on a x86 platform then one needs to expose in current environment
$ export I2C_VIRTUAL_MODE=1
/*
* Example controling MOD-IO's relays' state over OPC-UA protocol
* OPC-UA server which controls MOD-IO's relays' state over OPC-UA protocol
* Current format of exposed OPC-UA node variables is:
* <mod-io_number>.<relay_number>
* For example:
* i2c0.relay0
* i2c0.relay1
* i2c1.relay0
* Based on
* https://www.kernel.org/doc/Documentation/i2c/dev-interface
* https://github.com/open62541/open62541/blob/master/examples/tutorial_server_variable.c
* https://stackoverflow.com/questions/9642732/parsing-command-line-arguments-in-c
*/
#include <stdio.h>
......@@ -14,17 +21,73 @@
#include <unistd.h>
#include <signal.h>
#include "open62541.h"
#include <argp.h>
// The default port of OPC-UA server
const int DEFAULT_OPC_UA_PORT = 4840;
const int DEFAULT_MODE = 0;
// CLI arguments handling
const char *argp_program_version = "OSIE OPC-UA coupler 0.0.1";
const char *argp_program_bug_address = "ivan@nexedi.com";
static char doc[] = "OPC-UA server which controls MOD-IO's relays' state over OPC-UA protocol.";
static char args_doc[] = "...";
static struct argp_option options[] = {
{ "port", 'p', "4840", 0, "Port to bind to."},
{ "device", 'd', "/dev/i2c-1", 0, "Linux block device path."},
{ "slave-address-list", 's', "0x58", 0, "Comma separated list of slave I2C addresses."},
{ "mode", 'm', "0", 0, "Set different modes of operation of coupler. Default (0) is set attached \
I2C's state state. Virtual (1) which does NOT set any I2C slaves' state."},
{ 0 }
};
struct arguments {
int mode;
int port;
char *device;
char *slave_address_list;
};
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
struct arguments *arguments = state->input;
switch (key) {
case 'p':
arguments->port = arg ? atoi (arg) : DEFAULT_OPC_UA_PORT;
//printf("got arg port=%s\n", arg);
break;
case 'd':
arguments->device = arg;
//printf("got arg device=%s\n", arg);
break;
case 's':
arguments->slave_address_list = arg;
//printf("got arg slave_address_list=%s\n", arg);
break;
case 'm':
arguments->mode = arg ? atoi (arg) : DEFAULT_MODE;
break;
case ARGP_KEY_ARG:
return 0;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 };
// global relay state
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
// XXX: what if we have more than 2 MOd-IOs / I2C slaves, we need better structure
// the default addresses of MOD-IOs
const int DEFAULT_I2C_0_ADDR = 0x58;
static char *DEFAULT_I2C_0_ADDR = "0x58";
// the list of attached I2C slaves
const int DEFAULT_I2C_SLAVE_ADDR = 0x58;
int I2C_SLAVE_ADDR_LIST[] = {0, 0, 0, 0, 0}; // XXX: make dynamic array
// XXX: make dynamic array
int I2C_SLAVE_ADDR_LIST[] = {0, 0, 0, 0, 0};
// the block device at host machine
static char *DEFAULT_I2C_BLOCK_DEVICE_NAME = "/dev/i2c-1";
......@@ -33,6 +96,25 @@ char *I2C_BLOCK_DEVICE_NAME;
// global virtual mode needed for testing on x86 platform
bool I2C_VIRTUAL_MODE = 0;
static int getI2CSlaveListLength() {
/*
* Return ONLY registred I2C slaves
*/
int i;
int addr;
int counter = 0;
int length = sizeof(I2C_SLAVE_ADDR_LIST) / sizeof(int);
for(i = 0; i < length; i++)
{
addr = I2C_SLAVE_ADDR_LIST[i];
if (addr!= 0) {
counter++;
}
}
return counter;
}
static int setRelayState(int command, int i2c_addr) {
/*
* Set relays' state over I2C
......@@ -97,7 +179,7 @@ static void addVariable(UA_Server *server) {
/*
* Create all variables representing MOD-IO's relays
*/
int length = sizeof(I2C_SLAVE_ADDR_LIST) / sizeof(int);
int length = getI2CSlaveListLength();
if (length>=1) {
// IC2-0
addIntegerVariableNode(server, "i2c0.relay0", "I2C0 / Relay 0");
......@@ -272,7 +354,9 @@ static void afterWriteTimeI2C1_3(UA_Server *server,
}
}
static void addValueCallbackToCurrentTimeVariable(UA_Server *server) {
int length = getI2CSlaveListLength();
// I2C0
// relay 0
UA_NodeId currentNodeId0 = UA_NODEID_STRING(1, "i2c0.relay0");
......@@ -302,34 +386,36 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) {
callback3.onWrite = afterWriteTimeI2C0_3;
UA_Server_setVariableNode_valueCallback(server, currentNodeId3, callback3);
// I2C1
// relay 0
UA_NodeId currentNodeId4 = UA_NODEID_STRING(1, "i2c1.relay0");
UA_ValueCallback callback4;
callback4.onRead = beforeReadTime;
callback4.onWrite = afterWriteTimeI2C1_0;
UA_Server_setVariableNode_valueCallback(server, currentNodeId4, callback4);
if(length > 1){
// I2C1
// relay 0
UA_NodeId currentNodeId4 = UA_NODEID_STRING(1, "i2c1.relay0");
UA_ValueCallback callback4;
callback4.onRead = beforeReadTime;
callback4.onWrite = afterWriteTimeI2C1_0;
UA_Server_setVariableNode_valueCallback(server, currentNodeId4, callback4);
// relay 1
UA_NodeId currentNodeId5 = UA_NODEID_STRING(1, "i2c1.relay1");
UA_ValueCallback callback5;
callback5.onRead = beforeReadTime;
callback5.onWrite = afterWriteTimeI2C1_1;
UA_Server_setVariableNode_valueCallback(server, currentNodeId5, callback5);
// relay 1
UA_NodeId currentNodeId5 = UA_NODEID_STRING(1, "i2c1.relay1");
UA_ValueCallback callback5;
callback5.onRead = beforeReadTime;
callback5.onWrite = afterWriteTimeI2C1_1;
UA_Server_setVariableNode_valueCallback(server, currentNodeId5, callback5);
// relay 2
UA_NodeId currentNodeId6 = UA_NODEID_STRING(1, "i2c1.relay2");
UA_ValueCallback callback6;
callback6.onRead = beforeReadTime;
callback6.onWrite = afterWriteTimeI2C1_2;
UA_Server_setVariableNode_valueCallback(server, currentNodeId6, callback6);
// relay 2
UA_NodeId currentNodeId6 = UA_NODEID_STRING(1, "i2c1.relay2");
UA_ValueCallback callback6;
callback6.onRead = beforeReadTime;
callback6.onWrite = afterWriteTimeI2C1_2;
UA_Server_setVariableNode_valueCallback(server, currentNodeId6, callback6);
// relay 2
UA_NodeId currentNodeId7 = UA_NODEID_STRING(1, "i2c1.relay3");
UA_ValueCallback callback7;
callback7.onRead = beforeReadTime;
callback7.onWrite = afterWriteTimeI2C1_3;
UA_Server_setVariableNode_valueCallback(server, currentNodeId7, callback7);
// relay 2
UA_NodeId currentNodeId7 = UA_NODEID_STRING(1, "i2c1.relay3");
UA_ValueCallback callback7;
callback7.onRead = beforeReadTime;
callback7.onWrite = afterWriteTimeI2C1_3;
UA_Server_setVariableNode_valueCallback(server, currentNodeId7, callback7);
}
}
......@@ -365,43 +451,32 @@ int main(int argc, char **argv) {
long result;
char *eptr;
// read environment to see if we run daemon in real or virtual mode (usable for testing on x86)
const char* s = getenv("I2C_VIRTUAL_MODE");
if(s!=NULL){
I2C_VIRTUAL_MODE = atoi(s);
}
printf("I2C_VIRTUAL_MODE=%d\n", I2C_VIRTUAL_MODE);
// handle comand line arguments
if (argc == 1) {
// no paramaters at all
I2C_BLOCK_DEVICE_NAME = DEFAULT_I2C_BLOCK_DEVICE_NAME;
I2C_SLAVE_ADDR_LIST[0] = DEFAULT_I2C_0_ADDR;
}
if (argc == 2) {
// only block device specified
I2C_BLOCK_DEVICE_NAME = argv[1];
I2C_SLAVE_ADDR_LIST[0] = DEFAULT_I2C_0_ADDR;
// handle command line arguments
struct arguments arguments;
arguments.port = DEFAULT_OPC_UA_PORT;
arguments.mode = DEFAULT_MODE;
arguments.device = DEFAULT_I2C_BLOCK_DEVICE_NAME;
arguments.slave_address_list = DEFAULT_I2C_0_ADDR;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
printf("Mode=%d\n", arguments.mode);
printf("Listening port=%d\n", arguments.port);
printf("Block device=%s\n", arguments.device);
printf("Slave address list=%s\n", arguments.slave_address_list);
// transfer to global variables (CLI input)
I2C_VIRTUAL_MODE = arguments.mode;
I2C_BLOCK_DEVICE_NAME = arguments.device;
// convert arguments.slave_address_list -> I2C_SLAVE_ADDR_LIST
i = 0;
char *token = strtok(arguments.slave_address_list, ",");
while (token != NULL)
{
// from CLI we get a hexidecimal string as a char (0x58 for example), convert to decimal
result = strtol(token, &eptr, 16);
I2C_SLAVE_ADDR_LIST[i++] = result;
token = strtok (NULL, ",");
}
if (argc > 2) {
// both block device and I2C slave(s) specified
I2C_BLOCK_DEVICE_NAME = argv[1];
for(i=2; i < argc; i++){
// from CLI we get a hexidecimal string as a char (0x58 for example), convert to decimal
result = strtol(argv[i], &eptr, 16);
I2C_SLAVE_ADDR_LIST[i - 2] = result;
}
}
// debug info
printf("Block device=%s\n", I2C_BLOCK_DEVICE_NAME);
length = sizeof(I2C_SLAVE_ADDR_LIST) / sizeof(int);
for(i=0; i < length; i++){
if (I2C_SLAVE_ADDR_LIST[i] !=0) {
printf("I2C_slave=0x%x\n", I2C_SLAVE_ADDR_LIST[i]);
}
}
// always start attached slaves from a know safe shutdown state
safeShutdownI2CSlaveList();
......@@ -410,7 +485,7 @@ int main(int argc, char **argv) {
signal(SIGTERM, stopHandler);
UA_Server *server = UA_Server_new();
UA_ServerConfig_setDefault(UA_Server_getConfig(server));
UA_ServerConfig_setMinimal(UA_Server_getConfig(server), arguments.port, NULL);
UA_ServerConfig* config = UA_Server_getConfig(server);
config->verifyRequestTimestamp = UA_RULEHANDLING_ACCEPT;
......
......@@ -3,7 +3,7 @@ filename = instance-modbus.cfg.in
md5sum = 8637c6b714a0bb9f27c86f3928049b98
filename = instance-opc-ua.cfg.in
md5sum = b4e97874308a5e402753fc3140d5b6d6
md5sum = b6cf47dc85a0c1086cca5e3edcf969ab
filename = instance-opc-ua-x86.cfg.in
md5sum = a09e257f916683653b61483230034560
filename = instance-opc-ua-virtual.cfg.in
md5sum = 49f84a499d258771651983dec90e98c1
......@@ -20,10 +20,8 @@ extends = {{ template_monitor }}
[coupler-opc-ua]
recipe = slapos.cookbook:wrapper
# start with defaults
environment =
I2C_VIRTUAL_MODE=1
command-line =
{{ buildout['bin-directory'] }}/server ${instance-parameter:configuration.coupler_block_device} ${instance-parameter:configuration.coupler_i2c_slave_list}
{{ buildout['bin-directory'] }}/server -d ${instance-parameter:configuration.coupler_block_device} -s ${instance-parameter:configuration.coupler_i2c_slave_list} -m 1 -p ${instance-parameter:configuration.opc_ua_port}
wrapper-path = ${directory:service}/coupler-opc-ua-virtual
......@@ -42,8 +40,8 @@ url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
configuration.coupler_block_device =
configuration.coupler_i2c_slave_list =
configuration.coupler_block_device = /dev/i2c-1
configuration.coupler_i2c_slave_list = 0x58
# Define default parameter(s) that will be used later, in case user didn't
# specify it.
......
......@@ -21,7 +21,7 @@ extends = {{ template_monitor }}
recipe = slapos.cookbook:wrapper
# start with defaults
command-line =
{{ buildout['bin-directory'] }}/server ${instance-parameter:configuration.coupler_block_device} ${instance-parameter:configuration.coupler_i2c_slave_list}
{{ buildout['bin-directory'] }}/server -d ${instance-parameter:configuration.coupler_block_device} -s ${instance-parameter:configuration.coupler_i2c_slave_list} -p ${instance-parameter:configuration.opc_ua_port}
wrapper-path = ${directory:service}/coupler-opc-ua
......@@ -40,8 +40,8 @@ url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
configuration.coupler_block_device =
configuration.coupler_i2c_slave_list =
configuration.coupler_block_device = /dev/i2c-1
configuration.coupler_i2c_slave_list = 0x58
# Define default parameter(s) that will be used later, in case user didn't
# specify it.
......
......@@ -19,7 +19,7 @@ configure-command =
# XXX: add own instance which is able to expose an environmental variable (I2C_VIRTUAL_MODE=1)
[instance-profile]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance-opc-ua-x86.cfg.in
template = ${:_profile_base_location_}/instance-opc-ua-virtual.cfg.in
mode = 0644
rendered = ${buildout:directory}/instance.cfg
extensions = jinja2.ext.do
......
......@@ -19,8 +19,7 @@ parts =
index = https://pypi.python.org/simple/
[sources]
beremiz = hg https://hg.beremiz.org/beremiz/
beremiz = git https://github.com/beremiz/beremiz.git branch=default
[beremiz]
recipe = zc.recipe.egg:develop
......
#!/bin/bash
# manually run inside osie_plx_env
#source osie_plc_env/bin/activate
# start modbus server
python3 eggs/osie_plc/osie_plc.py &
# start OCR which will control machine over modbus
cd eggs/osie_plc
python2 osie_ocr.py
......@@ -8,16 +8,15 @@ import argparse
import configparser
def main():
# handle CLI arguments
parser = argparse.ArgumentParser()
parser.add_argument('--iterations', \
type = int, \
default = 10, \
default = 100, \
help='number of iterations to check')
parser.add_argument('--timeout', \
type = int, \
default = 5, \
default = 2, \
help='seconds to wait between checks')
parser.add_argument('--opc-ua-server', \
type = str, \
......@@ -34,10 +33,13 @@ def main():
OPC_UA_ADDRESS = args.opc_ua_server
OPC_UA_IDENTIFIER = args.opc_ua_node_identifier
# connect to a session at OPC-UA server
client = Client(OPC_UA_ADDRESS)
# for now this is the only test thus we start it without a wrapper
test_count = 1
test_failures = 0
expected_failures = 0
try:
client.connect()
......@@ -54,10 +56,15 @@ def main():
i2c0_relay0_after = var.get_value()
print("i2c0_relay0 (after) = ", i2c0_relay0_after)
# for the wait timeout runtime should have increased the value
assert i2c0_relay0_after > i2c0_relay0_before
if (i2c0_relay0_after <= i2c0_relay0_before):
# counter should have been increased, mark failure
test_failures += 1
finally:
client.disconnect()
# print out to sdtout results
print("Integration Tests %d Tests, %d Failures, %d Expected failures" \
%(test_count, test_failures, expected_failures))
if __name__ == "__main__":
main()
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