Difference between revisions of "Script Adapter (Pull)"
From Datonis
(Created page with " Edge Gateway Home > '''Script Adapter (Push)''' == Script Adapter Fields == {| class="wikitable" | colspan="1" |Connect JS Script | colspan="1" |Str...") |
m (→Flow) (Tag: Visual edit) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[Datonis Edge Gateway|Edge Gateway Home]] > '''Script Adapter ( | + | [[Datonis Edge Gateway|Edge Gateway Home]] > '''Script Adapter (Pull)''' |
== Script Adapter Fields == | == Script Adapter Fields == | ||
Line 5: | Line 5: | ||
| colspan="1" |Connect JS Script | | colspan="1" |Connect JS Script | ||
| colspan="1" |String | | colspan="1" |String | ||
− | | colspan="1" |Script to be executed to connect to target device and | + | | colspan="1" |Script to be executed to connect to target device. Context var 'transient_val' (in memory) can be used to store objects across connect/disconnect. Context var 'persistent_val' (persistent store) can be used to store objects across restart. Context var 'kvstore_val' can be used to create custom persistent maps and immediate commits/rollbacks. Context var 'logger_val' can be used for logging purpose. |
+ | |- | ||
+ | |Read Scan JS Script | ||
+ | |String | ||
+ | |Script to be executed during each scan prior to execute Tag scripts. Context var 'connection_val' holds return value of read connection script's return value. Context var 'transient_val', 'presistent_val', 'kvstore_val' and 'logger_val' are available. | ||
|- | |- | ||
| colspan="1" |Disconnect JS Script | | colspan="1" |Disconnect JS Script | ||
Line 28: | Line 32: | ||
| colspan="1" |executor_val | | colspan="1" |executor_val | ||
| colspan="1" |Is available for firing async tasks. Ex. This can be used to schedule at intervals etc. | | colspan="1" |Is available for firing async tasks. Ex. This can be used to schedule at intervals etc. | ||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|transient_val | |transient_val | ||
Line 48: | Line 48: | ||
|Used for logging. Example - logger_val.info() | |Used for logging. Example - logger_val.info() | ||
|- | |- | ||
− | | | + | |instruction_val |
− | | | + | |This is a map which contains the instruction json. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|scan_val | |scan_val | ||
− | |This | + | |This holds the return value of the Read Scan JS Script |
|- | |- | ||
|tag_val | |tag_val | ||
Line 74: | Line 58: | ||
|- | |- | ||
|connection_val | |connection_val | ||
− | |This holds the return value of the | + | |This holds the return value of the Write Connection JS script. |
|} | |} | ||
− | == | + | == Flow == |
− | + | The flow of this adapter is like any other Data Pull Adapter. Every scan_interval ms the Read Scan JS is executed and the return value of this script is stored in the scan_val which is available in the tag JS Script for each tag. If the tag is write tag then the Write Connection JS Script is executed and the return value of this script is stored in the connection_val which is available in the Tag JS Script. This is how the all the tag values are generated and sent to Datonis or written to any source. | |
− | |||
− |
Latest revision as of 17:25, 30 January 2020
Edge Gateway Home > Script Adapter (Pull)
Script Adapter Fields
Connect JS Script | String | Script to be executed to connect to target device. Context var 'transient_val' (in memory) can be used to store objects across connect/disconnect. Context var 'persistent_val' (persistent store) can be used to store objects across restart. Context var 'kvstore_val' can be used to create custom persistent maps and immediate commits/rollbacks. Context var 'logger_val' can be used for logging purpose. |
Read Scan JS Script | String | Script to be executed during each scan prior to execute Tag scripts. Context var 'connection_val' holds return value of read connection script's return value. Context var 'transient_val', 'presistent_val', 'kvstore_val' and 'logger_val' are available. |
Disconnect JS Script | String | Script to be executed to disconnect to target device and clean up listener. Context var 'connection_val' holds return value of read connection script's return value. Context var 'executor_val', 'transient_val', 'presistent_val', 'kvstore_val' and 'logger_val' are available. |
Write Connection JS Script | String | Script to be executed while executing instruction. Context var 'instruction_val' is set to instruction json values. Context var 'transient_val', 'presistent_val', 'kvstore_val' and 'logger_val' are available. |
Additional Java library URLs | String | URL paths of additional Java libraries (.jar) required by this connection and associated read/write tag scripts. All library URL paths must be comma seperated. e.g. file:/c:/mongo-driver/mongo-java-driver-3.6.2.jar, file:/c:/mongo-driver/snappy-java-1.1.4.jar |
Tag JS Script | String | Script to be executed during each to retrieve Tag value. Context var 'scan_val' holds received value of current scan. In case of write tag, context var 'tag_val' holds tag value set by instruction and 'connection_val' holds return value of write connection script. Context var 'transient_val', 'presistent_val', 'kvstore_val' and 'logger_val' are available. |
Script Tags
executor_val | Is available for firing async tasks. Ex. This can be used to schedule at intervals etc. |
transient_val | In memory map and can be used across connect/disconnect and through different adapters.
Usage - transient_val.put(Object value) |
persistent_val | In memory file storage map which can be used across restart of Edge.
Usage - persistent_val.put(Object value) |
kvstore_val | Can be used to create custom persistent maps. |
logger_val | Used for logging. Example - logger_val.info() |
instruction_val | This is a map which contains the instruction json. |
scan_val | This holds the return value of the Read Scan JS Script |
tag_val | This variable contains the value of the write tag that is to be set by the instruction received by Edge. |
connection_val | This holds the return value of the Write Connection JS script. |
Flow
The flow of this adapter is like any other Data Pull Adapter. Every scan_interval ms the Read Scan JS is executed and the return value of this script is stored in the scan_val which is available in the tag JS Script for each tag. If the tag is write tag then the Write Connection JS Script is executed and the return value of this script is stored in the connection_val which is available in the Tag JS Script. This is how the all the tag values are generated and sent to Datonis or written to any source.