Browse Source

跟新可视化编辑

样式分支
fyf 2 years ago
parent
commit
8ec8160542
13 changed files with 280 additions and 110 deletions
  1. +4
    -0
      BPASmartClient.MessageName/BPASmartClient.MessageName.csproj
  2. +7
    -5
      BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs
  3. +2
    -1
      BPASmartClient.MessageName/MessageName.cs
  4. +49
    -0
      BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs
  5. +23
    -0
      BPASmartClient.MessageName/接收消息Model/滚动线/ConveyorBeltMessageModel.cs
  6. +3
    -5
      BPASmartClient.MessageName/接收消息Model/物料仓/SilosMessageModel.cs
  7. +8
    -2
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  8. +2
    -1
      BPASmartClient.SCADAControl/NewConveyorBelt.xaml
  9. +97
    -17
      BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs
  10. +4
    -13
      BPASmartClient.SCADAControl/Silos.xaml
  11. +74
    -63
      BPASmartClient.SCADAControl/Silos.xaml.cs
  12. +2
    -0
      BPASmartClient.SCADAControl/SwitchButton.cs
  13. +5
    -3
      SCADA.Test/MainWindow.xaml.cs

+ 4
- 0
BPASmartClient.MessageName/BPASmartClient.MessageName.csproj View File

@@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>


<ItemGroup>
<Folder Include="发送消息Model\" />
</ItemGroup>

</Project> </Project>

+ 7
- 5
BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs View File

@@ -24,16 +24,18 @@ namespace BPASmartClient.MessageName.Enum.运行状态
/// </summary> /// </summary>
Stop Stop
} }

/// <summary>
/// 运行状态Model
/// </summary>
public class RunEnumModel public class RunEnumModel
{ {
/// <summary> /// <summary>
/// 运行状态
/// 消息id号:ID号
/// </summary> /// </summary>
public RunEnum Run { get; set; }
public string MessageID { get; set; }
/// <summary> /// <summary>
/// ID号
/// 运行状态
/// </summary> /// </summary>
public string ID { get; set; }
public RunEnum Run { get; set; }
} }
} }

+ 2
- 1
BPASmartClient.MessageName/MessageName.cs View File

@@ -48,7 +48,6 @@ namespace BPASmartClient.MessageName
// #endregion // #endregion
//} //}



/// <summary> /// <summary>
/// 消息名称管理中心-枚举 /// 消息名称管理中心-枚举
/// </summary> /// </summary>
@@ -75,4 +74,6 @@ namespace BPASmartClient.MessageName




} }


} }

+ 49
- 0
BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MessageName.接收消息Model
{
/// <summary>
/// 事件消息Model:配置
/// </summary>
public class EventReceiveMessage
{
/// <summary>
/// 消息号
/// </summary>
public string MeaageID { get; set; }
/// <summary>
/// 消息名称:枚举
/// </summary>
public MessageNameEnum Name { get; set; }
/// <summary>
/// 空:保留
/// </summary>
public string Value { get; set; }
/// <summary>
/// 消息标题
/// </summary>
public string Title { get; set; }

public EventReceiveMessage()
{
MeaageID=GetMessageID.GetID();
}
}

/// <summary>
/// 四位消息号
/// </summary>
public static class GetMessageID
{
public static int i = 0;
public static string GetID()
{
i++;
return ((Convert.ToInt32(i) + 1).ToString().PadLeft(4, '0'));
}
}
}

+ 23
- 0
BPASmartClient.MessageName/接收消息Model/滚动线/ConveyorBeltMessageModel.cs View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MessageName.接收消息Model.滚动线
{
/// <summary>
/// 滚动线数据设置-Model
/// </summary>
public class ConveyorBeltMessageModel
{
/// <summary>
/// 消息ID号:id 号
/// </summary>
public string MessageID { get; set; }
/// <summary>
/// 滚动线:标题
/// </summary>
public string Title { get; set; }
}
}

