OzWrapper.OzOGS.OzOGS_Allocation¶
Standalone factory allocation harness for the OGS array.
Boots an instance of OzWrapper.OzOGS.OzOGS.OzOGS outside the
main Sensor orchestrator, drives one reading cycle at a time on demand
via MQTT control topics on broker.hivemq.com, and reflects state on
the front-panel RGB LED through OzWrapper.OzRGB.OzRGB. Used on
the factory bench when commissioning a new gas-sensor board and
producing the slot-to-gas allocation map that the runtime configuration
will eventually carry.
- MQTT topics:
/ogs/start(sub) - trigger one read+publish cycle./ogs/restart(sub) - reinitialise the OGS wrapper./ogs/ledstatus(pub) - human-readable status string./ogs/data(pub) - averaged readings as JSON.
Example
>>> import OzWrapper.OzOGS.OzOGS_Allocation
Note
Reads its OGS configuration from allocation_ogs.json co-located
with this module. See OzWrapper.OzOGS.OzOGS for the sensor
wrapper contract this script drives, and the same module’s
reference JSON for the expected ogs configuration shape.
Attributes¶
Functions¶
|
Route incoming MQTT control messages into the allocation loop. |
|
Log MQTT subscription acknowledgements from the broker. |
Module Contents¶
- OzWrapper.OzOGS.OzOGS_Allocation.on_message(client, userdata, msg)[source]¶
Route incoming MQTT control messages into the allocation loop.
Sets the module-global flags consumed by the main loop in
__main__:/ogs/start->flagStart = True(triggers one read+publish)./ogs/restart->restartFlag = True(reinitialisesOzWrapper.OzOGS.OzOGS.OzOGS).
- Parameters:
client – The
paho.mqtt.client.Clientinstance.userdata – User-defined data set on the client (unused).
msg (
paho.mqtt.client.MQTTMessage) – Incoming message;topic,qosandpayloadare inspected. The payload itself is ignored for routing - onlytopicmatters.
- Returns:
Mutates module-level flags.
- Return type:
None
- Raises:
None – All branches are simple flag assignments.
Example
>>> client.publish("/ogs/start", "")
Note
The
/ogs/ledstatusbranch is intentionally commented out because the LED status flag is now driven by the main loop directly, not by an external trigger.
- OzWrapper.OzOGS.OzOGS_Allocation.on_subscribe(client, userdata, mid, granted_qos)[source]¶
Log MQTT subscription acknowledgements from the broker.
Standard
paho.mqtton_subscribecallback signature; emits a singleSubscribed: <mid> <qos>line so the operator can confirm that/ogs/startand/ogs/restartare wired up.- Parameters:
client – The
paho.mqtt.client.Clientinstance.userdata – User-defined data set on the client (unused).
mid (
int) – Message ID of the subscribe request.granted_qos (
list[int]) – QoS levels granted per topic by the broker.
- Returns:
Side effect only - prints to stdout.
- Return type:
None
- Raises:
None – All work is a single print call.
Example
>>> on_subscribe(client, None, 1, [1])
Note
Wired up at module import time on the global
client.
- OzWrapper.OzOGS.OzOGS_Allocation.client¶
- OzWrapper.OzOGS.OzOGS_Allocation.flagStart = False¶
- OzWrapper.OzOGS.OzOGS_Allocation.network_status¶
- OzWrapper.OzOGS.OzOGS_Allocation.restartFlag = True¶