accordionq2 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. accordionq2-1.0.0/PKG-INFO +345 -0
  2. accordionq2-1.0.0/README.md +334 -0
  3. accordionq2-1.0.0/accordionq2/__init__.py +7 -0
  4. accordionq2-1.0.0/accordionq2/_base.py +82 -0
  5. accordionq2-1.0.0/accordionq2/application.py +58 -0
  6. accordionq2-1.0.0/accordionq2/channels.py +41 -0
  7. accordionq2-1.0.0/accordionq2/client.py +52 -0
  8. accordionq2-1.0.0/accordionq2/comm.py +171 -0
  9. accordionq2-1.0.0/accordionq2/connection.py +14 -0
  10. accordionq2-1.0.0/accordionq2/enums.py +152 -0
  11. accordionq2-1.0.0/accordionq2/exceptions.py +12 -0
  12. accordionq2-1.0.0/accordionq2/media.py +27 -0
  13. accordionq2-1.0.0/accordionq2/models.py +370 -0
  14. accordionq2-1.0.0/accordionq2/modules.py +46 -0
  15. accordionq2-1.0.0/accordionq2/numeric_results.py +112 -0
  16. accordionq2-1.0.0/accordionq2/resources.py +50 -0
  17. accordionq2-1.0.0/accordionq2.egg-info/PKG-INFO +345 -0
  18. accordionq2-1.0.0/accordionq2.egg-info/SOURCES.txt +30 -0
  19. accordionq2-1.0.0/accordionq2.egg-info/dependency_links.txt +1 -0
  20. accordionq2-1.0.0/accordionq2.egg-info/requires.txt +3 -0
  21. accordionq2-1.0.0/accordionq2.egg-info/top_level.txt +1 -0
  22. accordionq2-1.0.0/pyproject.toml +22 -0
  23. accordionq2-1.0.0/setup.cfg +4 -0
  24. accordionq2-1.0.0/tests/test_application.py +43 -0
  25. accordionq2-1.0.0/tests/test_channels.py +59 -0
  26. accordionq2-1.0.0/tests/test_comm.py +119 -0
  27. accordionq2-1.0.0/tests/test_connection.py +16 -0
  28. accordionq2-1.0.0/tests/test_media.py +13 -0
  29. accordionq2-1.0.0/tests/test_modules.py +86 -0
  30. accordionq2-1.0.0/tests/test_numeric_results.py +156 -0
  31. accordionq2-1.0.0/tests/test_performance.py +77 -0
  32. accordionq2-1.0.0/tests/test_resources.py +60 -0
