diff --git a/.vs/20230724_MBJC_upperpc/DesignTimeBuild/.dtbcache.v2 b/.vs/20230724_MBJC_upperpc/DesignTimeBuild/.dtbcache.v2
index 841f9b9..d7b081c 100644
Binary files a/.vs/20230724_MBJC_upperpc/DesignTimeBuild/.dtbcache.v2 and b/.vs/20230724_MBJC_upperpc/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/.vs/20230724_MBJC_upperpc/v17/.futdcache.v2 b/.vs/20230724_MBJC_upperpc/v17/.futdcache.v2
index b2cfcf4..d752754 100644
Binary files a/.vs/20230724_MBJC_upperpc/v17/.futdcache.v2 and b/.vs/20230724_MBJC_upperpc/v17/.futdcache.v2 differ
diff --git a/.vs/20230724_MBJC_upperpc/v17/.suo b/.vs/20230724_MBJC_upperpc/v17/.suo
index f1a9102..8dfd552 100644
Binary files a/.vs/20230724_MBJC_upperpc/v17/.suo and b/.vs/20230724_MBJC_upperpc/v17/.suo differ
diff --git a/.vs/ProjectEvaluation/20230724_mbjc_upperpc.metadata.v6.1 b/.vs/ProjectEvaluation/20230724_mbjc_upperpc.metadata.v6.1
index 7219ba2..927d320 100644
Binary files a/.vs/ProjectEvaluation/20230724_mbjc_upperpc.metadata.v6.1 and b/.vs/ProjectEvaluation/20230724_mbjc_upperpc.metadata.v6.1 differ
diff --git a/.vs/ProjectEvaluation/20230724_mbjc_upperpc.projects.v6.1 b/.vs/ProjectEvaluation/20230724_mbjc_upperpc.projects.v6.1
index 72c45a9..502132c 100644
Binary files a/.vs/ProjectEvaluation/20230724_mbjc_upperpc.projects.v6.1 and b/.vs/ProjectEvaluation/20230724_mbjc_upperpc.projects.v6.1 differ
diff --git a/20230724_MBJC_upperpc.csproj b/20230724_MBJC_upperpc.csproj
index 4941955..8ffe259 100644
--- a/20230724_MBJC_upperpc.csproj
+++ b/20230724_MBJC_upperpc.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/App.config b/App.config
index 7198842..1f1c83d 100644
--- a/App.config
+++ b/App.config
@@ -12,8 +12,11 @@
+
+
+
-
+
@@ -34,7 +37,7 @@
-
+
@@ -55,7 +58,7 @@
-
+
@@ -76,7 +79,7 @@
-
+
@@ -97,7 +100,7 @@
-
+
@@ -118,7 +121,7 @@
-
+
@@ -139,7 +142,7 @@
-
+
@@ -161,7 +164,7 @@
-
+
diff --git a/DataAccess/DBHelp.cs b/DataAccess/DBHelp.cs
index 6680251..cd01a4a 100644
--- a/DataAccess/DBHelp.cs
+++ b/DataAccess/DBHelp.cs
@@ -253,7 +253,13 @@ namespace _20230724_MBJC_upperpc.DataAccess
/// 值
public static void insertData(string tablename, BeaconModel beacon)
{
- string sql = string.Format("insert into {0}(StationID,RecordTime,Datetime,Ralative_Heading_Angle,Ralative_Pitch_Angle,Position_Distance,Propagationtime,BasicSite_JD,BasicSite_WD,BasicSite_Depth,BasicSite_Heading_Angle,BasicSite_Pitch_Angle,BasicSite_Roll_Angle,BasicSite_Heading_Speed,BasicSite_Pitch_Speed,BasicSite_Roll_Speed,BasicSite_Forword_A,BasicSite_Right_A,BasicSite_Sky_A,Beacon_JD,Beacon_WD,Beacon_Depth,Beacon_Roll_Angle,Beacon_Pitch_Angle,Beacon_Heading_Angle,Temp) VALUES({1},'{2}','{3}',{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26});", tablename, beacon.ID, System.DateTime.Now, beacon.Datetime, beacon.Ralative_Heading_Angle, beacon.Ralative_Pitch_Angle, beacon.Position_Distance, beacon.Propagationtime, beacon.BasicSite_JD, beacon.BasicSite_WD, beacon.BasicSite_Depth, beacon.BasicSite_Heading_Angle, beacon.BasicSite_Pitch_Angle, beacon.BasicSite_Roll_Angle, beacon.BasicSite_Heading_Speed, beacon.BasicSite_Pitch_Speed, beacon.BasicSite_Roll_Speed, beacon.BasicSite_Forword_A, beacon.BasicSite_Right_A, beacon.BasicSite_Sky_A, beacon.Beacon_JD, beacon.Beacon_WD, beacon.Beacon_Depth, beacon.Beacon_Roll_Angle,beacon.Beacon_Pitch_Angle, beacon.Beacon_Heading_Angle, beacon.Temp);
+ string sql = string.Format("insert into {0}(StationID,RecordTime,Datetime,Ralative_Heading_Angle,Ralative_Pitch_Angle,Position_Distance,Propagationtime,BasicSite_JD,BasicSite_WD,BasicSite_Depth,BasicSite_Heading_Angle,BasicSite_Pitch_Angle,BasicSite_Roll_Angle,BasicSite_Heading_Speed,BasicSite_Pitch_Speed,BasicSite_Roll_Speed,BasicSite_Forword_A,BasicSite_Right_A,BasicSite_Sky_A,Beacon_JD,Beacon_WD,Beacon_Depth,Beacon_Roll_Angle,Beacon_Pitch_Angle,Beacon_Heading_Angle,Temp) VALUES({1},'{2}','{3}',{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26});", tablename, beacon.ID, System.DateTime.Now, beacon.Datetime, beacon.Ralative_Heading_Angle, beacon.Ralative_Pitch_Angle, beacon.Position_Distance, beacon.Propagationtime, beacon.BasicSite_JD, beacon.BasicSite_WD, beacon.BasicSite_Depth, beacon.BasicSite_Heading_Angle, beacon.BasicSite_Pitch_Angle, beacon.BasicSite_Roll_Angle, beacon.BasicSite_Heading_Speed, beacon.BasicSite_Pitch_Speed, beacon.BasicSite_Roll_Speed, beacon.BasicSite_Forword_A, beacon.BasicSite_Right_A, beacon.BasicSite_Sky_A, beacon.Beacon_JD, beacon.Beacon_WD, beacon.Beacon_Depth, beacon.Beacon_Roll_Angle, beacon.Beacon_Pitch_Angle, beacon.Beacon_Heading_Angle, beacon.Temp);
+ ExecuteNonQuery(sql, 1);
+ }
+
+ public static void insertAlarmInfo(string tablename, AlarmInfo alarmInfo)
+ {
+ string sql = string.Format("insert into {0}(StationID,RecordTime,ParaName,ParaState) VALUES({1},'{2}','{3}','{4}');", tablename, alarmInfo.StationID, System.DateTime.Now, alarmInfo.ParaName, alarmInfo.ParaState);
ExecuteNonQuery(sql, 1);
}
diff --git a/Models/AlarmInfoModel.cs b/Models/AlarmInfoModel.cs
index 138286d..4c01386 100644
--- a/Models/AlarmInfoModel.cs
+++ b/Models/AlarmInfoModel.cs
@@ -104,7 +104,7 @@ namespace _20230724_MBJC_upperpc.Models
public int StationID
{
get { return stationId; }
- set { stationId = value; }
+ set { stationId = value; this.DoNotify(); }
}
@@ -115,7 +115,7 @@ namespace _20230724_MBJC_upperpc.Models
public DateTime RecordTime
{
get { return recordTime; }
- set { recordTime = value; }
+ set { recordTime = value; this.DoNotify(); }
}
private string paraName;
@@ -125,7 +125,7 @@ namespace _20230724_MBJC_upperpc.Models
public string ParaName
{
get { return paraName; }
- set { paraName = value; }
+ set { paraName = value; this.DoNotify(); }
}
private string paraState;
@@ -135,17 +135,8 @@ namespace _20230724_MBJC_upperpc.Models
public string ParaState
{
get { return paraState; }
- set { paraState = value; }
+ set { paraState = value; this.DoNotify(); }
}
- private int isHandled;
- ///
- /// 故障事件是否处理 0未处理 1已处理 2处理中
- ///
- public int IsHandled
- {
- get { return isHandled; }
- set { isHandled = value; }
- }
}
}
diff --git a/Models/ClientModel.cs b/Models/ClientModel.cs
index dc11534..ecc39b3 100644
--- a/Models/ClientModel.cs
+++ b/Models/ClientModel.cs
@@ -97,62 +97,62 @@ namespace _20230724_MBJC_upperpc.Models
//保存原始数据
tools.AddLgoToTXT("原始报文.txt", tools.Save_Path + System.DateTime.Now.ToString("yyyy_MM_dd") + @"\", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ---- " + message + "\r\n");
-
+ DateTime date = DateTime.Now;
string[] msgs = message.Split(',');
BeaconModel beacon = new BeaconModel();
beacon.ID = int.Parse(msgs[1]);
- beacon.Datetime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(int.Parse(msgs[2]));
- beacon.Ralative_Heading_Angle = float.Parse(msgs[3]);
- beacon.Ralative_Pitch_Angle = float.Parse(msgs[4]);
- beacon.Position_Distance = float.Parse(msgs[5]);
- beacon.Propagationtime = float.Parse(msgs[6]);
- beacon.BasicSite_JD = float.Parse(msgs[7]);
- beacon.BasicSite_WD = float.Parse(msgs[8]);
- beacon.BasicSite_Depth = float.Parse(msgs[9]);
- beacon.BasicSite_Heading_Angle = float.Parse(msgs[10]);
- beacon.BasicSite_Pitch_Angle = float.Parse(msgs[11]);
- beacon.BasicSite_Roll_Angle = float.Parse(msgs[12]);
- beacon.BasicSite_Heading_Speed = float.Parse(msgs[13]);
- beacon.BasicSite_Pitch_Speed = float.Parse(msgs[14]);
- beacon.BasicSite_Roll_Speed = float.Parse(msgs[15]);
- beacon.BasicSite_Forword_A = float.Parse(msgs[16]);
- beacon.BasicSite_Right_A = float.Parse(msgs[17]);
- beacon.BasicSite_Sky_A = float.Parse(msgs[18]);
- beacon.Beacon_JD = float.Parse(msgs[19]);
- beacon.Beacon_WD = float.Parse(msgs[20]);
- beacon.Beacon_Depth = float.Parse(msgs[21]);
- beacon.Beacon_Roll_Angle = float.Parse(msgs[22]);
- beacon.Beacon_Pitch_Angle = float.Parse(msgs[23]);
- beacon.Beacon_Heading_Angle = float.Parse(msgs[24]);
- beacon.Temp = float.Parse(msgs[25]);
+ beacon.Datetime = string.IsNullOrEmpty(msgs[2]) ? date : TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)).AddSeconds(int.Parse(msgs[2]));
+ beacon.Ralative_Heading_Angle = string.IsNullOrEmpty(msgs[3]) ? 0 : float.Parse(msgs[3]);
+ beacon.Ralative_Pitch_Angle = string.IsNullOrEmpty(msgs[4]) ? 0 : float.Parse(msgs[4]);
+ beacon.Position_Distance = string.IsNullOrEmpty(msgs[5]) ? 0 : float.Parse(msgs[5]);
+ beacon.Propagationtime = string.IsNullOrEmpty(msgs[6]) ? 0 : float.Parse(msgs[6]);
+ beacon.BasicSite_JD = string.IsNullOrEmpty(msgs[7]) ? 0 : float.Parse(msgs[7]);
+ beacon.BasicSite_WD = string.IsNullOrEmpty(msgs[8]) ? 0 : float.Parse(msgs[8]);
+ beacon.BasicSite_Depth = string.IsNullOrEmpty(msgs[9]) ? 0 : float.Parse(msgs[9]);
+ beacon.BasicSite_Heading_Angle = string.IsNullOrEmpty(msgs[10]) ? 0 : float.Parse(msgs[10]);
+ beacon.BasicSite_Pitch_Angle = string.IsNullOrEmpty(msgs[11]) ? 0 : float.Parse(msgs[11]);
+ beacon.BasicSite_Roll_Angle = string.IsNullOrEmpty(msgs[12]) ? 0 : float.Parse(msgs[12]);
+ beacon.BasicSite_Heading_Speed = string.IsNullOrEmpty(msgs[13]) ? 0 : float.Parse(msgs[13]);
+ beacon.BasicSite_Pitch_Speed = string.IsNullOrEmpty(msgs[14]) ? 0 : float.Parse(msgs[14]);
+ beacon.BasicSite_Roll_Speed = string.IsNullOrEmpty(msgs[15]) ? 0 : float.Parse(msgs[15]);
+ beacon.BasicSite_Forword_A = string.IsNullOrEmpty(msgs[16]) ? 0 : float.Parse(msgs[16]);
+ beacon.BasicSite_Right_A = string.IsNullOrEmpty(msgs[17]) ? 0 : float.Parse(msgs[17]);
+ beacon.BasicSite_Sky_A = string.IsNullOrEmpty(msgs[18]) ? 0 : float.Parse(msgs[18]);
+ beacon.Beacon_JD = string.IsNullOrEmpty(msgs[19]) ? 0 : float.Parse(msgs[19]);
+ beacon.Beacon_WD = string.IsNullOrEmpty(msgs[20]) ? 0 : float.Parse(msgs[20]);
+ beacon.Beacon_Depth = string.IsNullOrEmpty(msgs[21]) ? 0 : float.Parse(msgs[21]);
+ beacon.Beacon_Roll_Angle = string.IsNullOrEmpty(msgs[22]) ? 0 : float.Parse(msgs[22]);
+ beacon.Beacon_Pitch_Angle = string.IsNullOrEmpty(msgs[23]) ? 0 : float.Parse(msgs[23]);
+ beacon.Beacon_Heading_Angle = string.IsNullOrEmpty(msgs[24]) ? 0 : float.Parse(msgs[24]);
+ beacon.Temp = string.IsNullOrEmpty(msgs[25]) ? 0 : float.Parse(msgs[25]);
//数据存储
DBHelper.insertData("beaconmodel", beacon);
switch (beacon.ID)
{
- case 1:
+ case 25:
MainWindow.viewModel.Beacon1.Beacon = beacon;
break;
- case 2:
+ case 27:
MainWindow.viewModel.Beacon2.Beacon = beacon;
break;
- case 3:
+ case 28:
MainWindow.viewModel.Beacon3.Beacon = beacon;
break;
- case 4:
+ case 30:
MainWindow.viewModel.Beacon4.Beacon = beacon;
break;
- case 5:
+ case 49:
MainWindow.viewModel.Beacon5.Beacon = beacon;
break;
- case 6:
+ case 98:
MainWindow.viewModel.Beacon6.Beacon = beacon;
break;
- case 7:
+ case 32:
MainWindow.viewModel.Beacon7.Beacon = beacon;
break;
- case 8:
+ case 44:
MainWindow.viewModel.Beacon8.Beacon = beacon;
break;
default:
diff --git a/ViewModels/BeaconViewModel.cs b/ViewModels/BeaconViewModel.cs
index 9795a04..67a3b13 100644
--- a/ViewModels/BeaconViewModel.cs
+++ b/ViewModels/BeaconViewModel.cs
@@ -1,4 +1,5 @@
using _20230724_MBJC_upperpc.Common;
+using _20230724_MBJC_upperpc.DataAccess;
using _20230724_MBJC_upperpc.Models;
using System;
using System.Collections.Generic;
@@ -10,13 +11,13 @@ namespace _20230724_MBJC_upperpc.ViewModels
{
public class BeaconViewModel : NotifyBase
{
-
+
private BeaconModel beacon = new BeaconModel();
public BeaconModel Beacon
{
get { return beacon; }
- set { beacon = value; this.DoNotify(); DoFresh();}
+ set { beacon = value; this.DoNotify(); DoFresh(); }
}
private List beaconList = new List();
@@ -26,9 +27,10 @@ namespace _20230724_MBJC_upperpc.ViewModels
public List BeaconList
{
get { return beaconList; }
- set {
- beaconList = value;
- this.DoNotify();
+ set
+ {
+ beaconList = value;
+ this.DoNotify();
}
}
@@ -209,6 +211,35 @@ namespace _20230724_MBJC_upperpc.ViewModels
AlarmInfo.PYPercent_FY = Math.Abs(AlarmInfo.PY_FY) / Beacon_FY_DIS;
//偏航角偏移百分比
AlarmInfo.PYPercent_PH = Math.Abs(AlarmInfo.PY_PH) / Beacon_FY_DIS;
+
+ AlarmInfo alarmInfo = null;
+ #region 保存告警信息
+ if (AlarmInfo.PY_JL > 1)
+ {
+ alarmInfo = new AlarmInfo() { StationID = Beacon.ID, RecordTime = System.DateTime.Now, ParaName = "偏移距离", ParaState = "偏移距离" + AlarmInfo.PY_JL + "米,达到极限距离的" + AlarmInfo.PYPercent_JL * 100 + "%。" };
+ DBHelper.insertAlarmInfo("alarminfo", alarmInfo);
+ MainWindow.viewModel.AlarmInfoList.Add(alarmInfo);
+ }
+ if (AlarmInfo.PYPercent_HG > 1)
+ {
+ alarmInfo = new AlarmInfo() { StationID = Beacon.ID, RecordTime = System.DateTime.Now, ParaName = "横滚角", ParaState = "偏移角度" + AlarmInfo.PY_HG + "°,达到极限角度的" + AlarmInfo.PYPercent_JL * 100 + "%。" };
+ DBHelper.insertAlarmInfo("alarminfo", alarmInfo);
+ MainWindow.viewModel.AlarmInfoList.Add(alarmInfo);
+ }
+
+ if (AlarmInfo.PYPercent_FY > 1)
+ {
+ alarmInfo = new AlarmInfo() { StationID = Beacon.ID, RecordTime = System.DateTime.Now, ParaName = "俯仰角", ParaState = "偏移角度" + AlarmInfo.PY_FY + "°,达到极限角度的" + AlarmInfo.PYPercent_FY * 100 + "%。" };
+ DBHelper.insertAlarmInfo("alarminfo", alarmInfo);
+ MainWindow.viewModel.AlarmInfoList.Add(alarmInfo);
+ }
+ if (AlarmInfo.PYPercent_PH > 1)
+ {
+ alarmInfo = new AlarmInfo() { StationID = Beacon.ID, RecordTime = System.DateTime.Now, ParaName = "偏航角", ParaState = "偏移角度" + AlarmInfo.PY_PH + "°,达到极限角度的" + AlarmInfo.PYPercent_PH * 100 + "%。" };
+ DBHelper.insertAlarmInfo("alarminfo", alarmInfo);
+ MainWindow.viewModel.AlarmInfoList.Add(alarmInfo);
+ }
+ #endregion
}
}
diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs
index 9bad230..b00e4a8 100644
--- a/ViewModels/MainViewModel.cs
+++ b/ViewModels/MainViewModel.cs
@@ -5,6 +5,7 @@ using _20230724_MBJC_upperpc.Views;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.Intrinsics.X86;
@@ -117,6 +118,17 @@ namespace _20230724_MBJC_upperpc.ViewModels
set { client = value; this.DoNotify(); }
}
+ private ObservableCollection alarmInfoList = new ObservableCollection();
+ ///
+ /// 告警信息列表
+ ///
+ public ObservableCollection AlarmInfoList
+ {
+ get { return alarmInfoList; }
+ set { alarmInfoList = value; this.DoNotify(); }
+ }
+
+
///
/// 连接基阵上位机软件客户端的ip和端口号
///
@@ -147,6 +159,7 @@ namespace _20230724_MBJC_upperpc.ViewModels
this.AlarmInfoCommand.DoCanExcute = new Func