Domatica Quantum System

1.Domatica Quantum Node Configuration

Share
Was this helpful? Yes No Suggest edit

1.1.Configuration Tool

The Configuration Tool is a software that allows you to easily and quickly configure the Domatica Quantum System (DQS) devices. It has a builtin device library that is constantly increasing, that allows you to use a large number of sensors, actuators, meters, protocols, etc, with Domatica Quantum System.

You can Download this tool from here.

Share
Was this helpful? Yes No Suggest edit

1.1.1.Create a Workspace

A “Branch”, like in a tree, is one part of you project, that must have, at least, one Quantum Node, but can have several Quantum Nodes, when these are connected using DomatiCAN Bus.

To create a new Branch, open your Domatica Tool and create a new Branch, using the “Add” button above the “Branch” area.

Then, name the Branch and add the modules for this Branch by clicking the “Add” button and inserting the Quantum Node serial number.

TOOL_CREATE_WORKSPACE

Click “OK” twice and you have created your Branch.

Share
Was this helpful? Yes No Suggest edit

1.1.2.Network Configuration

You can change all network configurations in your Quantum Node like DHCP, IP Address, Netmask, Default Gateway, Server IP Address, ports, etc.

To do that, edit your Branch by clicking twice in the branch or selecting the branch and clicking the “Edit” button (Pencil). Then, to edit, Select Quantum Node serial number and click the “Edit” button (Pencil).

NETWORK CONFIGURATIONS

Click on “Discover” button to find your Quantum Node and its network configurations. When the Quantum Node is found, the fields will be completed automatically. Now you can change all the settings and to save them to the Quantum Node, click “Set” button. Click “OK” to exit the Network Configurations.

GPRS Communications

In this window you can also change the GPRS settings, when available in your hardware.