@@ -0,0 +1,345 @@
1
+ Metadata-Version: 2.4
2
+ Name: accordionq2
3
+ Version: 1.0.0
4
+ Summary: Python client for the AccordionQ2 Hardware Management REST API
5
+ Author: eSharp AB
6
+ License: Proprietary
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest>=7; extra == "dev"
11
+
12
+ # AccordionQ2 Python Client
13
+
14
+ Python client library for the **AccordionQ2 Hardware Management REST API**.
15
+ This is the Python counterpart of the
16
+ [.NET WebApiClient](https://git.esharp.se/esharp/accordion-projects/webapiclient);
17
+ both libraries expose the same API surface so switching between them feels
18
+ natural.
19
+
20
+ ## Requirements
21
+
22
+ | Requirement | Details |
23
+ |-------------|---------|
24
+ | Python | 3.8 or later |
25
+ | Platform | Windows, Linux (including ARM / Raspberry Pi) |
26
+ | Architecture | 32-bit and 64-bit |
27
+ | Dependencies | **None** — stdlib only (`urllib`, `json`, `enum`, `dataclasses`) |
28
+
29
+ ## Installation
30
+
31
+ Install directly from a local checkout (editable mode recommended during
32
+ development):
33
+
34
+ ```bash
35
+ pip install -e .
36
+ ```
37
+
38
+ Or, for a regular install:
39
+
40
+ ```bash
41
+ pip install .
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ```python
47
+ from accordionq2 import AccordionQ2Client
48
+
49
+ with AccordionQ2Client("http://agent64.local:5000") as client:
50
+ # Check the hardware connection
51
+ status = client.connection.get_status()
52
+ print("Connected:", status.is_connected)
53
+
54
+ # Read a sensor value
55
+ temp = client.resources.get_value("TempRegulator.CPU_TEMP")
56
+ print("CPU temperature:", temp)
57
+
58
+ # List all channels
59
+ for ch in client.channels.get_all():
60
+ print(f" {ch.alias}: type={ch.channel_type}, unit={ch.unit}")
61
+ ```
62
+
63
+ The client can also be used without a `with` block:
64
+
65
+ ```python
66
+ client = AccordionQ2Client("http://agent64.local:5000")
67
+ names = client.resources.get_names()
68
+ client.close()
69
+ ```
70
+
71
+ ### Constructor
72
+
73
+ ```python
74
+ AccordionQ2Client(base_url, timeout=30.0)
75
+ ```
76
+
77
+ | Parameter | Description |
78
+ |------------|-------------|
79
+ | `base_url` | Base URL of the AccordionQ2 WebApi, e.g. `"http://raspberrypi:5000"` |
80
+ | `timeout` | HTTP request timeout in seconds (default **30**) |
81
+
82
+ ---
83
+
84
+ ## API Reference
85
+
86
+ The client exposes six **groups**, each covering one area of the hardware
87
+ API. All methods are **synchronous** and raise
88
+ `AccordionQ2ApiError` on HTTP errors.
89
+
90
+ ### `client.connection` — Connection Status
91
+
92
+ | Method | Returns | Description |
93
+ |--------|---------|-------------|
94
+ | `get_status()` | `ConnectionStatusDto` | Check whether the API is connected to the hardware manager. |
95
+
96
+ ```python
97
+ status = client.connection.get_status()
98
+ if not status.is_connected:
99
+ print("Error:", status.last_error)
100
+ ```
101
+
102
+ ---
103
+
104
+ ### `client.resources` — Resource Values
105
+
106
+ Resources represent readable/writable hardware values such as voltages,
107
+ temperatures, and firmware revisions. They are identified by a dotted name
108
+ string (e.g. `"TempRegulator.CPU_TEMP"`).
109
+
110
+ | Method | Returns | Description |
111
+ |--------|---------|-------------|
112
+ | `get_names()` | `list[str]` | List all available resource names. |
113
+ | `get_value(name)` | `str` | Read the current value of a single resource. |
114
+ | `set_value(name, value)` | — | Write a value to a single resource. |
115
+ | `get_values(names)` | `dict[str, str]` | Read multiple resources in one call. |
116
+ | `set_values(resources)` | — | Write multiple resources in one call. |
117
+ | `transact(name, value)` | `str` | Write then read (command/response pattern). |
118
+
119
+ ```python
120
+ # Single read
121
+ voltage = client.resources.get_value("0.1.ESH10000158.MON_3V3")
122
+
123
+ # Batch read
124
+ values = client.resources.get_values([
125
+ "TempRegulator.CPU_TEMP",
126
+ "Engine.Uptime",
127
+ ])
128
+ for name, val in values.items():
129
+ print(f"{name} = {val}")
130
+ ```
131
+
132
+ ---
133
+
134
+ ### `client.channels` — Hardware Channels
135
+
136
+ Channels represent multi-purpose I/O pins (analog, digital, I2C, SPI, etc.).
137
+
138
+ | Method | Returns | Description |
139
+ |--------|---------|-------------|
140
+ | `get_all()` | `list[ChannelDto]` | Return every configured channel. |
141
+ | `get_channel(alias=, net_name=)` | `ChannelDto` | Look up one channel by alias or net name. |
142
+ | `configure(config)` | — | Partial-update a single channel. |
143
+ | `configure_many(configs)` | — | Partial-update multiple channels. |
144
+
145
+ ```python
146
+ from accordionq2.models import ChannelConfigRequest
147
+ from accordionq2.enums import ChannelTypes
148
+
149
+ # Look up by alias
150
+ ch = client.channels.get_channel(alias="0.1.ESH10000158.MON_3V3")
151
+ print(f"Type: {ch.channel_type}, Direction: {ch.direction}")
152
+
153
+ # Check flags
154
+ if ch.channel_type & ChannelTypes.ANALOG:
155
+ print("This is an analog channel")
156
+
157
+ # Partial update (only the fields you set are changed)
158
+ client.channels.configure(ChannelConfigRequest(
159
+ alias="0.1.ESH10000158.MON_3V3",
160
+ description="Main 3.3 V rail monitor",
161
+ unit="V",
162
+ ))
163
+ ```
164
+
165
+ ---
166
+
167
+ ### `client.modules` — Module Management
168
+
169
+ | Method | Returns | Description |
170
+ |--------|---------|-------------|
171
+ | `get_all()` | `list[ModuleSettingsDto]` | All modules (loaded and unloaded). |
172
+ | `get_loaded()` | `list[ModuleSettingsDto]` | Currently loaded modules only. |
173
+ | `load(module)` | — | Load a module. |
174
+ | `unload(module)` | — | Unload a module. |
175
+ | `configure(module)` | — | Update module configuration. |
176
+ | `get_physical_system()` | `PhysicalSystemDto` | Hardware topology (host, MAC, modules). |
177
+ | `get_licensed_apps()` | `list[AppLicenseDto]` | Licensed applications. |
178
+ | `get_all_apps()` | `list[AppLicenseDto]` | All applications. |
179
+
180
+ ```python
181
+ system = client.modules.get_physical_system()
182
+ print(f"Host: {system.host}, MAC: {system.mac}")
183
+ for mod in system.modules:
184
+ print(f" Slot {mod.index}: {mod.name} ({mod.product_id})")
185
+
186
+ for m in client.modules.get_loaded():
187
+ print(f" {m.name} (enabled={m.enabled})")
188
+ ```
189
+
190
+ ---
191
+
192
+ ### `client.application` — Application Lifecycle
193
+
194
+ | Method | Returns | Description |
195
+ |--------|---------|-------------|
196
+ | `get_name()` | `str` | Application module name. |
197
+ | `get_identification()` | `str` | Application identification string. |
198
+ | `get_status()` | `ModuleStatus` | Current status (enum). |
199
+ | `reset()` | — | Reset the application engine. |
200
+ | `list_config_files()` | `list[str]` | Available configuration files. |
201
+ | `get_loaded_config_files()` | `list[str]` | Currently loaded config files. |
202
+ | `load_config_file(name)` | — | Load a configuration file. |
203
+ | `save_config_file(name)` | — | Save configuration to a file. |
204
+ | `download_config_file(name)` | `bytes` | Download a config file as raw bytes. |
205
+ | `upload_config_file(name, data)` | — | Upload a config file (bytes). |
206
+ | `delete_config_file(name)` | — | Delete a config file from the device. |
207
+
208
+ ```python
209
+ from accordionq2.enums import ModuleStatus
210
+
211
+ status = client.application.get_status()
212
+ if status == ModuleStatus.OK:
213
+ print("Application is running normally")
214
+
215
+ # Configuration file round-trip
216
+ data = client.application.download_config_file("factory.cfg")
217
+ client.application.upload_config_file("factory_backup.cfg", data)
218
+ ```
219
+
220
+ ---
221
+
222
+ ### `client.media` — Media Files
223
+
224
+ | Method | Returns | Description |
225
+ |--------|---------|-------------|
226
+ | `list_files()` | `list[str]` | List media files on the device. |
227
+ | `download_file(name)` | `bytes` | Download a media file. |
228
+ | `upload_file(name, data)` | — | Upload a media file (bytes). |
229
+ | `delete_file(name)` | — | Delete a media file. |
230
+
231
+ ```python
232
+ for f in client.media.list_files():
233
+ print(f)
234
+
235
+ # Download and save locally
236
+ content = client.media.download_file("waveform.bin")
237
+ with open("waveform.bin", "wb") as fp:
238
+ fp.write(content)
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Models
244
+
245
+ All models live in `accordionq2.models`.
246
+
247
+ | Class | Description |
248
+ |-------|-------------|
249
+ | `ConnectionStatusDto` | `is_connected` (bool), `last_error` (str or None) |
250
+ | `ChannelDto` | Full channel description (18 fields including type, direction, alias, unit, etc.) |
251
+ | `ChannelConfigRequest` | Partial-update request — only non-`None` fields are applied |
252
+ | `ChannelLookupRequest` | Identify a channel by `alias` or `net_name` |
253
+ | `ModuleSettingsDto` | Module configuration (`name`, `enabled`, `class_name`, `initial_data`, etc.) |
254
+ | `PhysicalSystemDto` | Hardware topology (`host`, `mac`, `firmware`, `modules` list) |
255
+ | `PhysicalModuleDto` | One hardware slot (`index`, `name`, `product_id`, `revision`, `serial_number`) |
256
+ | `AppLicenseDto` | License info (`name`, `key`, `expires`, `type`) |
257
+
258
+ Response models provide a `from_dict(data)` class method; request models
259
+ provide a `to_dict()` instance method.
260
+
261
+ ## Enumerations
262
+
263
+ All enums live in `accordionq2.enums`.
264
+
265
+ | Enum | Type | Values |
266
+ |------|------|--------|
267
+ | `ModuleStatus` | `str, Enum` | `UNKNOWN`, `OK`, `WARNING`, `ERROR`, `DISABLED` |
268
+ | `AppTypes` | `str, Enum` | `UNKNOWN`, `SOFTWARE_MODULE`, `HARDWARE_MODULE` |
269
+ | `MpioUsageTypes` | `str, Enum` | `UNDEFINED`, `HIDDEN_SYSTEM_CONTROL`, `READ_ONLY_SYSTEM_CONTROL`, `USER_ALLOCATABLE`, `BUS_SIGNAL` |
270
+ | `DirectionTypes` | `IntFlag` | `UNDEFINED`, `IN`, `OUT` |
271
+ | `ChannelTypes` | `IntFlag` | `UNDEFINED`, `ANALOG`, `DIGITAL`, `TEMPERATURE`, `I2C`, `SPI`, `UART`, and many more |
272
+
273
+ `IntFlag` enums support bitwise operations:
274
+
275
+ ```python
276
+ from accordionq2.enums import ChannelTypes, DirectionTypes
277
+
278
+ combined = ChannelTypes.ANALOG | ChannelTypes.DIGITAL
279
+ if ch.channel_type & ChannelTypes.I2C:
280
+ print("I2C channel")
281
+
282
+ if ch.direction & DirectionTypes.IN:
283
+ print("Input capable")
284
+ ```
285
+
286
+ ---
287
+
288
+ ## Error Handling
289
+
290
+ All API errors raise `AccordionQ2ApiError` (importable from the top-level
291
+ package). The exception carries the HTTP status code and the server's error
292
+ message:
293
+
294
+ ```python
295
+ from accordionq2 import AccordionQ2ApiError
296
+
297
+ try:
298
+ ch = client.channels.get_channel(alias="does.not.exist")
299
+ except AccordionQ2ApiError as e:
300
+ print(f"HTTP {e.status_code}: {e}")
301
+ ```
302
+
303
+ ---
304
+
305
+ ## Running the Integration Tests
306
+
307
+ The test suite uses [pytest](https://docs.pytest.org/) and talks to a live
308
+ AccordionQ2 device.
309
+
310
+ ```bash
311
+ # Install with test dependencies
312
+ pip install -e ".[dev]"
313
+
314
+ # Run all integration tests
315
+ pytest tests/ -m integration -v
316
+
317
+ # Override the default device URL
318
+ ACCORDIONQ2_API_URL=http://mydevice:5000 pytest tests/ -m integration
319
+ ```
320
+
321
+ The default URL is `http://agent64.local:5000`.
322
+
323
+ ---
324
+
325
+ ## Comparison with the .NET Client
326
+
327
+ Both clients expose the same API surface with idiomatic naming for their
328
+ respective language:
329
+
330
+ | Concept | .NET (`AccordionQ2Client`) | Python (`AccordionQ2Client`) |
331
+ |---------|---------------------------|------------------------------|
332
+ | Lifecycle | `IDisposable` / `using` | Context manager / `with` |
333
+ | Methods | `GetValueAsync(name)` | `get_value(name)` |
334
+ | Concurrency | `async` / `await` | Synchronous (thread-safe) |
335
+ | Nullability | `string?` | `None` |
336
+ | Config | `ChannelConfigRequest.Enabled = true` | `ChannelConfigRequest(enabled=True)` |
337
+ | Enums | `ChannelTypes.Analog` | `ChannelTypes.ANALOG` |
338
+ | Errors | `AccordionQ2ApiException` | `AccordionQ2ApiError` |
339
+ | Dependencies | Newtonsoft.Json | None (stdlib only) |
340
+
341
+ ---
342
+
343
+ ## License
344
+
345
+ Proprietary — see your license agreement for details.
@@ -0,0 +1,334 @@
1
+ # AccordionQ2 Python Client
2
+
3
+ Python client library for the **AccordionQ2 Hardware Management REST API**.
4
+ This is the Python counterpart of the
5
+ [.NET WebApiClient](https://git.esharp.se/esharp/accordion-projects/webapiclient);
6
+ both libraries expose the same API surface so switching between them feels
7
+ natural.
8
+
9
+ ## Requirements
10
+
11
+ | Requirement | Details |
12
+ |-------------|---------|
13
+ | Python | 3.8 or later |
14
+ | Platform | Windows, Linux (including ARM / Raspberry Pi) |
15
+ | Architecture | 32-bit and 64-bit |
16
+ | Dependencies | **None** — stdlib only (`urllib`, `json`, `enum`, `dataclasses`) |
17
+
18
+ ## Installation
19
+
20
+ Install directly from a local checkout (editable mode recommended during
21
+ development):
22
+
23
+ ```bash
24
+ pip install -e .
25
+ ```
26
+
27
+ Or, for a regular install:
28
+
29
+ ```bash
30
+ pip install .
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ```python
36
+ from accordionq2 import AccordionQ2Client
37
+
38
+ with AccordionQ2Client("http://agent64.local:5000") as client:
39
+ # Check the hardware connection
40
+ status = client.connection.get_status()
41
+ print("Connected:", status.is_connected)
42
+
43
+ # Read a sensor value
44
+ temp = client.resources.get_value("TempRegulator.CPU_TEMP")
45
+ print("CPU temperature:", temp)
46
+
47
+ # List all channels
48
+ for ch in client.channels.get_all():
49
+ print(f" {ch.alias}: type={ch.channel_type}, unit={ch.unit}")
50
+ ```
51
+
52
+ The client can also be used without a `with` block:
53
+
54
+ ```python
55
+ client = AccordionQ2Client("http://agent64.local:5000")
56
+ names = client.resources.get_names()
57
+ client.close()
58
+ ```
59
+
60
+ ### Constructor
61
+
62
+ ```python
63
+ AccordionQ2Client(base_url, timeout=30.0)
64
+ ```
65
+
66
+ | Parameter | Description |
67
+ |------------|-------------|
68
+ | `base_url` | Base URL of the AccordionQ2 WebApi, e.g. `"http://raspberrypi:5000"` |
69
+ | `timeout` | HTTP request timeout in seconds (default **30**) |
70
+
71
+ ---
72
+
73
+ ## API Reference
74
+
75
+ The client exposes six **groups**, each covering one area of the hardware
76
+ API. All methods are **synchronous** and raise
77
+ `AccordionQ2ApiError` on HTTP errors.
78
+
79
+ ### `client.connection` — Connection Status
80
+
81
+ | Method | Returns | Description |
82
+ |--------|---------|-------------|
83
+ | `get_status()` | `ConnectionStatusDto` | Check whether the API is connected to the hardware manager. |
84
+
85
+ ```python
86
+ status = client.connection.get_status()
87
+ if not status.is_connected:
88
+ print("Error:", status.last_error)
89
+ ```
90
+
91
+ ---
92
+
93
+ ### `client.resources` — Resource Values
94
+
95
+ Resources represent readable/writable hardware values such as voltages,
96
+ temperatures, and firmware revisions. They are identified by a dotted name
97
+ string (e.g. `"TempRegulator.CPU_TEMP"`).
98
+
99
+ | Method | Returns | Description |
100
+ |--------|---------|-------------|
101
+ | `get_names()` | `list[str]` | List all available resource names. |
102
+ | `get_value(name)` | `str` | Read the current value of a single resource. |
103
+ | `set_value(name, value)` | — | Write a value to a single resource. |
104
+ | `get_values(names)` | `dict[str, str]` | Read multiple resources in one call. |
105
+ | `set_values(resources)` | — | Write multiple resources in one call. |
106
+ | `transact(name, value)` | `str` | Write then read (command/response pattern). |
107
+
108
+ ```python
109
+ # Single read
110
+ voltage = client.resources.get_value("0.1.ESH10000158.MON_3V3")
111
+
112
+ # Batch read
113
+ values = client.resources.get_values([
114
+ "TempRegulator.CPU_TEMP",
115
+ "Engine.Uptime",
116
+ ])
117
+ for name, val in values.items():
118
+ print(f"{name} = {val}")
119
+ ```
120
+
121
+ ---
122
+
123
+ ### `client.channels` — Hardware Channels
124
+
125
+ Channels represent multi-purpose I/O pins (analog, digital, I2C, SPI, etc.).
126
+
127
+ | Method | Returns | Description |
128
+ |--------|---------|-------------|
129
+ | `get_all()` | `list[ChannelDto]` | Return every configured channel. |
130
+ | `get_channel(alias=, net_name=)` | `ChannelDto` | Look up one channel by alias or net name. |
131
+ | `configure(config)` | — | Partial-update a single channel. |
132
+ | `configure_many(configs)` | — | Partial-update multiple channels. |
133
+
134
+ ```python
135
+ from accordionq2.models import ChannelConfigRequest
136
+ from accordionq2.enums import ChannelTypes
137
+
138
+ # Look up by alias
139
+ ch = client.channels.get_channel(alias="0.1.ESH10000158.MON_3V3")
140
+ print(f"Type: {ch.channel_type}, Direction: {ch.direction}")
141
+
142
+ # Check flags
143
+ if ch.channel_type & ChannelTypes.ANALOG:
144
+ print("This is an analog channel")
145
+
146
+ # Partial update (only the fields you set are changed)
147
+ client.channels.configure(ChannelConfigRequest(
148
+ alias="0.1.ESH10000158.MON_3V3",
149
+ description="Main 3.3 V rail monitor",
150
+ unit="V",
151
+ ))
152
+ ```
153
+
154
+ ---
155
+
156
+ ### `client.modules` — Module Management
157
+
158
+ | Method | Returns | Description |
159
+ |--------|---------|-------------|
160
+ | `get_all()` | `list[ModuleSettingsDto]` | All modules (loaded and unloaded). |
161
+ | `get_loaded()` | `list[ModuleSettingsDto]` | Currently loaded modules only. |
162
+ | `load(module)` | — | Load a module. |
163
+ | `unload(module)` | — | Unload a module. |
164
+ | `configure(module)` | — | Update module configuration. |
165
+ | `get_physical_system()` | `PhysicalSystemDto` | Hardware topology (host, MAC, modules). |
166
+ | `get_licensed_apps()` | `list[AppLicenseDto]` | Licensed applications. |
167
+ | `get_all_apps()` | `list[AppLicenseDto]` | All applications. |
168
+
169
+ ```python
170
+ system = client.modules.get_physical_system()
171
+ print(f"Host: {system.host}, MAC: {system.mac}")
172
+ for mod in system.modules:
173
+ print(f" Slot {mod.index}: {mod.name} ({mod.product_id})")
174
+
175
+ for m in client.modules.get_loaded():
176
+ print(f" {m.name} (enabled={m.enabled})")
177
+ ```
178
+
179
+ ---
180
+
181
+ ### `client.application` — Application Lifecycle
182
+
183
+ | Method | Returns | Description |
184
+ |--------|---------|-------------|
185
+ | `get_name()` | `str` | Application module name. |
186
+ | `get_identification()` | `str` | Application identification string. |
187
+ | `get_status()` | `ModuleStatus` | Current status (enum). |
188
+ | `reset()` | — | Reset the application engine. |
189
+ | `list_config_files()` | `list[str]` | Available configuration files. |
190
+ | `get_loaded_config_files()` | `list[str]` | Currently loaded config files. |
191
+ | `load_config_file(name)` | — | Load a configuration file. |
192
+ | `save_config_file(name)` | — | Save configuration to a file. |
193
+ | `download_config_file(name)` | `bytes` | Download a config file as raw bytes. |
194
+ | `upload_config_file(name, data)` | — | Upload a config file (bytes). |
195
+ | `delete_config_file(name)` | — | Delete a config file from the device. |
196
+
197
+ ```python
198
+ from accordionq2.enums import ModuleStatus
199
+
200
+ status = client.application.get_status()
201
+ if status == ModuleStatus.OK:
202
+ print("Application is running normally")
203
+
204
+ # Configuration file round-trip
205
+ data = client.application.download_config_file("factory.cfg")
206
+ client.application.upload_config_file("factory_backup.cfg", data)
207
+ ```
208
+
209
+ ---
210
+
211
+ ### `client.media` — Media Files
212
+
213
+ | Method | Returns | Description |
214
+ |--------|---------|-------------|
215
+ | `list_files()` | `list[str]` | List media files on the device. |
216
+ | `download_file(name)` | `bytes` | Download a media file. |
217
+ | `upload_file(name, data)` | — | Upload a media file (bytes). |
218
+ | `delete_file(name)` | — | Delete a media file. |
219
+
220
+ ```python
221
+ for f in client.media.list_files():
222
+ print(f)
223
+
224
+ # Download and save locally
225
+ content = client.media.download_file("waveform.bin")
226
+ with open("waveform.bin", "wb") as fp:
227
+ fp.write(content)
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Models
233
+
234
+ All models live in `accordionq2.models`.
235
+
236
+ | Class | Description |
237
+ |-------|-------------|
238
+ | `ConnectionStatusDto` | `is_connected` (bool), `last_error` (str or None) |
239
+ | `ChannelDto` | Full channel description (18 fields including type, direction, alias, unit, etc.) |
240
+ | `ChannelConfigRequest` | Partial-update request — only non-`None` fields are applied |
241
+ | `ChannelLookupRequest` | Identify a channel by `alias` or `net_name` |
242
+ | `ModuleSettingsDto` | Module configuration (`name`, `enabled`, `class_name`, `initial_data`, etc.) |
243
+ | `PhysicalSystemDto` | Hardware topology (`host`, `mac`, `firmware`, `modules` list) |
244
+ | `PhysicalModuleDto` | One hardware slot (`index`, `name`, `product_id`, `revision`, `serial_number`) |
245
+ | `AppLicenseDto` | License info (`name`, `key`, `expires`, `type`) |
246
+
247
+ Response models provide a `from_dict(data)` class method; request models
248
+ provide a `to_dict()` instance method.
249
+
250
+ ## Enumerations
251
+
252
+ All enums live in `accordionq2.enums`.
253
+
254
+ | Enum | Type | Values |
255
+ |------|------|--------|
256
+ | `ModuleStatus` | `str, Enum` | `UNKNOWN`, `OK`, `WARNING`, `ERROR`, `DISABLED` |
257
+ | `AppTypes` | `str, Enum` | `UNKNOWN`, `SOFTWARE_MODULE`, `HARDWARE_MODULE` |
258
+ | `MpioUsageTypes` | `str, Enum` | `UNDEFINED`, `HIDDEN_SYSTEM_CONTROL`, `READ_ONLY_SYSTEM_CONTROL`, `USER_ALLOCATABLE`, `BUS_SIGNAL` |
259
+ | `DirectionTypes` | `IntFlag` | `UNDEFINED`, `IN`, `OUT` |
260
+ | `ChannelTypes` | `IntFlag` | `UNDEFINED`, `ANALOG`, `DIGITAL`, `TEMPERATURE`, `I2C`, `SPI`, `UART`, and many more |
261
+
262
+ `IntFlag` enums support bitwise operations:
263
+
264
+ ```python
265
+ from accordionq2.enums import ChannelTypes, DirectionTypes
266
+
267
+ combined = ChannelTypes.ANALOG | ChannelTypes.DIGITAL
268
+ if ch.channel_type & ChannelTypes.I2C:
269
+ print("I2C channel")
270
+
271
+ if ch.direction & DirectionTypes.IN:
272
+ print("Input capable")
273
+ ```
274
+
275
+ ---
276
+
277
+ ## Error Handling
278
+
279
+ All API errors raise `AccordionQ2ApiError` (importable from the top-level
280
+ package). The exception carries the HTTP status code and the server's error
281
+ message:
282
+
283
+ ```python
284
+ from accordionq2 import AccordionQ2ApiError
285
+
286
+ try:
287
+ ch = client.channels.get_channel(alias="does.not.exist")
288
+ except AccordionQ2ApiError as e:
289
+ print(f"HTTP {e.status_code}: {e}")
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Running the Integration Tests
295
+
296
+ The test suite uses [pytest](https://docs.pytest.org/) and talks to a live
297
+ AccordionQ2 device.
298
+
299
+ ```bash
300
+ # Install with test dependencies
301
+ pip install -e ".[dev]"
302
+
303
+ # Run all integration tests
304
+ pytest tests/ -m integration -v
305
+
306
+ # Override the default device URL
307
+ ACCORDIONQ2_API_URL=http://mydevice:5000 pytest tests/ -m integration
308
+ ```
309
+
310
+ The default URL is `http://agent64.local:5000`.
311
+
312
+ ---
313
+
314
+ ## Comparison with the .NET Client
315
+
316
+ Both clients expose the same API surface with idiomatic naming for their
317
+ respective language:
318
+
319
+ | Concept | .NET (`AccordionQ2Client`) | Python (`AccordionQ2Client`) |
320
+ |---------|---------------------------|------------------------------|
321
+ | Lifecycle | `IDisposable` / `using` | Context manager / `with` |
322
+ | Methods | `GetValueAsync(name)` | `get_value(name)` |
323
+ | Concurrency | `async` / `await` | Synchronous (thread-safe) |
324
+ | Nullability | `string?` | `None` |
325
+ | Config | `ChannelConfigRequest.Enabled = true` | `ChannelConfigRequest(enabled=True)` |
326
+ | Enums | `ChannelTypes.Analog` | `ChannelTypes.ANALOG` |
327
+ | Errors | `AccordionQ2ApiException` | `AccordionQ2ApiError` |
328
+ | Dependencies | Newtonsoft.Json | None (stdlib only) |
329
+
330
+ ---
331
+
332
+ ## License
333
+
334
+ Proprietary — see your license agreement for details.
@@ -0,0 +1,7 @@
1
+ """AccordionQ2 Python client library for the Hardware Management REST API."""
2
+
3
+ from .client import AccordionQ2Client
4
+ from .exceptions import AccordionQ2ApiError
5
+
6
+ __all__ = ["AccordionQ2Client", "AccordionQ2ApiError"]
7
+ __version__ = "1.0.0"