diff --git a/InSituLaboratory.Entities/tools.cs b/InSituLaboratory.Entities/tools.cs
index bebb908..38b37f7 100644
--- a/InSituLaboratory.Entities/tools.cs
+++ b/InSituLaboratory.Entities/tools.cs
@@ -186,6 +186,30 @@ namespace InSituLaboratory.Entities
return txt;
}
+
+
+ ///
+ /// 将文本文件读取到末尾
+ ///
+ ///
+ ///
+ public static string ReadTXT_StreamReader(string pathAName)
+ {
+ StreamReader ObjectName = new StreamReader(pathAName);
+ return ObjectName.ReadToEnd();
+ }
+
+ ///
+ /// 逐行读取文件,返回数组
+ ///
+ ///
+ ///
+ public static string[] ReadTXT_ReadAllLines(string pathAName)
+ {
+ string[] txtContent = null;
+ txtContent = System.IO.File.ReadAllLines(pathAName, Encoding.UTF8);
+ return txtContent;
+ }
#endregion
#region 文件是否被占用
diff --git a/InSituLaboratory/Common/DataParsing.cs b/InSituLaboratory/Common/DataParsing.cs
index 1a57283..1d459ec 100644
--- a/InSituLaboratory/Common/DataParsing.cs
+++ b/InSituLaboratory/Common/DataParsing.cs
@@ -48,7 +48,7 @@ namespace InSituLaboratory.Common
//crc
static byte nr_crc = 0;
- ///
+ ///
/// 数据解析
///
///
@@ -331,6 +331,24 @@ namespace InSituLaboratory.Common
db.Insertable(dataParsingModel).ExecuteCommand();
}
}
+
+ //反馈正常时序
+ if (dataNew[1] == 0x01 && dataNew[2] == 0x07)
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+
}
diff --git a/InSituLaboratory/Common/TXTDataParsing.cs b/InSituLaboratory/Common/TXTDataParsing.cs
new file mode 100644
index 0000000..099eea6
--- /dev/null
+++ b/InSituLaboratory/Common/TXTDataParsing.cs
@@ -0,0 +1,81 @@
+using InSituLaboratory.Entities.ExperimentalStationEntities;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace InSituLaboratory.Common
+{
+ ///
+ /// 基站返回的数据解析
+ ///
+ public class TXTDataParsing
+ {
+ //连接钥匙
+ private static readonly string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["db"].ConnectionString;
+
+ //获取当前程序运行路径
+ private string Save_Path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"数据记录\";
+
+ //系统状态表
+ public SysStatus sysStatus = new SysStatus();
+
+ //当前工作设备 0-待机 1-工作
+ public CurrentWorkEquipment currentWorkEquipment = new CurrentWorkEquipment();
+
+ //当前故障设备 0-正常 1-故障
+ public CurrentFaultyEquipment currentFaultyEquipment = new CurrentFaultyEquipment();
+
+ //包头
+ string head = "AABB";
+
+ //包尾
+ string tail = "EEFF";
+
+ //版本号 -固定
+ byte version = 0x01;
+
+ //crc
+ static byte nr_crc = 0;
+
+
+ ///
+ /// 数据解析
+ ///
+ ///
+ public void ParsingData(List byteList)
+ {
+ //如果数组长度为0 舍弃
+ if (byteList.Count() == 0)
+ return;
+
+ //将报文中的内容截取出来 并保存至本地TXT文件内
+ string NR_TXT = "";
+ for (int i = 0; i < byteList.Count; i++)
+ {
+ NR_TXT += byteList[i].ToString("X2") + " ";
+ }
+
+ //SqlSugar配置文件
+ ConnectionConfig connectionConfig = new ConnectionConfig()
+ {
+ ConnectionString = ConnStr,
+ IsAutoCloseConnection = true,
+ DbType = DbType.Sqlite
+ };
+
+ //包头包尾校验
+ if ((byteList[0].ToString("X2") + byteList[1].ToString("X2")) != head || (byteList[byteList.Count -1].ToString("X2") + byteList[byteList.Count -2].ToString("X2")) != tail)
+ return;
+
+
+
+
+
+
+
+ }
+ }
+}
diff --git a/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs b/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs
index ee30b30..a382f74 100644
--- a/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs
+++ b/InSituLaboratory/ViewModels/Pages/DashboardViewModel.cs
@@ -14,6 +14,7 @@ using InSituLaboratory.IService;
using Prism.Commands;
using System.Windows;
using System.Windows.Forms;
+using InSituLaboratory.Entities;
namespace InSituLaboratory.ViewModels.Pages
{
@@ -97,22 +98,31 @@ namespace InSituLaboratory.ViewModels.Pages
///
/// 读取文本文档
///
- ///
+ ///
public void DoRead(object o)
{
- System.Windows.Forms.MessageBox.Show("暂无此项功能!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
-
+ string? info = null;
+ string? txtContent = null;
OpenFileDialog openFileDialog = new OpenFileDialog();
-
openFileDialog.Title = "选择文件";
-
openFileDialog.Multiselect = false;//选择多个文件
-
openFileDialog.RestoreDirectory = true;//跟踪上次打开的文件的目录
-
+ //openFileDialog.Filter = "所有文件(*.*)|*";
openFileDialog.Filter = "Text files(*.txt) | *.txt";
+ openFileDialog.CheckFileExists = true;
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ info = openFileDialog.FileName;
+ }
+ if (!string.IsNullOrEmpty(info))
+ {
+ //逐行读取文件,返回数组
+ txtContent = tools.ReadTXT_StreamReader(info);
+
+
+ }
+
-
}
}
diff --git a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs
index 01ec752..74308a6 100644
--- a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs
+++ b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs
@@ -2289,16 +2289,17 @@ namespace InSituLaboratory.ViewModels.Pages
if (regex.IsMatch(w.ToString()))
{
int worktime = (int)w;
- byteaq.Add((byte)(worktime & 0xFF));
- byteaq.Add((byte)((worktime & 0xFF00) >> 8));
- byteaq.Add((byte)((worktime & 0xFF0000) >> 16));
byteaq.Add((byte)((worktime >> 24) & 0xFF));
+ byteaq.Add((byte)((worktime & 0xFF0000) >> 16));
+ byteaq.Add((byte)((worktime & 0xFF00) >> 8));
+ byteaq.Add((byte)(worktime & 0xFF));
}
else
{
byte[] bytes = BitConverter.GetBytes(w);
Array.Reverse(bytes);
byte[] bytes1 = tools.PadArrayWithZeros(bytes, 4);
+ Array.Reverse(bytes1);
byteaq.AddRange(bytes1);
}
@@ -2309,16 +2310,17 @@ namespace InSituLaboratory.ViewModels.Pages
if (regex.IsMatch(dm.ToString()))
{
int durationTime = (int)dm;
- byteaq.Add((byte)(durationTime & 0xFF));
- byteaq.Add((byte)((durationTime & 0xFF00) >> 8));
- byteaq.Add((byte)((durationTime & 0xFF0000) >> 16));
byteaq.Add((byte)((durationTime >> 24) & 0xFF));
+ byteaq.Add((byte)((durationTime & 0xFF0000) >> 16));
+ byteaq.Add((byte)((durationTime & 0xFF00) >> 8));
+ byteaq.Add((byte)(durationTime & 0xFF));
}
else
{
byte[] bytesm = BitConverter.GetBytes(dm);
Array.Reverse(bytesm);
byte[] bytesm1 = tools.PadArrayWithZeros(bytesm, 4);
+ Array.Reverse(bytesm1);
byteaq.AddRange(bytesm1);
}
@@ -2339,6 +2341,12 @@ namespace InSituLaboratory.ViewModels.Pages
throw new Exception("当前所下发的时序中电能板4总功耗:" + EnergyBoard4 + "W" + " ,已超过电能板4额定功率250W \n 时序无法下发,请修改设备后重试!!!");
}
}
+ var length_data = byteaq.Count() - 6;
+ byte[] bytes_length = BitConverter.GetBytes(length_data);
+ byteaq[6] = bytes_length[1];
+ byteaq[7] = bytes_length[0];
+
+
return byteaq;
}
diff --git a/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml b/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml
index e43b78f..3932299 100644
--- a/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml
+++ b/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml
@@ -154,7 +154,7 @@
-