In this article, we'll be discussing MTConnect adapter scripts and how they apply to both MTConnect machines as well as any other machine with a Data Collection Method to transform data coming from it.
Note: See the Configuration Script Overview-V2 for an overall look at the V2 adapter scripts.
Specify Version
The first line within your Adapter Script should indicate which version of Adapter Script you're using. To use a V2 adapter script, enter the following.
version: 2
Note: If there is no version set, version 1 will be assumed.
Controlling Data Item Input
There are several options to control how incoming MTConnect data items are handled and whether they are passed through to the adapter’s output or not.
- mtconnect-passthrough: optional
- allow-keys: optional
- deny-keys: optional
- declare-keys: optional
mtconnect-passthrough
- required: no
- valid range: [true, false]
- default value: true
By default, mtconnect and mtconnect-adapter devices will pass through all MTConnect data items received and emit them in the output stream of the IO instance. If this value is set to false, only items defined in a data-items block will be output.
version: 2
mtconnect-passthrough: false
allow-keys
- required: no
- valid range: list
By default, when mtconnect-passthrough is enabled, all incoming data items will be passed through directly. If an allow-keys list is specified, then only data items with keys matching the allow-keys list will be passed through.
Keys are specified as a YAML list, one entry per line. An asterisk character (*) can be used as a wildcard to match multiple similar keys. For more complex matching, full regular expressions are supported as values by wrapping the values in regular expression delimiters (//) .
Note: YAML syntax requires any items starting with a * character to be surrounded by quotes.
allow-keys:
- part_count
- system
- execution*
- '*load'
- /[xyz]cut\d?/
Data item keys such as part_count, execution, execution2, Aload, xcut, ycut, zcut1 will be passed, and all other data items will be blocked.
deny-keys
- required: no
- valid range: list
By default, when mtconnect-passthrough is enabled, all incoming data items will be passed through directly. If a deny-keys list is specified, then any data items with keys matching the deny-keys list will be blocked and will not appear in the adapter’s output.
Keys are specified as a YAML list, one entry per line. An asterisk character (*) can be used as a wildcard to match multiple similar keys. For more complex matching, full regular expressions are supported as values by wrapping the values in regular expression delimiters (//) .
Note: YAML syntax requires any items starting with a * character to be surrounded by quotes.
deny-keys:
- program
- block*
- '*load'
- /[xyz]pos\d?/
Data item keys such as program, block1, xpos, Yload, zpos2 will be dropped, but other data items will be passed.
declare-keys
- required: no
- valid range: list
- aliases: keys
In order to use incoming MTConnect data items in any other parts of the adapter script (such as transform rules in the variables block, or in the data-items block), they must be listed out explicitly. The adapter otherwise doesn’t know what MTConnect data items are coming in and being passed through.
Keys are specified as a YAML list.
Data-items can be declared and used throughout an adapter script even if mtconnect-passthrough is turned off or the keys are matched in the deny-keys list.
declare-keys:
- execution1
- spindle_speed
- part_count
By declaring keys, we'll call attention to specific keys that are needed to be transformed.
version: 2
mtconnect-passthrough: false
declare-keys:
- Execution
- mode
Next Steps
After the inputs section is complete, the variables and data-items sections can be filled in like any other adapter script. For more information on data-items and conditions and variables.
version: 2
mtconnect-passthrough: false
declare-keys:
- Execution
- mode
variables:
modified_execution:
- source: Execution
- state:
- ACTIVE: mode == "AUTOMATIC"
data-items:
- modified_execution
Comments
0 comments
Please sign in to leave a comment.