|
@@ -167,7 +167,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
/// 设置高频状态 |
|
|
/// 设置高频状态 |
|
|
_logger.LogInformation($"{heartRate.Serialno} 进入高频心率启动状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval}"); |
|
|
_logger.LogInformation($"{heartRate.Serialno} 进入高频心率启动状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval}"); |
|
|
// 设置高频状态 |
|
|
// 设置高频状态 |
|
|
var freqFirstPhr = phr.OrderByDescending(i => i.Timestamp).First(); |
|
|
|
|
|
|
|
|
var freqFirstPhr = phr.OrderByDescending(i => i.LastUpdate).First(); |
|
|
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr); |
|
|
await _deviceCacheMgr.SetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno, freqFirstPhr); |
|
|
//phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
//phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
} |
|
|
} |
|
@@ -175,7 +175,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
/// 取连续正常次数正常值的平均值,推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
/// 取连续正常次数正常值的平均值,推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
#region 检查是否连续12个值都是正常的 |
|
|
#region 检查是否连续12个值都是正常的 |
|
|
// 获取最近连续正常次数个心率记录 |
|
|
// 获取最近连续正常次数个心率记录 |
|
|
var lastPhr = phr.OrderByDescending(i => i.Timestamp).Take(stopHighFreqSampleCount).ToList(); |
|
|
|
|
|
|
|
|
var lastPhr = phr.OrderByDescending(i => i.LastUpdate).Take(stopHighFreqSampleCount).ToList(); |
|
|
|
|
|
|
|
|
// 检查是否连续12个值都是正常的 |
|
|
// 检查是否连续12个值都是正常的 |
|
|
if (lastPhr.All(i => i.PregnancyHeartRate >= triggerHighFreqLow && i.PregnancyHeartRate <= triggerHighFreqHigh)) |
|
|
if (lastPhr.All(i => i.PregnancyHeartRate >= triggerHighFreqLow && i.PregnancyHeartRate <= triggerHighFreqHigh)) |
|
@@ -188,6 +188,11 @@ namespace HealthMonitor.Service.Resolver |
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,连续 {stopHighFreqSampleCount} 次采样心率正常,将下发指令"); |
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,连续 {stopHighFreqSampleCount} 次采样心率正常,将下发指令"); |
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString()); |
|
|
await SaveAndPushFreqFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString()); |
|
|
|
|
|
|
|
|
|
|
|
// 删除高频状态的首条记录 |
|
|
|
|
|
await _deviceCacheMgr.DelPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 连续正常结束高频心率状态, timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
} |
|
|
} |
|
@@ -201,8 +206,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
/// 取所有值的平均值,推送胎心数据到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
/// 取所有值的平均值,推送胎心数据到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
if (highFreqSampleTimes == 0) |
|
|
if (highFreqSampleTimes == 0) |
|
|
{ |
|
|
{ |
|
|
var avgPhr = phr.OrderByDescending(i => i.Timestamp) |
|
|
|
|
|
.Where(i => i.Timestamp >= phrFreqstatus?.Timestamp) |
|
|
|
|
|
|
|
|
var avgPhr = phr.OrderByDescending(i => i.LastUpdate) |
|
|
|
|
|
.Where(i => i.LastUpdate >= phrFreqstatus?.LastUpdate) |
|
|
.Skip(1) // 去除首条 |
|
|
.Skip(1) // 去除首条 |
|
|
.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
@@ -225,12 +230,12 @@ namespace HealthMonitor.Service.Resolver |
|
|
var filterPhr = phr |
|
|
var filterPhr = phr |
|
|
.Where(i => i.LastUpdate >= phrFreqstatus?.LastUpdate); |
|
|
.Where(i => i.LastUpdate >= phrFreqstatus?.LastUpdate); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var avgPhr = filterPhr |
|
|
var avgPhr = filterPhr |
|
|
.Skip(1) // 去除首条 |
|
|
|
|
|
.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
|
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
|
|
|
|
|
|
.OrderByDescending(i => i.LastUpdate) |
|
|
|
|
|
.Skip(1) // 去除首条 |
|
|
|
|
|
.Take(12) // 计算最后12条 |
|
|
|
|
|
//.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
|
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
// 推送胎心数据到 api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
// 推送胎心数据到 api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
// 计算一般心率得到胎心系数 |
|
|
// 计算一般心率得到胎心系数 |
|
|
//await SaveAndPushFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr); |
|
|
//await SaveAndPushFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, avgPhr); |
|
@@ -246,7 +251,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
// 删除高频状态的首条记录 |
|
|
// 删除高频状态的首条记录 |
|
|
await _deviceCacheMgr.DelPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
await _deviceCacheMgr.DelPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 超时结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒"); |
|
|
} |
|
|
} |
|
|
// 正常心率 |
|
|
// 正常心率 |
|
|
else |
|
|
else |
|
|