Browse Source

gengx

样式分支
fyf 2 years ago
parent
commit
60775f3074
6 changed files with 118 additions and 65 deletions
  1. +8
    -0
      BPASmartClient.MessageName/MessageName.cs
  2. +1
    -1
      BPASmartClient.MessageName/发送消息Model/EventSendMessage.cs
  3. +13
    -1
      BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs
  4. +65
    -22
      BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs
  5. +27
    -37
      BPASmartClient.SCADAControl/Silos.xaml.cs
  6. +4
    -4
      SCADA.Test/RunCanvas.xaml.cs

+ 8
- 0
BPASmartClient.MessageName/MessageName.cs View File

@@ -73,6 +73,14 @@ namespace BPASmartClient.MessageName
/// </summary> /// </summary>
ConveyorBeltRunStatus, ConveyorBeltRunStatus,


/// <summary>
/// 发送消息
/// </summary>
SendMessageName,
/// <summary>
/// 接收消息
/// </summary>
ReceiveMessageName,
} }


/// <summary> /// <summary>


+ 1
- 1
BPASmartClient.MessageName/发送消息Model/EventSendMessage.cs View File

@@ -18,7 +18,7 @@ namespace BPASmartClient.MessageName.发送消息Model
/// <summary> /// <summary>
/// 控件名称 /// 控件名称
/// </summary> /// </summary>
public object ControlName { get; set; }
public string ControlName { get; set; }
/// <summary> /// <summary>
/// 控件标题 /// 控件标题
/// </summary> /// </summary>


+ 13
- 1
BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs View File

@@ -9,8 +9,16 @@ namespace BPASmartClient.MessageName.接收消息Model
/// <summary> /// <summary>
/// 事件消息[接收端]Model:配置 /// 事件消息[接收端]Model:配置
/// </summary> /// </summary>
public class EventReceiveMessage: MessageBase
public class EventReceiveMessage:MessageBase
{ {
///// <summary>
///// 消息号
///// </summary>
//public string MeaageID { get; set; }
//// <summary>
///// 消息名称:枚举
///// </summary>
//public MessageNameEnum MeaageName { get; set; }
/// <summary> /// <summary>
/// 空:保留 /// 空:保留
/// </summary> /// </summary>
@@ -19,5 +27,9 @@ namespace BPASmartClient.MessageName.接收消息Model
/// 消息标题:标志控件说明 /// 消息标题:标志控件说明
/// </summary> /// </summary>
public string Title { get; set; } public string Title { get; set; }
//public EventReceiveMessage()
//{
// MeaageID = GetMessageID.GetID();
//}
} }
} }

+ 65
- 22
BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs View File

@@ -3,6 +3,7 @@ using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl; using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName; using BPASmartClient.MessageName;
using BPASmartClient.MessageName.EnumHelp; using BPASmartClient.MessageName.EnumHelp;
using BPASmartClient.MessageName.发送消息Model;
using BPASmartClient.MessageName.接收消息Model; using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.滚动线; using BPASmartClient.MessageName.接收消息Model.滚动线;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -57,6 +58,8 @@ namespace BPASmartClient.SCADAControl


private void NewConveyorBelt_Loaded(object sender, RoutedEventArgs e) private void NewConveyorBelt_Loaded(object sender, RoutedEventArgs e)
{ {
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged;
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged;
foreach (TextBlock tb in FindVisualChildren<TextBlock>(this)) foreach (TextBlock tb in FindVisualChildren<TextBlock>(this))
{ {
// do something with tb here // do something with tb here
@@ -68,16 +71,28 @@ namespace BPASmartClient.SCADAControl
} }
} }
} }
EventNameList.CollectionChanged += EventNameList_CollectionChanged;
} }
private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (EventSendNameList.Count > 0)
{
try
{
EventSendNameListStr = JsonConvert.SerializeObject(EventSendNameList);


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


} }
catch (Exception ex) catch (Exception ex)
@@ -310,44 +325,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("消息名称")]
public string EventNameListStr
[Category("名称[自动生成]")]
public string EventReceiveNameListStr
{ {
get { return (string)GetValue(EventNameListStrProperty); }
set { SetValue(EventNameListStrProperty, value); }
get { return (string)GetValue(EventReceiveNameListStrProperty); }
set { SetValue(EventReceiveNameListStrProperty, value); }
} }
public static readonly DependencyProperty EventNameListStrProperty =
DependencyProperty.Register("EventNameListStr", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty));
[Category("消息名称集合")]
public ObservableCollection<EventReceiveMessage> EventNameList
public static readonly DependencyProperty EventReceiveNameListStrProperty =
DependencyProperty.Register("EventReceiveNameListStr", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty));
[Category("消息接收名称集合")]
public ObservableCollection<EventReceiveMessage> EventReceiveNameList
{ {
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventNameListProperty); }
set { SetValue(EventNameListProperty, value); }
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventReceiveNameListProperty); }
set { SetValue(EventReceiveNameListProperty, value); }
} }
public static readonly DependencyProperty EventNameListProperty =
DependencyProperty.Register("EventNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged));
public static readonly DependencyProperty EventReceiveNameListProperty =
DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged));
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh();
[Category("名称[自动生成]")]
public string EventSendNameListStr
{
get { return (string)GetValue(EventSendNameListStrProperty); }
set { SetValue(EventSendNameListStrProperty,value); }
}
public static readonly DependencyProperty EventSendNameListStrProperty =
DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty));
[Category("消息发送名称集合")]
public ObservableCollection<EventSendMessage> EventSendNameList
{
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); }
set { SetValue(EventSendNameListProperty,value); }
}
public static readonly DependencyProperty EventSendNameListProperty =
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(NewConveyorBelt),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged)));

