---- add presence normal related defines
This commit is contained in:
parent
3feaffc5c2
commit
409f4ff2cb
|
@ -83,9 +83,10 @@ function Decode(fPort, data, variables) {
|
|||
}
|
||||
// select only one below
|
||||
// For NC(Normal Closed states
|
||||
// data.Sensor1_Door_Contact_Open = bytes[3]===0?"Door Closed":"Door Open";
|
||||
data.Sensor1_Door_Contact_Open = bytes[3] === 0 ? "Door Closed" : "Door Open";
|
||||
|
||||
// For NC(Normal Closed states
|
||||
data.Sensor1_Door_Contact_Open = bytes[3] === 1 ? "Door Closed" : "Door Open";
|
||||
//data.Sensor1_Door_Contact_Open = bytes[3]===1?"Door Closed":"Door Open";
|
||||
|
||||
data.Sensor2_Motion_Detected = bytes[4] === 0 ? "No Motion" : "Motion Detected";
|
||||
data.Sensor3_Emergency_Button = bytes[5] === 0 ? "Alarm Push Down" : "No Alarm, Released";
|
||||
|
@ -97,7 +98,7 @@ function Decode(fPort, data, variables) {
|
|||
data.Unconcious_State = bytes[11];
|
||||
switch (bytes[12]) {
|
||||
case 0x0:
|
||||
data.Fall_Down_Detected_State = "Presence_None";
|
||||
data.Fall_Down_Detected_State = "Presence_Normal";
|
||||
break;
|
||||
case 0x01:
|
||||
data.Fall_Down_Detected_State = "Presence_Fall_Down";
|
||||
|
@ -117,6 +118,8 @@ function Decode(fPort, data, variables) {
|
|||
}
|
||||
data.OverStay_Detected_State = (bytes[13] == 0x0) ? "No" : "Yes";
|
||||
data.OverStay_Duration_in_Seconds = (bytes[14] << 8 | bytes[15]);
|
||||
data.No_Movement_Duration_in_Seconds = (bytes[16] << 8 | bytes[17]);
|
||||
data.Unconcious_Duration_in_Seconds = (bytes[16] << 8 | bytes[17]);
|
||||
}
|
||||
return { "Yunhorn_SmarToilets_data": data };
|
||||
}
|
||||
|
|
|
@ -181,6 +181,8 @@ typedef struct STS_OO_SensorStatusDataTypeDef
|
|||
uint32_t over_stay_duration; // sensor 1, door lock or door contact, time lenght of overstay in seconds
|
||||
uint16_t occupancy_duration; // sensor 3, motion detection duration
|
||||
uint32_t fall_laydown_duration; // sensor 3, fall down not rise up duration
|
||||
uint32_t no_movement_duration;
|
||||
uint32_t unconcious_duration;
|
||||
uint8_t occupancy_over_stay_state; //
|
||||
uint8_t battery_Pct; /* % of battery two digits, 88% (00-99)% */
|
||||
uint8_t dutycycletimelevel; /* level=0,255 */
|
||||
|
@ -197,6 +199,12 @@ typedef struct STS_OO_SensorStatusDataTypeDef
|
|||
uint32_t event_sensor3_fall_start_time;
|
||||
uint32_t event_sensor3_fall_stop_time;
|
||||
uint32_t event_sensor3_fall_duration;
|
||||
uint32_t event_sensor3_no_movement_start_time;
|
||||
uint32_t event_sensor3_no_movement_stop_time;
|
||||
uint32_t event_sensor3_no_movement_duration;
|
||||
uint32_t event_sensor3_unconcious_start_time;
|
||||
uint32_t event_sensor3_unconcious_stop_time;
|
||||
uint32_t event_sensor3_unconcious_duration;
|
||||
uint32_t event_sensor4_start_time;
|
||||
uint32_t event_sensor4_stop_time;
|
||||
uint32_t event_sensor4_duration;
|
||||
|
@ -208,7 +216,7 @@ typedef struct STS_OO_SensorStatusDataTypeDef
|
|||
|
||||
|
||||
enum sts_presence_fall_detection_type {
|
||||
STS_PRESENCE_NONE=0,
|
||||
STS_PRESENCE_NORMAL=0,
|
||||
STS_PRESENCE_FALL,
|
||||
STS_PRESENCE_RISING,
|
||||
STS_PRESENCE_LAYDOWN,
|
||||
|
|
|
@ -291,7 +291,7 @@ void STS_Combined_Status_Processing(void)
|
|||
|
||||
switch(sts_fall_rising_detected_result)
|
||||
{
|
||||
case STS_PRESENCE_NONE:
|
||||
case STS_PRESENCE_NORMAL:
|
||||
//do nothing
|
||||
break;
|
||||
|
||||
|
|
|
@ -123,9 +123,9 @@ volatile uint8_t detected_hs_zone=0;;
|
|||
volatile uint16_t motion_count=0, motion_feature_count=0;
|
||||
static acc_detector_presence_result_t sts_motion_dataset[DEFAULT_MOTION_DATASET_LEN];
|
||||
static STS_PRESENCE_Motion_Featuer_t sts_motion_feature[DEFAULT_MOTION_FEATURE_LEN];
|
||||
volatile uint8_t sts_fall_rising_detected_result = STS_PRESENCE_NONE;
|
||||
volatile uint8_t sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;
|
||||
volatile uint8_t sts_fall_rising_detected_result_changed_flag =0;
|
||||
volatile uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NONE;
|
||||
volatile uint8_t last_sts_fall_rising_detected_result= STS_PRESENCE_NORMAL;
|
||||
volatile float last_average_presence_distance;
|
||||
volatile uint16_t sts_fall_rising_pattern_factor1=0, sts_fall_rising_pattern_factor2=0;
|
||||
volatile uint16_t sts_roc_acc_standard_variance=0;
|
||||
|
@ -528,7 +528,7 @@ int sts_presence_rss_fall_rise_detection(void)
|
|||
}
|
||||
//APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
|
||||
|
||||
uint8_t thiscnt= motion_detected_count;
|
||||
//uint8_t thiscnt= motion_detected_count;
|
||||
|
||||
if (motion_detected_count++ == 10) {
|
||||
motion_detected_count=0;
|
||||
|
@ -782,13 +782,13 @@ void STS_YunhornCheckStandardDeviation(void)
|
|||
{
|
||||
sts_fall_rising_detected_result = STS_PRESENCE_LAYDOWN;
|
||||
} else {
|
||||
sts_fall_rising_detected_result = STS_PRESENCE_NONE;
|
||||
sts_fall_rising_detected_result = STS_PRESENCE_NORMAL;
|
||||
}
|
||||
}
|
||||
last_sts_fall_rising_detected_result = sts_fall_rising_detected_result;
|
||||
last_average_presence_distance = average_presence_distance;
|
||||
#if 0
|
||||
if (sts_fall_rising_detected_result != STS_PRESENCE_NONE)
|
||||
if (sts_fall_rising_detected_result != STS_PRESENCE_NORMAL)
|
||||
{
|
||||
STS_FallDetection_LampBarProcess();
|
||||
}
|
||||
|
|
|
@ -501,13 +501,14 @@ void STS_PRESENCE_SENSOR_Init_Send_Data(void)
|
|||
sts_o7_sensorData.state_sensor4_on_off = 0x0;
|
||||
sts_o7_sensorData.rss_presence_distance = 0x0;
|
||||
sts_o7_sensorData.rss_presence_score = 0x0;
|
||||
sts_o7_sensorData.fall_state = STS_PRESENCE_NONE;
|
||||
sts_o7_sensorData.fall_state = STS_PRESENCE_NORMAL;
|
||||
sts_o7_sensorData.fall_speed = 0x0;
|
||||
sts_o7_sensorData.fall_gravity = 0x0;
|
||||
sts_o7_sensorData.over_stay_state = 0x0;
|
||||
sts_o7_sensorData.over_stay_duration = 0x0;
|
||||
sts_o7_sensorData.unconscious_state = 0x0;
|
||||
sts_o7_sensorData.unconscious_duration = 0x0;
|
||||
sts_o7_sensorData.no_movement_duration = 0x0;
|
||||
|
||||
sts_o7_sensorData.event_sensor1_start_time = 0x0;
|
||||
sts_o7_sensorData.event_sensor1_duration = 0x0;
|
||||
|
@ -549,6 +550,10 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
|
|||
sensor_data->over_stay_state = sts_o7_sensorData.over_stay_state;
|
||||
sensor_data->over_stay_duration = sts_o7_sensorData.event_sensor1_duration;
|
||||
|
||||
// no_movement or unconcious duration
|
||||
sensor_data->unconscious_duration = sts_o7_sensorData.event_sensor3_unconcious_duration;
|
||||
sensor_data->no_movement_duration = sts_o7_sensorData.event_sensor3_no_movement_duration;
|
||||
|
||||
APP_LOG(TS_OFF,VLEVEL_L,"\r\n ... Over Stay Duration=%u Sec\r\n", sensor_data->over_stay_duration);
|
||||
|
||||
sensor_data->fall_state = sts_fall_rising_detected_result;
|
||||
|
@ -609,6 +614,7 @@ void STS_PRESENCE_SENSOR_Init(void)
|
|||
sts_o7_sensorData.over_stay_state = 0;
|
||||
sts_o7_sensorData.over_stay_duration = 0;
|
||||
sts_o7_sensorData.unconscious_duration = 0;
|
||||
sts_o7_sensorData.no_movement_duration = 0;
|
||||
sts_o7_sensorData.unconscious_state = 0;
|
||||
|
||||
STS_SENSOR_Power_ON(0);
|
||||
|
@ -951,7 +957,7 @@ void OnSensor3BStateChanged(void)
|
|||
#endif
|
||||
switch (sts_fall_rising_detected_result)
|
||||
{
|
||||
case STS_PRESENCE_NONE:
|
||||
case STS_PRESENCE_NORMAL:
|
||||
sts_o7_sensorData.event_sensor3_motion_stop_time = sensor_event_time.Seconds;
|
||||
break;
|
||||
|
||||
|
@ -967,13 +973,16 @@ void OnSensor3BStateChanged(void)
|
|||
break;
|
||||
|
||||
case STS_PRESENCE_LAYDOWN:
|
||||
case STS_PRESENCE_UNCONSCIOUS:
|
||||
sts_o7_sensorData.fall_laydown_duration = 0;
|
||||
break;
|
||||
|
||||
case STS_PRESENCE_STAYSTILL:
|
||||
case STS_PRESENCE_NO_MOVEMENT:
|
||||
|
||||
case STS_PRESENCE_UNCONSCIOUS:
|
||||
sts_o7_sensorData.event_sensor3_no_movement_start_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor3_unconcious_start_time = sensor_event_time.Seconds;
|
||||
sts_o7_sensorData.event_sensor3_unconcious_duration = 0;
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration = 0;
|
||||
sts_o7_sensorData.fall_laydown_duration = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -957,6 +957,8 @@ static void SendTxData(void)
|
|||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //13 occupancy over time or not
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //14 occupancy over stay duration MSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //15 occupancy over stay duration LSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.no_movement_duration>>8)&0xff; //16 occupancy over stay duration LSB
|
||||
AppData.Buffer[i++] = (uint8_t)(sensorData.no_movement_duration)&0xff; //17 occupancy over stay duration LSB
|
||||
}
|
||||
uint8_t ich= (sts_lamp_bar_color>>4 & 0x0f);
|
||||
uint8_t icl= (sts_lamp_bar_color & 0x0f);
|
||||
|
@ -1154,7 +1156,7 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
|||
|
||||
}
|
||||
|
||||
// to be defiend later for SOS threshold TODO XXXX
|
||||
// to be defined later for SOS threshold TODO XXXX
|
||||
if (STS_Status_SOS_Pushdown==sts_hall2_read)
|
||||
{
|
||||
sts_o7_sensorData.event_sensor2_duration = current_time.Seconds - sts_o7_sensorData.event_sensor2_start_time;
|
||||
|
@ -1194,11 +1196,12 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
|||
STS_PRESENCE_STAYSTILL
|
||||
*/
|
||||
switch (sts_fall_rising_detected_result){
|
||||
case STS_PRESENCE_NONE:
|
||||
case STS_PRESENCE_NORMAL:
|
||||
sts_o7_sensorData.fall_state = 0;
|
||||
sts_o7_sensorData.fall_laydown_duration=0;
|
||||
sts_o7_sensorData.unconscious_state =0;
|
||||
sts_o7_sensorData.unconscious_duration =0;
|
||||
sts_o7_sensorData.no_movement_duration =0;
|
||||
break;
|
||||
case STS_PRESENCE_FALL:
|
||||
sts_o7_sensorData.event_sensor3_fall_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_fall_start_time;
|
||||
|
@ -1214,9 +1217,12 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
|||
break;
|
||||
case STS_PRESENCE_LAYDOWN:
|
||||
break;
|
||||
|
||||
case STS_PRESENCE_UNCONSCIOUS:
|
||||
break;
|
||||
case STS_PRESENCE_STAYSTILL:
|
||||
case STS_PRESENCE_NO_MOVEMENT:
|
||||
sts_o7_sensorData.event_sensor3_no_movement_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_no_movement_start_time;
|
||||
sts_o7_sensorData.event_sensor3_unconcious_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_unconcious_start_time;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue