# IoT OS Platform: Software Infrastructure for Next-Gen Industrial IoT
## 4 Implementation Case Study
### Implementation
#### 4.2.2 Real Time Alarm Guarantee  
As described in the previous section, compared to other systems in the past, we needed to perform strong real-time identification and alarm within a large factory area. Combined with our previous design ideas for data access and task scheduling in the IoT OS Platform, we introduced several edge computing devices. According to the geographical location of the cameras, we sent the video stream address and its inference tasks to the nearby edge nodes for calculation, and then collected the alarm data to the central platform for display.  
After completing deployment and scheduling, its data flow architecture is shown in Figure 12.  
During the process, we mainly focused on how to reduce the transmission time spent on business. According to the timing chart, our timing rules are shown in Figure 13. Firstly, the camera transmits the RTSP encoded stream data to the frame processing process on the edge device. After the frame data is extracted, we record this timestamp globally. Then, the frame processing process will place this frame data into a shared memory for the inference process to use. After the inference process reads this frame of data from the shared memory, we record the timestamp of the start of inference globally. After the inference is completed, the inference time can be obtained. Afterwards, the inference process will send the results to the central server, which will then present the results to the browser. On the central server, when data are pushed to the browser, we record the timestamp of the end of transmission to obtain the total time spent. Afterwards, we calculate the transmission time by subtracting the two. In order to minimize the impact of random disturbances as much as possible, we conducted 100 tests on the workflow of each algorithm and took its average value.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Raw API** & **Semantic in IoT OS Platform** \\ \hline
**POST** /api/v1/device/getStatus & read \\ \hline
**POST**/api/v1/device/setStatus & write \\ \hline
**POST**/api/v1/login & open \\ \hline
**POST**/api/v1/logout & close \\ \hline
**POST**/api/v1/alarm/getAlarmLogList & exception \\ \hline \hline \end{tabular}
\end{table}
Table 6: Mapping raw API to semantic.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Raw API** & **Semantic in IoT OS Platform** \\ \hline
**boolean** & **CLIENT\_QueryDevState** & read \\ \hline
**boolean** & **CLIENT\_ControlDeviceE** & write \\ \hline
**LLong** & **CLIENT\_LoginWithHighLevelSecurity** & open \\ \hline
**boolean** & **CLIENT\_Logout** & close \\ \hline
**interface** & **rfMesCallBack** & exception \\ \hline \hline \end{tabular}
\end{table}
Table 7: Mapping call methods to semantic.  
We conducted performance tests on 16 algorithms deployed in the system, and counted the time it took for these algorithms to receive alarm results from accessing video streams to the browser end, as shown in Table 8.  
It can be observed that in the system, the total time for identifying anomalies and issuing alarms is basically less than 0.2 s. Among them, the Fatigue Work and the Sleep on Duty algorithm have the least total time consumption, and the YOLOv8 algorithm is used at the bottom of both, so they have good performance in inference. The personnel fall algorithm uses an ONNX format model for posture recognition, but its optimization is relatively poor, resulting in higher inference time. Although the inference time is algorithm related and fluctuates greatly, the calculated transmission delay remains within a stable range of 70-84 milliseconds. By calculating the proportion of transmission time to total process time, it is possible to better observe and confirm that transmission will not become a bottleneck in the real-time performance of the system. In summary, by constructing a  
Figure 12: The inference data flow architecture.  
Figure 13: Time consumption calculation method.  
complete workflow of frame retrieval inference alarm, it can be verified that the IoT OS Platform performs well in real-time design.