BPASmartClient.MessageName/Enum/物料仓/SilosRunEnum.cs → BPASmartClient.MessageName/接收消息Model/物料仓/SilosMessageModel.cs View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace BPASmartClient.MessageName.Enum.物料仓
namespace BPASmartClient.MessageName.接收消息Model.物料仓
{ {
/// <summary> /// <summary>
/// 物料仓数据设置-Model /// 物料仓数据设置-Model
@@ -12,9 +12,9 @@ namespace BPASmartClient.MessageName.Enum.物料仓
public class SilosMessageModel public class SilosMessageModel
{ {
/// <summary> /// <summary>
/// 物料仓:仓
/// 消息ID号:id
/// </summary> /// </summary>
public string id { get; set; }
public string MessageID { get; set; }
/// <summary> /// <summary>
/// 物料仓:标题 /// 物料仓:标题
/// </summary> /// </summary>
@@ -24,6 +24,4 @@ namespace BPASmartClient.MessageName.Enum.物料仓
/// </summary> /// </summary>
public string Value { get; set; } public string Value { get; set; }
} }


} }

+ 8
- 2
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj View File

@@ -10,6 +10,12 @@
<None Remove="Images\光柱.png" /> <None Remove="Images\光柱.png" />
</ItemGroup> </ItemGroup>


<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.1.3.50" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" /> <ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" />
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> <ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" />
@@ -18,10 +24,10 @@


<ItemGroup> <ItemGroup>
<Reference Include="Antlr3.Runtime"> <Reference Include="Antlr3.Runtime">
<HintPath>DLL\Antlr3.Runtime.dll</HintPath>
<HintPath>..\BPASmartClient.Compiler\DLL\Antlr3.Runtime.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unvell.ReoScript"> <Reference Include="Unvell.ReoScript">
<HintPath>DLL\Unvell.ReoScript.dll</HintPath>
<HintPath>..\BPASmartClient.Compiler\DLL\Unvell.ReoScript.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>




+ 2
- 1
BPASmartClient.SCADAControl/NewConveyorBelt.xaml View File

@@ -23,8 +23,9 @@
Fill="Transparent" Fill="Transparent"
Stroke="{Binding StrokeBrush, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}" Stroke="{Binding StrokeBrush, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}"
StrokeThickness="{Binding StrokeThickness, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}" /> StrokeThickness="{Binding StrokeThickness, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}" />

</Canvas> </Canvas>
</Viewbox> </Viewbox>
<TextBlock Text="{Binding Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Tag="标题" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,-40,0,-40" Foreground="#FF25AD12" FontSize="30"></TextBlock>
</Grid> </Grid>
</UserControl> </UserControl>

+ 97
- 17
BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs View File

@@ -3,6 +3,9 @@ using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl; using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName; using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.运行状态; using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.滚动线;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -29,6 +32,7 @@ namespace BPASmartClient.SCADAControl
public partial class NewConveyorBelt : UserControl, IExecutable public partial class NewConveyorBelt : UserControl, IExecutable
{ {
#region 临时变量 #region 临时变量
TextBlock textBlock = null;
Path Path_mp = null; Path Path_mp = null;
Path Path_cb = null; Path Path_cb = null;
Storyboard storyboard = new Storyboard(); Storyboard storyboard = new Storyboard();
@@ -48,6 +52,38 @@ namespace BPASmartClient.SCADAControl
StrokeDashArray = new DoubleCollection { 1.5, 1.5 }; StrokeDashArray = new DoubleCollection { 1.5, 1.5 };
StrokeFillBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00BEFA")); StrokeFillBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00BEFA"));
StrokeThickness = 2; StrokeThickness = 2;
this.Loaded += NewConveyorBelt_Loaded; ;
}

private void NewConveyorBelt_Loaded(object sender, RoutedEventArgs e)
{
foreach (TextBlock tb in FindVisualChildren<TextBlock>(this))
{
// do something with tb here
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "标题")
{
textBlock = tb;
}
}
}
EventNameList.CollectionChanged += EventNameList_CollectionChanged;
}

private void EventNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (EventNameList.Count > 0)
{
try
{
EventNameListStr = JsonConvert.SerializeObject(EventNameList);

}
catch (Exception ex)
{
}
}
} }


