Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CommunicationMonitoring.cpp@0:a33375289d79, 2021-12-22 (annotated)
- Committer:
- kikuchi8810
- Date:
- Wed Dec 22 11:15:12 2021 +0000
- Revision:
- 0:a33375289d79
- Child:
- 1:6633661058ec
CommunicationMonitoring Class
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kikuchi8810 | 0:a33375289d79 | 1 | #include "CommunicationMonitoring.h" |
| kikuchi8810 | 0:a33375289d79 | 2 | |
| kikuchi8810 | 0:a33375289d79 | 3 | CommunicationMonitoring::CommunicationMonitoring() |
| kikuchi8810 | 0:a33375289d79 | 4 | { |
| kikuchi8810 | 0:a33375289d79 | 5 | device_num = 0; |
| kikuchi8810 | 0:a33375289d79 | 6 | } |
| kikuchi8810 | 0:a33375289d79 | 7 | |
| kikuchi8810 | 0:a33375289d79 | 8 | int CommunicationMonitoring::init(int _time_out_ms, int _int_time_ms) |
| kikuchi8810 | 0:a33375289d79 | 9 | { |
| kikuchi8810 | 0:a33375289d79 | 10 | comminfo[device_num].time_out_ms = _time_out_ms; |
| kikuchi8810 | 0:a33375289d79 | 11 | comminfo[device_num].int_time_ms = _int_time_ms; |
| kikuchi8810 | 0:a33375289d79 | 12 | comminfo[device_num].Available = false; |
| kikuchi8810 | 0:a33375289d79 | 13 | comminfo[device_num].count_ms = _time_out_ms; |
| kikuchi8810 | 0:a33375289d79 | 14 | comminfo[device_num].pre_count_ms = 0; |
| kikuchi8810 | 0:a33375289d79 | 15 | |
| kikuchi8810 | 0:a33375289d79 | 16 | return device_num; |
| kikuchi8810 | 0:a33375289d79 | 17 | |
| kikuchi8810 | 0:a33375289d79 | 18 | if(device_num < 9) device_num++; |
| kikuchi8810 | 0:a33375289d79 | 19 | } |
| kikuchi8810 | 0:a33375289d79 | 20 | |
| kikuchi8810 | 0:a33375289d79 | 21 | void CommunicationMonitoring::Monitoring(bool commCheck, int _device_num) |
| kikuchi8810 | 0:a33375289d79 | 22 | { |
| kikuchi8810 | 0:a33375289d79 | 23 | comminfo[_device_num].count_ms += comminfo[_device_num].int_time_ms; |
| kikuchi8810 | 0:a33375289d79 | 24 | |
| kikuchi8810 | 0:a33375289d79 | 25 | if(commCheck) comminfo[_device_num].pre_count_ms = comminfo[_device_num].count_ms - comminfo[_device_num].int_time_ms; |
| kikuchi8810 | 0:a33375289d79 | 26 | |
| kikuchi8810 | 0:a33375289d79 | 27 | comminfo[_device_num].Available = comminfo[_device_num].time_out_ms > (comminfo[_device_num].count_ms - comminfo[_device_num].pre_count_ms); |
| kikuchi8810 | 0:a33375289d79 | 28 | |
| kikuchi8810 | 0:a33375289d79 | 29 | if(comminfo[_device_num].count_ms > comminfo[_device_num].time_out_ms * 1000) comminfo[_device_num].count_ms = comminfo[_device_num].time_out_ms; //オーバーフロー対策 |
| kikuchi8810 | 0:a33375289d79 | 30 | } |
| kikuchi8810 | 0:a33375289d79 | 31 | |
| kikuchi8810 | 0:a33375289d79 | 32 | bool CommunicationMonitoring::getAvailable(int _device_num) |
| kikuchi8810 | 0:a33375289d79 | 33 | { |
| kikuchi8810 | 0:a33375289d79 | 34 | return comminfo[_device_num].Available; |
| kikuchi8810 | 0:a33375289d79 | 35 | } |