From ead6ded30d16878323b15ac8f47f409726e81d97 Mon Sep 17 00:00:00 2001 From: MoYue Date: Tue, 2 Jul 2024 10:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=BD=93=E5=89=8D=E6=97=B6?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/SequentialDistributionViewModel.cs | 62 +++++++++++++++++-- .../ViewModels/Pages/ViewModelBase.cs | 13 ++-- .../Pages/SequentialDistributionView.xaml | 57 ++++++++++++++++- 3 files changed, 122 insertions(+), 10 deletions(-) diff --git a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs index 440e5e0..5ba4bd7 100644 --- a/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs +++ b/InSituLaboratory/ViewModels/Pages/SequentialDistributionViewModel.cs @@ -1,11 +1,14 @@ -using InSituLaboratory.Common; +using Azure; +using InSituLaboratory.Common; using InSituLaboratory.Entities; using InSituLaboratory.Entities.SqlSugar; using InSituLaboratory.IService; using InSituLaboratory.IService.Sensor; using InSituLaboratory.Models; using InSituLaboratory.Service; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Query.Internal; +using Prism.Commands; using Prism.Regions; using Prism.Services.Dialogs; using System; @@ -33,6 +36,7 @@ namespace InSituLaboratory.ViewModels.Pages public CurrentSequentiualModel CurrentSequentiual { get; set; } = new CurrentSequentiualModel(); //当前运行时序状态表 public SequentStatusModel sequentStatusModel { get; set; } = new SequentStatusModel(); + System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$"); #endregion @@ -1530,6 +1534,40 @@ namespace InSituLaboratory.ViewModels.Pages } #endregion + /// + /// 请求当前时序 + /// + /// + public override void DoSync(object o) + { + string[] msg = o.ToString().Split(','); + switch (msg[0]) + { + //时序1 + case "sequent1": + DoSyncSend(0x01); + break; + //时序2 + case "sequent2": + DoSyncSend(0x02); + break; + //时序3 + case "sequent3": + DoSyncSend(0x03); + break; + //时序4 + case "sequent4": + DoSyncSend(0x04); + break; + //时序5 + case "sequent5": + DoSyncSend(0x05); + break; + default: + break; + } + System.Windows.Forms.MessageBox.Show("已请求当前时序同步!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } /// /// 转义封装 @@ -1596,7 +1634,7 @@ namespace InSituLaboratory.ViewModels.Pages /// - /// 命令发送 + /// 命令发送 ---时序清空 /// /// 时序号 /// 操作类型 @@ -1612,6 +1650,22 @@ namespace InSituLaboratory.ViewModels.Pages } + /// + /// 请求当前时序下发 + /// + /// 时序组号 + public void DoSyncSend(byte x1) + { + //消息体 + byte[] byteaq = new byte[] { 0x92, 0x02, 0x10, 0x01, 0x00, 0x00, 0x00, 0x01, x1 }; + List buffer = Escape(byteaq); + string list = tools.byteToHexStr(buffer.ToArray()); + byte[] bytea = tools.ConvertHexStringToBytes(list); + RelayViewModel.clientModel.SendData(bytea); + + } + + /// /// 时序下发封装数据域 /// @@ -1661,7 +1715,7 @@ namespace InSituLaboratory.ViewModels.Pages System.TimeSpan t3 = endTime - startTime; float getMinute = (float)t3.TotalMinutes; - + year = (ulong)startTime.Year * 10000000000UL; month = (ulong)startTime.Month * 100000000UL; @@ -1753,7 +1807,7 @@ namespace InSituLaboratory.ViewModels.Pages } if (totalTime > getMinute) { - throw new Exception("当前所下发的时序中,所有设备工作总时长:"+ totalTime + "分钟,已经超过时序规定时长:"+ getMinute + "分钟!" + "\n请修改设备后重试!!!"); + throw new Exception("当前所下发的时序中,所有设备工作总时长:" + totalTime + "分钟,已经超过时序规定时长:" + getMinute + "分钟!" + "\n请修改设备后重试!!!"); } //b = new List() { 4, 3, 4, 6 }; diff --git a/InSituLaboratory/ViewModels/Pages/ViewModelBase.cs b/InSituLaboratory/ViewModels/Pages/ViewModelBase.cs index d79074b..b4052b4 100644 --- a/InSituLaboratory/ViewModels/Pages/ViewModelBase.cs +++ b/InSituLaboratory/ViewModels/Pages/ViewModelBase.cs @@ -1,4 +1,5 @@ -using Prism.Commands; +using Microsoft.Identity.Client.NativeInterop; +using Prism.Commands; using Prism.Mvvm; using Prism.Regions; using System; @@ -64,9 +65,11 @@ namespace InSituLaboratory.ViewModels.Pages public DelegateCommand StartCommand { get; set; }//一键启动 public DelegateCommand SynchronizationCommand { get; set; }//时间同步 - + public DelegateCommand SyncCommand { get; set; }//请求当前时序 + + #region 时序1-5 刷新 新增/编辑 删除 下发 启动 暂停 清空 - + public DelegateCommand RefreshS1Command { get; set; } public DelegateCommand SendS1Command { get; set; } public DelegateCommand ModifyS1Command { get; set; } @@ -124,6 +127,7 @@ namespace InSituLaboratory.ViewModels.Pages ReductionCommand = new DelegateCommand(DoReduction); StartCommand = new DelegateCommand(DoStart); SynchronizationCommand = new DelegateCommand(DoSynchronization); + SyncCommand = new DelegateCommand(DoSync); #region 时序1-5 刷新 新增/编辑 删除 下发 启动 暂停 清空 @@ -189,10 +193,11 @@ namespace InSituLaboratory.ViewModels.Pages public virtual void DoStart() { } public virtual void DoSynchronization() { } private string PageName { get; set; } + public virtual void DoSync(object o) { } #region 时序1-5 刷新 新增/编辑 删除 下发 启动 暂停 清空 - + public virtual void RefreshS1() { } public virtual void SendS1() { } public virtual void DoModifyS1(object model) { } diff --git a/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml b/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml index d9f4ee8..026db38 100644 --- a/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml +++ b/InSituLaboratory/Views/Pages/SequentialDistributionView.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:InSituLaboratory.Views.Pages" + xmlns:converters="clr-namespace:InSituLaboratory.Base;assembly=InSituLaboratory.Base" xmlns:c="clr-namespace:InSituLaboratory.Controls;assembly=InSituLaboratory.Controls" xmlns:hc="https://handyorg.github.io/handycontrol" mc:Ignorable="d" @@ -15,7 +16,8 @@ - + + - + + + @@ -167,6 +171,15 @@ @@ -275,6 +288,7 @@ @@ -396,6 +419,7 @@ @@ -516,6 +549,7 @@ @@ -636,6 +679,7 @@