linking
4 minute read
/etc/motorcortex/config/
└── linking
    ├── agv-control.link.json
    ├── base.link.json
    ├── joystick.link.json
    ├── machine-control.link.json
    ├── safety-selector.link.json
    ├── setpoint-generator.link.json
    └── signal-generator.link.json
General
In xxx.link.json you can set motorcortex parameters and define links between these parameters. This way you can communicate data from one Module to another Module. This works also across Tasks.
You are only allowed to link parameters that have the same data type and size on both ends of the link. It is not allowed to link parameterType: output as Destination, an output can only be a Source.
All possible xxx.link.json options are explained in the 
linking.schema.v4.json
xxx.link.json example
{
  "Version": "1.0.0",
  "Groups": [
    {
      "Name": "LinkExample",
      "SystemMode": "All",
      "Links": [
        {
          "Source": {
            "Path": "root/Control/boolOutput"
          },
          "Destination": {
            "Path": "root/Logic/boolInput"
          }
        }
      ]
    },
    {
      "Name": "Simulation",
      "SystemMode": "Simulation",
      "Links": [
        {
          "Source": {
            "Path": "root/Simulator/doubleOutput"
          },
          "Destination": {
            "Path": "root/Control/doubleInput"
          }
        }
      ]
    }
  ]
}
xxx.link.json explained
Inside the xxx.link.json you can create multiple "Groups", a group contains a "Name" and information about the action like: "links" and/or "setParameters". With the "systemMode" you can specify for which Application mode this group should be active. If you want to disable or enable groups from the xxx.link.json, you can use the "Enable": function.
 
#Version
You can apply a version to your xxx.link.json with "Version":, check out 
linking.schema.v4.json how to to set up your versioning.
#Groups
You can create your own "Group":, to assign a link or set a parameter.
#Name
Each group contains a "Name": in here you can specify a name to your liking.
#SystemMode
Inside the config.json you can define the Application Mode, per mode, different links can be created in the xxx.link.json. For each group the "systemMode": can be defined (All,  Production or Simulation) with the "systemMode", you can specify in which Application Mode the group is active:
| Application Mode | SystemMode | 
|---|---|
| Production | AllorProduction | 
| Simulation | AllorSimulation | 
#Enable
With the "Enable": flag you can enable or disable the current group, this is done by defining a True, or False statement.
#SetParameters
SetParameters are used to change the the "Value": of the specified "Path":.
| Parameter | Description | 
|---|---|
| "Value": | Here you can specify anytype ofValuethat you want to assign to thePath. | 
| "Force": | Here you can specify if you want to Forcethe value, to thePath, This can either beTrueorFalse. | 
| "Path": | Here you can specify the Path, to which theValueis written. (path example:root/.../...) | 
| "Index": | Here you can specify the Indexexpressed asnumber, index 0 is equal to the the first element in a array[0]. | 
| "Length": | Here you can specify the Lengthofelementsexpressed as anumber. Example: If the"Index": 1, with"Length": 2,Index 1 and 2are written to theDestination. | 
   "Name": "Simulation",
      "SystemMode": "Simulation",
      "SetParameters":
        {
          "Path": "root/Logic/:busToState/estop_buttons_channel1",
          "Value": [
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true
          ],
          "Force": true
        } 
 
#Links
"Links": are used to link a source to a destination, it is allowed to link a source to multiple destinations, but it is not allowed to link multiple sources to one destination.
In the "Source": and "Destination":: you fill in your preferred path (root/.../...). To the Source you can specify information like: "Gain":, "Offset":, "Index": , "Length":, "Invert": and for the Destination only a "Index": and "Length".
| Parameter | Description | 
|---|---|
| "Source": | Here you can specify the Pathof theSourcethat you want to link to theDestination. | 
| "Destination": | Here you can specify the pathof thedestination. | 
| "Invert": | Here you can invert the Source, invert is only applied to a value0or1. | 
| "Gain": | Here you can specify the Gain, theSourceis multiplied by the definedGainto get a newDestinationvalue. | 
| "Offset": | Here you can specify the Offsetapplied to theDestination. | 
| "Index": | Here you can specify the Indexexpressed asnumber, index 0 is equal to the the first element in a array[0]. | 
| "Length": | Here you can specify the Lengthofelementsexpressed as anumber. Example: If the"Index": 1, with"Length": 2, you will write onlyIndex 1 and 2to theDestination. | 
Note
The order of information sending to the Destination is first the Offset, after which the Source * Gain is added.
      "Name": "Joystick",
      "SystemMode": "All",
      "Enable": true,
      "Links": [
        {
          "Gain": 1.0,
          "Offset": 0.0,
          "Source": {
            "Path": "root/Joystick1/axes",
            "Index": 4,
            "Length": 1
          },
          "Destination": {
            "Path": "root/Control/hostInJointVelocity",
            "Index": 0
          }
        }
      ]