To do that, activate GPRS communications by selecting the GPRS box and insert the APN , User and Password. You can get this information from your Service Provider or by searching the web for the APN list. (Example: http://www.hw-group.com/products/HWg-Ares/HWg-Ares_GSM_APN_en.html).

IMPORTANT:

FOR THE GPRS SETTINGS TO TAKE ACTION YOU HAVE TO DEPLOY ALL THE CONFIGURATION AND REBOOT THE QUANTUM NODE.

Share
Was this helpful? Yes No Suggest edit

1.1.3.Adding Devices

Share
Was this helpful? Yes No Suggest edit

1.1.3.1.Add Modbus Devices

Select the Branch you want to configure and add a new device by clicking the “Add” button on the right side of the Tool.

Then, select the Modbus device you want to add and and click “Add” button.

TOOL_ADD_MODBUS_DEVICE

In the next window, name the Modbus Device and check the Modbus settings. These must coincide with the settings in the Modbus equipment.

TOOL_MODBUS_DEVICE_SETTINGS

If you are using a Modbus TCP/IP equipment, change the communication channel to TCP and check the TCP settings.

TOOL_MODBUS_TCP_DEVICE_SETTINGS

Enable or disable the registers on the list, by clicking the “Enable” checkbox.

TOOL_MODBUS_REGISTER_LIST

Click “Ok” and you have created your Modbus device.

Share
Was this helpful? Yes No Suggest edit

1.1.3.2.Add KNX Systems

With the Configuration Tool, you will be able to control and monitor KNX Systems using Quantum Node, by adding them to the Configuration Tool. This is made based on ETS configuration files .esf and .knxproj.

First you must choose the “KNX Hints File” language. This file will help to assign the functions to the group addresses. You must choose the language in wich the ETS programming was made.

tool_knx_hints_language

Go to Settings tab, “KNX Hints File” and chose a language from the list. This language is the language used in your ETS Programming file.

Select the Branch and add a new device by clicking the “Add” button on the right side of the Tool.

tool_add_knx

Then, on “KNX”, select what version of ETS Project you want to import and click “Add” button.

In the next window, click on “Import”, navigate to the wanted ETS project file and click open.

tool_import_knxproj

Validate Group Address Function, Description, Data Size, Flags and Enable or Disable group addresses, and click “Ok”.

tool_knx_groups

If you have only one KNX/IP Interface in your network, select “Auto IP Interface” and the system will find it and connect automatically, if you have more than one, insert its IP Address and port correctly.

Click “Next” and you you will see a list of all the software devices created.

tool_knx_devices

Check if everything is according to your needs and click “OK” to finish adding KNX System.

Share
Was this helpful? Yes No Suggest edit

1.1.3.3.Add HDL BusPro System

Select the branch you want to configure, and on the right side, click the ‘Add’ icon.

When the branch window appears, select ‘Buspro Wizard’, and then click on the ‘Add’ icon.

clean_tool_add_buspro

The Buspro Wizard window will then open. In the window select the ‘Modules’ tab, and then input the name of your project, the Buspro Network IP address, and port number into the provided fields.

clean_tool_buspro_wizzard_modules

To add a Buspro Module select the module from the provided product “Module Types” list, and then click on the ‘Add’ button. The added module can then have its description and information modified in the “Modules” Table.

In the ‘Zones’ tab you can create a specific zone for your project, enabling your Buspro devices to be effectively organized.

clean_tool_buspro_wizzard_zonesTo create, remove, or edit zones the following buttons should be used:

  • New Root – Creates a new root
  • New – Creates a new zone or Sub-zone under the Root or Zone
  • Edit – Edit the selected root or zone
  • Delete – deletes the selected root or zone

Using the ‘Devices’ tab, you can add a connected device to a Buspro module.

clean_tool_buspro_wizzard_devices_1Simply select the device you want to add, and click the “Add” button. Name your selected device in the field provided, select your chosen zone, and then click ‘Next’.

In the next window click on the “Select” tab to select the resource for this device, and then click “Ok” and “Finish”.

clean_tool_buspro_wizzard_devices_2When you have finished adding devices, click “Ok”. This will save the Buspro devices to your project.

Share
Was this helpful? Yes No Suggest edit

1.1.3.4.Add Control Devices

Select the Branch to add the device and click Add Device Button.

Navigate to “Control” and  select the type of control device you want to add and click “Add” button.

clean_tool_add_control

In the next window, rename your device and select the output where the control device is connected and click “Ok”.

clean_tool_control_properties

Share
Was this helpful? Yes No Suggest edit

1.1.3.5.Add Metering Devices

Select the Branch to add the device and click the “Add Device” button and in the next window, select the type of metering device you want to add and click “Add” button.

clean_tool_add_metering

In the next window, rename your device and select the input where the control device is connected and click “Ok”. If you want, you can also change other properties for this device.

clean_tool_metering_parameters

Share
Was this helpful? Yes No Suggest edit

1.1.3.6.Add Metering With Control

This option is only to use when you have an On/Off controlled circuit with a CT from Domatica measuring its consumption.

Select the Branch to add the device and click Add Device Button. Then, on “Metering With Control”, select the type of device you want to add and click “Add” button.

clean_tool_add_metering_with_control

In the next window, rename your device and select the input and output where the control device is connected and click “Ok”. If you want, you can also change other properties for this device.

clean_tool_metering_with_control_properties

Share
Was this helpful? Yes No Suggest edit

1.1.4.Branch Information

To check the information from the connected modules, select the Branch and click on the Information Button.

Then choose whether it is on a local network, or in a remote location (e.g. trough the web). If your PC is in the same network (same IP range) select “Local Network” and hit “Get”. If  you PC is on a different network (different IP range), insert remote IP address and remote port and hit “Get”.

TOOL_BRANCH_INFORMATION

Share
Was this helpful? Yes No Suggest edit

1.1.5.Deploy

When you finish adding devices, the newly modified configuration must be sent to the modules.

To do this select the modified branch, and then click on the ‘Deploy’ button.

clean_tool_deploy_1

After the ‘Deploy’ button has been clicked, you must choose if you are deploying using a “Local Network” (PC and Quantum Node on the same local network and same IP range), or a “Remote Location” (deploying through the web or to different IP range network).

clean_tool_deploy_2After this has been done, in the “Server” settings, you must select “Keep current configuration” if you have made changes to the default network configuration, or “Set default configuration” to use default settings.

Also, if you are not using a software that updates the date and time of the Quantum Node, you must synchronize UTC by selecting from the list, the correct time zone.

You also have a “Project Resume” where you can see your branch information such as:

  • Total number of modules;
  • Modules Serial numbers;
  • Modbus Registers used;
  • KNX Group Addresses used;
  • HDL/BusPro Registers used;
  • Inputs and Outputs used;
  • Total number of software Tags/Devices

Click Deploy to send the configuration to Quantum Node System, and when the message “Deployment Process Finished” is displayed on the screen, you have successfully configured your system.

clean_tool_deploy_finished

Share
Was this helpful? Yes No Suggest edit

2.Handling Data with DQC Services

Share
Was this helpful? Yes No Suggest edit

2.1.Domatica Quantum Cloud REST API

INTRODUCTION

Scope

This document is the User Manual for the Domatica Quantum Cloud REST API, developed by Domatica Global Solutions, SA.

Use this document to:

  • Get yourself familiarized with Domatica Cloud Services REST API;
  • Quickly start using Domatica Cloud Services.

NOTE: Read and understand this document and all related documents before installing, operating, or maintaining your device.

Qualified Personnel

Installation procedures must be carried out and inspected by qualified personnel. Qualified personnel are those who, based on their training and experience, are capable of identifying risks and avoiding potential hazards when working with this product

List of devices

The following list of devices example, is connected to the DIY (Do It Yourself) Online Development Kit. You can request a list of the devices by using Request System File REST call.

Note: Each project has a different list of devices, depending of your configuration.

List of devices

Light # 1

DCS_CONTROL_ON_OFF_1.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

DCS_CONTROL_ON_OFF_1.percentcontrol

[REAL TIME – State of light: percentcontrol = 0 – 100%]

Light # 2

DCS_CONTROL_ON_OFF_2.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

DCS_CONTROL_ON_OFF_2.percentcontrol

[REAL TIME – State of light: percentcontrol = 0 – 100%]

Light # 3

DCS_CONTROL_ON_OFF_3.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

DCS_CONTROL_ON_OFF_3.percentcontrol

[REAL TIME – State of light: percentcontrol = 0 – 100%]

Light # 4

DCS_CONTROL_ON_OFF_4.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

Light # 5

DCS_CONTROL_ON_OFF_5.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

Light # 6

DCS_CONTROL_ON_OFF_6.control

[REAL TIME – State of light: control = 0 – OFF; control = 1 – ON]

Energy Meter

DCS_ENERGY_METER.instShowValue

[REAL TIME- Instant consumption: instShowValue= #Value# –  #Value#/10=Watts]

DCS_ENERGY_METER.instStoreAvgValue

[LOG DATA- Average Consumption during 5 minutes’ period: instStoreAvgValue = #Value# –  #Value#/10=Watts]

DCS_ENERGY_METER.instStoreMinValue

[LOG DATA- Minimum Consumption value during 5 minutes’ period: instStoreMinValue = #Value# –  #Value#/10=Watts]

DCS_ENERGY_METER.instStoreMaxValue

[LOG DATA- Maximum Consumption value during 5 minutes’ period: instStoreMinValue = #Value# –  #Value#/10=Watts]

DCS_ENERGY_METER.accStoreValue

[LOG DATA- Accumulated Energy during 5 minutes’ period: instStoreAvgValue = #Value# –  #Value#/10000=kWh]

Temperature Sensor

DCS_TEMPERATURE.instShowValue

[REAL TIME- Instant temperature value: instShowValue= #Value# –  #Value#/100=ºC]

DCS_TEMPERATURE.instStoreAvgValue

[LOG DATA- Average temperature value during 5 minutes’ period: instStoreAvgValue = #Value# –  #Value#/100=ºC]

DCS_TEMPERATURE.instStoreMinValue

[LOG DATA- Minimum temperature value during 5 minutes’ period: instStoreMinValue = #Value# –  #Value#/100=ºC]

DCS_TEMPERATURE.instStoreMaxValue

[LOG DATA- Maximum temperature value during 5 minutes’ period: instStoreMinValue = #Value# –  #Value#/100=ºC]

Push Button

DCS_BUTTON.instShowValue

[REAL TIME- Button position: instShowValue=1 – pressed; instShowValue=0 – release]

DCS_BUTTON.instStoreAvgValue

[LOG DATA, changed state instShowValue=1 – pressed; instShowValue=0 – release]

REST API

The vGatewayId and gToken are the set of identifiers for each equipment provide by Domatica.

Set Value

To set multiple values across multiple gateways, place a https post method to the following url:

https://dqc.domaticasolutions.com/api/v1/operation/monitorControl/set

METHOD: POST

BODY (data:”1” – Light ON; data:”0” – Light OFF):

{
"gTokens": [{
"vGatewayId": 1311768465454927053,
"gToken": "39992D9EF2E8928039BA0BAF8D02A8A0"
}],
"objects": [{
"vGatewayId": 1311768465454927053,
"idname": "DCS_CONTROL_ON_OFF_1.control",
"data": "1"
}]
}

REPLY

{"objects":[{"vGatewayId":1311768465454927053,"idname":"DCS_CONTROL_ON_OFF_1.control","data":"1"}]}

Get Value

To get multiple values across multiple gateways, place an https post method to the following url:

https://dqc.domaticasolutions.com/api/v1/operation/monitorControl/get

METHOD: POST

BODY

{
"gTokens": [{
"vGatewayId": 1311768465454927053,
"gToken": "39992D9EF2E8928039BA0BAF8D02A8A0"
}],
"objects": [{
"vGatewayId": 1311768465454927053,
"idname": "DCS_TEMPERATURE.instShowValue",
"data": ""
}]
}

REPLY

{"objects":[{"vGatewayId":1311768465454927053,"idname":"DCS_DEVICE__TEMPERATURE__9.instShowValue ","data":"2450"}]}

This data value means 24,50 ºC.

Request Log File

To request log file across multiple gateways, place a http post method to the following url:
https://dqc.domaticasolutions.com/api/v1/operation/monitorControl/requestlog
The parameters on the request must be base 64 encoded (example: www.base64decode.org)

$quantity=10; $tolerance=5 -> JHF1YW50aXR5PTEwOyAkdG9sZXJhbmNlPTU=

METHOD: POST
BODY

{
 "vGatewayId": 1311768465454927053,
 "gToken": "39992D9EF2E8928039BA0BAF8D02A8A0",
 "parameters": "JHF1YW50aXR5PTEwOyAkdG9sZXJhbmNlPTU="
 }

REPLY
You need to decompress from GZip format the Result Message (Example: http://www.txtwizard.net/compression).

Also you can request Log File from a timestamp

parameters="$timestamp=1463763303;$tolerance=5"; -> cGFyYW1ldGVycz0iJHRpbWVzdGFtcD0xNDYzNzYzMzAzOyR0b2xlcmFuY2U9NSI7

Request System File

To request system files across multiple gateways, place an https post method to the following url:
https://dqc.domaticasolutions.com/api/v1/operation/monitorControl/requestSystemFile

METHOD: POST

BODY:

{
"vGatewayId": 1311768465454927053,
"gToken": "39992D9EF2E8928039BA0BAF8D02A8A0",
"parameters": ""
}

REPLY
You need to decompress from GZip format the Result Message (Example: http://www.txtwizard.net/compression).

Share
Was this helpful? Yes No Suggest edit

3.DQNx User Program File

1 Quantum Node User Program File

1.1 Introduction

This document is to describe the Domatica Quantum Node (DQN) User Program File.

The User Program is the code that allows the user to create actions based on the events from the DQS, and, as it is completely configurable, you can do just about anything, such as:

  • Act at a given Date/Time
  • Act if Condition evaluating instant measurents
  • Act if Condition evaluating accumulated measurents
  • Act if Variation during time
  • Control specific equipment using devices from DQS
  • PID Control

1.2 Basic User Program topology

The basic topology for the User Program is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<iDomUserProgram>
      <UserParameters>
            ...
      </UserParameters>
      <UserTasks>
            <UserTask id="xxxxx" idname="IdName" name="NameOfTheTask" enabled="true" isprocess="false">
                  <Events>
                        ...
                  </Events>
                  <Code>
                        ...
                  </Code>
            </UserTask>
            ...
      </UserTasks>
</iDomUserProgram>

 

1.2.1 XML Prolog

All the xml files must start with the following xml prolog:

<?xml version="1.0" encoding="UTF-8"?>

1.2.2 Root Element

<iDomUserProgram>
...
</iDomUserProgram>

All the User Program code must be inside root element.

 

1.2.3 User Parameters

      <UserParameters>
            ...
      </UserParameters>

In this Element is where are defined all the paramenters needed to the tasks.

1.2.4 User Tasks Element

      <UserTasks>
            ...
      </UserTasks>

All the tasks must be created inside this Root Element.

1.2.4.1 User Task Element

            <UserTask id="xxxxx" idname="IdName" name="NameOfTheTask" enabled="true" isprocess="false">
                  <Events>
                        ...
                  </Events>
                  <Code>
                        ...
                  </Code>
            </UserTask>

The task element starts with the Task definition where we have:

id – Task Identifier

idname – Task Identifier Name

name – Name of the Task

enabled – Defines if the task is enabled or not enabled

isprocess – Defines if the task is runing as process. If true, the task can be called by id directly, if false, the task will run only if the trigger events happen.

1.3 List of instructions

To construct a User Task, you need to use the following available instructions.

1.3.1 CODELINE_MNEMONICTYPE_TWO_OPERANDS

Use as <INSTRUCTION op1=”XXX” op2=”YYY”/>

INSTRUCTIONS:

CCODELINE_SET: “SET”,”ASSIGN”

CCODELINE_ADD: “ADD”

CCODELINE_SUBTRACT: “SUB”,”SUBTRACT”

CCODELINE_MUL: “MUL”,”MULTIPLY”

CCODELINE_DIV: “DIV”,”DIVIDE”

CCODELINE_ZEROSUBTRACT: “ZSUB”,”ZEROSUB”

CCODELINE_MOD: “MOD”

CCODELINE_ASINE3: “ASIN3”

CCODELINE_ACOSINE3: “ACOS3”

CCODELINE_ASINE6: “ASIN6”

CCODELINE_ACOSINE6: “ACOS6”

CCODELINE_SINE3: “SIN3”

CCODELINE_COSINE3: “COS3”

CCODELINE_TANGENT3: “TAN3”

CCODELINE_ARCTANGENT3: “ATAN3”

CCODELINE_SINE6: “SIN6”

CCODELINE_COSINE6: “COS6”

CCODELINE_TANGENT6: “TAN6”

CCODELINE_ARCTANGENT6: “ATAN6”

CCODELINE_SQUAREROOT: “SQRT”

CCODELINE_POWER: “POWER”

CCODELINE_BITWISE_SHL: “SHL”

CCODELINE_BITWISE_SHR: “SHR”

CCODELINE_BITWISE_LAN: “AND”

CCODELINE_BITWISE_LOR: “OR”

CCODELINE_BITWISE_SBT: “SBIT”

CCODELINE_BITWISE_CBT: “CBIT”

CCODELINE_BITWISE_LXOR: “XOR”

CCODELINE_FLOAT32_TO_INT: “FLOAT32TOINT”

CCODELINE_INT_TO_FLOAT32: “INTTOFLOAT32”

CCODELINE_FLOAT16_TO_INT: “FLOAT16TOINT”

CCODELINE_INT_TO_FLOAT16: “INTTOFLOAT16”

1.3.2 CODELINE_MNEMONICTYPE_ONE_OPERAND

Use as <INSTRUCTION op=”XXX”/>

INSTRUCTIONS:

CCODELINE_TOGGLE: “TOGGLE”

CCODELINE_RAND: “RAND”, “RANDOM”;

CCODELINE_DELAY: “DELAY”,”SLEEP”

CCODELINE_INVALIDATE: “INVALIDATE”

CCODELINE_BITWISE_NOT: “NOT”

CCODELINE_BYTEORDER_3412: “ORDER3412”

CCODELINE_BYTEORDER_2143: “ORDER2143”

CCODELINE_BYTEORDER_4321: “ORDER4321”

CCODELINE_DEC2E4_TO_INT: “DEC2E4TOINT”

CCODELINE_INT_TO_DEC2E4: “INTTODEC2E4”

1.3.3 CODELINE_MNEMONICTYPE_CONTROL

Use as <INSTRUCTION />

INSTRUCTIONS:

CCODELINE_RETURN: “RETURN”

CCODELINE_ELSE: “ELSE”

CCODELINE_END_BLOCK: “END”

1.3.4 CODELINE_MNEMONICTYPE_CONDITION

Use as <INSTRUCTION op1=”XXX” operation=”YYY” op2=”ZZZ”/>

INSTRUCTIONS:

CCODELINE_IF: “IF”

1.4 Complete example

This exemples represents a User Program that compares an instShowValue from a Device, with a reference value and actuates on other device when the condition is true.

<?xml version="1.0" encoding="UTF-8"?>
<iDomUserProgram>
      <UserParameters>
            <UserParameter id="UPAFF000001" idname="#DQC2DP_P#GLOBALCOUNTER#_UPAFF000001" name="GLOBALCOUNTER" type="VARIABLE" enabled="true"/>
            <UserParameter id="UPAFF000002" idname="#DQC2DP_P#MINUTECOUNTER#_UPAFF000002" name="MINUTECOUNTER" type="VARIABLE" enabled="true"/>
            <UserParameter id="#DQC2RP#notify#1#actions" idname="#DQC2RP#notify#1#actions" name="RULE#1 notify_obj" type="VARIABLE" enabled="true"/>
            <UserParameter id="#1#notifyTimer" idname="#1#notifyTimer" name="RULE#1 TIMER Notification" type="VARIABLE" enabled="true"/>
            <UserParameter id="#1#conditionTimer" idname="#1#conditionTimer" name="RULE#1 TIMER Conditions" type="VARIABLE" enabled="true"/>
            <UserParameter id="#1#lock" idname="#1#lock" name="RULE#1 lock" type="VARIABLE" enabled="true"/>
      </UserParameters>
      <UserTasks>
            <UserTask id="UTK02000001" idname="#DQC2DP_T#_UTK02000001" name="GlobalCounterIncrement" enabled="true" isprocess="false">
                  <Events>
                        <On op1="SystemClock" operation="" op2=""/>
                  </Events>
                  <Code>
                        <Add op1="UPAFF000001" op2="1"/>
                  </Code>
            </UserTask>
            <UserTask id="UTK02000002" idname="#DQC2DP_T#_UTK02000002" name="MinuteCounterIncrement" enabled="true" isprocess="false">
                  <Events>
                        <On op1="UPAFF000001" operation="" op2=""/>
                  </Events>
                  <Code>
                        <Assign op1="UPAFF000002" op2="UPAFF000001"/>
                        <Mod op1="UPAFF000002" op2="60"/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK1" idname="#1#UTK1" name="1UTK1" enabled="true">
                  <Events>
                        <On op1="$Start" operation="" op2=""/>
                  </Events>
                  <Code>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="1000" description="Reset notify_obj"/>
                        <Assign op1="#1#notifyTimer" op2="0" description="Reset and Stop timer_not"/>
                        <Assign op1="#1#conditionTimer" op2="0" description="stop condition timer"/>
                        <Assign op1="#1#lock" op2="0" description="flag to check if condition was alreay executed"/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK2" idname="#1#UTK2" name="1UTK2" enabled="true">
                  <Events>
                        <On op1="DEV00000001.instShowValue" operation="GREATEROREQUAL" op2="2200"/>
                  </Events>
                  <Code>
                        <If op1="#1#conditionTimer" operation="GREATER" op2="0" description=""/>
                        <Return/>
                        <End/>
                        <If op1="SystemClock" operation="MINOR" op2="$DateTime(2017-05-09 *:*:* *)" description="Filter before initial date"/>
                        <Return/>
                        <End/>
                        <If op1="SystemClock" operation="GREATER" op2="$DateTime(2030-12-31 *:*:* *)" description="Filter after initial date"/>
                        <Return/>
                        <End/>
                        <!-- TimeEnd > TimeStart -->
                        <If op1="SystemClock" operation="MINOR" op2="$DateTime(*-*-* 10:00:00 *)" description="Filter before initial date"/>
                        <Return/>
                        <End/>
                        <If op1="SystemClock" operation="GREATER" op2="$DateTime(*-*-* 20:00:00 *)" description="Filter after initial date"/>
                        <Return/>
                        <End/>
                        <If op1="SystemClock" operation="NOTEQUAL" op2="$DateTime(*-*-* *:*:* 254)" description="Filter day of the week"/>
                        <Return/>
                        <End/>
                        <If op1="#1#lock" operation="EQUAL" op2="0" description=""/>
                        <Assign op1="#1#lock" op2="1"/>
                        <Assign op1="#1#conditionTimer" op2="UPAFF000001" description="UserConditionTimeInterval"/>
                        <Add op1="#1#conditionTimer" op2="600" description="UserConditionTimeInterval"/>
                        <End/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK3" idname="#1#UTK3" name="1UTK3" enabled="true">
                  <Events>
                        <On op1="DEV00000001.instShowValue" operation="MINOR" op2="2200"/>
                  </Events>
                  <Code>
                        <Assign op1="#1#lock" op2="0"/>
                        <Assign op1="#1#conditionTimer" op2="0"/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK4" idname="#1#UTK4" name="1UTK4" enabled="true">
                  <Events>
                        <On op1="#1#conditionTimer" operation="MINOR" op2="UPAFF000001" description=""/>
                  </Events>
                  <Code>
                        <If op1="#1#conditionTimer" operation="EQUAL" op2="0"/>
                        <Return/>
                        <End/>
                        <Assign op1="#1#conditionTimer" op2="0"/>
                        <If op1="#DQC2RP#notify#1#actions" operation="EQUAL" op2="1000" description=""/>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="1001"/>
                        <Return/>
                        <End/>
                        <If op1="#DQC2RP#notify#1#actions" operation="MINOR" op2="1000" description=""/>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="1002"/>
                        <Return/>
                        <End/>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="#DQC2RP#notify#1#actions"/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK5" idname="#1#UTK5" name="1UTK5" enabled="true">
                  <Events>
                        <On op1="#DQC2RP#notify#1#actions" operation="EQUAL" op2="999" description="Notify ACK"/>
                  </Events>
                  <Code>
                        <Assign op1="#1#notifyTimer" op2="UPAFF000001" description="Start notify once interval min 60.000"/>
                        <Add op1="#1#notifyTimer" op2="30" description="Start notify once interval min 60.000"/>
                  </Code>
            </UserTask>
            <UserTask id="#1#UTK6" idname="#1#UTK6" name="1UTK6" enabled="true">
                  <Events>
                        <On op1="#1#notifyTimer" operation="MINOR" op2="UPAFF000001" description="notify once interval ended"/>
                  </Events>
                  <Code>
                        <If op1="#1#notifyTimer" operation="EQUAL" op2="0" description=""/>
                        <Return/>
                        <End/>
                        <If op1="#DQC2RP#notify#1#actions" operation="EQUAL" op2="999"/>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="1000" description="Reset notify_obj"/>
                        <End/>
                        <If op1="#DQC2RP#notify#1#actions" operation="EQUAL" op2="1002"/>
                        <Assign op1="#DQC2RP#notify#1#actions" op2="1000" description="Reset notify_obj"/>
                        <End/>
                  </Code>
            </UserTask>
            <UserTask id="#1#actions#1" idname="#1#actions#1" name="#1#actions" enabled="true">
                  <Events>
                        <On op1="#DQC2RP#notify#1#actions" operation="GREATER" op2="1000" description=""/>
                  </Events>
                  <Code>
                        <Assign op1="DEV00000002.control" op2="1"/>
                  </Code>
            </UserTask>
      </UserTasks>
</iDomUserProgram>
Share
Was this helpful? Yes No Suggest edit

4.XML Configuration File

1 Quantum Node XML Configuration File

1.1 Basic Configuration File

The basic file to be able to deploy to the Quantum Node, is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<idom version="3.0" id="587204401" idhex="23000731" timestamp="1479478450">  <applications>
    <application name="Domatica Quantum Cloud" version="2.0">
      <commands />
    </application>
  </applications>
  <project name="QUANTUM_NODE_BASIC" dateTime="2016/11/21 09:08:48">
    <communications>
      <networkInterfaces>
        <networkInterface id="1" type="LAN" scope="public" enabled="true" />
        <networkInterface id="2" type="GPRS" scope="public" enabled="false">
          <parameter name="apn" value="" />
          <parameter name="user" value="" />
          <parameter name="password" value="" />
        </networkInterface>
      </networkInterfaces>
      <services>
        <service id="1" name="Domatica Quantum Cloud" address="dqc.domaticasolutions.com" port="7701" cipher="" retryInterval="30" enabled="true" netiface="" />
        <service id="2" name="" address="" port="1000" cipher="" retryInterval="30" enabled="false" netiface="" />
        <service id="3" name="" address="" port="1000" cipher="" retryInterval="30" enabled="false" netiface="" />
      </services>
    </communications>
    <modules>
      <module id="0x2300096C" name="" description="" keywords="" masterGateway="true" />
    </modules>
    <externalModules />
    <serverModules />
    <zones>
    </zones>
    <constants />
    <devices>
    </devices>
    <parameters />
    <tasks />
  </project>
</idom>

This file only has the Quantum Node creation and the Services connections.

In the following items, we will describe all the xml file components.

1.2 XML Prolog

All the xml files must start with the following xml prolog:

<?xml version="1.0" encoding="UTF-8"?>

1.3 Root Element

<idom version="3.0" id="587204401" idhex="23000731" timestamp="1479478450">
...
</idom>

Here you have:

  • version=“3.0”Hardware version of the Quantum Node Pro;
  • id=“587204401”id of the master Quantum Node Pro in decimal base representation;
  • idhex=“23000731” – id of the Master Quantum Node Pro in hexadecimal representation;
  • timestamp=“1479478450”timestamp of file creation.

 

1.4 Project Element

<project name="QUANTUM_NODE" dateTime="2016/11/18 14:14:10">
...
</project>

In this xml element, there will be the entire Quantum Node project.

1.5 Applications Element

Here is an xml element that it is not interpreted or processed by the SDK or Quantum Node, but it can be useful for applications to execute some commands when receive the xml file from the Quantum Node.

 

  <applications>
    <application name="Domatica Quantum Cloud" version="2.0">
      <commands />
    </application>
  </applications>

1.6 Communications Element

In this xml element is where are defined the communication interfaces and services where to the Quantum Node is going to send the data.

    <communications>
      ...
    </communications>

1.6.1 Network Interfaces

In this xml sub-element are defined the available network interfaces such as LAN and GPRS, and, this last one, with the needed parameters, such as APN, User and Password.

      <networkInterfaces>
        <networkInterface id="1" type="LAN" scope="public" enabled="true" />
        <networkInterface id="2" type="GPRS" scope="public" enabled="true">
          <parameter name="apn" value="internet" />
          <parameter name="user" value="user1" />
          <parameter name="password" value="password1" />
        </networkInterface>
      </networkInterfaces>

 

1.6.2 Services

Services are to define the address and port where to, the Quantum Node will be connected to send and receive data. There can be up to 3 Services running simultaneously.

      <services>
        <service id="1" name="Domatica Quantum Cloud" address="dqc.domaticasolutions.com" port="7701" cipher="" retryInterval="30" enabled="true" netiface="" />
        <service id="2" name="Service_2" address="host2.dns.com" port="2222" cipher="" retryInterval="30" enabled="true" netiface="" />
        <service id="3" name="Service_3" address="host3.dns,com" port="3333" cipher="" retryInterval="30" enabled="true" netiface="" />
      </services>

 

1.7 Quantum Node Modules

In this block of code, is where are defined the Quantum Nodes of the project, whether they are Quantum Node Pro or Quantum Node Extender devices. They are represented by their Serial Number in hexadecimal format.

    <modules>
      <module id="0x23000731" name="" description="" keywords="" masterGateway="true" />
      <module id="0x43000ABC" name="" description="" keywords="" />
    </modules>

In this case, we have one Quantum Node Pro3 with SN 0x23000731, wich is the master, and one Quantum Node Extender with SN 0x43000ABC.

1.8 DQNx Element

The DQNx is the Domatica Quantum Node running on Operating Systems.

We will use as example, the gateway running on RaspBian (Linux), in a RaspberryPi.

In this Element we will insert the Libraries needed to your project. These libraries will allow to add more functionalities to your DQNx.

These libraries can be made by any developer and, when inserted to the ipfx, will look something like the following:

      <dqnx>
      <xConnectors>
        <xConnector id="RaspPI" libname="RaspberryIO_v101">
          <dqObjs>
            <dqObj dqoName="GPIO_0" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_1" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_2" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_3" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_4" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_5" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_6" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_7" dqoTypeName="BIT" dqoAttributes="rwx"/>
          </dqObjs>
        </xConnector>
      </xConnectors>
    </dqnx>

In this case, the xConnector id is RaspPi, wich means RaspberryPi, and the Library is RaspberryIO_v101.

The dqObjs are the objects that will be processed by the SDK and the Quantum Node. Here we have GPIO (General Purpose Input Output) from the RaspberryPi.

The Attributes dqoName, dqoTypeName and dqoAttributes are mandatory for the dqObjs.

But, as you will develop your own libraries, you can have any other kind of attibutes, and other xConnectors.

Example:

<dqnx>
<xConnectors>
<xConnector id="Modbus Energy Meter" libname="ModbusEnergyMeter_v101">
                  <myObjs>
                        <obj id="0001" dqo="Voltage L1-N" type="inputRegister"/>
                  </myObjs>
                  <dqObjs>
                        <dqObj addr="0001" type="COIL" interval="1000" dqoName="MODBUS_0" dqoTypeName="BIT" dqoAttributes="rwx"/>
                  </dqObjs>
</xConnector>
            <xConnector id="Triple Sensor" libname="WeatherStationLib">
                  <dqObjs>
                        <dqObj dqoName="Temperature" dqoTypeName="SINT32" dqoAttributes="rwx"/>
                        <dqObj dqoName="CO2" dqoTypeName="SINT32" dqoAttributes="rwx"/>
                        <dqObj dqoName="Relative Humidity" dqoTypeName="SINT32" dqoAttributes="rwx"/>
                  </dqObjs>
</xConnector>
</xConnectors>
</dqnx>

In this case, we have an example with two xConnectors. The Modbus Energy Meter and the Triple Sensor.

The first one has two types of objects, the myObjs and the dqObjs.The dqObjs has the three mandatory attributes, and three more (addr, type and interval) and the myObjs has the attributes defined by the developer. The second o

The triple Sensor has dqObjs only, with the three mandatory attributes.

1.9 External Modules

External modules are all the devices/equipments from wich the Quantum Node will be gathering data and that are not Quantum Node modules.

They must be created inside the External Modules element.

    <externalModules>
      ...
    </externalModules>

These can be of the following types:

  • Modbus RTU
  • Modbus TCP/IP
  • KNX / EIB;
  • HDL / Buspro
  • ZIGBEE
  • DCON
  • DMX512

1.9.1 Modbus RTU

The Modbus RTU externalModules are defined as follows:

      <externalModule id="0xF0000001" name="MODBUS_RTU" decription="" keywords="" coordinator="0x23000731" type="ModBus Server" version="2.1">
        <communicationsChannel type="RTU485">
          <parameter name="baud rate" value="9600" />
          <parameter name="number of bits" value="8" />
          <parameter name="parity" value="none" />
          <parameter name="stop bits" value="1" />
          <parameter name="slaveId" value="1" />
        </communicationsChannel>
        <module>
          <parameter name="request time" value="100" />
          <parameter name="address decrease by one" value="false" />
          <parameter name="lsw first" value="true" />
        </module>
        <data>
          <registers>
            <register id="ModbusInputReg0000" description="VOLTAGE L1-N" keywords="" type="InputRegister" address="0" arrayLength="1" dataType="SINT32" time="0" exponent="0" enabled="true" />
          </registers>
        </data>
      </externalModule>

The external module has an id, name and a coordinator. The coordinator is the serial number of the Quantum Node Pro that is gathering its data.

Communication channel is also defined, as are all its communication parameters such as baud rate, number of bits, parity, stop bits and slave id.

All of the Modbus Registers available, are also defined within the registers xml element.

1.9.2 Modbus TCP

Modbus TCP modules are defined as follows:

      <externalModule id="0xF000000F" name="MODBUS_TCP" decription="" keywords="" coordinator="0x23000731" type="ModBus Server" version="2.1">
        <communicationsChannel type="TCP">
          <parameter name="remote address" value="192.168.0.100" />
          <parameter name="remote port" value="502" />
          <parameter name="unitId" value="1" />
        </communicationsChannel>
        <module>
          <parameter name="request time" value="100" />
          <parameter name="address decrease by one" value="false" />
          <parameter name="lsw first" value="false" />
        </module>
        <data>
          <registers>
            <register id="ModbusReg1000" description="3-PHASE SYSTEM VOLTAGE" keywords="" type="Register" address="4096" arrayLength="1" dataType="UINT32" time="0" exponent="1" enabled="true" />
          </registers>
        </data>
      </externalModule>

The external module has an id, name and a coordinator. The coordinator is the serial number of the Quantum Node Pro that is gathering its data.

Communication channel is also defined, as all its communication parameters such as baud rate, number of bits, parity, stop bits and slave id.

All of the Modbus Registers available, are also defined within the registers xml element.

1.9.3 KNX / EIB

 

KNX / EIB external modules do not refer to the KNX modules in the knx network, but to the hole system as one. The information needed to this external module, comes from the .knxproj file, for ETS4 and ETS5 projects, or .esf file for ETS3 projects.

The external module is defined as follows:

 

      <externalModule id="0xF000000E" name="KNX_PROJECT" decription="" keywords="" coordinator="0x23000731" type="Knx System" version="2.0">
        <module>
          <parameter name="remote address" value="" />
          <parameter name="remote port" value="" />
          <parameter name="group address style" value="three level" />
          <parameter name="hide 16 bit groups" value="false" />
          <parameter name="project name" value="KNX_PROJECT" />
          <parameter name="project date" value="" />
          <parameter name="request time" value="50" />
        </module>
        <data>
          <groups>
            <group id="KNXGroup00_0_005" description="ON&amp;OFF" keywords="LIGHT ON/OFF CONTROL (NO STATUS)" address="0/0/5" dataSize="1 bit" readTime="0" communication="true" read="true" write="true" transmit="true" update="true" readOnInit="true" enabled="true" />
            <group id="KNXGroup00_0_012" description="TEMPERATURE 2" keywords="TEMPERATURE (ºC)" address="0/0/12" dataSize="2 bytes" readTime="0" communication="true" read="true" write="true" transmit="true" update="true" readOnInit="true" enabled="true" />
          </groups>
        </data>
      </externalModule>

The external module has an id, name and a coordinator. The coordinator is the serial number of the Quantum Node Pro that is gathering its data.

In the <module> xml element there are the parameters for the connection to the knx system.

All the data is defined in <data> with the information from the group addresses from ETS project file.

1.9.4 HDL / BusPro

HDL / Buspro external modules are defined as follows:

 

      <externalModule id="0xF0000005" name="BUSPRO_PROJECT" description="" keywords="" coordinator="0x23000731" originId="" type="BusPro Server" version="1.0">
        <communicationsChannel type="UDP">
          <parameter name="remote address" value="192.168.1.255" />
          <parameter name="remote port" value="6000" />
        </communicationsChannel>
        <data>
          <modules>
            <module id="1" devid="0x0102" type="MT-SINGLE-CHANNEL" requestTime="-1" />
          </modules>
          <registers>
            <register modId="1" regId="BUSPRO_0102_SC_001" description="Single Channel 1" keywords="" type="SINGLECHANNEL" address="1" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_002" description="Single Channel 2" keywords="" type="SINGLECHANNEL" address="2" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_003" description="Single Channel 3" keywords="" type="SINGLECHANNEL" address="3" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_004" description="Single Channel 4" keywords="" type="SINGLECHANNEL" address="4" enabled="true" />
          </registers>
        </data>
      </externalModule>

The external module has an id, name and a coordinator. The coordinator is the serial number of the Quantum Node that is “coordinating” it.

Communications channel is also defined, as all its communication parameters such as remote address and remote por.

All of the BusPro registers are also defined in the <registers> xml element.

1.10 Server Modules

Quantum Node can work as a server for Modbus TCP data, that is created in the <serverModules> xml element.

All the data are made available through Modbus Registers.

    <serverModules>
      <serverModule id="0xF1000001" name="Server Module ModBus TCP/IP Up" description="" keywords="" coordinator="0x23000731" type="MODBUS" version="2.2">
        <communicationsChannel iface="ETH:0" port="502" />
        <modules>
          <module unitId="1">
            <registers>
              <register address="0x03E8" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EA" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EC" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EE" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F0" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F2" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F4" object="QUANTUM_NODE_OUTPUT_DEVICE.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F6" object="QUANTUM_NODE_OUTPUT_DEVICE.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F8" object="QUANTUM_NODE_INPUT_DEVICE.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FA" object="QUANTUM_NODE_INPUT_DEVICE.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FC" object="QUANTUM_NODE_INPUT_DEVICE.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FE" object="QUANTUM_NODE_INPUT_DEVICE.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0400" object="QUANTUM_NODE_INPUT_DEVICE.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0402" object="QUANTUM_NODE_INPUT_DEVICE.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0404" object="Root_BPRO_MACHINE_CONTROL__ONOFF_.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0406" object="Root_BPRO_MACHINE_CONTROL__ONOFF_.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0408" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040A" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040C" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040E" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0410" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0412" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0414" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0416" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
            </registers>
          </module>
        </modules>
      </serverModule>
    </serverModules>

1.11 Zones

Zones are defined in the <zones> xml element. The zones are part os the devices idname (see 1.10)

    <zones>
      <zone name="QUANTUM_NODE" path="QUANTUM_NODE" />
      <zone name="KNX_PROJECT" path="QUANTUM_NODE\KNX_PROJECT" />
      <zone name="KNX" path="QUANTUM_NODE\KNX_PROJECT\KNX" />
      <zone name="GROUP" path="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" />
      <zone name="Root" path="Root" />
    </zones>

1.12 Devices

The list of devices in the Quantum Node must be created in <devices> xml element.

All devices have an id and an idname wich are unique within the project file. For each Device there is a driver and the zone where it is stored and the parameters that will be used by the driver.

    <devices>
      <device id="DEV00000001" type="STDInstMeter" driver="STD-ModBusGeneric-Voltage" idname="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N" zone="QUANTUM_NODE" name="MODBUS_RTU - VOLTAGE L1-N" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0xF0000001.ModbusInputReg0000" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
      <device id="DEV00000006" type="STDControl" driver="STD-GenericOnOffNO" idname="QUANTUM_NODE_OUTPUT_DEVICE" zone="QUANTUM_NODE" name="OUTPUT_DEVICE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="output" value="0x23000731.PWMOUTPUT1" />
      </device>
      <device id="DEV00000007" type="STDInstMeter" driver="STD-Humidity-Generic-Min-Max-Analog" idname="QUANTUM_NODE_INPUT_DEVICE" zone="QUANTUM_NODE" name="INPUT_DEVICE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0x23000731.ANALOGINPUT1" />
        <parameter name="maximum" value="10000" />
        <parameter name="maximum_analog" value="4400" />
        <parameter name="maximum_value" value="10000" />
        <parameter name="minimum" value="0" />
        <parameter name="minimum_analog" value="0" />
        <parameter name="minimum_value" value="0" />
        <parameter name="nominal" value="5000" />
        <parameter name="store_period" value="5" />
        <parameter name="value" value="0" />
      </device>
      <device id="DEV00000008" type="STDControl" driver="STD-Buspro-Control-OnOff-WithoutLog" idname="Root_BPRO_MACHINE_CONTROL__ONOFF_" zone="Root" name="BPRO MACHINE CONTROL (ONOFF)" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="register" value="0xF0000005.BUSPRO_0102_SC_001" />
      </device>
      <device id="DEV00000013" type="STDControl" driver="STD-KNXGeneric-OnOff-WithoutState" idname="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF" zone="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" name="ON&amp;OFF" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="group" value="0xF000000E.KNXGroup00_0_005" />
      </device>
      <device id="DEV00000014" type="STDInstMeter" driver="STD-KNXGeneric-Temperature-Celsius" idname="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2" zone="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" name="TEMPERATURE 2" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="group" value="0xF000000E.KNXGroup00_0_012" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
      <device id="DEV00000016" type="STDInstMeter" driver="STD-ModBusGeneric-Voltage" idname="QUANTUM_NODE_MODBUS_TCP___3_PHASE_SYSTEM_VOLTAGE" zone="QUANTUM_NODE" name="MODBUS_TCP - 3-PHASE SYSTEM VOLTAGE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0xF000000F.ModbusReg1000" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
    </devices>

Each Device corresponds to one data variable that is being monitored and/or stored in the logs.

Example:

  • Electric Current from phase one being monitored with a Modbus RTU Power Analyser;
  • Temperature from a Temperature Probe connected to input;
  • OnOff control from an HDL/BusPro device;
  • Etc.

2 Atachments

2.1 IPFX Full Project file

 
<?xml version="1.0" encoding="UTF-8"?>
<idom version="3.0" id="587204401" idhex="23000731" timestamp="1479484126">
  <applications>
    <application name="Domatica Quantum Cloud" version="2.0">
      <commands />
    </application>
  </applications>
  <project name="QUANTUM_NODE" dateTime="2016/11/18 15:48:46">
    <communications>
      <connections>
        <connection type="DOMATINET" address="192.168.0.1" remoteport="3002" localport="0" password="" />
      </connections>
      <networkInterfaces>
        <networkInterface id="1" type="LAN" scope="public" enabled="true" />
        <networkInterface id="2" type="GPRS" scope="public" enabled="true">
          <parameter name="apn" value="internet" />
          <parameter name="user" value="" />
          <parameter name="password" value="" />
        </networkInterface>
      </networkInterfaces>
      <services>
        <service id="1" name="Domatica Quantum Cloud" address="dqc.domaticasolutions.com" port="7701" cipher="" retryInterval="30" enabled="true" netiface="" />
        <service id="2" name="Service_2" address="host2.dns.com" port="2222" cipher="" retryInterval="30" enabled="true" netiface="" />
        <service id="3" name="Service_3" address="host3.dns,com" port="3333" cipher="" retryInterval="30" enabled="true" netiface="" />
      </services>
    </communications>
    <modules>
      <module id="0x23000731" name="" description="" keywords="" masterGateway="true" />
      <module id="0x43000ABC" name="" description="" keywords="" />
    </modules>
      <dqnx>
      <xConnectors>
        <xConnector id="RaspPI" libname="RaspberryIO_v101">
          <dqObjs>
            <dqObj dqoName="GPIO_0" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_1" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_2" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_3" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_4" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_5" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_6" dqoTypeName="BIT" dqoAttributes="rwx"/>
            <dqObj dqoName="GPIO_7" dqoTypeName="BIT" dqoAttributes="rwx"/>
          </dqObjs>
        </xConnector>
      </xConnectors>
    </dqnx>
    <externalModules>
      <externalModule id="0xF0000001" name="MODBUS_RTU" decription="" keywords="" coordinator="0x23000731" type="ModBus Server" version="2.1">
        <communicationsChannel type="RTU485">
          <parameter name="baud rate" value="9600" />
          <parameter name="number of bits" value="8" />
          <parameter name="parity" value="none" />
          <parameter name="stop bits" value="1" />
          <parameter name="slaveId" value="1" />
        </communicationsChannel>
        <module>
          <parameter name="request time" value="100" />
          <parameter name="address decrease by one" value="false" />
          <parameter name="lsw first" value="true" />
        </module>
        <data>
          <registers>
            <register id="ModbusInputReg0000" description="VOLTAGE L1-N" keywords="" type="InputRegister" address="0" arrayLength="1" dataType="SINT32" time="0" exponent="0" enabled="true" />
          </registers>
        </data>
      </externalModule>
      <externalModule id="0xF000000F" name="MODBUS_TCP" decription="" keywords="" coordinator="0x23000731" type="ModBus Server" version="2.1">
        <communicationsChannel type="TCP">
          <parameter name="remote address" value="192.168.0.100" />
          <parameter name="remote port" value="502" />
          <parameter name="unitId" value="1" />
        </communicationsChannel>
        <module>
          <parameter name="request time" value="100" />
          <parameter name="address decrease by one" value="false" />
          <parameter name="lsw first" value="false" />
        </module>
        <data>
          <registers>
            <register id="ModbusReg1000" description="3-PHASE SYSTEM VOLTAGE" keywords="" type="Register" address="4096" arrayLength="1" dataType="UINT32" time="0" exponent="1" enabled="true" />
          </registers>
        </data>
      </externalModule>
      <externalModule id="0xF000000E" name="KNX_PROJECT" decription="" keywords="" coordinator="0x23000731" type="Knx System" version="2.0">
        <module>
          <parameter name="remote address" value="" />
          <parameter name="remote port" value="" />
          <parameter name="group address style" value="three level" />
          <parameter name="hide 16 bit groups" value="false" />
          <parameter name="project name" value="KNX_PROJECT" />
          <parameter name="project date" value="" />
          <parameter name="request time" value="50" />
        </module>
        <data>
          <groups>
            <group id="KNXGroup00_0_005" description="ON&amp;OFF" keywords="LIGHT ON/OFF CONTROL (NO STATUS)" address="0/0/5" dataSize="1 bit" readTime="0" communication="true" read="true" write="true" transmit="true" update="true" readOnInit="true" enabled="true" />
            <group id="KNXGroup00_0_012" description="TEMPERATURE 2" keywords="TEMPERATURE (ºC)" address="0/0/12" dataSize="2 bytes" readTime="0" communication="true" read="true" write="true" transmit="true" update="true" readOnInit="true" enabled="true" />
          </groups>
        </data>
      </externalModule>
      <externalModule id="0xF0000005" name="BUSPRO_PROJECT" description="" keywords="" coordinator="0x23000731" originId="" type="BusPro Server" version="1.0">
        <communicationsChannel type="UDP">
          <parameter name="remote address" value="192.168.1.255" />
          <parameter name="remote port" value="6000" />
        </communicationsChannel>
        <data>
          <modules>
            <module id="1" devid="0x0102" type="MT-SINGLE-CHANNEL" requestTime="-1" />
          </modules>
          <registers>
            <register modId="1" regId="BUSPRO_0102_SC_001" description="Single Channel 1" keywords="" type="SINGLECHANNEL" address="1" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_002" description="Single Channel 2" keywords="" type="SINGLECHANNEL" address="2" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_003" description="Single Channel 3" keywords="" type="SINGLECHANNEL" address="3" enabled="true" />
            <register modId="1" regId="BUSPRO_0102_SC_004" description="Single Channel 4" keywords="" type="SINGLECHANNEL" address="4" enabled="true" />
          </registers>
        </data>
      </externalModule>
    </externalModules>
    <serverModules>
      <serverModule id="0xF1000001" name="Server Module ModBus TCP/IP Up" description="" keywords="" coordinator="0x23000731" type="MODBUS" version="2.2">
        <communicationsChannel iface="ETH:0" port="502" />
        <modules>
          <module unitId="1">
            <registers>
              <register address="0x03E8" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EA" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EC" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03EE" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F0" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F2" object="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F4" object="QUANTUM_NODE_OUTPUT_DEVICE.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F6" object="QUANTUM_NODE_OUTPUT_DEVICE.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03F8" object="QUANTUM_NODE_INPUT_DEVICE.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FA" object="QUANTUM_NODE_INPUT_DEVICE.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FC" object="QUANTUM_NODE_INPUT_DEVICE.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x03FE" object="QUANTUM_NODE_INPUT_DEVICE.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0400" object="QUANTUM_NODE_INPUT_DEVICE.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0402" object="QUANTUM_NODE_INPUT_DEVICE.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0404" object="Root_BPRO_MACHINE_CONTROL__ONOFF_.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0406" object="Root_BPRO_MACHINE_CONTROL__ONOFF_.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0408" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF.control" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040A" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF.lock" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040C" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instUnitID" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x040E" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instShowValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0410" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instStoreAvgValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0412" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instMinValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0414" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instNominalValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
              <register address="0x0416" object="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2.instMaxValue" arrayLength="1" dataType="SINT32" functions="" description="" enabled="true" />
            </registers>
          </module>
        </modules>
      </serverModule>
    </serverModules>
    <zones>
      <zone name="QUANTUM_NODE" path="QUANTUM_NODE" />
      <zone name="KNX_PROJECT" path="QUANTUM_NODE\KNX_PROJECT" />
      <zone name="KNX" path="QUANTUM_NODE\KNX_PROJECT\KNX" />
      <zone name="GROUP" path="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" />
      <zone name="Root" path="Root" />
    </zones>
    <constants />
    <devices>
      <device id="DEV00000001" type="STDInstMeter" driver="STD-ModBusGeneric-Voltage" idname="QUANTUM_NODE_MODBUS_RTU___VOLTAGE_L1_N" zone="QUANTUM_NODE" name="MODBUS_RTU - VOLTAGE L1-N" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0xF0000001.ModbusInputReg0000" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
      <device id="DEV00000006" type="STDControl" driver="STD-GenericOnOffNO" idname="QUANTUM_NODE_OUTPUT_DEVICE" zone="QUANTUM_NODE" name="OUTPUT_DEVICE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="output" value="0x23000731.PWMOUTPUT1" />
      </device>
      <device id="DEV00000007" type="STDInstMeter" driver="STD-Humidity-Generic-Min-Max-Analog" idname="QUANTUM_NODE_INPUT_DEVICE" zone="QUANTUM_NODE" name="INPUT_DEVICE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0x23000731.ANALOGINPUT1" />
        <parameter name="maximum" value="10000" />
        <parameter name="maximum_analog" value="4400" />
        <parameter name="maximum_value" value="10000" />
        <parameter name="minimum" value="0" />
        <parameter name="minimum_analog" value="0" />
        <parameter name="minimum_value" value="0" />
        <parameter name="nominal" value="5000" />
        <parameter name="store_period" value="5" />
        <parameter name="value" value="0" />
      </device>
      <device id="DEV00000008" type="STDControl" driver="STD-Buspro-Control-OnOff-WithoutLog" idname="Root_BPRO_MACHINE_CONTROL__ONOFF_" zone="Root" name="BPRO MACHINE CONTROL (ONOFF)" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="register" value="0xF0000005.BUSPRO_0102_SC_001" />
      </device>
      <device id="DEV00000013" type="STDControl" driver="STD-KNXGeneric-OnOff-WithoutState" idname="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_ON_OFF" zone="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" name="ON&amp;OFF" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="group" value="0xF000000E.KNXGroup00_0_005" />
      </device>
      <device id="DEV00000014" type="STDInstMeter" driver="STD-KNXGeneric-Temperature-Celsius" idname="QUANTUM_NODE_KNX_PROJECT_KNX_GROUP_TEMPERATURE_2" zone="QUANTUM_NODE\KNX_PROJECT\KNX\GROUP" name="TEMPERATURE 2" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="group" value="0xF000000E.KNXGroup00_0_012" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
      <device id="DEV00000016" type="STDInstMeter" driver="STD-ModBusGeneric-Voltage" idname="QUANTUM_NODE_MODBUS_TCP___3_PHASE_SYSTEM_VOLTAGE" zone="QUANTUM_NODE" name="MODBUS_TCP - 3-PHASE SYSTEM VOLTAGE" desc="" keywords="" stateless="false" visible="true" enabled="true">
        <parameter name="input" value="0xF000000F.ModbusReg1000" />
        <parameter name="maximum" value="0" />
        <parameter name="minimum" value="0" />
        <parameter name="nominal" value="0" />
        <parameter name="store_period" value="5" />
      </device>
    </devices>
    <parameters />
    <tasks />
  </project>
</idom>
Share
Was this helpful? Yes No Suggest edit

5.xConnectors

1 Quantum Node Xconnector

 

1.1 Introduction

xConnectors are the way developers can integrate their own equipments with Domatica Quantum Node. This way all the information and options available in the integrated equipment can be used by the DQNx, treated and the become available in the cloud.

This document explains the entire procedure for you to create your own xConnector.

For this purpose, we will use as an example, the DQNx running on a RaspberryPi and we will show how to use RaspberryPi’s GPIO to read from sensors and to actuate.

 

1.2 Generate basic files

To start creating your xConnector, you can download the xConnector Generator from HERE. You can use xConGen executable file (xConGen.exe) in windows or the equivalent (xConGen) to Linux Environments.

 

1.2.1 How to use xConnector Generator

In Windows environment, open Command Prompt in the folder where the executable file is and type xConGen.exe nameOfxConnector.

Example:

 

In Linux Environments, Open the terminal in the folder where the executable file is and type ./xConGen nameOfxConnector

 

 

Lets consider that we want to create the RaspberryGPIO_v101.so xConnector.

This will generate a folder named RaspberryGPIO_v101, with three files in it:

  1. cbp – this is the Codeblocks project file;
  2. cpp – this is the c++ code file;
  3. h – this is the header file

 

1.2.2 RaspberryGPIO_v101.cpp

This file is generated with all the functions you will need already created, and no code in it.

 #include "RaspberryGPIO_v101.h"
 //#########################################################
 // DO NOT CHANGE
 //#########################################################
 #include <dqnxConnectorBaseV1.cpp>

CxConnectorBase* dqnxCreateConnectorObject()
 {
 return new RaspberryGPIO_v101();
 }
 //#########################################################
 //TODO: EDIT HERE

/
RaspberryGPIO_v101::RaspberryGPIO_v101()
 {
 //TODO: EDIT HERE
 }

 

RaspberryGPIO_v101::~RaspberryGPIO_v101()
 {
 //TODO: EDIT HERE
 }

 

void RaspberryGPIO_v101::Init(std::list<std::string> &objectList, const si8* configString, si8 *connectorSignature, ui32 &pumpInterval)
 {
 //TODO: EDIT HERE
 }

This method is called on DQNx init event.

 

std::list<std::string> &objectList – is a simplified list of the objects, only with the name.

const si8* configString – is the xml piece of code for the xconnector.

si8 *connectorSignature – for future use;

ui32 &pumpInterval – returns the pump interval in miliseconds.

 

void RaspberryGPIO_v101::Pump()
{
//TODO: EDIT HERE
}

This method will be executed at the rate of pumpInterval.

 

void RaspberryGPIO_v101::ObjectEvent(CxConnectorObject* obj)
{
//TODO: EDIT HERE
}

This method will execute whenever there is an event.

 

void RaspberryGPIO_v101::ObjectQuestion(CxConnectorObject* obj)
{
//TODO: EDIT HERE
}

 

This method is to request values from the DQNx objects.

 

void RaspberryGPIO_v101::DataEvent(const void *data, const ui32 data_size)
{
//TODO: EDIT HERE
}

This is a binary stream, which creates a tunnel of information that can be used, among other things, to interact with the hardware running DQNx.

 

1.2.3 RaspberryGPIO_v101.h

 

#ifndef _DQNxxCon_RaspberryGPIO_v101_HEADER_
#define _DQNxxCon_RaspberryGPIO_v101_HEADER_
#include "dqnxConnectorBaseV1.h"

class RaspberryGPIO_v101 : public CxConnectorBase
{
//#########################################################
// DO NOT CHANGE
//#########################################################
public:
RaspberryGPIO_v101();
virtual ~RaspberryGPIO_v101();
virtual void Init(std::list<std::string> &objectList, const si8* configString, si8 *connectorSignature, ui32 &pumpInterval);
virtual void Pump();
virtual void ObjectEvent(CxConnectorObject* obj);
virtual void ObjectQuestion(CxConnectorObject* obj);
virtual void DataEvent(const void *data, const ui32 data_size);
//#########################################################
//TODO: EDIT HERE
};

#endif //_DQNxxCon_RaspberryGPIO_v101_HEADER_

 

1.2.4 DQNxConnectorV1.h

    CxConnectorObject(std::string name, std::string attr)
        : name(name)
        , attr(attr)
        , undefined(true)
    {   }

    std::string Name() { return name; }

    void setString(std::string d)
    {
        data = d;
        toDQNx[this] = false;
    }

    void setUI32(ui32 d)            { setUnsignedInt(d); }
    void setUI16(ui16 d)            { setUnsignedInt(d); }
    void setUI8(ui8 d)              { setUnsignedInt(d); }
    void setSI32(si32 d)            { setSignedInt(d); }
    void setSI16(si16 d)            { setSignedInt(d); }
    void setSI8(si8 d)              { setSignedInt(d); }
    void setFloat32(float d)
    {
      toDQNx[this] = false;
      std::ostringstream ostr;
      ostr << d;
      data = ostr.str();
    }

    std::string getString()         { return data; }
    ui32 getUI32()                  { return getUnsignedInt(); }
    ui16 getUI16()                  { return getUnsignedInt(); }
    ui8 getUI8()                    { return getUnsignedInt(); }
    si32 getSI32()                  { return getSignedInt(); }
    si16 getSI16()                  { return getSignedInt(); }
    si8 getSI8()                    { return getSignedInt(); }
    float getFloat32()
{
      float result;
      try
      {
        result = ::atof(data.c_str());
      }
      catch(...)
      {
        result = 0;
      }
      return result;
    }

  void UpdateDQN()
  {
        toDQNx[this] = false;
  }

  void ForceEvent()
  {
        toDQNx[this] = true;
  }

  bool IsUndefined()
  {
    return undefined;
  }

  bool canRead()
  {
    return (attr.find("R") != std::string::npos);
  }

  bool canWrite()
  {
    return (attr.find("W") != std::string::npos);
  }

  bool canExecute()
  {
    return (attr.find("X") != std::string::npos);
  }

 

1.2.5 Other header files

You can create other header files to complete your xConnector. In this case, we have created the RaspGPIO.h header file which will define the GPIO to be Read or Write (Input or Output).

2 Appendix

Example files for xConnector to read or write from/to Raspberry Pi’s GPIO.

2.1 RaspberryGPIO_v101.cpp

#include "RaspberryGPIO_v101.h"
 //#########################################################
 // DO NOT CHANGE
 //#########################################################
 #include <dqnxConnectorBaseV1.cpp>

CxConnectorBase* dqnxCreateConnectorObject()
 {
 return new RaspberryGPIO_v101();
 }

//#########################################################
 //TODO: EDIT HERE

#include "RaspGPIO.h"
 RaspberryGPIO_v101::RaspberryGPIO_v101()
 {
 //TODO: EDIT HERE
 }
 RaspberryGPIO_v101::~RaspberryGPIO_v101()
 {
 //TODO: EDIT HERE
 }

void RaspberryGPIO_v101::Init(std::list<std::string> &objectList, const si8* configString, si8 *connectorSignature, ui32 &pumpInterval)
 {
 pumpInterval = 2;
 this->objectList = objectList;
 printf(configString);
 std::list<std::string>::iterator iList = objectList.begin();
 while (iList != objectList.end())
 {
 std::string objname = *iList;
 CxConnectorObject* obj = GetObject(objname);
 if (obj)
 {
 if (obj->Name().find("GPIO_") == 0)
 {
 try
 {
 si32 gpioId = strtol(obj->Name().substr(5).c_str(), 0, 10);
 CRaspGPIO::Export(gpioId);
 if (obj->canWrite())
 {
 CRaspGPIO::Direction(gpioId, 1);
 }
 else
 {
 CRaspGPIO::Direction(gpioId, 0);
 }
 }
 catch (...)
 {
 }
 }
 }
 ++iList;
 }
 }

void RaspberryGPIO_v101::Pump()
 {
 std::list<std::string>::iterator iList = objectList.begin();
 while (iList != objectList.end())
 {
 std::string objname = *iList;
 CxConnectorObject* obj = GetObject(objname);
 if (obj)
 {
 try
 {
 if ((obj) && (!obj->canWrite()) && (obj->canRead()))
 {
 si32 gpioId = strtol(obj->Name().substr(5).c_str(), 0, 10);
 si32 value = CRaspGPIO::Read(gpioId);
 obj->setSI32(value);
 }
 }
 catch (...)
 {
 }
 }
 ++iList;
 }
 }

void RaspberryGPIO_v101::ObjectEvent(CxConnectorObject* obj)
 {
 if (obj->canWrite())
 {
 try
 {
 si32 gpioId = strtol(obj->Name().substr(5).c_str(), 0, 10);
 CRaspGPIO::Write(gpioId, obj->getSI32()!=0?1:0);
 }
 catch (...)
 {
 }
 }
 }

void RaspberryGPIO_v101::ObjectQuestion(CxConnectorObject* obj)
 {
 //TODO: EDIT HERE
 }

void RaspberryGPIO_v101::DataEvent(const void *data, const ui32 data_size)
 {
 //TODO: EDIT HERE
 }

2.2 RaspberryGPIO_v101.h

#ifndef _DQNxxCon_RaspberryGPIO_v101_HEADER_
#define _DQNxxCon_RaspberryGPIO_v101_HEADER_
#include "dqnxConnectorBaseV1.h"

class RaspberryGPIO_v101 : public CxConnectorBase
{
//#########################################################
// DO NOT CHANGE
//#########################################################
public:
  RaspberryGPIO_v101();
  virtual ~RaspberryGPIO_v101();
  virtual void Init(std::list<std::string> &objectList, const si8* configString, si8 *connectorSignature, ui32 &pumpInterval);
  virtual void Pump();
  virtual void ObjectEvent(CxConnectorObject* obj);
  virtual void ObjectQuestion(CxConnectorObject* obj);
  virtual void DataEvent(const void *data, const ui32 data_size);

//#########################################################
//TODO: EDIT HERE
  std::list<std::string> objectList;
};

#endif //_DQNxxCon_RaspberryGPIO_v101_HEADER_

 

2.3 RaspGPIO.h

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>


#define RASP_GPIO_DIRECTION_IN            0
#define RASP_GPIO_LOW_VALUE                 0

class CRaspGPIO
{
public:
    static int Export(int pin)
    {
        char buffer[8];
        ssize_t bytes_written;
        int fd;
        fd = open("/sys/class/gpio/export", O_WRONLY);
        if (-1 == fd)
        {
            fprintf(stderr, "Failed to open export for writing!\n");
            return(-1);
        }
        bytes_written = snprintf(buffer, 8, "%d", pin);
        write(fd, buffer, bytes_written);
        close(fd);
        return(0);
    }

    static int Unexport(int pin)
    {
        char buffer[8];
        ssize_t bytes_written;
        int fd;


        fd = open("/sys/class/gpio/unexport", O_WRONLY);
        if (-1 == fd)
        {
            fprintf(stderr, "Failed to open unexport for writing!\n");
            return(-1);
        }


        bytes_written = snprintf(buffer, 8, "%d", pin);
        write(fd, buffer, bytes_written);
        close(fd);
        return(0);
    }


    static int Direction(int pin, int dir)
    {
        static const char s_directions_str[] = "in\0out";
        char path[80];
        int fd;
        snprintf(path, 80, "/sys/class/gpio/gpio%d/direction", pin);
        fd = open(path, O_WRONLY);
        if (-1 == fd)
        {
            fprintf(stderr, "Failed to open gpio direction for writing!\n");
            return(-1);
        }


        if (-1 == write(fd, &s_directions_str[RASP_GPIO_DIRECTION_IN == dir ? 0 : 3], RASP_GPIO_DIRECTION_IN == dir ? 2 : 3))
        {
            fprintf(stderr, "Failed to set direction!\n");
            return(-1);
        }


       close(fd);
        return(0);
    }


    static int Read(int pin)
    {
        char path[80];
        char value_str[3];
        int fd;


        snprintf(path, 80, "/sys/class/gpio/gpio%d/value", pin);
        fd = open(path, O_RDONLY);
        if (-1 == fd)
        {
            fprintf(stderr, "Failed to open gpio value for reading!\n");
            return(-1);
        }


       if (-1 == read(fd, value_str, 3))
        {
            fprintf(stderr, "Failed to read value!\n");
            return(-1);
        }


       close(fd);


       return(atoi(value_str));
    }


   static int Write(int pin, int value)
    {
        static const char s_values_str[] = "01";
     //fprintf(stderr, "RaspGPIO::Write: GPIO_%d = %d!\n", pin, value);
        char path[80];
        int fd;
        snprintf(path, 80, "/sys/class/gpio/gpio%d/value", pin);
        fd = open(path, O_WRONLY);
        if (-1 == fd)
        {
            fprintf(stderr, "Failed to open gpio value for writing!\n");
            return(-1);
        }
        if (1 != write(fd, &s_values_str[RASP_GPIO_LOW_VALUE == value ? 0 : 1], 1))
        {
            fprintf(stderr, "Failed to write value!\n");
            return(-1);
        }
        close(fd);
        return(0);
    }
};

 

Share
Was this helpful? Yes No Suggest edit
Suggest Edit
Share