public string ControlType => "滚动线"; public string ControlType => "滚动线";
@@ -248,8 +284,8 @@ namespace BPASmartClient.SCADAControl
set { SetValue(TextProperty, value); } set { SetValue(TextProperty, value); }
} }
public static readonly DependencyProperty TextProperty = public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty));
DependencyProperty.Register("Text", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));
private static void onTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.TargetRefresh();
[Category("主题订阅")] [Category("主题订阅")]
public string ConveyorBeltLeft public string ConveyorBeltLeft
{ {
@@ -274,39 +310,72 @@ namespace BPASmartClient.SCADAControl
} }
public static readonly DependencyProperty ConveyorBeltStopProperty = public static readonly DependencyProperty ConveyorBeltStopProperty =
DependencyProperty.Register("ConveyorBeltStop", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); DependencyProperty.Register("ConveyorBeltStop", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty));


[Category("消息名称")] [Category("消息名称")]
public MessageNameEnum EventRunName
public string EventNameListStr
{ {
get { return (MessageNameEnum)GetValue(EventRunNameProperty); }
set { SetValue(EventRunNameProperty, value); }
get { return (string)GetValue(EventNameListStrProperty); }
set { SetValue(EventNameListStrProperty, value); }
} }
public static readonly DependencyProperty EventRunNameProperty =
DependencyProperty.Register("EventRunName", typeof(MessageNameEnum), typeof(NewConveyorBelt), new PropertyMetadata(MessageNameEnum.Null, onEventRunNameChanged));
private static void onEventRunNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh();
public static readonly DependencyProperty EventNameListStrProperty =
DependencyProperty.Register("EventNameListStr", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty));
[Category("消息名称集合")]
public ObservableCollection<EventReceiveMessage> EventNameList
{
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventNameListProperty); }
set { SetValue(EventNameListProperty, value); }
}
public static readonly DependencyProperty EventNameListProperty =
DependencyProperty.Register("EventNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged));
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh();
#endregion #endregion


#region 属性变更事件 #region 属性变更事件
public void Register() public void Register()
{ {
if (EventRunName != MessageNameEnum.Null) Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler");
if (!string.IsNullOrEmpty(EventNameListStr))
{
try
{
EventNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventNameListStr);
}
catch (Exception ex)
{


}
}
if (EventNameList != null)
{
EventNameList?.ToList().ForEach(x =>
{
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.Name.ToString(), "EventHandler");
});
}
} }


public void EventRunNameHandler(object sender, InnerMessageEventArgs e)
public void EventHandler(object sender, InnerMessageEventArgs e)
{ {
try try
{ {
if (IsExecuteState = true) if (IsExecuteState = true)
{ {
if (e.obj_MessageObj is RunEnumModel)
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{ {

RunEnumModel runEnum = (RunEnumModel)e.obj_MessageObj;
//if (runEnum.ID == Text)
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{
Direction = mode.Run == RunEnum.Run ? 1 : ((mode.Run == RunEnum.Run_Left) ? 2 : 0);
}
}
else if (e.obj_MessageObj is ConveyorBeltMessageModel)//接收到数据模型
{
ConveyorBeltMessageModel mode = (ConveyorBeltMessageModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{ {
Direction = runEnum.Run == RunEnum.Run ? 1 : ((runEnum.Run == RunEnum.Run_Left) ? 2 : 0);
Text = mode.Title;
} }
} }
} }
@@ -336,6 +405,17 @@ namespace BPASmartClient.SCADAControl
} }
} }


/// <summary>
/// 目标属性刷新
/// </summary>
public void TargetRefresh()
{
if (textBlock != null )
{
textBlock.Text = Text;
}
}

public void RunNameRefresh() public void RunNameRefresh()
{ {


+ 4
- 13
BPASmartClient.SCADAControl/Silos.xaml View File

@@ -58,26 +58,17 @@ d:DesignHeight="270" d:DesignWidth="180" >
Foreground="#FF00FFF9" Foreground="#FF00FFF9"
Text="(g)" /> Text="(g)" />
</StackPanel> </StackPanel>

<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock
Margin="0,50,0,0"
HorizontalAlignment="Center"
FontSize="50"
Foreground="#FFFFA400" Tag="Text"
Text="{Binding Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
Grid.Row="1"
<TextBlock
Grid.Row="1" Tag="Text"
Margin="0,70,0,0" Margin="0,70,0,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
FontSize="25" FontSize="25"
Foreground="#FFFFA400" Foreground="#FFFFA400"
Text=" 号仓" />
</StackPanel>
Text="{Binding Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<Image <Image
Grid.RowSpan="2" Grid.RowSpan="2"
Source="/BPASmartClient.SCADAControl;component/Images/光柱.png" Source="/BPASmartClient.SCADAControl;component/Images/光柱.png"
Stretch="Fill" /> Stretch="Fill" />
<ListBox Visibility="Collapsed" ItemsSource="{Binding EventNameList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></ListBox>
</Grid> </Grid>
</UserControl> </UserControl>

+ 74
- 63
BPASmartClient.SCADAControl/Silos.xaml.cs View File

@@ -2,10 +2,14 @@
using BPASmartClient.MessageCommunication; using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl; using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName; using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.物料仓;
using BPASmartClient.MessageName.Enum.运行状态; using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.物料仓;
using Newtonsoft.Json;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -46,16 +50,28 @@ namespace BPASmartClient.SCADAControl
this.DataContext = this; this.DataContext = this;
Width = 180; Width = 180;
Height = 270; Height = 270;
//Value = "25.23";
//Title = "香料";
//Text = "1";
//this.SizeChanged += Silos_SizeChanged; ;
this.Loaded += Silos_Loaded; this.Loaded += Silos_Loaded;
} }


private void Silos_Loaded(object sender, RoutedEventArgs e) private void Silos_Loaded(object sender, RoutedEventArgs e)
{ {
Silos_SizeChanged(null, null); Silos_SizeChanged(null, null);
EventNameList.CollectionChanged += EventNameList_CollectionChanged;
}

private void EventNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (EventNameList.Count > 0)
{
try
{
EventNameListStr = JsonConvert.SerializeObject(EventNameList);

}
catch (Exception ex)
{
}
}
} }


