增加时序清空,启动,暂停功能

This commit is contained in:
MoYue 2024-06-19 14:01:51 +08:00
parent eaf62bcb94
commit caf075a267
4 changed files with 379 additions and 6 deletions

View File

@ -33,7 +33,7 @@ namespace InSituLaboratory.ViewModels.Pages
public class RelayViewModel : ViewModelBase
{
#region Entity
public ClientModel clientModel { get; set; } = new ClientModel();//Socket 通信类
public static ClientModel clientModel { get; set; } = new ClientModel();//Socket 通信类
public SysSensorModel sysSensorModel { get; set; } = new SysSensorModel(); // 传感器表
public SysSensorModels sysSensorModels { get; set; } = new SysSensorModels(); //传感器表
public LogModel logModel { get; set; } //日志记录表

View File

@ -1,4 +1,5 @@
using InSituLaboratory.Entities;
using InSituLaboratory.Common;
using InSituLaboratory.Entities;
using InSituLaboratory.Entities.SqlSugar;
using InSituLaboratory.IService;
using InSituLaboratory.IService.Sensor;
@ -288,6 +289,10 @@ namespace InSituLaboratory.ViewModels.Pages
int num = 0;
for (int i = 0; i < datalist.Length; i++)
{
if (datalist[1].SequenceGroup == datalist[i + 1].SequenceGroup)
{
}
@ -307,6 +312,73 @@ namespace InSituLaboratory.ViewModels.Pages
}
/// <summary>
/// 时序清空
/// </summary>
public override void ClearS1()
{
if (sequentStatusModel.SequentialStartTime1 == null || sequentStatusModel.SequentialEndTime1 == null)
{
System.Windows.Forms.MessageBox.Show("时序1: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x01, 0x02);
System.Windows.Forms.MessageBox.Show("命令已下发!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序启动
/// </summary>
public override void BeginS1()
{
if (sequentStatusModel.SequentialStartTime1 == null || sequentStatusModel.SequentialEndTime1 == null)
{
System.Windows.Forms.MessageBox.Show("时序1: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x01, 0x03);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序暂停
/// </summary>
public override void SuspendS1()
{
if (sequentStatusModel.SequentialStartTime1 == null || sequentStatusModel.SequentialEndTime1 == null)
{
System.Windows.Forms.MessageBox.Show("时序1: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x01, 0x04);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
#endregion
#region 2
@ -427,6 +499,72 @@ namespace InSituLaboratory.ViewModels.Pages
}
}
/// <summary>
/// 时序清空
/// </summary>
public override void ClearS2()
{
if (sequentStatusModel.SequentialStartTime2 == null || sequentStatusModel.SequentialEndTime2 == null)
{
System.Windows.Forms.MessageBox.Show("时序2: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x02, 0x02);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序启动
/// </summary>
public override void BeginS2()
{
if (sequentStatusModel.SequentialStartTime2 == null || sequentStatusModel.SequentialEndTime2 == null)
{
System.Windows.Forms.MessageBox.Show("时序2: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x02, 0x03);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序暂停
/// </summary>
public override void SuspendS2()
{
if (sequentStatusModel.SequentialStartTime2 == null || sequentStatusModel.SequentialEndTime2 == null)
{
System.Windows.Forms.MessageBox.Show("时序2: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x02, 0x04);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
#endregion
#region 3
@ -547,6 +685,72 @@ namespace InSituLaboratory.ViewModels.Pages
}
}
/// <summary>
/// 时序清空
/// </summary>
public override void ClearS3()
{
if (sequentStatusModel.SequentialStartTime3 == null || sequentStatusModel.SequentialEndTime3 == null)
{
System.Windows.Forms.MessageBox.Show("时序3: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x03, 0x02);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序启动
/// </summary>
public override void BeginS3()
{
if (sequentStatusModel.SequentialStartTime3 == null || sequentStatusModel.SequentialEndTime3 == null)
{
System.Windows.Forms.MessageBox.Show("时序3: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x03, 0x03);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序暂停
/// </summary>
public override void SuspendS3()
{
if (sequentStatusModel.SequentialStartTime3 == null || sequentStatusModel.SequentialEndTime3 == null)
{
System.Windows.Forms.MessageBox.Show("时序3: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x03, 0x04);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
#endregion
#region 4
@ -667,6 +871,72 @@ namespace InSituLaboratory.ViewModels.Pages
}
}
/// <summary>
/// 时序清空
/// </summary>
public override void ClearS4()
{
if (sequentStatusModel.SequentialStartTime4 == null || sequentStatusModel.SequentialEndTime4 == null)
{
System.Windows.Forms.MessageBox.Show("时序4: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x04, 0x02);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序启动
/// </summary>
public override void BeginS4()
{
if (sequentStatusModel.SequentialStartTime4 == null || sequentStatusModel.SequentialEndTime4 == null)
{
System.Windows.Forms.MessageBox.Show("时序4: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x04, 0x03);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序暂停
/// </summary>
public override void SuspendS4()
{
if (sequentStatusModel.SequentialStartTime4 == null || sequentStatusModel.SequentialEndTime4 == null)
{
System.Windows.Forms.MessageBox.Show("时序4: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x04, 0x04);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
#endregion
#region 5
@ -787,6 +1057,72 @@ namespace InSituLaboratory.ViewModels.Pages
}
}
/// <summary>
/// 时序清空
/// </summary>
public override void ClearS5()
{
if (sequentStatusModel.SequentialStartTime5 == null || sequentStatusModel.SequentialEndTime5 == null)
{
System.Windows.Forms.MessageBox.Show("时序5: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x05, 0x02);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序启动
/// </summary>
public override void BeginS5()
{
if (sequentStatusModel.SequentialStartTime5 == null || sequentStatusModel.SequentialEndTime5 == null)
{
System.Windows.Forms.MessageBox.Show("时序5: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x05, 0x03);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
/// <summary>
/// 时序暂停
/// </summary>
public override void SuspendS5()
{
if (sequentStatusModel.SequentialStartTime5 == null || sequentStatusModel.SequentialEndTime5 == null)
{
System.Windows.Forms.MessageBox.Show("时序5: 开始时间和结束时间不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
if (RelayViewModel.SocketInfo.ConnectionMessage == "断开")
{
dosend(0x05, 0x04);
}
else
{
System.Windows.Forms.MessageBox.Show("请先连接服务端!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
#endregion
@ -852,5 +1188,22 @@ namespace InSituLaboratory.ViewModels.Pages
return buffer;
}
/// <summary>
/// 命令发送
/// </summary>
/// <param name="x1">时序号</param>
/// <param name="x2">操作类型</param>
public void dosend(byte x1,byte x2)
{
//消息体
byte[] byteaq = new byte[] { 0x91, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, x1, x2 };
List<byte> buffer = Escape(byteaq);
string list = tools.byteToHexStr(buffer.ToArray());
byte[] bytea = tools.ConvertHexStringToBytes(list);
RelayViewModel.clientModel.SendData(bytea);
}
}
}

View File

@ -65,7 +65,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand SynchronizationCommand { get; set; }//时间同步
#region 1-5 /
#region 1-5 /
public DelegateCommand RefreshS1Command { get; set; }
public DelegateCommand SendS1Command { get; set; }
@ -73,6 +73,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand<object> DeleteS1Command { get; set; }
public DelegateCommand BeginS1Command { get; set; }
public DelegateCommand SuspendS1Command { get; set; }
public DelegateCommand ClearS1Command { get; set; }
public DelegateCommand RefreshS2Command { get; set; }
@ -81,6 +82,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand<object> DeleteS2Command { get; set; }
public DelegateCommand BeginS2Command { get; set; }
public DelegateCommand SuspendS2Command { get; set; }
public DelegateCommand ClearS2Command { get; set; }
public DelegateCommand RefreshS3Command { get; set; }
public DelegateCommand SendS3Command { get; set; }
@ -88,6 +90,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand<object> DeleteS3Command { get; set; }
public DelegateCommand BeginS3Command { get; set; }
public DelegateCommand SuspendS3Command { get; set; }
public DelegateCommand ClearS3Command { get; set; }
public DelegateCommand RefreshS4Command { get; set; }
public DelegateCommand SendS4Command { get; set; }
@ -95,6 +98,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand<object> DeleteS4Command { get; set; }
public DelegateCommand BeginS4Command { get; set; }
public DelegateCommand SuspendS4Command { get; set; }
public DelegateCommand ClearS4Command { get; set; }
public DelegateCommand RefreshS5Command { get; set; }
public DelegateCommand SendS5Command { get; set; }
@ -102,6 +106,7 @@ namespace InSituLaboratory.ViewModels.Pages
public DelegateCommand<object> DeleteS5Command { get; set; }
public DelegateCommand BeginS5Command { get; set; }
public DelegateCommand SuspendS5Command { get; set; }
public DelegateCommand ClearS5Command { get; set; }
#endregion
@ -120,7 +125,7 @@ namespace InSituLaboratory.ViewModels.Pages
StartCommand = new DelegateCommand(DoStart);
SynchronizationCommand = new DelegateCommand(DoSynchronization);
#region 1-5 /
#region 1-5 /
RefreshS1Command = new DelegateCommand(RefreshS1);
SendS1Command = new DelegateCommand(SendS1);
@ -128,6 +133,7 @@ namespace InSituLaboratory.ViewModels.Pages
DeleteS1Command = new DelegateCommand<object>(DoDeleteS1);
BeginS1Command = new DelegateCommand(BeginS1);
SuspendS1Command = new DelegateCommand(SuspendS1);
ClearS1Command = new DelegateCommand(ClearS1);
RefreshS2Command = new DelegateCommand(RefreshS2);
SendS2Command = new DelegateCommand(SendS2);
@ -135,6 +141,7 @@ namespace InSituLaboratory.ViewModels.Pages
DeleteS2Command = new DelegateCommand<object>(DoDeleteS2);
BeginS2Command = new DelegateCommand(BeginS2);
SuspendS2Command = new DelegateCommand(SuspendS2);
ClearS2Command = new DelegateCommand(ClearS2);
RefreshS3Command = new DelegateCommand(RefreshS3);
SendS3Command = new DelegateCommand(SendS3);
@ -142,6 +149,7 @@ namespace InSituLaboratory.ViewModels.Pages
DeleteS3Command = new DelegateCommand<object>(DoDeleteS3);
BeginS3Command = new DelegateCommand(BeginS3);
SuspendS3Command = new DelegateCommand(SuspendS3);
ClearS3Command = new DelegateCommand(ClearS3);
RefreshS4Command = new DelegateCommand(RefreshS4);
SendS4Command = new DelegateCommand(SendS4);
@ -149,6 +157,7 @@ namespace InSituLaboratory.ViewModels.Pages
DeleteS4Command = new DelegateCommand<object>(DoDeleteS4);
BeginS4Command = new DelegateCommand(BeginS4);
SuspendS4Command = new DelegateCommand(SuspendS4);
ClearS4Command = new DelegateCommand(ClearS4);
RefreshS5Command = new DelegateCommand(RefreshS5);
SendS5Command = new DelegateCommand(SendS5);
@ -156,6 +165,7 @@ namespace InSituLaboratory.ViewModels.Pages
DeleteS5Command = new DelegateCommand<object>(DoDeleteS5);
BeginS5Command = new DelegateCommand(BeginS5);
SuspendS5Command = new DelegateCommand(SuspendS5);
ClearS5Command = new DelegateCommand(ClearS5);
#endregion
}
@ -181,7 +191,7 @@ namespace InSituLaboratory.ViewModels.Pages
private string PageName { get; set; }
#region 1-5 /
#region 1-5 /
public virtual void RefreshS1() { }
public virtual void SendS1() { }
@ -189,6 +199,7 @@ namespace InSituLaboratory.ViewModels.Pages
public virtual void DoDeleteS1(object model) { }
public virtual void BeginS1() { }
public virtual void SuspendS1() { }
public virtual void ClearS1() { }
public virtual void RefreshS2() { }
@ -197,6 +208,7 @@ namespace InSituLaboratory.ViewModels.Pages
public virtual void DoDeleteS2(object model) { }
public virtual void BeginS2() { }
public virtual void SuspendS2() { }
public virtual void ClearS2() { }
public virtual void RefreshS3() { }
@ -205,6 +217,7 @@ namespace InSituLaboratory.ViewModels.Pages
public virtual void DoDeleteS3(object model) { }
public virtual void BeginS3() { }
public virtual void SuspendS3() { }
public virtual void ClearS3() { }
public virtual void RefreshS4() { }
@ -213,6 +226,7 @@ namespace InSituLaboratory.ViewModels.Pages
public virtual void DoDeleteS4(object model) { }
public virtual void BeginS4() { }
public virtual void SuspendS4() { }
public virtual void ClearS4() { }
public virtual void RefreshS5() { }
@ -221,6 +235,7 @@ namespace InSituLaboratory.ViewModels.Pages
public virtual void DoDeleteS5(object model) { }
public virtual void BeginS5() { }
public virtual void SuspendS5() { }
public virtual void ClearS5() { }
#endregion

View File

@ -164,6 +164,7 @@
</Button.Background>
</Button>
<Button Content="下发" Style="{StaticResource NormalButtonStyle}" Command="{Binding SendS1Command}" Width="60" Margin="5,0" Background="#FFA07A"/>
<Button Content="清空" Style="{StaticResource NormalButtonStyle}" Command="{Binding ClearS1Command}" Width="60" Margin="5,0" Background="#CD8C95"/>
<Button Content="启动" Style="{StaticResource NormalButtonStyle}" Command="{Binding BeginS1Command}" Width="60" Margin="5,0" Background="#9400D3"/>
<Button Content="暂停" Style="{StaticResource NormalButtonStyle}" Command="{Binding SuspendS1Command}" Width="60" Margin="5,0" Background="#CDC0B0"/>
</StackPanel>
@ -283,6 +284,7 @@
</Button.Background>
</Button>
<Button Content="下发" Style="{StaticResource NormalButtonStyle}" Command="{Binding SendS2Command}" Width="60" Margin="5,0" Background="#FFA07A"/>
<Button Content="清空" Style="{StaticResource NormalButtonStyle}" Command="{Binding ClearS2Command}" Width="60" Margin="5,0" Background="#CD8C95"/>
<Button Content="启动" Style="{StaticResource NormalButtonStyle}" Command="{Binding BeginS2Command}" Width="60" Margin="5,0" Background="#9400D3"/>
<Button Content="暂停" Style="{StaticResource NormalButtonStyle}" Command="{Binding SuspendS2Command}" Width="60" Margin="5,0" Background="#CDC0B0"/>
</StackPanel>
@ -403,6 +405,7 @@
</Button.Background>
</Button>
<Button Content="下发" Style="{StaticResource NormalButtonStyle}" Command="{Binding SendS3Command}" Width="60" Margin="5,0" Background="#FFA07A"/>
<Button Content="清空" Style="{StaticResource NormalButtonStyle}" Command="{Binding ClearS3Command}" Width="60" Margin="5,0" Background="#CD8C95"/>
<Button Content="启动" Style="{StaticResource NormalButtonStyle}" Command="{Binding BeginS3Command}" Width="60" Margin="5,0" Background="#9400D3"/>
<Button Content="暂停" Style="{StaticResource NormalButtonStyle}" Command="{Binding SuspendS3Command}" Width="60" Margin="5,0" Background="#CDC0B0"/>
</StackPanel>
@ -522,6 +525,7 @@
</Button.Background>
</Button>
<Button Content="下发" Style="{StaticResource NormalButtonStyle}" Command="{Binding SendS4Command}" Width="60" Margin="5,0" Background="#FFA07A"/>
<Button Content="清空" Style="{StaticResource NormalButtonStyle}" Command="{Binding ClearS4Command}" Width="60" Margin="5,0" Background="#CD8C95"/>
<Button Content="启动" Style="{StaticResource NormalButtonStyle}" Command="{Binding BeginS4Command}" Width="60" Margin="5,0" Background="#9400D3"/>
<Button Content="暂停" Style="{StaticResource NormalButtonStyle}" Command="{Binding SuspendS4Command}" Width="60" Margin="5,0" Background="#CDC0B0"/>
</StackPanel>
@ -641,6 +645,7 @@
</Button.Background>
</Button>
<Button Content="下发" Style="{StaticResource NormalButtonStyle}" Command="{Binding SendS5Command}" Width="60" Margin="5,0" Background="#FFA07A"/>
<Button Content="清空" Style="{StaticResource NormalButtonStyle}" Command="{Binding ClearS5Command}" Width="60" Margin="5,0" Background="#CD8C95"/>
<Button Content="启动" Style="{StaticResource NormalButtonStyle}" Command="{Binding BeginS5Command}" Width="60" Margin="5,0" Background="#9400D3"/>
<Button Content="暂停" Style="{StaticResource NormalButtonStyle}" Command="{Binding SuspendS5Command}" Width="60" Margin="5,0" Background="#CDC0B0"/>
</StackPanel>