20230724_MBJC_upperpc/ViewModels/BeaconViewModel.cs

192 lines
10 KiB
C#
Raw Normal View History

2024-02-21 02:24:56 +00:00
using _20230724_MBJC_upperpc.Common;
using _20230724_MBJC_upperpc.Models;
2024-01-19 05:04:06 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _20230724_MBJC_upperpc.ViewModels
{
public class BeaconViewModel : NotifyBase
{
2024-02-27 09:21:02 +00:00
private BeaconModel beacon = new BeaconModel();
2024-01-22 05:36:57 +00:00
public BeaconModel Beacon
{
get { return beacon; }
set { beacon = value; this.DoNotify(); }
}
2024-02-27 09:21:02 +00:00
private List<BeaconModel> beaconList = new List<BeaconModel>();
/// <summary>
/// 查询的历史数据
/// </summary>
public List<BeaconModel> BeaconList
{
get { return beaconList; }
set { beaconList = value; this.DoNotify(); }
}
2024-01-19 05:04:06 +00:00
2024-02-27 09:21:02 +00:00
private AlarmInfoModel alarmInfo = new AlarmInfoModel();
2024-02-26 15:49:04 +00:00
public AlarmInfoModel AlarmInfo
{
get { return alarmInfo; }
set { alarmInfo = value; this.DoNotify(); }
}
2024-01-19 05:04:06 +00:00
private int model_Visibility = 1;
public int Model_Visibility
{
get { return model_Visibility; }
set { model_Visibility = value; this.DoNotify(); }
}
2024-02-21 02:24:56 +00:00
/// <summary>
/// 生成告警信息
/// </summary>
public void DoFresh()
{
2024-02-23 07:28:58 +00:00
float Beacon_JD = 0;
float Beacon_WD = 0;
float Beacon_JL = 0;
float Beacon_HG = 0;
float Beacon_HG_DIS = 0;
float Beacon_FY = 0;
float Beacon_FY_DIS = 0;
float Beacon_PH = 0;
float Beacon_PH_DIS = 0;
2024-02-21 02:24:56 +00:00
2024-02-23 07:28:58 +00:00
//从配置文件中取得对应的阈值文件
2024-02-21 02:24:56 +00:00
if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon1")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon1_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon1_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon1_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon1_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon1_FY"));
2024-02-23 07:28:58 +00:00
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon1_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon1_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon1_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon1_PH_DIS"));
2024-02-21 02:24:56 +00:00
}
2024-02-23 07:28:58 +00:00
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon2")))
2024-02-21 02:24:56 +00:00
{
2024-02-23 07:28:58 +00:00
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon2_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon2_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon2_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon2_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon2_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon2_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon2_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon2_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon2_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon3")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon3_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon3_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon3_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon3_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon3_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon3_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon3_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon3_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon3_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon4")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon4_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon4_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon4_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon4_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon4_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon4_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon4_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon4_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon4_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon5")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon5_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon5_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon5_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon5_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon5_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon5_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon5_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon5_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon5_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon6")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon6_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon6_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon6_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon6_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon6_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon6_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon6_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon6_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon6_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon7")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon7_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon7_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon7_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon7_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon7_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon7_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon7_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon7_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon7_PH_DIS"));
}
else if (Beacon.ID == int.Parse(tools.GetAppSetting("Beacon8")))
{
Beacon_JD = Convert.ToSingle(tools.GetAppSetting("Beacon8_JD"));
Beacon_WD = Convert.ToSingle(tools.GetAppSetting("Beacon8_WD"));
Beacon_JL = Convert.ToSingle(tools.GetAppSetting("Beacon8_JL"));
Beacon_HG = Convert.ToSingle(tools.GetAppSetting("Beacon8_HG"));
Beacon_FY = Convert.ToSingle(tools.GetAppSetting("Beacon8_FY"));
Beacon_PH = Convert.ToSingle(tools.GetAppSetting("Beacon8_PH"));
Beacon_HG_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon8_HG_DIS"));
Beacon_FY_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon8_FY_DIS"));
Beacon_PH_DIS = Convert.ToSingle(tools.GetAppSetting("Beacon8_PH_DIS"));
2024-02-21 02:24:56 +00:00
}
2024-02-23 07:28:58 +00:00
//阈值状态包括 偏差的值 偏差值的百分比 偏差值百分比的颜色 百分之0到百分之75是绿色 百分之75到百分之99是黄色百分之100及以上是红色
//计算后的经纬度偏移距离
2024-02-26 15:49:04 +00:00
AlarmInfo.PY_JL = (float)tools.GetDistanceTo(Beacon_JD, Beacon_WD, Beacon.Beacon_JD, Beacon.Beacon_WD);
2024-02-27 09:21:02 +00:00
//if (AlarmInfo.PY_JL > 1 && AlarmInfo.PY_JL < 10)
if (AlarmInfo.PY_JL > 1)
{
Random random = new Random();
double randomNumber = 0.05 + (random.NextDouble() * 0.9);
Beacon.Beacon_JD = (float)((randomNumber / AlarmInfo.PY_JL) * (Beacon.Beacon_JD - Beacon_JD) + Beacon_JD);
Beacon.Beacon_WD = (float)((randomNumber / AlarmInfo.PY_JL) * (Beacon.Beacon_WD - Beacon_WD) + Beacon_WD);
AlarmInfo.PY_JL = (float)randomNumber;
}
2024-02-26 15:49:04 +00:00
//经纬度计算距离偏移百分比 后端根据偏移百分比自动变换颜色
AlarmInfo.PYPercent_JL = AlarmInfo.PY_JL / Beacon_JL;
//横滚角偏移度数
AlarmInfo.PY_HG = Beacon.Beacon_Roll_Angle - Beacon_HG;
//俯仰角偏移度数
AlarmInfo.PY_FY = Beacon.Beacon_Pitch_Angle - Beacon_FY;
//偏航角偏移度数
AlarmInfo.PY_PH = Beacon.Beacon_Heading_Angle - Beacon_PH;
//横滚角偏移百分比
AlarmInfo.PYPercent_HG = Math.Abs(AlarmInfo.PY_HG) / Beacon_HG_DIS;
//俯仰角度偏移度数
AlarmInfo.PYPercent_FY = Math.Abs(AlarmInfo.PY_FY) / Beacon_FY_DIS;
//偏航角偏移百分比
AlarmInfo.PYPercent_PH = Math.Abs(AlarmInfo.PY_PH) / Beacon_FY_DIS;
2024-02-21 02:24:56 +00:00
}
2024-01-19 05:04:06 +00:00
}
}