Initial content, migrated from the aml gateway rpi7-am-1
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
# bar-detection
|
# bar-detection
|
||||||
|
|
||||||
Detects bars entering and leaving the oven and writes in-detect-oven / out-detect-oven
|
Runs continuously, once a second. Detects a bar entering the oven on the rising edge of the
|
||||||
|
entry photocell `Hin` (3) and writes a pulse to `in-detect-oven` (11). Detects a bar leaving
|
||||||
|
when the reading it calls `THact` crosses above 600 and writes a pulse to `out-detect-oven`
|
||||||
|
(12). Both outputs are i7state pulse signals, consumed by `bar-tracker`.
|
||||||
|
|
||||||
|
**Known mismatch, kept as it runs today:** `signals.yml` maps id 17 to the name `THact`, but
|
||||||
|
signal 17 is `THprocess`; the real `THact` is 18. The exit trigger therefore fires on
|
||||||
|
`THprocess`. Correcting it means changing the id to 18 in `signals.yml` and tagging a new
|
||||||
|
version.
|
||||||
|
|
||||||
|
Runs in `docker.izazpi.cloud/aml/aml-python`; the version is in `schedule.yaml`.
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
from i7lib.client import run
|
||||||
|
|
||||||
|
prev_hin = 1.0
|
||||||
|
prev_thact = 610.0
|
||||||
|
|
||||||
|
|
||||||
|
def logic(plant):
|
||||||
|
global prev_hin, prev_thact
|
||||||
|
|
||||||
|
hin = plant.state.get("Hin", 0.0)
|
||||||
|
thact = plant.state.get("THact", 0.0)
|
||||||
|
|
||||||
|
batch = plant.new_write_batch()
|
||||||
|
|
||||||
|
if hin > 0 and prev_hin == 0:
|
||||||
|
batch.add(signal_id=11, value=1.0, name="in-detect-oven")
|
||||||
|
|
||||||
|
if thact > 600 and prev_thact <= 600:
|
||||||
|
batch.add(signal_id=12, value=1.0, name="out-detect-oven")
|
||||||
|
|
||||||
|
if batch.payload:
|
||||||
|
plant.send(batch)
|
||||||
|
|
||||||
|
prev_hin = hin
|
||||||
|
prev_thact = thact
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run(logic, interval_ms=1000, offset_ms=100)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: bar-detection
|
||||||
|
active: true
|
||||||
|
schedule: "* * * * *"
|
||||||
|
action: ensure
|
||||||
|
runOnStartup: true
|
||||||
|
imageName: docker.izazpi.cloud/aml/aml-python:0.1.0
|
||||||
|
command: ["python", "/app/bar_detection.py"]
|
||||||
|
maxCpuCores: 0.5
|
||||||
|
maxMemoryMb: 128
|
||||||
|
autoremove: false
|
||||||
|
logOption: 1
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
- { id: 3, name: 'Hin', read: 1, write: 0 }
|
||||||
|
- { id: 17, name: 'THact', read: 1, write: 0 }
|
||||||
|
- { id: 11, name: 'in-detect-oven', read: 0, write: 1 }
|
||||||
|
- { id: 12, name: 'out-detect-oven', read: 0, write: 1 }
|
||||||
Reference in New Issue
Block a user