5. 详细时序图

此处列举了每个功能的详细时序图

5.1. 握手

数据格式定义见: 握手格式(handshake)

!pragma teoz true
participant 手机 as P #cyan
box 设备 #LightBlue
box BLE
participant Write as W #khaki
participant Indication as I  #lightgreen
end box
participant MCU as M #deepskyblue
participant 传感器 as S #lightcoral
end box

autonumber
note over W, S: 上电
M -> S : 检查传感器种类
...
note over P, I: 手机连接BLE
...
== 发送命令 ==

P ->(10) W : Lynx.request.handshake()
W -> M:
M -> I:
P (10)<- I : Lynx.response.handshake(\n\t softVersion, \n\t hardwareType,\n\t error)

5.2. 压力垫计时

此功能涉及到 副驾格式(copilot)测量格式(measure)

设备收到测量命令之后开始采集传感器。

如果在超时时间内主副压力垫依次检测到松开和踩上,那么会返回结果。 最终的 result 是从主压力垫松开到副压力垫踩上的时间,单位是毫秒。

如果未能在超时时间内采集到合法的传感器信号,那么会返回对应的错误。

!pragma teoz true
participant 手机 as P #cyan
box 设备(开始) #LightBlue
box BLE
participant Write as W #khaki
participant Indication as I  #lightgreen
participant Central as C  #darkseagreen
end box
participant MCU as M #deepskyblue
participant 传感器 as S #lightcoral
end box

box 设备(结束) #LightBlue
participant BLE as B2
participant MCU as M2 #deepskyblue
participant 传感器 as S2 #lightcoral
participant NFC as N2 #coral
end box


autonumber
...
note over P, I: 手机连接BLE
...

== 添加压力垫计时(结束)设备 ==

P <- N2 : 读取设备的 NFC Tag, 获取设备序列号
P ->(10) W : Lynx.request.copilot(sn, \n\t timeoutInSecond)
W -> M :
M -> I :
I ->(10) P: Lynx.response.copilot(error)

M -> C ++:
note over C, B2 : 设备互联
C -> M --:

M -> I :
I ->(10) P : Lynx.indication.copilot(error)

== 发送命令 ==

P ->(10) W : Lynx.request.measure(start,\n\t  timeoutInSecond)
W -> M :
note over C, B2 : 信息同步
M -> I:
I ->(10) P: Lynx.response.measure(error)

== 开始测量 ==
?-> M ++:
M -> S :
& M2 -> S2 :
note over M, S2 : 持续检测,直到有结果或超时
S -> M :
S2 -> M2 :
note over C, B2 : 返回结果给(开始)设备
C -> M :

== 测量完毕 ==
M -> I -- :
P (10)<- I : Lynx.indication.measure(result, error)

5.3. 坐位体前屈测距

此功能涉及到 测量格式(measure)

设备收到测量命令之后开始采集传感器。

如果在超时时间内遮挡板移动至少1cm然后停止至少0.4秒,那么设备会返回最终位置的结果。 最终的 result 是传感器和遮挡板之间的距离,单位是毫秒。

如果未能在超时时间内采集到合法的传感器信号,那么会返回对应的错误。

!pragma teoz true
participant 手机 as P #cyan
box 设备 #LightBlue
box BLE
participant Write as W #khaki
participant Indication as I  #lightgreen
end box
participant MCU as M #deepskyblue
participant 传感器 as S #lightcoral
end box

autonumber
...
note over P,I: BLE已连接
...
== 发送命令 ==

P ->(10) W : Lynx.request.measure(start, timeoutInSecond)
W -> M :
M -> I:
I ->(10) P: Lynx.response.measure(error)

== 开始测量 ==
?-> M ++:
M -> S :
note over M, S : 持续检测,直到有结果或超时
S -> M:

== 测量完毕 ==
M -> I -- :
P (10)<- I : Lynx.indication.measure(result, error)

5.4. 跳远测距

时序图同 坐位体前屈测距.

设备收到测量命令之后开始采集传感器。

如果在超时时间内检测到有传感器被遮挡,并且位置稳定约0.5秒,那么设备会返回最终位置的结果。 最终的 result 是遮挡物的最近端和最远端的位置,起点从光栅接线端开始计算。 远端占高16位,近端占低16位。单位均是毫米。

如果未能在超时时间内采集到合法的传感器信号,那么会返回对应的错误。

5.5. 获取最后一次结果

数据格式定义见: 最后结果格式(latest result)

返回的是上一次测量结果和错误。

备注

如果已经开始新的测量,那么上一次的结果会被清空,即使本次还没有测量结束。

!pragma teoz true
participant 手机 as P #cyan
box 设备 #LightBlue
box BLE
participant Write as W #khaki
participant Indication as I  #lightgreen
end box
participant MCU as M #deepskyblue
participant 传感器 as S #lightcoral
end box

autonumber
...
note over P,I: BLE已连接
...
== 发送命令 ==

P ->(10) W : Lynx.request.latestResult()
W -> M:
M -> I:
P (10)<- I : Lynx.response.latestResult(result, error)