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

on_message(client, userdata, msg)

Route incoming MQTT control messages into the allocation loop.

on_subscribe(client, userdata, mid, granted_qos)

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 (reinitialises OzWrapper.OzOGS.OzOGS.OzOGS).

Parameters:
  • client – The paho.mqtt.client.Client instance.

  • userdata – User-defined data set on the client (unused).

  • msg (paho.mqtt.client.MQTTMessage) – Incoming message; topic, qos and payload are inspected. The payload itself is ignored for routing - only topic matters.

Returns:

Mutates module-level flags.

Return type:

None

Raises:

None – All branches are simple flag assignments.

Example

>>> client.publish("/ogs/start", "")

Note

The /ogs/ledstatus branch 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.mqtt on_subscribe callback signature; emits a single Subscribed: <mid> <qos> line so the operator can confirm that /ogs/start and /ogs/restart are wired up.

Parameters:
  • client – The paho.mqtt.client.Client instance.

  • 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