#endregion #endregion


#region 属性变更事件 #region 属性变更事件
public void Register() public void Register()
{ {
if (!string.IsNullOrEmpty(EventNameListStr))
if (!string.IsNullOrEmpty(EventReceiveNameListStr))
{
try
{
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr);
}
catch (Exception ex)
{

}
}
if (!string.IsNullOrEmpty(EventSendNameListStr))
{ {
try try
{ {
EventNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventNameListStr);
EventSendNameList = JsonConvert.DeserializeObject<ObservableCollection<EventSendMessage>>(EventSendNameListStr);
} }
catch (Exception ex) catch (Exception ex)
{ {


} }
} }
if (EventNameList != null)
if (EventReceiveNameList != null)
{ {
EventNameList?.ToList().ForEach(x =>
EventReceiveNameList?.ToList().ForEach(x =>
{ {
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.MeaageName.ToString(), "EventHandler");
Class_InnerMessageBus.GetInstance().ListenMessage(this,x.MeaageName.ToString(),"EventHandler");
}); });
} }
} }
@@ -361,7 +404,7 @@ namespace BPASmartClient.SCADAControl
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息 if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{ {
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj; RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号: //必对消息号:
if (msg != null) if (msg != null)
{ {
@@ -371,7 +414,7 @@ namespace BPASmartClient.SCADAControl
else if (e.obj_MessageObj is ConveyorBeltMessageModel)//接收到数据模型 else if (e.obj_MessageObj is ConveyorBeltMessageModel)//接收到数据模型
{ {
ConveyorBeltMessageModel mode = (ConveyorBeltMessageModel)e.obj_MessageObj; ConveyorBeltMessageModel mode = (ConveyorBeltMessageModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号: //必对消息号:
if (msg != null) if (msg != null)
{ {


+ 27
- 37
BPASmartClient.SCADAControl/Silos.xaml.cs View File

@@ -60,9 +60,9 @@ namespace BPASmartClient.SCADAControl


private void Silos_Loaded(object sender, RoutedEventArgs e) private void Silos_Loaded(object sender, RoutedEventArgs e)
{ {
Loading();
EventNameList.CollectionChanged += EventNameList_CollectionChanged;
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged;
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged;
Loading();
} }


private void EventSendNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) private void EventSendNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -79,14 +79,13 @@ namespace BPASmartClient.SCADAControl
} }
} }
} }

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


} }
catch (Exception ex) catch (Exception ex)
@@ -114,10 +113,8 @@ namespace BPASmartClient.SCADAControl


#region 动画 #region 动画
/// <summary> /// <summary>
/// 字节改变
/// 加载内部变量
/// </summary> /// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void Loading() public void Loading()
{ {
//查找 //查找
@@ -201,7 +198,6 @@ namespace BPASmartClient.SCADAControl
storyboard.Children.Add(animation); storyboard.Children.Add(animation);
} }



public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{ {
if (depObj != null) if (depObj != null)
@@ -253,33 +249,29 @@ 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("名称[自动生成]")]
private string EventNameListStr
public string EventReceiveNameListStr
{ {
get { return (string)GetValue(EventNameListStrProperty); }
set { SetValue(EventNameListStrProperty, value); }
get { return (string)GetValue(EventReceiveNameListStrProperty); }
set { SetValue(EventReceiveNameListStrProperty, value); }
} }
private static readonly DependencyProperty EventNameListStrProperty =
DependencyProperty.Register("EventNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty));

public static readonly DependencyProperty EventReceiveNameListStrProperty =
DependencyProperty.Register("EventReceiveNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty));
[Category("消息接收名称集合")] [Category("消息接收名称集合")]
public ObservableCollection<EventReceiveMessage> EventNameList
public ObservableCollection<EventReceiveMessage> EventReceiveNameList
{ {
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventNameListProperty); }
set { SetValue(EventNameListProperty, value); }
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventReceiveNameListProperty); }
set { SetValue(EventReceiveNameListProperty, value); }
} }
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();

