How to: Initialize Device Settings from File
The guide demonstrates how to read parameter values from a text file using an expression and apply them to a device.
Please note that calling functions from MosFiles, MosUtils objects will immediately put the script module into demo mode if it is not licensed
Before starting, create a file on your disk named startup.ini with the following content:
Open Monokot Server Administrator, create a Modbus TCP device named MyModbusDevice, double-click Scripts on the Server Explorer pane. Click New Expression and set the name Initializer for the expression that appears. Insert the following code into the expression code editor:
Press Ctrl + Enter to apply the change in the code editor.
In order for the changes to take effect on the server, click the Sync button. Since no trigger is specified for the expression, it will be executed once at the time of creation. After the expression is executed, the Host and SlaveId properties of MyModbusDevice will be 192.168.1.1 and 9 respectively. To verify this, select MyModbusDevice in the Device Manager and click the Sync button to receive changes from the server.
Last updated