diff --git a/JiangsuEarthquake/.vs/JiangsuEarthquake/DesignTimeBuild/.dtbcache.v2 b/JiangsuEarthquake/.vs/JiangsuEarthquake/DesignTimeBuild/.dtbcache.v2 index 93fa394..1522e65 100644 Binary files a/JiangsuEarthquake/.vs/JiangsuEarthquake/DesignTimeBuild/.dtbcache.v2 and b/JiangsuEarthquake/.vs/JiangsuEarthquake/DesignTimeBuild/.dtbcache.v2 differ diff --git a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.futdcache.v2 b/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.futdcache.v2 deleted file mode 100644 index cbb9a2c..0000000 Binary files a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.futdcache.v2 and /dev/null differ diff --git a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.suo b/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.suo deleted file mode 100644 index b555a08..0000000 Binary files a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/.suo and /dev/null differ diff --git a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/DocumentLayout.json b/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/DocumentLayout.json deleted file mode 100644 index 9c47f48..0000000 --- a/JiangsuEarthquake/.vs/JiangsuEarthquake/v17/DocumentLayout.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "Version": 1, - "WorkspaceRootPath": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\", - "Documents": [ - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|f:\\code\\jseq\\20240301_jseq_upperpc\\jiangsuearthquake\\jiangsuearthquake\\viewmodels\\mainviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\viewmodels\\mainviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\jiangsuearthquake\\models\\lowercomputermodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\models\\lowercomputermodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\jiangsuearthquake\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\jiangsuearthquake\\views\\systemcontrolview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\views\\systemcontrolview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" - }, - { - "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\adm\\AppData\\Local\\Temp\\.vsdbgsrc\\793d914da17c09bdc8d37c92770294fd4f8e6e28e7f354949aefb80506ef516b\\DependencyObject.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|f:\\code\\jseq\\20240301_jseq_upperpc\\jiangsuearthquake\\jiangsuearthquake\\viewmodels\\boosterstationstatedataviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\viewmodels\\boosterstationstatedataviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\jiangsuearthquake\\app.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\app.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\jiangsuearthquake\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" - }, - { - "AbsoluteMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|f:\\code\\jseq\\20240301_jseq_upperpc\\jiangsuearthquake\\jiangsuearthquake\\common\\tools.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{51CD2C1B-B7CD-4AC0-8087-846E14D316AD}|JiangsuEarthquake\\JiangsuEarthquake.csproj|solutionrelative:jiangsuearthquake\\common\\tools.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" - } - ], - "DocumentGroupContainers": [ - { - "Orientation": 0, - "VerticalTabListWidth": 256, - "DocumentGroups": [ - { - "DockedWidth": 163, - "SelectedChildIndex": 8, - "Children": [ - { - "$type": "Document", - "DocumentIndex": 6, - "Title": "App.config", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\App.config", - "RelativeDocumentMoniker": "JiangsuEarthquake\\App.config", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\App.config", - "RelativeToolTip": "JiangsuEarthquake\\App.config", - "ViewState": "AQIAABIAAAAAAAAAAAAAAC4AAAAoAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000601|", - "WhenOpened": "2024-04-24T08:54:53.626Z", - "IsPinned": true, - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 4, - "Title": "DependencyObject.cs", - "DocumentMoniker": "C:\\Users\\adm\\AppData\\Local\\Temp\\.vsdbgsrc\\793d914da17c09bdc8d37c92770294fd4f8e6e28e7f354949aefb80506ef516b\\DependencyObject.cs", - "ToolTip": "C:\\Users\\adm\\AppData\\Local\\Temp\\.vsdbgsrc\\793d914da17c09bdc8d37c92770294fd4f8e6e28e7f354949aefb80506ef516b\\DependencyObject.cs [\u53EA\u8BFB]", - "ViewState": "AQIAAKoFAAAAAAAAAIAzwL8FAAACAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-07-08T08:35:05.858Z", - "EditorCaption": " [\u53EA\u8BFB]" - }, - { - "$type": "Document", - "DocumentIndex": 5, - "Title": "BoosterStationStateDataViewModel.cs", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\ViewModels\\BoosterStationStateDataViewModel.cs", - "RelativeDocumentMoniker": "JiangsuEarthquake\\ViewModels\\BoosterStationStateDataViewModel.cs", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\ViewModels\\BoosterStationStateDataViewModel.cs", - "RelativeToolTip": "JiangsuEarthquake\\ViewModels\\BoosterStationStateDataViewModel.cs", - "ViewState": "AQIAAAQDAAAAAAAAAAAuwBkDAAAwAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-07-08T08:20:55.119Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 8, - "Title": "Tools.cs", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Common\\Tools.cs", - "RelativeDocumentMoniker": "JiangsuEarthquake\\Common\\Tools.cs", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Common\\Tools.cs", - "RelativeToolTip": "JiangsuEarthquake\\Common\\Tools.cs", - "ViewState": "AQIAAFgBAAAAAAAAAAAUwAAAAAAAAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-07-08T08:19:12.338Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "LowerComputerModel.cs", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Models\\LowerComputerModel.cs", - "RelativeDocumentMoniker": "JiangsuEarthquake\\Models\\LowerComputerModel.cs", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Models\\LowerComputerModel.cs", - "RelativeToolTip": "JiangsuEarthquake\\Models\\LowerComputerModel.cs", - "ViewState": "AQIAAMkAAAAAAAAAAAAkwNQAAAAlAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-07-05T07:31:43.911Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 3, - "Title": "SystemControlView.xaml", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Views\\SystemControlView.xaml", - "RelativeDocumentMoniker": "JiangsuEarthquake\\Views\\SystemControlView.xaml", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\Views\\SystemControlView.xaml*", - "RelativeToolTip": "JiangsuEarthquake\\Views\\SystemControlView.xaml*", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", - "WhenOpened": "2024-07-05T06:33:41.961Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "MainWindow.xaml", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\MainWindow.xaml", - "RelativeDocumentMoniker": "JiangsuEarthquake\\MainWindow.xaml", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\MainWindow.xaml", - "RelativeToolTip": "JiangsuEarthquake\\MainWindow.xaml", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", - "WhenOpened": "2024-07-02T06:09:17.045Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 7, - "Title": "App.xaml", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\App.xaml", - "RelativeDocumentMoniker": "JiangsuEarthquake\\App.xaml", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\App.xaml", - "RelativeToolTip": "JiangsuEarthquake\\App.xaml", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", - "WhenOpened": "2024-07-01T06:30:26.069Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 0, - "Title": "MainViewModel.cs", - "DocumentMoniker": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\ViewModels\\MainViewModel.cs", - "RelativeDocumentMoniker": "JiangsuEarthquake\\ViewModels\\MainViewModel.cs", - "ToolTip": "F:\\Code\\JSEQ\\20240301_JSEQ_upperpc\\JiangsuEarthquake\\JiangsuEarthquake\\ViewModels\\MainViewModel.cs*", - "RelativeToolTip": "JiangsuEarthquake\\ViewModels\\MainViewModel.cs*", - "ViewState": "AQIAAPoIAAAAAAAAAAAswB8JAAAbAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2024-06-26T09:47:38.344Z", - "EditorCaption": "" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.metadata.v7.bin b/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.metadata.v7.bin deleted file mode 100644 index c5d9ce9..0000000 Binary files a/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.metadata.v7.bin and /dev/null differ diff --git a/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.projects.v7.bin b/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.projects.v7.bin deleted file mode 100644 index 4a00581..0000000 Binary files a/JiangsuEarthquake/.vs/ProjectEvaluation/jiangsuearthquake.projects.v7.bin and /dev/null differ diff --git a/JiangsuEarthquake/JiangsuEarthquake/App.config b/JiangsuEarthquake/JiangsuEarthquake/App.config index e76e51f..54516b6 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/App.config +++ b/JiangsuEarthquake/JiangsuEarthquake/App.config @@ -2,7 +2,7 @@ - + diff --git a/JiangsuEarthquake/JiangsuEarthquake/Common/Tools.cs b/JiangsuEarthquake/JiangsuEarthquake/Common/Tools.cs index 89cd3fa..c28e5b0 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/Common/Tools.cs +++ b/JiangsuEarthquake/JiangsuEarthquake/Common/Tools.cs @@ -447,13 +447,13 @@ namespace JiangsuEarthquake.Common #endregion - #region 异或校验和 + #region 校验和 public static byte CheckSum(byte[] buffer) { byte sum = 0; foreach (byte b in buffer) { - sum ^= b; + sum += b; } return sum; diff --git a/JiangsuEarthquake/JiangsuEarthquake/Models/LowerComputerModel.cs b/JiangsuEarthquake/JiangsuEarthquake/Models/LowerComputerModel.cs index 5b81afc..b3e50c3 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/Models/LowerComputerModel.cs +++ b/JiangsuEarthquake/JiangsuEarthquake/Models/LowerComputerModel.cs @@ -53,7 +53,7 @@ namespace JiangsuEarthquake.Models checkByte.Add(byteList[i]); checkCodeCRC = Tools.CheckSum(checkByte.ToArray()); //CRC校验失败 - if (checkCodeCRC != byteList[^1]) + if (checkCodeCRC != byteList[byteList.Count-2]) { string content = "接驳盒数据CRC校验失败" ; sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; @@ -95,7 +95,7 @@ namespace JiangsuEarthquake.Models case 0x30: //接驳盒端其他传感器集合 byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); - if (byteLength != 106) //长度校验失败 + if (byteLength != 110) //长度校验失败 { string content = "接驳盒其他传感器集合数据长度校验失败"; sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; @@ -403,7 +403,7 @@ namespace JiangsuEarthquake.Models //远程控制 //读取长度 byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); - if (byteLength != 13) //长度校验失败 + if (byteLength != 9) //长度校验失败 { string content = "接驳盒远程控制回复长度校验失败" ; sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; @@ -448,6 +448,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Seis1 = (ImageSource)Application.Current.FindResource("DeviceOff"); else MainViewModel.baseStationStateModel2.JunBox_Seis1 = (ImageSource)Application.Current.FindResource("DeviceOff"); + + MainWindow.mainViewModel.MainSeisPowerOffIsReceived = true; + MainWindow.mainViewModel.MainSeisPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.MainSeisPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerMainSeisPowerOff.Stop(); + MainWindow.mainViewModel.MainSeisMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.MainSeisMsg = "主地震仪电源关闭成功!"; + MainWindow.mainViewModel.timerMainSeisMsgHidden.Start(); + MainWindow.mainViewModel.MainSeisMsgForeground = new SolidColorBrush(Colors.Green); }); state = "Off"; @@ -460,6 +469,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Seis1 = (ImageSource)Application.Current.FindResource("DeviceOn"); else MainViewModel.baseStationStateModel2.JunBox_Seis1 = (ImageSource)Application.Current.FindResource("DeviceOn"); + + MainWindow.mainViewModel.MainSeisPowerOnIsReceived = true; + MainWindow.mainViewModel.MainSeisPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.MainSeisPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerMainSeisPowerOff.Stop(); + MainWindow.mainViewModel.MainSeisMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.MainSeisMsg = "主地震仪电源开启成功!"; + MainWindow.mainViewModel.timerMainSeisMsgHidden.Start(); + MainWindow.mainViewModel.MainSeisMsgForeground = new SolidColorBrush(Colors.Green); }); state = "On"; @@ -486,6 +504,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Seis2 = (ImageSource)Application.Current.FindResource("DeviceOff"); else MainViewModel.baseStationStateModel2.JunBox_Seis2 = (ImageSource)Application.Current.FindResource("DeviceOff"); + + MainWindow.mainViewModel.BackupSeisPowerOffIsReceived = true; + MainWindow.mainViewModel.BackupSeisPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.BackupSeisPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerBackupSeisPowerOff.Stop(); + MainWindow.mainViewModel.BackupSeisMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.BackupSeisMsg = "备地震仪电源关闭成功!"; + MainWindow.mainViewModel.timerBackupSeisMsgHidden.Start(); + MainWindow.mainViewModel.BackupSeisMsgForeground = new SolidColorBrush(Colors.Green); }); state = "Off"; @@ -498,6 +525,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Seis2 = (ImageSource)Application.Current.FindResource("DeviceOn"); else MainViewModel.baseStationStateModel2.JunBox_Seis2 = (ImageSource)Application.Current.FindResource("DeviceOn"); + + MainWindow.mainViewModel.BackupSeisPowerOnIsReceived = true; + MainWindow.mainViewModel.BackupSeisPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.BackupSeisPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerBackupSeisPowerOn.Stop(); + MainWindow.mainViewModel.BackupSeisMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.BackupSeisMsg = "备地震仪电源开启成功!"; + MainWindow.mainViewModel.timerBackupSeisMsgHidden.Start(); + MainWindow.mainViewModel.BackupSeisMsgForeground = new SolidColorBrush(Colors.Green); }); state = "On"; @@ -524,6 +560,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Elect = (ImageSource)Application.Current.FindResource("DeviceOff"); else MainViewModel.baseStationStateModel2.JunBox_Elect = (ImageSource)Application.Current.FindResource("DeviceOff"); + + MainWindow.mainViewModel.ElectPowerOffIsReceived = true; + MainWindow.mainViewModel.ElectPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.ElectPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerElectPowerOff.Stop(); + MainWindow.mainViewModel.ElectMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.ElectMsg = "电磁电源关闭成功!"; + MainWindow.mainViewModel.timerElectMsgHidden.Start(); + MainWindow.mainViewModel.ElectMsgForeground = new SolidColorBrush(Colors.Green); }); state = "Off"; @@ -536,6 +581,15 @@ namespace JiangsuEarthquake.Models MainViewModel.baseStationStateModel1.JunBox_Elect = (ImageSource)Application.Current.FindResource("DeviceOn"); else MainViewModel.baseStationStateModel2.JunBox_Elect = (ImageSource)Application.Current.FindResource("DeviceOn"); + + MainWindow.mainViewModel.ElectPowerOnIsReceived = true; + MainWindow.mainViewModel.ElectPowerOpenBtnIsEnabled = true; + MainWindow.mainViewModel.ElectPowerCloseBtnIsEnabled = true; + MainWindow.mainViewModel.timerElectPowerOn.Stop(); + MainWindow.mainViewModel.ElectMsgVisibility = Visibility.Visible; + MainWindow.mainViewModel.ElectMsg = "电磁电源开启成功!"; + MainWindow.mainViewModel.timerElectMsgHidden.Start(); + MainWindow.mainViewModel.ElectMsgForeground = new SolidColorBrush(Colors.Green); }); state = "On"; @@ -935,229 +989,284 @@ namespace JiangsuEarthquake.Models break; - case 0x07: - //接驳盒请求读取上位机现在时间 - //读取时间 - byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); - if (byteLength != 8) //长度校验失败 - { - string content = "接驳盒请求读取上位机现在时间数据长度校验失败"; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); + } - try - { - //发送失败信息 - if (id == 1) - { - if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) - MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - } - else if (id == 2) - { - if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) - MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - } - } - catch (Exception ex) - { - content = "接驳盒读取上位机现在时间长度校验失败信息发送失败," + ex.Message; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); - } - } - else + break; + + case 0x06: + //接驳盒回复上位机主动下发的校时信息 + byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); + if (byteLength != 8) //长度校验失败 + { + string content = "接驳盒回复上位机主动下发的校时信息长度校验失败"; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + + try + { + //发送失败信息 + if (id == 1) { + if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + else if (id == 2) + { + if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + } + catch (Exception ex) + { + content = "接驳盒回复上位机主动下发的校时信息长度校验失败信息发送失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + } + else + { + int time = BitConverter.ToInt32(new byte[] { byteList[9], byteList[8], byteList[7], byteList[6] }, 0); + DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + DateTime checkTime = epoch.AddSeconds(time).ToLocalTime(); + + string record = "接驳盒回复上位机主动下发的校时信息,时间为:" + checkTime.ToString(); + + sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{id}','{DateTime.Now}','海底地震监测基站-接驳盒','校时','{record}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + break; + + case 0x07: + //接驳盒请求读取上位机现在时间 + //读取时间 + byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); + if (byteLength != 8) //长度校验失败 + { + string content = "接驳盒请求读取上位机现在时间数据长度校验失败"; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + + try + { + //发送失败信息 + if (id == 1) + { + if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + else if (id == 2) + { + if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + } + catch (Exception ex) + { + content = "接驳盒读取上位机现在时间长度校验失败信息发送失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + } + else + { + List SendData = new List(); + SendData.AddRange(new byte[2] { 0xEF, 0xFE }); //帧头(H=0xEF 0xFE) + SendData.AddRange(new byte[2] { 0x00, 0x08 }); //长度(L=8)(MSH MSL)(从地址码到最后) + SendData.Add(0x01); //地址码 + SendData.Add(0x07); //功能码 + + TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0); + int totalSeconds = (int)ts.TotalSeconds; + string hexSeconds = totalSeconds.ToString("X2"); + byte[] timeByte = Tools.HexStringToByteArray(hexSeconds); + timeByte = Tools.PadArrayWithZeros(timeByte, 4); + SendData.AddRange(timeByte); //UTC时间 + + byte checkCode = Tools.CheckSum(SendData.ToArray()); + SendData.Add(checkCode); //校验 + SendData.Add(0x16); //结束符(0x16) + + try + { + if (id == 1) + { + if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + MainWindow.mainViewModel.serverModel1.SendMessage(SendData.ToArray()); + } + else if (id == 2) + { + if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + MainWindow.mainViewModel.serverModel2.SendMessage(SendData.ToArray()); + } + } + catch (Exception ex) + { + string content = "接驳盒读取上位机现在时间解析成功信息发送失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + } + break; + + case 0x20: + //接驳盒发送数据给上位机 + //传输事件 + byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); + if (byteLength != 18) //长度校验失败 + { + string content = "接驳盒告警数据长度校验失败"; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + + try + { + //发送失败信息 + if (id == 1) + { + if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + else if (id == 2) + { + if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + } + } + catch (Exception ex) + { + content = "接驳盒告警数据长度校验失败信息发送失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + } + else + { + string ParaName; + int ParaNum; + DateTime DataTime; + string ParaContent; + + try + { + ParaName = ReturnEvent(byteList[6], byteList[7]); + ParaNum = byteList[8]; + int timeUTC = BitConverter.ToInt32(new byte[4] { byteList[12], byteList[11], byteList[10], byteList[9] }, 0); + // Unix时间戳起始时间 + DateTime epoch = new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Utc); + // 将时间戳转换为UTC时间 + DataTime = epoch.AddSeconds(timeUTC); + int millisecond = BitConverter.ToInt16(new byte[2] { byteList[14], byteList[13] }, 0); + int data = BitConverter.ToInt32(new byte[4] { byteList[18], byteList[17], byteList[16], byteList[15] }, 0); + string eventName = ReturnEventName(byteList[19]); + ParaContent = eventName + ",当前数值为" + data; + + try + { + //发送成功信息 List SendData = new List(); SendData.AddRange(new byte[2] { 0xEF, 0xFE }); //帧头(H=0xEF 0xFE) - SendData.AddRange(new byte[2] { 0x00, 0x08 }); //长度(L=8)(MSH MSL)(从地址码到最后) - SendData.Add(0x01); //地址码 - SendData.Add(0x07); //功能码 - - TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0); - int totalSeconds = (int)ts.TotalSeconds; - string hexSeconds = totalSeconds.ToString("X2"); - byte[] timeByte = Tools.HexStringToByteArray(hexSeconds); - timeByte = Tools.PadArrayWithZeros(timeByte, 4); - SendData.AddRange(timeByte); //UTC时间 - + SendData.AddRange(new byte[2] { 0x00, 0x07 }); //长度(L=6)(MSH MSL)(从地址码到最后) + SendData.Add(0x01); //地址码(ADDR=00) + SendData.Add(functionCode); //功能码(FUNC=02) + SendData.AddRange(new byte[2] { byteList[6], byteList[7] }); //事件码(x,y) + SendData.Add(0x01); //接收应答(ACK:0-解析失败,1-解析成功) byte checkCode = Tools.CheckSum(SendData.ToArray()); - SendData.Add(checkCode); //校验 + SendData.Add(checkCode); //校验(CS = 帧头 ...+... 应答) SendData.Add(0x16); //结束符(0x16) - try + if (id == 1) { - if (id == 1) - { - if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) - MainWindow.mainViewModel.serverModel1.SendMessage(SendData.ToArray()); - } - else if (id == 2) - { - if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) - MainWindow.mainViewModel.serverModel2.SendMessage(SendData.ToArray()); - } + if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + MainWindow.mainViewModel.serverModel1.SendMessage(SendData.ToArray()); } - catch (Exception ex) + else if (id == 2) { - string content = "接驳盒读取上位机现在时间解析成功信息发送失败," + ex.Message; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); + if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + MainWindow.mainViewModel.serverModel2.SendMessage(SendData.ToArray()); } } - break; - - case 0x20: - //接驳盒发送数据给上位机 - //传输事件 - byteLength = BitConverter.ToInt16(new byte[] { byteList[3], byteList[2] }, 0); - if (byteLength != 18) //长度校验失败 + catch (Exception ex) { - string content = "接驳盒告警数据长度校验失败"; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据校验','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); - - try - { - //发送失败信息 - if (id == 1) - { - if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) - MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - } - else if (id == 2) - { - if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) - MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - } - } - catch (Exception ex) - { - content = "接驳盒告警数据长度校验失败信息发送失败," + ex.Message; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); - } - } - else - { - string ParaName; - int ParaNum; - DateTime DataTime; - string ParaContent; - - try - { - ParaName = ReturnEvent(byteList[6], byteList[7]); - ParaNum = byteList[8]; - int timeUTC = BitConverter.ToInt32(new byte[4] { byteList[12], byteList[11], byteList[10], byteList[9] }, 0); - // Unix时间戳起始时间 - DateTime epoch = new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Utc); - // 将时间戳转换为UTC时间 - DataTime = epoch.AddSeconds(timeUTC); - int millisecond = BitConverter.ToInt16(new byte[2] { byteList[14], byteList[13] }, 0); - int data = BitConverter.ToInt32(new byte[4] { byteList[18], byteList[17], byteList[16], byteList[15] }, 0); - string eventName = ReturnEventName(byteList[19]); - ParaContent = eventName + ",当前数值为" + data; - - try - { - //发送成功信息 - if (id == 1) - { - if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) - MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x01).ToArray()); - } - else if (id == 2) - { - if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) - MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x01).ToArray()); - } - } - catch (Exception ex) - { - string content = "接驳盒告警数据解析成功信息发送失败," + ex.Message; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); - } - - - #region 更新到实时数据显示页面 - //更新到前端 - App.Current.Dispatcher.Invoke(() => - { - if (id == 1) - MainViewModel.realTimeDataViewModel1.AlarmList.Clear(); - - sql = String.Format("select * from alarm_info where StationID = {0} ORDER by id desc limit 7", id); - MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1); - int index = 1; - while (dataReader.Read()) - { - AlarmRecordModel alarmRecordModel = new AlarmRecordModel(); - alarmRecordModel.Index = index++; - alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]); - alarmRecordModel.ParaName = dataReader["ParaName"].ToString(); - alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); - alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); - if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 1) - { - alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); - } - else if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 2) - { - alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); - } - else - { - alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed"); - } - - if (id == 1) - MainViewModel.realTimeDataViewModel1.AlarmList.Add(alarmRecordModel); - else - MainViewModel.realTimeDataViewModel2.AlarmList.Add(alarmRecordModel); - } - dataReader.Dispose(); - }); - #endregion - - } - catch (Exception ex) - { - string content = "接驳盒告警信息解析失败," + ex.Message; - sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据解析','{content}');"; - DBHelper.ExecuteNonQuery(sql, 1); - - //try - //{ - // //发送失败信息 - // if (id == 1) - // { - // if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) - // MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - // } - // else if (id == 2) - // { - // if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) - // MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); - // } - //} - //catch - //{ - - //} - - break; - } - - //数据存储 - sql = $"insert into alarm_info(StationID,RecordTime,DataTime,ParaName,ParaNum," + - $"ParaContent,IsHandled) values('{id}','{DateTime.Now}','{DataTime}','{ParaName}','{ParaNum}'," + - $"'{ParaContent}','0');"; + string content = "接驳盒告警数据解析成功信息发送失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据发送','{content}');"; DBHelper.ExecuteNonQuery(sql, 1); } + + #region 更新到实时数据显示页面 + //更新到前端 + App.Current.Dispatcher.Invoke(() => + { + if (id == 1) + MainViewModel.realTimeDataViewModel1.AlarmList.Clear(); + + sql = String.Format("select * from alarm_info where StationID = {0} ORDER by id desc limit 7", id); + MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1); + int index = 1; + while (dataReader.Read()) + { + AlarmRecordModel alarmRecordModel = new AlarmRecordModel(); + alarmRecordModel.Index = index++; + alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]); + alarmRecordModel.ParaName = dataReader["ParaName"].ToString(); + alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); + alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); + if (dataReader["UrgencyLevel"].ToString() == "1") + { + alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); + } + else if (dataReader["UrgencyLevel"].ToString() == "2") + { + alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); + } + else + { + alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed"); + } + + if (id == 1) + MainViewModel.realTimeDataViewModel1.AlarmList.Add(alarmRecordModel); + else + MainViewModel.realTimeDataViewModel2.AlarmList.Add(alarmRecordModel); + } + dataReader.Dispose(); + }); + #endregion + + } + catch (Exception ex) + { + string content = "接驳盒告警信息解析失败," + ex.Message; + sql = $"insert into alarm_run_info(StationID,RecordTime,ParaName,ParaContent) values('{id}','{DateTime.Now}','接驳盒数据解析','{content}');"; + DBHelper.ExecuteNonQuery(sql, 1); + + //try + //{ + // //发送失败信息 + // if (id == 1) + // { + // if (MainWindow.mainViewModel.serverModel1 != null && MainWindow.mainViewModel.serverModel1.IsOpened) + // MainWindow.mainViewModel.serverModel1.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + // } + // else if (id == 2) + // { + // if (MainWindow.mainViewModel.serverModel2 != null && MainWindow.mainViewModel.serverModel2.IsOpened) + // MainWindow.mainViewModel.serverModel2.SendMessage(ServerReplyData(byteList[5], byteList[6], 0x00).ToArray()); + // } + //} + //catch + //{ + + //} + break; + } + + //数据存储 + sql = $"insert into alarm_info(StationID,RecordTime,DataTime,ParaName,ParaNum," + + $"ParaContent,IsHandled) values('{id}','{DateTime.Now}','{DataTime}','{ParaName}','{ParaNum}'," + + $"'{ParaContent}','0');"; + DBHelper.ExecuteNonQuery(sql, 1); } break; diff --git a/JiangsuEarthquake/JiangsuEarthquake/Models/ServerModel.cs b/JiangsuEarthquake/JiangsuEarthquake/Models/ServerModel.cs index dbdb420..78d6a6b 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/Models/ServerModel.cs +++ b/JiangsuEarthquake/JiangsuEarthquake/Models/ServerModel.cs @@ -145,10 +145,10 @@ namespace JiangsuEarthquake.Models bool result = false; try { - Task.Factory.StartNew(new Action(() => - { + //Task.Factory.StartNew(new Action(() => + //{ result = _server.SendToAll(SendData); - })); + //})); } catch { diff --git a/JiangsuEarthquake/JiangsuEarthquake/ViewModels/MainViewModel.cs b/JiangsuEarthquake/JiangsuEarthquake/ViewModels/MainViewModel.cs index a92df10..fbb6006 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/ViewModels/MainViewModel.cs +++ b/JiangsuEarthquake/JiangsuEarthquake/ViewModels/MainViewModel.cs @@ -529,11 +529,11 @@ namespace JiangsuEarthquake.ViewModels alarmRecordModel.ParaNum = Convert.ToInt32(string.IsNullOrEmpty(dataReader["ParaNum"].ToString()) ? 0 : dataReader["ParaNum"]); alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); - if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 1) + if (dataReader["UrgencyLevel"].ToString() == "1") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed"); } - else if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 2) + else if (dataReader["UrgencyLevel"].ToString() == "2") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); } @@ -541,11 +541,11 @@ namespace JiangsuEarthquake.ViewModels { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); } - if (Convert.ToInt32(dataReader["IsHandled"]) == 0) + if (dataReader["IsHandled"].ToString() == "0") { alarmRecordModel.IsHandled = "未处理"; } - else if (Convert.ToInt32(dataReader["IsHandled"]) == 1) + else if (dataReader["IsHandled"].ToString() == "1") { alarmRecordModel.IsHandled = "已处理"; } @@ -576,11 +576,11 @@ namespace JiangsuEarthquake.ViewModels alarmRecordModel.ParaNum = Convert.ToInt32(string.IsNullOrEmpty(dataReader["ParaNum"].ToString()) ? 0 : dataReader["ParaNum"]); alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); - if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 1) + if (dataReader["UrgencyLevel"].ToString() == "1") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed"); } - else if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 2) + else if (dataReader["UrgencyLevel"].ToString() == "2") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); } @@ -588,11 +588,11 @@ namespace JiangsuEarthquake.ViewModels { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); } - if (Convert.ToInt32(dataReader["IsHandled"]) == 0) + if (dataReader["IsHandled"].ToString() == "0") { alarmRecordModel.IsHandled = "未处理"; } - else if (Convert.ToInt32(dataReader["IsHandled"]) == 1) + else if (dataReader["IsHandled"].ToString() == "1") { alarmRecordModel.IsHandled = "已处理"; } @@ -1737,11 +1737,11 @@ namespace JiangsuEarthquake.ViewModels alarmRecordModel.ParaName = dataReader["ParaName"].ToString(); alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); - if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 1) + if (dataReader["UrgencyLevel"].ToString() == "1") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); } - else if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 2) + else if (dataReader["UrgencyLevel"].ToString() == "2") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); } @@ -1764,11 +1764,11 @@ namespace JiangsuEarthquake.ViewModels alarmRecordModel.ParaName = dataReader["ParaName"].ToString(); alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString(); alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString(); - if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 1) + if (dataReader["UrgencyLevel"].ToString() == "1") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow"); } - else if (Convert.ToInt32(dataReader["UrgencyLevel"]) == 2) + else if (dataReader["UrgencyLevel"].ToString() == "2") { alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange"); } @@ -3686,8 +3686,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "通信未连接!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3703,8 +3703,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "通信未连接!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3723,8 +3723,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "打开主地震仪电源发送失败!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; } string sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','海底地震监测基站-接驳盒','系统控制','{MainSeisMsg}');"; @@ -3751,8 +3751,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "通信未连接!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3768,8 +3768,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "通信未连接!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3788,8 +3788,8 @@ namespace JiangsuEarthquake.ViewModels MainSeisMsg = "关闭主地震仪电源发送失败!"; timerMainSeisMsgHidden.Start(); MainSeisMsgForeground = new SolidColorBrush(Colors.Red); - MainSeisPowerOpenBtnIsEnabled = false; - MainSeisPowerCloseBtnIsEnabled = false; + MainSeisPowerOpenBtnIsEnabled = true; + MainSeisPowerCloseBtnIsEnabled = true; } string sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','海底地震监测基站-接驳盒','系统控制','{MainSeisMsg}');"; @@ -3818,8 +3818,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "通信未连接!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3835,8 +3835,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "通信未连接!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3855,8 +3855,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "打开备地震仪电源发送失败!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; } string sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','海底地震监测基站-接驳盒','系统控制','{BackupSeisMsg}');"; @@ -3883,8 +3883,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "通信未连接!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3900,8 +3900,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "通信未连接!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; break; } } @@ -3920,8 +3920,8 @@ namespace JiangsuEarthquake.ViewModels BackupSeisMsg = "关闭备地震仪电源发送失败!"; timerBackupSeisMsgHidden.Start(); BackupSeisMsgForeground = new SolidColorBrush(Colors.Red); - BackupSeisPowerOpenBtnIsEnabled = false; - BackupSeisPowerCloseBtnIsEnabled = false; + BackupSeisPowerOpenBtnIsEnabled = true; + BackupSeisPowerCloseBtnIsEnabled = true; } string sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','海底地震监测基站-接驳盒','系统控制','{BackupSeisMsg}');"; @@ -3967,8 +3967,8 @@ namespace JiangsuEarthquake.ViewModels ElectMsg = "通信未连接!"; timerElectMsgHidden.Start(); ElectMsgForeground = new SolidColorBrush(Colors.Red); - ElectPowerOpenBtnIsEnabled = false; - ElectPowerCloseBtnIsEnabled = false; + ElectPowerOpenBtnIsEnabled = true; + ElectPowerCloseBtnIsEnabled = true; break; } //} @@ -4032,8 +4032,8 @@ namespace JiangsuEarthquake.ViewModels ElectMsg = "通信未连接!"; timerElectMsgHidden.Start(); ElectMsgForeground = new SolidColorBrush(Colors.Red); - ElectPowerOpenBtnIsEnabled = false; - ElectPowerCloseBtnIsEnabled = false; + ElectPowerOpenBtnIsEnabled = true; + ElectPowerCloseBtnIsEnabled = true; break; } //} @@ -4052,8 +4052,8 @@ namespace JiangsuEarthquake.ViewModels ElectMsg = "关闭电磁电源发送失败!"; timerElectMsgHidden.Start(); ElectMsgForeground = new SolidColorBrush(Colors.Red); - ElectPowerOpenBtnIsEnabled = false; - ElectPowerCloseBtnIsEnabled = false; + ElectPowerOpenBtnIsEnabled = true; + ElectPowerCloseBtnIsEnabled = true; } string sql = $"insert into log_record(StationID,RecordTime,Device_Name,Operation_Type,Record) values('2','{DateTime.Now}','海底地震监测基站-接驳盒','系统控制','{ElectMsg}');"; diff --git a/JiangsuEarthquake/JiangsuEarthquake/Views/LogRecordView.xaml b/JiangsuEarthquake/JiangsuEarthquake/Views/LogRecordView.xaml index ec2cf2e..27c7af1 100644 --- a/JiangsuEarthquake/JiangsuEarthquake/Views/LogRecordView.xaml +++ b/JiangsuEarthquake/JiangsuEarthquake/Views/LogRecordView.xaml @@ -259,12 +259,16 @@ +