---
# Model of the figure 'measurement-steps'. Edit this file; `kokeb-docs figures` draws it. Never edit the SVGs.
kind: seq
id: measurement-steps
title: "Start, wait and read one measurement"
alt: >-
  One measurement with the SFM executor: StartMeasurement reads the scale factors and starts the sensor, your code
  sleeps the returned wait and polls, and ReadSample then reads nine bytes, checks each CRC and returns a sample.
reads: >-
  Participants, left to right: Your code, SfmFlowMeter<Port> and Your port. The steps run from top to bottom. Your code sends StartMeasurement(Air) to SfmFlowMeter<Port>. SfmFlowMeter<Port> sends Write(read-scale command) to Your port. Your port returns true to SfmFlowMeter<Port>. SfmFlowMeter<Port> sends Read(9 bytes: scale, offset, unit + CRC) to Your port. Your port returns true to SfmFlowMeter<Port>. A note over SfmFlowMeter<Port> says: CRC, compare with the table. SfmFlowMeter<Port> sends Write(start command) to Your port. SfmFlowMeter<Port> returns Result<Wait>{12 ms} to Your code. Your code does sleep 12 ms itself. Your code sends Poll() to SfmFlowMeter<Port>. SfmFlowMeter<Port> returns Result<Wait>{0} (measuring) to Your code. Your code sends ReadSample() to SfmFlowMeter<Port>. SfmFlowMeter<Port> sends Read(9 bytes) to Your port. A note over SfmFlowMeter<Port> says: CRC per word, status check, scale. SfmFlowMeter<Port> returns Result<Sample> to Your code.
print: landscape
sources:
  - docs/model/measurement-steps.seq.yml
participants:
  - {id: app, label: "Your code", tone: magenta}
  - {id: core, label: "SfmFlowMeter<Port>", tone: green}
  - {id: port, label: "Your port", tone: teal}
steps:
  - {from: app, to: core, label: "StartMeasurement(Air)"}
  - {from: core, to: port, label: "Write(read-scale command)"}
  - {from: port, to: core, label: "true", return: true}
  - {from: core, to: port, label: "Read(9 bytes: scale, offset, unit + CRC)"}
  - {from: port, to: core, label: "true", return: true}
  - {note: "CRC, compare with the table", over: [core, port]}
  - {from: core, to: port, label: "Write(start command)"}
  - {from: core, to: app, label: "Result<Wait>{12 ms}", return: true}
  - {from: app, to: app, label: "sleep 12 ms"}
  - {from: app, to: core, label: "Poll()"}
  - {from: core, to: app, label: "Result<Wait>{0} (measuring)", return: true}
  - {from: app, to: core, label: "ReadSample()"}
  - {from: core, to: port, label: "Read(9 bytes)"}
  - {note: "CRC per word, status check, scale", over: [core, port]}
  - {from: core, to: app, label: "Result<Sample>", return: true}