public static readonly DependencyProperty EventReceiveNameListProperty =
DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(Silos), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), new PropertyChangedCallback(onEventNameListChanged)));
[Category("名称[自动生成]")] [Category("名称[自动生成]")]
private string EventSendNameListStr
public string EventSendNameListStr
{ {
get { return (string)GetValue(EventSendNameListStrProperty); } get { return (string)GetValue(EventSendNameListStrProperty); }
set { SetValue(EventSendNameListStrProperty, value); } set { SetValue(EventSendNameListStrProperty, value); }
} }
private static readonly DependencyProperty EventSendNameListStrProperty =
public static readonly DependencyProperty EventSendNameListStrProperty =
DependencyProperty.Register("EventSendNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty)); DependencyProperty.Register("EventSendNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty));

[Category("消息发送名称集合")] [Category("消息发送名称集合")]
public ObservableCollection<EventSendMessage> EventSendNameList public ObservableCollection<EventSendMessage> EventSendNameList
{ {
@@ -288,6 +280,7 @@ namespace BPASmartClient.SCADAControl
} }
public static readonly DependencyProperty EventSendNameListProperty = public static readonly DependencyProperty EventSendNameListProperty =
DependencyProperty.Register("EventSendNameList", typeof(ObservableCollection<EventSendMessage>), typeof(Silos), new PropertyMetadata(new ObservableCollection<EventSendMessage>(), new PropertyChangedCallback(onEventNameListChanged))); DependencyProperty.Register("EventSendNameList", typeof(ObservableCollection<EventSendMessage>), typeof(Silos), new PropertyMetadata(new ObservableCollection<EventSendMessage>(), new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();


[Category("值设定")] [Category("值设定")]
public int Direction public int Direction
@@ -302,6 +295,7 @@ namespace BPASmartClient.SCADAControl
{ {
(d as Silos)?.Refresh(); (d as Silos)?.Refresh();
} }

#endregion #endregion


#region 函数 #region 函数
@@ -367,25 +361,17 @@ namespace BPASmartClient.SCADAControl
#region 运行事件 #region 运行事件
public void Register() public void Register()
{ {
if (!string.IsNullOrEmpty(EventNameListStr))
if (!string.IsNullOrEmpty(EventReceiveNameListStr))
{ {
try try
{ {
EventNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventNameListStr);
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr);
} }
catch (Exception ex) catch (Exception ex)
{ {


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

if (!string.IsNullOrEmpty(EventSendNameListStr)) if (!string.IsNullOrEmpty(EventSendNameListStr))
{ {
try try
@@ -397,6 +383,10 @@ namespace BPASmartClient.SCADAControl


} }
} }
EventReceiveNameList?.ToList().ForEach(x =>
{
Class_InnerMessageBus.GetInstance().ListenMessage(this,x.MeaageName.ToString(),"EventHandler");
});
} }
/// <summary> /// <summary>
/// 统一事件消息处理中心 /// 统一事件消息处理中心
@@ -412,7 +402,7 @@ namespace BPASmartClient.SCADAControl
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息 if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{ {
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj; RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号: //必对消息号:
if (msg!=null) if (msg!=null)
{ {
@@ -421,7 +411,7 @@ namespace BPASmartClient.SCADAControl
}else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型 }else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型
{ {
SilosMessageModel mode = (SilosMessageModel)e.obj_MessageObj; SilosMessageModel mode = (SilosMessageModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号: //必对消息号:
if (msg != null) if (msg != null)
{ {


+ 4
- 4
SCADA.Test/RunCanvas.xaml.cs View File

@@ -48,10 +48,10 @@ namespace SCADA.Test
RootCanvas.Children.Clear(); RootCanvas.Children.Clear();
foreach (FrameworkElement element in canvas) foreach (FrameworkElement element in canvas)
{ {
if (element.GetType().GetInterface("IExecutable") != null)
{
element.GetType().GetProperty("IsExecuteState").SetValue(element, true);
}
//if (element.GetType().GetInterface("IExecutable") != null)
//{
// element.GetType().GetProperty("IsExecuteState").SetValue(element, true);
//}


if (element is IExecutable executable) if (element is IExecutable executable)
{ {


Loading…
Cancel
Save