--- revised for time stamp

This commit is contained in:
Yunhorn 2024-07-26 19:08:54 +08:00
parent 63d42c07eb
commit 6dd59ad942
3 changed files with 60 additions and 49 deletions

View File

@ -164,8 +164,8 @@ typedef struct STS_OO_SensorStatusDataTypeDef
uint8_t lamp_bar_color; /* measured color ID, 0,1,2,3,4,5,6,7,8,9 */ uint8_t lamp_bar_color; /* measured color ID, 0,1,2,3,4,5,6,7,8,9 */
uint8_t workmode; /* work mode, 0,1,2,3,4 */ uint8_t workmode; /* work mode, 0,1,2,3,4 */
uint8_t state_sensor1_on_off; /* reedswitch or hall element 0: open, 1: closed */ uint8_t state_sensor1_on_off; /* reedswitch or hall element 0: open, 1: closed */
uint8_t state_sensor2_on_off; /* pcr_sensor_on_off; 1: occupancy, 0: no occupancy */ uint8_t state_sensor2_on_off; /* reedswitch or hall element 0: open, 1: closed */
uint8_t state_sensor3_on_off; /* urinal_sensor_on_off urinal sensor state */ uint8_t state_sensor3_on_off; /* motion RSS, pcr_sensor_on_off; 1: occupancy, 0: no occupancy */
uint8_t state_sensor4_on_off; /* reserved_sensor_on_off sensor state */ uint8_t state_sensor4_on_off; /* reserved_sensor_on_off sensor state */
uint16_t rss_presence_distance; // in mm uint16_t rss_presence_distance; // in mm
uint8_t rss_presence_zone[10]; uint8_t rss_presence_zone[10];
@ -191,14 +191,15 @@ typedef struct STS_OO_SensorStatusDataTypeDef
uint32_t event_sensor1_stop_time; uint32_t event_sensor1_stop_time;
uint32_t event_sensor1_duration; uint32_t event_sensor1_duration;
uint32_t event_sensor2_start_time; uint32_t event_sensor2_start_time; /* reedswitch or hale element */
uint32_t event_sensor2_start_timestamp; uint32_t event_sensor2_start_timestamp;
uint32_t event_sensor2_stop_time; uint32_t event_sensor2_stop_time;
uint32_t event_sensor2_stop_timestamp; uint32_t event_sensor2_stop_timestamp;
uint32_t event_sensor2_duration; uint32_t event_sensor2_duration;
uint32_t event_sensor3_motion_start_time; uint32_t event_sensor3_motion_start_time; /* RSS motion sensor */
uint32_t event_sensor3_motion_stop_time; uint32_t event_sensor3_motion_stop_time;
uint32_t event_sensor3_start_timestamp;
uint32_t event_sensor3_motion_duration; uint32_t event_sensor3_motion_duration;
uint32_t event_sensor3_fall_start_time; uint32_t event_sensor3_fall_start_time;
@ -215,7 +216,7 @@ typedef struct STS_OO_SensorStatusDataTypeDef
uint32_t event_sensor3_unconcious_stop_time; uint32_t event_sensor3_unconcious_stop_time;
uint32_t event_sensor3_unconcious_duration; uint32_t event_sensor3_unconcious_duration;
uint32_t event_sensor4_start_time; uint32_t event_sensor4_start_time; /* reserved */
uint32_t event_sensor4_stop_time; uint32_t event_sensor4_stop_time;
uint32_t event_sensor4_duration; uint32_t event_sensor4_duration;
uint8_t alarm_indictor_mute_state; uint8_t alarm_indictor_mute_state;

View File

