@@ -24,4 +24,6 @@ namespace BPASmartClient.MessageName.Enum.物料仓 | |||
/// </summary> | |||
public string Value { get; set; } | |||
} | |||
} |
@@ -24,4 +24,16 @@ namespace BPASmartClient.MessageName.Enum.运行状态 | |||
/// </summary> | |||
Stop | |||
} | |||
public class RunEnumModel | |||
{ | |||
/// <summary> | |||
/// 运行状态 | |||
/// </summary> | |||
public RunEnum Run { get; set; } | |||
/// <summary> | |||
/// ID号 | |||
/// </summary> | |||
public string ID { get; set; } | |||
} | |||
} |
@@ -232,7 +232,14 @@ namespace BPASmartClient.SCADAControl | |||
public static readonly DependencyProperty DirectionProperty = | |||
DependencyProperty.Register("Direction", typeof(int), typeof(NewConveyorBelt), | |||
new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); | |||
[Category("值设定")] | |||
public string Text | |||
{ | |||
get { return (string)GetValue(TextProperty); } | |||
set { SetValue(TextProperty, value); } | |||
} | |||
public static readonly DependencyProperty TextProperty = | |||
DependencyProperty.Register("Text", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); | |||
[Category("主题订阅")] | |||
public string ConveyorBeltLeft | |||
@@ -274,7 +281,10 @@ namespace BPASmartClient.SCADAControl | |||
#region 属性变更事件 | |||
public void Register() | |||
{ | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler"); | |||
if (EventRunName != MessageNameEnum.Null) | |||
{ | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString()+ Text, "EventRunNameHandler"); | |||
} | |||
} | |||
public void EventRunNameHandler(object sender, InnerMessageEventArgs e) | |||
@@ -283,11 +293,14 @@ namespace BPASmartClient.SCADAControl | |||
{ | |||
if (IsExecuteState = true) | |||
{ | |||
if (e.obj_MessageObj is RunEnum) | |||
if (e.obj_MessageObj is RunEnumModel) | |||
{ | |||
RunEnum runEnum = (RunEnum)e.obj_MessageObj; | |||
Direction = runEnum == RunEnum.Run ? 1 : ((runEnum == RunEnum.Run_Left)?2:0); | |||
RunEnumModel runEnum = (RunEnumModel)e.obj_MessageObj; | |||
if (runEnum.ID == Text) | |||
{ | |||
Direction = runEnum.Run == RunEnum.Run ? 1 : ((runEnum.Run == RunEnum.Run_Left) ? 2 : 0); | |||
} | |||
} | |||
} | |||
} | |||
@@ -238,8 +238,11 @@ namespace BPASmartClient.SCADAControl | |||
#region 运行事件 | |||
public void Register() | |||
{ | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler"); | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventDataName.ToString(), "EventDataNameHandler"); | |||
if (EventRunName != MessageNameEnum.Null) | |||
{ | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString()+ Text, "EventRunNameHandler"); | |||
Class_InnerMessageBus.GetInstance().ListenMessage(this, EventDataName.ToString() + Text, "EventDataNameHandler"); | |||
} | |||
} | |||
public void EventRunNameHandler(object sender, InnerMessageEventArgs e) | |||
@@ -248,10 +251,14 @@ namespace BPASmartClient.SCADAControl | |||
{ | |||
if (IsExecuteState = true) | |||
{ | |||
if (e.obj_MessageObj is RunEnum) | |||
if (e.obj_MessageObj is RunEnumModel) | |||
{ | |||
RunEnum runEnum = (RunEnum)e.obj_MessageObj; | |||
Direction = runEnum == RunEnum.Run ? 1 : 2; | |||
RunEnumModel runEnum = (RunEnumModel)e.obj_MessageObj; | |||
if (runEnum.ID == Text) | |||
{ | |||
Direction = runEnum.Run == RunEnum.Run ? 1 : 2; | |||
} | |||
} | |||
} | |||
} | |||
@@ -7,6 +7,10 @@ | |||
mc:Ignorable="d" | |||
Title="MainWindow" Height="450" Width="800"> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="200"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition/> | |||
@@ -14,5 +18,42 @@ | |||
<Button Click="Button_Click">加载文件</Button> | |||
<local:RunCanvas Grid.Row="1" x:Name="runCanvas"/> | |||
<Grid Grid.Column="1" Grid.RowSpan="2"> | |||
<Border BorderBrush="AntiqueWhite" BorderThickness="3"> | |||
<StackPanel> | |||
<TextBlock Margin="10,0,0,10" FontSize="24" HorizontalAlignment="Center">运行消息发送</TextBlock> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">消息名称</TextBlock> | |||
<ComboBox x:Name="mlname"></ComboBox> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">号</TextBlock> | |||
<TextBox x:Name="hm">1</TextBox> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">消息</TextBlock> | |||
<ComboBox x:Name="xx"></ComboBox> | |||
<Button Margin="10,10,0,10" Width="100" Height="40" Click="Button_Click_1">发送</Button> | |||
<TextBlock Margin="10,0,0,10" FontSize="24" HorizontalAlignment="Center">数据发送</TextBlock> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">消息名称</TextBlock> | |||
<ComboBox x:Name="xxnc"></ComboBox> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">仓号</TextBlock> | |||
<TextBox x:Name="ch">1</TextBox> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">标题</TextBlock> | |||
<TextBox x:Name="bt">标题</TextBox> | |||
<TextBlock Margin="10,0,0,10" FontSize="16">重量</TextBlock> | |||
<TextBox x:Name="zl">35.23</TextBox> | |||
<Button Margin="10,10,0,10" Width="100" Height="40" Click="Button_Click_2" >发送</Button> | |||
</StackPanel> | |||
</Border> | |||
</Grid> | |||
</Grid> | |||
</Window> |
@@ -1,4 +1,8 @@ | |||
using Microsoft.Win32; | |||
using BPASmartClient.MessageCommunication; | |||
using BPASmartClient.MessageName; | |||
using BPASmartClient.MessageName.Enum.物料仓; | |||
using BPASmartClient.MessageName.Enum.运行状态; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.IO; | |||
@@ -28,6 +32,9 @@ namespace SCADA.Test | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
xxnc.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | |||
mlname.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | |||
xx.ItemsSource = System.Enum.GetNames(typeof(RunEnum))?.ToList(); | |||
} | |||
#region 加载数据 | |||
@@ -70,5 +77,61 @@ namespace SCADA.Test | |||
} | |||
} | |||
private void Button_Click_1(object sender, RoutedEventArgs e) | |||
{ | |||
if (string.IsNullOrEmpty(mlname.Text)) | |||
{ | |||
MessageBox.Show("消息名称不能为空!"); | |||
return; | |||
} | |||
if (string.IsNullOrEmpty(xx.Text)) | |||
{ | |||
MessageBox.Show("命令不能为空!"); | |||
return; | |||
} | |||
RunEnumModel runEnumModel = new RunEnumModel(); | |||
runEnumModel.Run = ToEnumValue<RunEnum>(xx.Text); | |||
runEnumModel.ID = hm.Text; | |||
Class_InnerMessageBus.GetInstance().PostMessage(this, mlname.Text+ runEnumModel.ID, runEnumModel); | |||
} | |||
/// <summary> | |||
/// 根据枚举名称获取枚举值 | |||
/// </summary> | |||
public T ToEnumValue<T>(string name) | |||
{ | |||
return (T)Enum.Parse(typeof(T), name); | |||
} | |||
private void Button_Click_2(object sender, RoutedEventArgs e) | |||
{ | |||
if (string.IsNullOrEmpty(xxnc.Text)) | |||
{ | |||
MessageBox.Show("消息名称不能为空!"); | |||
return; | |||
} | |||
if (string.IsNullOrEmpty(ch.Text)) | |||
{ | |||
MessageBox.Show("仓号不能为空!"); | |||
return; | |||
} | |||
if (string.IsNullOrEmpty(bt.Text)) | |||
{ | |||
MessageBox.Show("标题不能为空!"); | |||
return; | |||
} | |||
if (string.IsNullOrEmpty(zl.Text)) | |||
{ | |||
MessageBox.Show("重量不能为空!"); | |||
return; | |||
} | |||
SilosMessageModel silosMessage = new SilosMessageModel(); | |||
silosMessage.id= ch.Text; | |||
silosMessage.Value = zl.Text; | |||
silosMessage.Title = bt.Text; | |||
Class_InnerMessageBus.GetInstance().PostMessage(this, xxnc.Text+ ch.Text, silosMessage); | |||
} | |||
} | |||
} |
@@ -9,6 +9,8 @@ | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SCADAControl\BPASmartClient.SCADAControl.csproj" /> | |||
</ItemGroup> | |||