Skip to content

Commit 74d6f1a

Browse files
committed
Updated README.md, docs
1 parent d0d734a commit 74d6f1a

File tree

5 files changed

+585
-13
lines changed

5 files changed

+585
-13
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,20 @@ provides `Output` window where standard output is redirected.
111111
The rest is the power of Python, its standard library, 3rd party libraries,
112112
and your own libraries and scripts.
113113

114-
Objects for access corresponding device memory: `mem0x`, `mem1x`, `mem3x`, `mem4x`.
114+
Every device has its own set of scripts: `Init`, `Loop` and `Final`.
115+
Those scripts accessable through device menu or contex menu for device.
116+
117+
`Init` script performs once at program start (when push `Start` button).
118+
It intended for making python `import` instruction, create objects, files etc.
119+
Modules, objects and files created within will be accessable from `Loop` and `Final` scripts.
120+
121+
`Loop` script performs cyclic until program not stopped.
122+
It has implicit cycle so user don't have to cycle his program manualy.
123+
124+
`Final` script performs once at program stop (when push `Stop` button).
125+
It intended for release resources previously created in `Init` and `Loop` scripts, save files etc.
126+
127+
Standard objects for access corresponding device memory: `mem0x`, `mem1x`, `mem3x`, `mem4x`.
115128

116129
Every object has set of get/set function to work with different data types:
117130
* `mem0x`, `mem1x`: `get<datatype>(bitoffset:int)->int` and `set<datatype>(bitoffset:int,value:int)`

doc/input/mainpage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Software implements such Modbus functions as:
1717
* `7 ` (`0x07`) - `READ_EXCEPTION_STATUS`
1818
* `15` (`0x0F`) - `WRITE_MULTIPLE_COILS`
1919
* `16` (`0x10`) - `WRITE_MULTIPLE_REGISTERS`
20+
* `17` (`0x11`) - `REPORT_SERVER_ID` (since v0.4)
2021
* `22` (`0x16`) - `MASK_WRITE_REGISTER` (since v0.3)
2122
* `23` (`0x17`) - `READ_WRITE_MULTIPLE_REGISTERS` (since v0.3)
2223

doc/input/server/server.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Port contains network settings for both TCP/IP and serial ports. Device contains
1414
The DataViewItem contains a single data unit to be read/write from the device and has many formats to represent
1515
the 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

Comments
 (0)