Configuration file of OPCUaCanOpenServer bases on xml syntax.
The name OPC is OPCUACANopenServer.xml and by default it is the same directory.
The general structure is:
<!--?xml version="1.0" encoding="UTF-8" ?--> <CanOpenOpcServerConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation="./CANOpenServerConfig.xsd"> <CanOpenOpcServerConfig> <NODETYPE name= name>" ... </NODETYPE> ... <NODETYPE name= name> ... </NODETYPE> <CANBUS parameters> ... </CANBUS> ... <CANBUS parameters> ... </CANBUS> <REGEXPR parameters> </REGEXPR> ... <REGEXPR parameters> </REGEXPR> <ITEM parameters> </ITEM> ... <ITEM parameters> </ITEM> <SETTINGS parameters> </SETTINGS> </CanOpenOpcServerConfig>
The top level tag CanOpwOpcServerConfig has two parameters. The first xmlns:xsi points out that the XML schema describes in the http://www.w3.org/2001/XMLSchema-instance. The second parameter is more important. It tells where the XSD file used by parser of OpcUa server is. It can be a URL or a file path.
The top tag can have several main type of elements: NODETYPE ,CANBUS, REGEXPR,ITEM, SETTINGS.
CANBUS
This is a typical can bus description.
<CANBUS speed="125000" port="can0" type="sock" name="Bus_1">
It has to have the bus name, bus speed and two parameters describe an interface. For Linux the value of type parameter can be only sock value for socketcan interface. For windows the value can be st systec,pk- peak, kv- kvaser. The port can be can0 .. canN. Inside the can bus tag it is possible to include two additional tag.
<NODEGUARD interval="60000"/> <SYNC interval="0"/>
It defines the value of node guarding interval and sync interval. If it is absent it means the system does not use them.
The NODETYPE has only one parameter name and inside all object and item describing further in section NODE can be included beside PDO TAG. Cobid of PDO object is unique for canbus and therefore it cannot be used inside the type. Inside NODETYPE the tags RPDO1,2,3,4 , TPDO1,2,3,4 and NPDO can be used. The parameter cobid od these tags is a basic cobid according of the ELMB specification. The real cobid will be calculated by server (cobid = basic cobid + node id).
<NODETYPE name= name> ...... </NODETYPE>
NODE
There are two forms of describing of can node. The first one includes the parameters type. The value of this parameters is a name on NODETYPE and all children of NODETYPE will be included in this node.
<NODE type="ELMB" name="ELMB_11" nodeid="11"/>
name type the name of NODETYPE nodeid node identification number in decimal
In the next form all children must be described explicitly.
<NODE name="ELMB_20" nodeid="20"> ... </NODE>
Inside this tag it is necessary to write which type of canopen object and item using in the system.
SDO, SDOITEM, PDO tags can be including into NODE.
SDO massage description includes name and index parameters. Inside SDO tags It is necessary to write sdo item tags.
<SDO index="100A" name="elmbSw" > <SDOITEM subindex="0" access="R" type="UInt32" name="swVersion" /> <SDOITEM subindex="1" access="R" type="UInt32" name="swMinorVersion"/> </SDO>
Parameters of SDOITEM:
SDOITEM Sdo item can be announced also on the node level but in this case it has an additional parameter index also in hexadecimal form.
<SDOITEM subindex="0" access="R" type="byte" index="1001" name="NodeError" />
The basic form of PDO description is:
<PDO access="R" name="RD" cobid="202" > <PDOITEM type="byte" name="v1" byteindex="0" /> <PDOITEM type="UInt32" name="v2" byteindex="1" /> </PDO>
Parameters of PDO:
The PDO must have at least one PDO item which has following parameters:
The type also can be bit in this case the form of the PDOITEM tag is:
<PDOITEM type="bit" bit = 1 name="v2" byteindex="1" /> The bit parameter is a number of a bit in byte.
The next form of PDO is to define of ELMB feature many channels PDO. There is additional parameter "numch" which tell how many channel using in this ELMB . In this case it is forbidden to use 0 byteindex parameter because the 0 byte in can massages is used as byte selector.
<PDO access="R" numch="64" name="TPDO3" cobid="3A0" > <PDOITEM type="byte" name="Flag" byteindex="1" /> <PDOITEM type="UInt32" name="Value" byteindex="2" /> </PDO>
Also there several special tag for pdo description. TPDO1, TPDO2,TPDO3,TPDO4 RPDO1, RPDO2,RPDO3,RPDO4 The cobid parameter is fixed for these tags. And it means the basic cobid according the ELMB specification. The real cobid will be calculated by server adding the node id.
Also NPDO tag can be used instead of PDO. The cobid parameters means can be changed but it means also the basic cobid and real cobid will be calculated late by server.
ITEM tag uses to define the item which calculated from readout value when it is reading. ITEM tags can be used on global ,CANBUS and NODE level. It has two parameters:
The formula syntax contains from normal mathematical constant, operation and function. Operands must be an address in address space.
<NODE name="node_2" nodeid="2" type ="ELMB"> <ITEM name="temp1" value="1/(9.577e-4+2.404e-4*log(TPDO3.Value40/(2.5-1.e-6*TPDO3.Value40))+2.341e-7*pow(log(TPDO3.Value40/(2.5-1.e-6*TPDO3.Value40)),3))-273.15"/> <ITEM name="temp2" value="1/(9.577e-4+2.404e-4*log(TPDO3.Value41/(2.5-1.e-6*TPDO3.Value41))+2.341e-7*pow(log(TPDO3.Value41/(2.5-1.e-6*TPDO3.Value41)),3))-273.15"/> </NODE>
In order to define several items using one formula first it is necessary to define the regular expression which uses to find all items in current scope. Then use this regular expression name in formula. During creation of address space the array of items create in form for each operand
<NODE name="node_19" type="ELMB" nodeid="19"> <REGEXPR name="$ro" value="TPDO3\.Value_[0-9]{1,2}"/> <ITEM name="temp" value="1/(9.577e-4+2.404e-4*log($ro/(2.5-1.e-6*$ro))+2.341e-7*pow(log($ro/(2.5-1.e-6*$ro)),3))-273.15"/> </NODE>
There are two tag which describe the behavior of server at startup time. The tag SET is to initialize variables.
The tag atStartup is to execute methods The syntax of SET tag is:
<SET variable="TraceLevel" value="255"/>The OpcUaCanOpenServer has several methods for buses and nodes:
"atStartup" tag allow to execute the methods at startup time for example:
<atStartup command="Start"/>or
<atStartup command="Bus.ELMB_1.Start"/>
This tag can have three attributes <SETTINGS NGcounter = "3" TypeConversion = "true" InitTimeout = "10" /> </verbatim>
All if attributes are optional. The default value are shown on the example.
The server will repeat sending nodeGuarding message if it has not detected the answer. The NGconter attribute defines this number. If an answer does not come the server sets the state of node to "disconnected".
The server try to convert server data type to client data type and vesa verso. if it is needed to disabled this options "TypeConversion " should be false.
When the server starts it send nmt or RTR message if it was defined in NODE or CANBUS section. In order to receive all data from CANBUS the server waits 10 sec before allowing clients to connect. If necessary the default value can be changed using "InitTimeout" attribute.
the OpcUaCanOpenServer address space have the "TraceLevel" item. This Item defines what kind of CANOpen message will be store.
In order to start store the following value can be written in this item:
This is bit code it mains that in case value = 3 the Pdo And Sdo message will be put in log file
<NODETYPE name="ELMB" > <!--ELMB configuration--> <SDOITEM subindex="0" access="R" type="byte" index="1001" name="NodeError" /> <SDOITEM subindex="0" access="R" type="UInt32" index="1009" name="hwVersion" /> <SDO index="100A" name="elmbSw" > <SDOITEM subindex="0" access="R" type="UInt32" name="swVersion" /> <SDOITEM subindex="1" access="R" type="UInt32" name="swMinorVersion" /> </SDO> <SDOITEM subindex="0" access="R" type="UInt16" index="100C" name="guardTime" /> <SDOITEM subindex="0" access="RW" type="byte" index="100D" name="lifeTime" /> <SDOITEM subindex="0" access="RW" type="UInt32" index="3100" name="serialNumber" /> <SDO index="1010" name="storeParams"> <SDOITEM subindex="1" access="RW" type="UInt32" name="save"/> </SDO> <SDO index="1011" name="RestoreParams"> <SDOITEM subindex="1" access="RW" type="UInt32" name="Load"/> </SDO> <!--ADC configuration--> <SDO index="2100" name="aiConfig" > <SDOITEM subindex="1" access="RW" type="byte" name="channelMax" /> <SDOITEM subindex="2" access="RW" type="byte" name="rate" /> <SDOITEM subindex="3" access="RW" type="byte" name="range" /> <SDOITEM subindex="4" access="RW" type="byte" name="mode" /> </SDO> <SDO index="1802" name="aiTransmit" > <SDOITEM subindex="2" access="RW" type="byte" name="aiTransmissionType" /> <SDOITEM subindex="5" access="RW" type="UInt16" name="aiEventTimer" /> </SDO> <!--Digital Outputs configuration--> <SDOITEM subindex="0" access="RW" type="byte" index="2300" name="doInitHigh" /> <!--Digital Inputs configuration--> <SDO index="1800" name="diTransmit"> <SDOITEM subindex="2" access="RW" type="byte" name="diTransmissionType" /> <SDOITEM subindex="5" access="RW" type="UInt16" name="diEventTimer" /> </SDO> <SDO index="6006" name="diInterrupt" > <SDOITEM subindex="1" access="RW" type="byte" name="diInterruptMaskF" /> <SDOITEM subindex="2" access="RW" type="byte" name="diInterruptMaskA" /> </SDO> <SDO index="6208" name="dioPortA" > <SDOITEM subindex="2" access="RW" type="byte" name="dioOutputMaskA" /> </SDO> <SDOITEM subindex="0" access="RW" type="bit" index="6005" name="diGlobalInterruptEnable" /> <SDOITEM subindex="0" access="RW" type="byte" index="2200" name="diDebounceTimer" /> <TPDO1 access="R" name="TPDO1" cobid="180" ><div id="_mcePaste"> <PDOITEM bit="0" type="bit" name="di_F_0" byteindex="0" /> <PDOITEM bit="1" type="bit" name="di_F_1" byteindex="0" /> <PDOITEM bit="2" type="bit" name="di_F_2" byteindex="0" /> <PDOITEM bit="3" type="bit" name="di_F_3" byteindex="0" /> <PDOITEM bit="4" type="bit" name="di_F_4" byteindex="0" /> <PDOITEM bit="5" type="bit" name="di_F_5" byteindex="0" /> <PDOITEM bit="6" type="bit" name="di_F_6" byteindex="0" /> <PDOITEM bit="7" type="bit" name="di_F_7" byteindex="0" /> <PDOITEM bit="0" type="bit" name="di_A_0" byteindex="1" /> <PDOITEM bit="1" type="bit" name="di_A_1" byteindex="1" /> <PDOITEM bit="2" type="bit" name="di_A_2" byteindex="1" /> <PDOITEM bit="3" type="bit" name="di_A_3" byteindex="1" /> <PDOITEM bit="4" type="bit" name="di_A_4" byteindex="1" /> <PDOITEM bit="5" type="bit" name="di_A_5" byteindex="1" /> <PDOITEM bit="6" type="bit" name="di_A_6" byteindex="1" /> <PDOITEM bit="7" type="bit" name="di_A_7" byteindex="1" /> </TPDO1> <SDO index="6200" name="do_read" > <SDOITEM subindex="1" access="R" type="byte" name="do_C_read" /> <SDOITEM subindex="2" access="R" type="byte" name="do_A_read" /> </SDO> <RPDO1 access="W" name="RPDO1" cobid="200" > <PDOITEM type="byte" name="do_write" byteindex="0" /> </RPDO1> <TPDO3 access="R" numch="64" name="TPDO3" cobid="380" > <PDOITEM type="byte" name="Flag" byteindex="1" /> <PDOITEM type="UInt32" name="Value" byteindex="2" /> </TPDO3> </NODETYPE>
<!--?xml version="1.0" encoding="UTF-8" ?--> <!--ELMB OPC UA configuration file--> <!--Generated for system ATLCICSDX1: at 2013.02.22 17:19:31.921--> !DOCTYPE CanOpenOpcServerConfig [ <!--ENTITY ELMB SYSTEM "OPCUA_nodeType_ELMB.xml"--> ] <CanOpenOpcServerConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Configuration/CANOpenServerConfig.xsd"> &ELMB; <!--Definition of type ELMB--> <CANBUS speed="125000" port="8" type="st" name="Bus_1"> <NODEGUARD interval="10000"/> <SYNC interval="60000"/> <NODE type="ELMB" name="ELMB_20" nodeid="20"/> <NODE type="ELMB" name="ELMB_23" nodeid="23"/> <NODE type="ELMB" name="ELMB_26" nodeid="26"/> <NODE type="ELMB" name="ELMB_27" nodeid="27"/> <NODE type="ELMB" name="ELMB_32" nodeid="32"/> <NODE type="ELMB" name="ELMB_33" nodeid="33"/> <NODE type="ELMB" name="ELMB_36" nodeid="34"/> </CANBUS> <CANBUS speed="125000" port="9" type="st" name="Bus_2"> <NODEGUARD interval="10000"/> <SYNC interval="60000"/> <NODE type="ELMB" name="ELMB_20" nodeid="20"/> <NODE type="ELMB" name="ELMB_23" nodeid="23"/> <NODE type="ELMB" name="ELMB_26" nodeid="26"/> <NODE type="ELMB" name="ELMB_27" nodeid="27"/> <NODE type="ELMB" name="ELMB_32" nodeid="32"/> <NODE type="ELMB" name="ELMB_33" nodeid="33"/> <NODE type="ELMB" name="ELMB_36" nodeid="34"/> </CANBUS> <CANBUS speed="125000" port="10" type="st" name="Bus_3"> <NODEGUARD interval="60000"/> <SYNC interval="0"/> <NODE type="ELMB" name="ELMB_1" nodeid="1"/> <NODE type="ELMB" name="ELMB_2" nodeid="3"/> <NODE type="ELMB" name="ELMB_3" nodeid="4"/> <NODE type="ELMB" name="ELMB_4" nodeid="5"/> <NODE type="ELMB" name="ELMB_5" nodeid="6"/> <NODE type="ELMB" name="ELMB_6" nodeid="7"/> <NODE type="ELMB" name="ELMB_7" nodeid="8"/> <NODE type="ELMB" name="ELMB_11" nodeid="11"/> <NODE type="ELMB" name="ELMB_13" nodeid="13"/> <NODE type="ELMB" name="ELMB_14" nodeid="14"/> <NODE type="ELMB" name="ELMB_15" nodeid="15"/> <NODE type="ELMB" name="ELMB_17" nodeid="17"/> <NODE type="ELMB" name="ELMB_18" nodeid="18"/> <NODE type="ELMB" name="ELMB_19" nodeid="19"/> </CANBUS> </CanOpenOpcServerConfig>
-- Main.vfilimon - 2013-06-13