public string ControlType => "物料仓"; public string ControlType => "物料仓";
@@ -152,22 +168,6 @@ namespace BPASmartClient.SCADAControl
#endregion #endregion


#region 属性 #region 属性
//private string _变量;
//public string ym_value
//{
// get
// {
// return _变量;
// }
// set
// {
// if (_变量 == value)
// return;
// _变量 = value;
// OnPropertyChanged("ym_value");
// }
//}

[Category("值设定")] [Category("值设定")]
public string Value public string Value
{ {
@@ -197,23 +197,24 @@ namespace BPASmartClient.SCADAControl
DependencyProperty.Register("Title", typeof(string), typeof(Silos), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); DependencyProperty.Register("Title", typeof(string), typeof(Silos), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));


[Category("消息名称")] [Category("消息名称")]
public MessageNameEnum EventRunName
public string EventNameListStr
{ {
get { return (MessageNameEnum)GetValue(EventRunNameProperty); }
set { SetValue(EventRunNameProperty, value); }
get { return (string)GetValue(EventNameListStrProperty); }
set { SetValue(EventNameListStrProperty, value); }
} }
public static readonly DependencyProperty EventRunNameProperty =
DependencyProperty.Register("EventRunName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null, onEventRunNameChanged));
private static void onEventRunNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.RunNameRefresh();
[Category("消息名称")]
public MessageNameEnum EventDataName
public static readonly DependencyProperty EventNameListStrProperty =
DependencyProperty.Register("EventNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty));
[Category("消息名称集合")]
public ObservableCollection<EventReceiveMessage> EventNameList
{ {
get { return (MessageNameEnum)GetValue(EventDataNameProperty); }
set { SetValue(EventDataNameProperty, value); }
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventNameListProperty); }
set { SetValue(EventNameListProperty, value); }
} }
public static readonly DependencyProperty EventDataNameProperty =
DependencyProperty.Register("EventDataName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null, onEventDataNameChanged));
private static void onEventDataNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();
public static readonly DependencyProperty EventNameListProperty =
DependencyProperty.Register("EventNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(Silos), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();

[Category("值设定")] [Category("值设定")]
public int Direction public int Direction
{ {
@@ -240,7 +241,6 @@ namespace BPASmartClient.SCADAControl
textBlockValue.Text = Value; textBlockValue.Text = Value;
textBlockText.Text = Text; textBlockText.Text = Text;
textBlockTitle.Text = Title; textBlockTitle.Text = Title;

} }
} }


@@ -273,65 +273,75 @@ namespace BPASmartClient.SCADAControl
} }
} }

/// <summary> /// <summary>
/// 运行名称变化事件 /// 运行名称变化事件
/// </summary> /// </summary>
public void RunNameRefresh() public void RunNameRefresh()
{ {
} }

