Skip to content

Commit 0f265f9

Browse files
authored
Allow easy set of ModbusDeviceInformation. (#859)
1 parent 88a85ea commit 0f265f9

14 files changed

+101
-82
lines changed

examples/common/asynchronous_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ def run_async_server():
100100
# ----------------------------------------------------------------------- #
101101
# If you don't set this or any fields, they are defaulted to empty strings.
102102
# ----------------------------------------------------------------------- #
103-
identity = ModbusDeviceIdentification()
104-
identity.VendorName = 'Pymodbus'
105-
identity.ModelName = 'Pymodbus Server'
106-
identity.MajorMinorRevision = version.short()
107-
identity.ProductCode = 'PM'
108-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
109-
identity.ProductName = 'Pymodbus Server'
103+
identity = ModbusDeviceIdentification(info_name= {
104+
'VendorName': 'Pymodbus',
105+
'ModelName': 'Pymodbus Server',
106+
'MajorMinorRevision': version.short(),
107+
'ProductCode': 'PM',
108+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
109+
'ProductName': 'Pymodbus Server',
110+
})
110111

111112
# ----------------------------------------------------------------------- #
112113
# run the server you want

examples/common/asyncio_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ async def run_server():
9898
# ----------------------------------------------------------------------- #
9999
# If you don't set this or any fields, they are defaulted to empty strings.
100100
# ----------------------------------------------------------------------- #
101-
identity = ModbusDeviceIdentification()
102-
identity.VendorName = 'Pymodbus'
103-
identity.ProductCode = 'PM'
104-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
105-
identity.ProductName = 'Pymodbus Server'
106-
identity.ModelName = 'Pymodbus Server'
107-
identity.MajorMinorRevision = version.short()
101+
identity = ModbusDeviceIdentification(info_name= {
102+
'VendorName': 'Pymodbus',
103+
'ProductCode': 'PM',
104+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
105+
'ProductName': 'Pymodbus Server',
106+
'ModelName': 'Pymodbus Server',
107+
'MajorMinorRevision': version.short(),
108+
})
108109

109110
# ----------------------------------------------------------------------- #
110111
# run the server you want

examples/common/callback_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,14 @@ def run_callback_server():
123123
# ----------------------------------------------------------------------- #
124124
# initialize the server information
125125
# ----------------------------------------------------------------------- #
126-
identity = ModbusDeviceIdentification()
127-
identity.VendorName = 'pymodbus'
128-
identity.ProductCode = 'PM'
129-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
130-
identity.ProductName = 'pymodbus Server'
131-
identity.ModelName = 'pymodbus Server'
132-
identity.MajorMinorRevision = version.short()
126+
identity = ModbusDeviceIdentification(info_name= {
127+
'VendorName': 'pymodbus',
128+
'ProductCode': 'PM',
129+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
130+
'ProductName': 'pymodbus Server',
131+
'ModelName': 'pymodbus Server',
132+
'MajorMinorRevision': version.short(),
133+
})
133134

134135
# ----------------------------------------------------------------------- #
135136
# run the server you want

examples/common/custom_datablock.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ def run_custom_db_server():
6161
# initialize the server information
6262
# ----------------------------------------------------------------------- #
6363

64-
identity = ModbusDeviceIdentification()
65-
identity.VendorName = 'pymodbus'
66-
identity.ProductCode = 'PM'
67-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
68-
identity.ProductName = 'pymodbus Server'
69-
identity.ModelName = 'pymodbus Server'
70-
identity.MajorMinorRevision = version.short()
64+
identity = ModbusDeviceIdentification(info_name= {
65+
'VendorName': 'pymodbus',
66+
'ProductCode': 'PM',
67+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
68+
'ProductName': 'pymodbus Server',
69+
'ModelName': 'pymodbus Server',
70+
'MajorMinorRevision': version.short(),
71+
})
7172

7273
# ----------------------------------------------------------------------- #
7374
# run the server you want

examples/common/custom_synchronous_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ def run_server():
100100
# ----------------------------------------------------------------------- #
101101
# If you don't set this or any fields, they are defaulted to empty strings.
102102
# ----------------------------------------------------------------------- #
103-
identity = ModbusDeviceIdentification()
104-
identity.VendorName = 'Pymodbus'
105-
identity.ProductCode = 'PM'
106-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
107-
identity.ProductName = 'Pymodbus Server'
108-
identity.ModelName = 'Pymodbus Server'
109-
identity.MajorMinorRevision = version.short()
103+
identity = ModbusDeviceIdentification(info_name= {
104+
'VendorName': 'Pymodbus',
105+
'ProductCode': 'PM',
106+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
107+
'ProductName': 'Pymodbus Server',
108+
'ModelName': 'Pymodbus Server',
109+
'MajorMinorRevision': version.short(),
110+
})
110111

111112
# ----------------------------------------------------------------------- #
112113
# run the server you want

examples/common/dbstore_update_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ def run_dbstore_update_server():
8282
# ----------------------------------------------------------------------- #
8383
# initialize the server information
8484
# ----------------------------------------------------------------------- #
85-
identity = ModbusDeviceIdentification()
86-
identity.VendorName = 'pymodbus'
87-
identity.ProductCode = 'PM'
88-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
89-
identity.ProductName = 'pymodbus Server'
90-
identity.ModelName = 'pymodbus Server'
91-
identity.MajorMinorRevision = version.short()
85+
identity = ModbusDeviceIdentification(info_name= {
86+
'VendorName': 'pymodbus',
87+
'ProductCode': 'PM',
88+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
89+
'ProductName': 'pymodbus Server',
90+
'ModelName': 'pymodbus Server',
91+
'MajorMinorRevision': version.short(),
92+
})
9293

9394
# ----------------------------------------------------------------------- #
9495
# run the server you want

examples/common/modbus_payload_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ def run_payload_server():
6868
# ----------------------------------------------------------------------- #
6969
# If you don't set this or any fields, they are defaulted to empty strings.
7070
# ----------------------------------------------------------------------- #
71-
identity = ModbusDeviceIdentification()
72-
identity.VendorName = 'Pymodbus'
73-
identity.ProductCode = 'PM'
74-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
75-
identity.ProductName = 'Pymodbus Server'
76-
identity.ModelName = 'Pymodbus Server'
77-
identity.MajorMinorRevision = version.short()
71+
identity = ModbusDeviceIdentification(info_name= {
72+
'VendorName': 'Pymodbus',
73+
'ProductCode': 'PM',
74+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
75+
'ProductName': 'Pymodbus Server',
76+
'ModelName': 'Pymodbus Server',
77+
'MajorMinorRevision': version.short(),
78+
})
7879
# ----------------------------------------------------------------------- #
7980
# run the server you want
8081
# ----------------------------------------------------------------------- #

examples/common/synchronous_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ def run_server():
9595
# ----------------------------------------------------------------------- #
9696
# If you don't set this or any fields, they are defaulted to empty strings.
9797
# ----------------------------------------------------------------------- #
98-
identity = ModbusDeviceIdentification()
99-
identity.VendorName = 'Pymodbus'
100-
identity.ProductCode = 'PM'
101-
identity.VendorUrl = 'http://github.com/riptideio/pymodbus/' #NOSONAR
102-
identity.ProductName = 'Pymodbus Server'
103-
identity.ModelName = 'Pymodbus Server'
104-
identity.MajorMinorRevision = version.short()
98+
ModbusDeviceIdentification(info_name= {
99+
'VendorName': 'Pymodbus',
100+
'ProductCode': 'PM',
101+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
102+
'ProductName': 'Pymodbus Server',
103+
'ModelName': 'Pymodbus Server',
104+
'MajorMinorRevision': version.short(),
105+
})
105106

106107
# ----------------------------------------------------------------------- #
107108
# run the server you want

examples/common/updating_server.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ def run_updating_server():
7171
# ----------------------------------------------------------------------- #
7272
# initialize the server information
7373
# ----------------------------------------------------------------------- #
74-
identity = ModbusDeviceIdentification()
75-
identity.__setitem__('VendorName', 'pymodbus')
76-
identity.__setitem__('ProductCode', 'PM')
77-
identity.__setitem__('VendorUrl', 'http://github.com/riptideio/pymodbus/') #NOSONAR
78-
identity.__setitem__('ProductName', 'pymodbus Server')
79-
identity.__setitem__('ModelName', 'pymodbus Server')
80-
identity.__setitem__('MajorMinorRevision', version.short())
74+
identity = ModbusDeviceIdentification(info_name= {
75+
'VendorName': 'pymodbus',
76+
'ProductCode': 'PM',
77+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
78+
'ProductName': 'pymodbus Server',
79+
'ModelName': 'pymodbus Server',
80+
'MajorMinorRevision': version.short(),
81+
})
8182

8283
# ----------------------------------------------------------------------- #
8384
# run the server you want

examples/contrib/deviceinfo_showcase_server.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ def run_server():
4141
# ----------------------------------------------------------------------- #
4242
# If you don't set this or any fields, they are defaulted to empty strings.
4343
# ----------------------------------------------------------------------- #
44-
identity = ModbusDeviceIdentification()
45-
identity.__setitem__('VendorName', 'Pymodbus')
46-
identity.__setitem__('ProductCode', 'PM')
47-
identity.__setitem__('VendorUrl', 'http://github.com/riptideio/pymodbus/') #NOSONAR
48-
identity.__setitem__('ProductName', 'Pymodbus Server')
49-
identity.__setitem__('ModelName', 'Pymodbus Server')
50-
identity.__setitem__('MajorMinorRevision', version.short())
44+
identity = ModbusDeviceIdentification(info_name= {
45+
'VendorName': 'Pymodbus',
46+
'ProductCode': 'PM',
47+
'VendorUrl': 'http://github.com/riptideio/pymodbus/', #NOSONAR
48+
'ProductName': 'Pymodbus Server',
49+
'ModelName': 'Pymodbus Server',
50+
'MajorMinorRevision': version.short(),
51+
52+
})
5153

5254
# ----------------------------------------------------------------------- #
5355
# Add an example which is long enough to force the ReadDeviceInformation

0 commit comments

Comments
 (0)