@@ -14,6 +14,10 @@ Port contains network settings for both TCP/IP and serial ports. Device contains
1414The DataViewItem contains a single data unit to be read/write from the device and has many formats to represent
1515the current data. Action provides simulation capabilities (automatic change of device memory values).
1616
17+ Since v0.4 version ` server ` application allows to extend logic of your Modbus device
18+ simulator using one the most popular programming language - Python.
19+ All you need to use scripting is installed Python interpreter and ` PyQt5 ` library.
20+
1721# Quickstart {#sec_server_quickstart}
1822
1923![ ] ( server_view.png )
@@ -512,4 +516,52 @@ Address of next action are calculated automaticaly according to it address and s
512516 * ` Random ` – randomize value between ` min ` and ` max ` ;
513517 * ` Copy ` – copy value from ` Source ` to ` Address ` array of ` DataType ` with size ` Size ` ;
514518* ` Byte order ` – byte order of current action;
515- * ` Register order ` – register order used for 32-bit size action and higher;
519+ * ` Register order ` – register order used for 32-bit size action and higher;
520+
521+ # Scripting
522+
523+ ` server ` application gives you access to the device's internal Modbus memory and
524+ provides ` Output ` window where standard output is redirected.
525+ The rest is the power of Python, its standard library, 3rd party libraries,
526+ and your own libraries and scripts.
527+
528+ Every device has its own set of scripts: ` Init ` , ` Loop ` and ` Final ` .
529+ Those scripts accessable through device menu or contex menu for device.
530+
531+ ` Init ` script performs once at program start (when push ` Start ` button).
532+ It intended for making python ` import ` instruction, create objects, files etc.
533+ Modules, objects and files created within will be accessable from ` Loop ` and ` Final ` scripts.
534+
535+ ` Loop ` script performs cyclic until program not stopped.
536+ It has implicit cycle so user don't have to cycle his program manualy.
537+
538+ ` Final ` script performs once at program stop (when push ` Stop ` button).
539+ It intended for release resources previously created in ` Init ` and ` Loop ` scripts, save files etc.
540+
541+ Standard objects for access corresponding device memory: ` mem0x ` , ` mem1x ` , ` mem3x ` , ` mem4x ` .
542+
543+ Every object has set of get/set function to work with different data types:
544+ * ` mem0x ` , ` mem1x ` : ` get<datatype>(bitoffset:int)->int ` and ` set<datatype>(bitoffset:int,value:int) `
545+ * ` mem3x ` , ` mem4x ` : ` get<datatype>(regoffset:int)->int ` and ` set<datatype>(regoffset:int,value:int) `
546+
547+ ` <datatype> ` : ` int8 ` , ` uint8 ` , ` int16 ` , ` uint16 ` , ` int32 ` , ` uint32 ` , ` int64 ` , ` uint64 ` , ` float ` , ` double ` .
548+
549+ Examples:
550+ ``` python
551+ v = mem0x.getint8(0 )
552+ mem1x.setint16(1 , - 1 )
553+ mem3x.setuint16(0 , 65535 )
554+ mem4x.setdouble(10 , 2.71828 )
555+ ```
556+
557+ Also index operation is supported.
558+ In case of discrete memory (` mem0x ` , ` mem1x ` ) it work with ` boolean ` values
559+ and for registers memory (` mem3x ` , ` mem4x ` ) it work with ` uint16 ` values:
560+
561+ ``` python
562+ b0 = mem0x[0 ]
563+ mem1x[38 ] = True
564+ mem3x[100 ] = 65535
565+ if mem4x[0 ] > 32768 :
566+ mem4x[0 ] = 0
567+ ```
0 commit comments