/// <summary> /// <summary>
/// 数据名称变化事件 /// 数据名称变化事件
/// </summary> /// </summary>
public void DataNameRefresh() public void DataNameRefresh()
{ {
} }
#endregion #endregion


#region 运行事件 #region 运行事件
public void Register() public void Register()
{ {
if (EventRunName != MessageNameEnum.Null) Class_InnerMessageBus.GetInstance().ListenMessage(this, EventRunName.ToString(), "EventRunNameHandler");
if (EventDataName != MessageNameEnum.Null) Class_InnerMessageBus.GetInstance().ListenMessage(this, EventDataName.ToString(), "EventDataNameHandler");
}

public void EventRunNameHandler(object sender, InnerMessageEventArgs e)
{
try
if (!string.IsNullOrEmpty(EventNameListStr))
{ {
if (IsExecuteState = true)
try
{
EventNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventNameListStr);
}
catch (Exception ex)
{ {
if (e.obj_MessageObj is RunEnumModel)
{


RunEnumModel runEnum = (RunEnumModel)e.obj_MessageObj;
if (runEnum.ID == Text)
{
Direction = runEnum.Run == RunEnum.Run ? 1 : 2;
}
}
} }
} }
catch (Exception ex)
if (EventNameList != null)
{ {

EventNameList?.ToList().ForEach(x =>
{
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.Name.ToString(), "EventHandler");
});
} }
} }

public void EventDataNameHandler(object sender, InnerMessageEventArgs e)
/// <summary>
/// 统一事件消息处理中心
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void EventHandler(object sender, InnerMessageEventArgs e)
{ {
try try
{ {
if (IsExecuteState = true)
if (IsExecuteState = true)//正在运行
{ {
if (e.obj_MessageObj is SilosMessageModel)
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{ {
SilosMessageModel silosMessageModel = (SilosMessageModel)e.obj_MessageObj;
if (silosMessageModel.id == Text)
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg!=null)
{ {
Title=silosMessageModel.Title;
Value= silosMessageModel.Value;
Direction = mode.Run == RunEnum.Run ? 1 : 2;
}
}else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型
{
SilosMessageModel mode = (SilosMessageModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{
Title = mode.Title;
Value = mode.Value;
} }
} }
} }
@@ -344,4 +354,5 @@ namespace BPASmartClient.SCADAControl
#endregion #endregion


} }

} }

+ 2
- 0
BPASmartClient.SCADAControl/SwitchButton.cs View File

@@ -141,4 +141,6 @@ namespace BPASmartClient.SCADAControl
public string ControlType => "控件"; public string ControlType => "控件";


} }


} }

+ 5
- 3
SCADA.Test/MainWindow.xaml.cs View File

@@ -1,7 +1,7 @@
using BPASmartClient.MessageCommunication; using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageName; using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.物料仓;
using BPASmartClient.MessageName.Enum.运行状态; using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.接收消息Model.物料仓;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -92,7 +92,7 @@ namespace SCADA.Test
} }
RunEnumModel runEnumModel = new RunEnumModel(); RunEnumModel runEnumModel = new RunEnumModel();
runEnumModel.Run = ToEnumValue<RunEnum>(xx.Text); runEnumModel.Run = ToEnumValue<RunEnum>(xx.Text);
runEnumModel.ID = hm.Text;
runEnumModel.MessageID = hm.Text;
Class_InnerMessageBus.GetInstance().PostMessage(this, mlname.Text, runEnumModel); Class_InnerMessageBus.GetInstance().PostMessage(this, mlname.Text, runEnumModel);
} }


@@ -127,11 +127,13 @@ namespace SCADA.Test
return; return;
} }
SilosMessageModel silosMessage = new SilosMessageModel(); SilosMessageModel silosMessage = new SilosMessageModel();
silosMessage.id= ch.Text;
silosMessage.MessageID = ch.Text;
silosMessage.Value = zl.Text; silosMessage.Value = zl.Text;
silosMessage.Title = bt.Text; silosMessage.Title = bt.Text;
Class_InnerMessageBus.GetInstance().PostMessage(this, xxnc.Text, silosMessage); Class_InnerMessageBus.GetInstance().PostMessage(this, xxnc.Text, silosMessage);


} }


} }
} }

Loading…
Cancel
Save