@ -221,20 +221,13 @@ void STS_YunhornSTSEventRFAC_Process(void)
*/ */
void STS_YunhornSTSEventP1_Process(void) void STS_YunhornSTSEventP1_Process(void)
{
{ {
sts_reed_hall_1_result = HALL1_STATE; //sts_hall1_read; sts_reed_hall_1_result = HALL1_STATE; //sts_hall1_read;
last_sts_reed_hall_1_result = sts_reed_hall_1_result; last_sts_reed_hall_1_result = sts_reed_hall_1_result;
}
{
sts_reed_hall_2_result = HALL2_STATE;// sts_hall2_read; sts_reed_hall_2_result = HALL2_STATE;// sts_hall2_read;
last_sts_reed_hall_2_result = sts_reed_hall_2_result; last_sts_reed_hall_2_result = sts_reed_hall_2_result;
}
STS_Combined_Status_Processing(); STS_Combined_Status_Processing();
} }
@ -620,7 +613,7 @@ void STS_Combined_Status_Processing(void)
//STS_Lamp_Bar_Refresh(); //STS_Lamp_Bar_Refresh();
if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag)|| (sts_reed_hall_changed_flag)) if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag))
{ {
//sts_rss_result_changed_flag =0; //sts_rss_result_changed_flag =0;
//sts_reed_hall_changed_flag =0; //sts_reed_hall_changed_flag =0;
@ -721,12 +714,21 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
sensor_data->lamp_bar_color = sts_lamp_bar_color; sensor_data->lamp_bar_color = sts_lamp_bar_color;
sensor_data->workmode = sts_work_mode; sensor_data->workmode = sts_work_mode;
sensor_data->state_sensor1_on_off = HALL1_STATE;//sts_hall1_read; //sts_hsts_reed_hall_result; // sts_hall1_read sensor_data->state_sensor1_on_off = HALL1_STATE;//sts_hall1_read; //sts_hsts_reed_hall_result; // sts_hall1_read
sensor_data->state_sensor2_on_off = sts_rss_result; sensor_data->state_sensor2_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read
sensor_data->state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read sensor_data->state_sensor3_on_off = sts_rss_result;
sensor_data->state_sensor4_on_off = sts_rss_2nd_result; sensor_data->state_sensor4_on_off = sts_rss_2nd_result;
if (sensor_data->state_sensor2_on_off==STS_Status_SOS_Pushdown)
{
sensor_data->event_sensor2_start_timestamp = sts_o7_sensorData.event_sensor2_start_timestamp; sensor_data->event_sensor2_start_timestamp = sts_o7_sensorData.event_sensor2_start_timestamp;
sensor_data->event_sensor2_stop_timestamp = sts_o7_sensorData.event_sensor2_stop_timestamp; sensor_data->event_sensor2_stop_timestamp = sts_o7_sensorData.event_sensor2_stop_timestamp;
sts_o7_sensorData.event_sensor2_start_timestamp = 0;
} else {
sensor_data->event_sensor2_start_timestamp = 0;
sensor_data->event_sensor2_stop_timestamp = 0;
sensor_data->event_sensor2_stop_timestamp = sts_o7_sensorData.event_sensor2_stop_timestamp;
sts_o7_sensorData.event_sensor2_stop_timestamp = 0;
}
if (sts_rss_result == STS_RESULT_MOTION) if (sts_rss_result == STS_RESULT_MOTION)
{ {
@ -780,7 +782,8 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
} else { } else {
sensor_data->fall_speed = 0; sensor_data->fall_speed = 0;
sensor_data->fall_gravity = 0; sensor_data->fall_gravity = 0;
sensor_data->event_sensor3_fall_start_time_stamp = 0;
sensor_data->event_sensor3_fall_stop_time_stamp =0;
} }
// For occupancy over time process // For occupancy over time process
@ -1120,14 +1123,16 @@ void OnSensor2StateChanged(void)
{ {
sts_o7_sensorData.event_sensor2_start_time = sensor_event_time.Seconds; sts_o7_sensorData.event_sensor2_start_time = sensor_event_time.Seconds;
sts_o7_sensorData.event_sensor2_start_timestamp = time_stamp; sts_o7_sensorData.event_sensor2_start_timestamp = time_stamp;
sts_o7_sensorData.event_sensor2_stop_time = 0;
sts_o7_sensorData.event_sensor2_duration = 0; sts_o7_sensorData.event_sensor2_duration = 0;
APP_LOG(TS_OFF, VLEVEL_L, "SOS PushDown ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor2_start_time ); APP_LOG(TS_OFF, VLEVEL_L, "SOS PushDown ---Timer start: %u\r\n",sts_o7_sensorData.event_sensor2_start_time );
}else if (sts_hall2_read==STS_Status_SOS_Release) }else if (sts_hall2_read==STS_Status_SOS_Release)
{ {
sts_o7_sensorData.event_sensor2_start_time = 0; sts_o7_sensorData.event_sensor2_start_time = 0;
sts_o7_sensorData.event_sensor2_start_timestamp = 0;
sts_o7_sensorData.event_sensor2_stop_time = sensor_event_time.Seconds; sts_o7_sensorData.event_sensor2_stop_time = sensor_event_time.Seconds;
sts_o7_sensorData.event_sensor2_stop_timestamp = time_stamp; sts_o7_sensorData.event_sensor2_stop_timestamp = time_stamp;
sts_o7_sensorData.over_stay_state = 0; //sts_o7_sensorData.over_stay_state = 0;
//sts_o7_sensorData.event_sensor2_duration = 0; //sts_o7_sensorData.event_sensor2_duration = 0;
} }
} }
@ -1149,6 +1154,7 @@ void OnSensor3StateChanged(void)
} else if (sts_rss_result == STS_RESULT_NO_MOTION) } else if (sts_rss_result == STS_RESULT_NO_MOTION)
{ {
sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds;
sts_o7_sensorData.event_sensor3_start_timestamp = 0;
//sts_o7_sensorData.event_sensor3_motion_duration = 0; //sts_o7_sensorData.event_sensor3_motion_duration = 0;
} }
@ -1175,6 +1181,7 @@ void OnSensor3AStateChanged(void)
} else if (sts_rss_result == STS_RESULT_NO_MOTION) } else if (sts_rss_result == STS_RESULT_NO_MOTION)
{ {
sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds; sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds;
sts_o7_sensorData.event_sensor3_start_timestamp = 0;
//sts_o7_sensorData.event_sensor3_motion_duration = 0; //sts_o7_sensorData.event_sensor3_motion_duration = 0;
} }

