Diese Seite wurde maschinell übersetzt und wurde noch nicht von einer Person überprüft. Englisch ist die Referenz; Korrekturen auf GitHub sind willkommen. GitHub

Cookwala / SDK und Szenarien / 022

A deep-fry trace inside the band, one that runs hot, and the limit that cuts heat at 200 degC

Deep frying is oil at 160 to 190 degC with a one-rung ladder. The envelope check reads the trace; the SafetyLimits pack says what the device does when oil passes 200 degC: cut heat.

Zielgruppe: robot maker · Ziel: Roboter für Menschen · Level: beginner

Zuerst lesen: /docs/CORE/ /docs/QUICKSTART/

Schritte

  1. Oil warms to 170, 178 and 175 degC with the koshari target of 175 plus or minus 10. checkEnvelope

  2. The oil climbs to 205 degC: it left the envelope. checkEnvelope

  3. The first limit in the default pack applies to frying and deep frying: above 200 degC the device cuts heat on its own. safetyLimits

  4. Without an oil thermometer there is no rung, even with a person watching. ladder

  5. The ladder answer is null.

Ergebnis

You know the three facts a fryer must implement: the band, the single rung, and the local limit above it. Next: scenario 034 plans koshari on the fryer robot with estimates forbidden.

Kommandozeile

printf '[{"t": 0, "tempC": 150}, {"t": 30, "tempC": 170}, {"t": 60, "tempC": 178}, {"t": 90, "tempC": 175}]' > trace.json && cookwala envelope cw.op.deep_fry trace.json --target 175 --tolerance 10
printf '[{"t": 0, "tempC": 150}, {"t": 30, "tempC": 170}, {"t": 60, "tempC": 185}, {"t": 90, "tempC": 205}]' > trace.json && cookwala envelope cw.op.deep_fry trace.json --target 175 --tolerance 10
curl -s http://localhost:7878/v1/safety-limits

Aufgezeichnete Ausgabe

Status: ok

[1] checkEnvelope: {"envelopeOk": true, "targetOk": true, "reason": "ok"}
[2] checkEnvelope: {"envelopeOk": false, "targetOk": false, "reason": "left_envelope"}
[3] safetyLimits: {"core": "0.2.0", "kind": "SafetyLimits", "id": "cookwala-default", "version": "0.2.0", "status": "draft", "limits": [{"id": "oil.max_temp", "kind": "max_temp", "action": "cut_heat", "message": "Cut heat above 200 °C: most cooking oils smoke and fire risk rises.", "source": "Common frying-oil smoke points; fire-safety practice", "appliesTo": {"medium": "oil", "ops": ["cw.op.fry", "cw.op.deep_fry"]}, "max": 200, "unit": "degC"}, {"id": "pan.max_surface", "kind": "max_temp", "action": "cut_heat", "message": "Cut heat above 280 °C pan surface (coatings degrade, oil ignites).", "source": "Cookware…
[4] ladder: null

Code

Ausführen: python scenarios/out/022-deep-fry-trace-and-the-oil-limit/python.py

# Scenario 022: A deep-fry trace inside the band, one that runs hot, and the limit that cuts heat at 200 degC
# Deep frying is oil at 160 to 190 degC with a one-rung ladder. The envelope check reads the trace; the SafetyLimits pack says what the device does when oil passes 200 degC: cut heat.
# Run a hub first: python hub/cookwala_hub.py --recipes examples
import json, os
from cookwala.client import CookwalaClient, CookwalaProblem

def load(path):
    with open(path, encoding="utf-8") as f:
        return json.load(f)

def pick(obj, path):
    for part in path.replace("]", "").replace("[", ".").split("."):
        obj = obj[int(part)] if part.isdigit() else (len(obj) if part == "length" else obj.get(part))
    return obj

c = CookwalaClient(os.environ.get("COOKWALA_HUB", "http://localhost:7878"))


# Step 1: Oil warms to 170, 178 and 175 degC with the koshari target of 175 plus or minus 10.
ok = c.check_envelope("cw.op.deep_fry", [{"t": 0, "tempC": 150}, {"t": 60, "tempC": 170}, {"t": 120, "tempC": 178}, {"t": 180, "tempC": 175}], {"value": 175, "tolerance": 10})
assert pick(ok, "envelopeOk") == True, pick(ok, "envelopeOk")
print("ok", "envelopeOk", "=", True)
assert pick(ok, "targetOk") == True, pick(ok, "targetOk")
print("ok", "targetOk", "=", True)
assert pick(ok, "reason") == "ok", pick(ok, "reason")
print("ok", "reason", "=", "ok")

# Step 2: The oil climbs to 205 degC: it left the envelope.
hot = c.check_envelope("cw.op.deep_fry", [{"t": 0, "tempC": 150}, {"t": 60, "tempC": 170}, {"t": 120, "tempC": 185}, {"t": 180, "tempC": 205}], {"value": 175, "tolerance": 10})
assert pick(hot, "envelopeOk") == False, pick(hot, "envelopeOk")
print("ok", "envelopeOk", "=", False)
assert pick(hot, "targetOk") == False, pick(hot, "targetOk")
print("ok", "targetOk", "=", False)
assert pick(hot, "reason") == "left_envelope", pick(hot, "reason")
print("ok", "reason", "=", "left_envelope")

# Step 3: The first limit in the default pack applies to frying and deep frying: above 200 degC the device cuts heat on its own.
limits = c.safety_limits()
assert pick(limits, "limits[0].id") == "oil.max_temp", pick(limits, "limits[0].id")
print("ok", "limits[0].id", "=", "oil.max_temp")
assert pick(limits, "limits[0].kind") == "max_temp", pick(limits, "limits[0].kind")
print("ok", "limits[0].kind", "=", "max_temp")
assert pick(limits, "limits[0].max") == 200, pick(limits, "limits[0].max")
print("ok", "limits[0].max", "=", 200)
assert pick(limits, "limits[0].action") == "cut_heat", pick(limits, "limits[0].action")
print("ok", "limits[0].action", "=", "cut_heat")
assert pick(limits, "limits[0].appliesTo.ops[1]") == "cw.op.deep_fry", pick(limits, "limits[0].appliesTo.ops[1]")
print("ok", "limits[0].appliesTo.ops[1]", "=", "cw.op.deep_fry")

# Step 4: Without an oil thermometer there is no rung, even with a person watching.
rung = c.ladder("cw.op.deep_fry", ["cw.sense.vision", "cw.sense.pan_surface_temp"], True, True)

# Step 5: The ladder answer is null.
assert rung == None, rung
print("ok", "rung", "=", None)

print("scenario complete")

scenarios/022-deep-fry-trace-and-the-oil-limit.json

Zurück: 021 Weiter: 023