View File

@ -960,27 +960,25 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t)(sensorData.workmode)&0xff; //02 WORK MODE AppData.Buffer[i++] = (uint8_t)(sensorData.workmode)&0xff; //02 WORK MODE
if (sts_work_mode == STS_RSS_MODE) if (sts_work_mode == STS_RSS_MODE)
{ {
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status reed switch
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //04 Sensor head #3 status RSS motion
} }
else if (sts_work_mode == STS_DUAL_MODE) else if (sts_work_mode == STS_DUAL_MODE)
{ {
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status reed switch
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status SOS button
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status RSS motion
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //06 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //06 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //07 occupancy over stay duration MSB AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //07 occupancy over stay duration MSB
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //08 occupancy over stay duration LSB AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //08 occupancy over stay duration LSB
} else if (sts_work_mode == STS_UNI_MODE) } else if (sts_work_mode == STS_UNI_MODE)
{ {
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor1_on_off)&0xff; //03 Sensor head #1 status reedswitch
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status SOS button
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status RSS motion
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status reserved
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance
@ -1031,17 +1029,22 @@ static void SendTxData(void)
if (sts_work_mode == STS_UNI_MODE) if (sts_work_mode == STS_UNI_MODE)
{ {
APP_LOG(TS_OFF, VLEVEL_L, APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| S1-Door | S2-Motion | S3-SOS | S4 |Distance(mm) | MotionScore| Unconscious | Over_Stay_(min) | Fall Detected|" "\r\n######| S1-Door | S2-SOS | S3-Motion | S4 |Distance(mm) | MotionScore| Unconscious | Over_Stay_(min) | Fall Detected|"
"\r\n######| %s | %1d | %s | %1d | %04d | %04d | %1d | %4d | %s |\r\n", "\r\n######| %s | %s | %d | %1d | %04d | %04d | %1d | %4d | %s |\r\n",
sts_door_status_code[sensorData.state_sensor1_on_off], sensorData.state_sensor2_on_off,sts_sos_status_code[sensorData.state_sensor3_on_off], sensorData.state_sensor4_on_off, sts_door_status_code[sensorData.state_sensor1_on_off],
sts_sos_status_code[sensorData.state_sensor2_on_off],
sensorData.state_sensor3_on_off,
sensorData.state_sensor4_on_off,
(uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score, (uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score,
sensorData.unconscious_state, sensorData.over_stay_duration, sts_fall_mode_code[sensorData.fall_state]); sensorData.unconscious_state, sensorData.over_stay_duration, sts_fall_mode_code[sensorData.fall_state]);
} else if (sts_work_mode == STS_DUAL_MODE) { } else if (sts_work_mode == STS_DUAL_MODE) {
APP_LOG(TS_OFF, VLEVEL_L, APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| S1-Door | S2-Motion | S3-SOS |\r\n" "\r\n######| S1-Door | S2-SOS | S3-Motion |\r\n"
"\r\n######| %s | %1d | %s |\r\n", "\r\n######| %s | %s | %d |\r\n",
sts_door_status_code[sensorData.state_sensor1_on_off], sensorData.state_sensor2_on_off,sts_sos_status_code[sensorData.state_sensor3_on_off]); sts_door_status_code[sensorData.state_sensor1_on_off],
sts_sos_status_code[sensorData.state_sensor2_on_off],
sensorData.state_sensor3_on_off);
} }
} }