Ver código fonte

4

样式分支
fyf 2 anos atrás
pai
commit
d6364baca8
18 arquivos alterados com 420 adições e 89 exclusões
  1. +6
    -2
      BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
  2. +7
    -1
      BPASmartClient.Compiler/IExecutable.cs
  3. +5
    -2
      BPASmartClient.MessageName/BPASmartClient.MessageName.csproj
  4. +0
    -29
      BPASmartClient.MessageName/DataName.cs
  5. +105
    -0
      BPASmartClient.MessageName/EnumHelp/EnumExtensions.cs
  6. +1
    -1
      BPASmartClient.MessageName/EnumHelp/RunEnum.cs
  7. +32
    -0
      BPASmartClient.MessageName/MessageName.cs
  8. +61
    -0
      BPASmartClient.MessageName/发送消息Model/EventSendMessage.cs
  9. +3
    -29
      BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs
  10. +6
    -1
      BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj
  11. BIN
     
  12. BIN
     
  13. +4
    -4
      BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs
  14. +11
    -3
      BPASmartClient.SCADAControl/Silos.xaml
  15. +158
    -12
      BPASmartClient.SCADAControl/Silos.xaml.cs
  16. +10
    -2
      SCADA.Test/MainWindow.xaml.cs
  17. +10
    -2
      SCADA.Test/RunCanvas.xaml.cs
  18. +1
    -1
      SmartClient.sln

+ 6
- 2
BPASmartClient.Compiler/BPASmartClient.Compiler.csproj Ver arquivo

@@ -1,11 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>DLL\Antlr3.Runtime.dll</HintPath>


+ 7
- 1
BPASmartClient.Compiler/IExecutable.cs Ver arquivo

@@ -1,5 +1,7 @@
using System;
using BPASmartClient.MessageName.接收消息Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -20,5 +22,9 @@ namespace BPASmartClient.Compiler
/// 控件类型
/// </summary>
string ControlType { get; }
///// <summary>
///// 消息名称
///// </summary>
//ObservableCollection<EventReceiveMessage> EventNameList { get; }
}
}

+ 5
- 2
BPASmartClient.MessageName/BPASmartClient.MessageName.csproj Ver arquivo

@@ -1,13 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<ItemGroup>
<Folder Include="发送消息Model\" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
</ItemGroup>

</Project>

+ 0
- 29
BPASmartClient.MessageName/DataName.cs Ver arquivo

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

namespace BPASmartClient.MessageName
{
/// <summary>
/// 数据订阅主题管理中心
/// </summary>
public class DataName
{
#region XX数据
/// <summary>
/// xxx消息
/// </summary>
[Category("测试"), Description("消息备注"), Browsable(true)]
public static string xxx = "xxx";
/// <summary>
/// xxx消息
/// </summary>
[Category("测试"), Description("消息备注1"), Browsable(true)]
public static string 测试 = "测试";
#endregion

}
}

+ 105
- 0
BPASmartClient.MessageName/EnumHelp/EnumExtensions.cs Ver arquivo

@@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace BPASmartClient.MessageName.EnumHelp
{
/// <summary>
/// 枚举
/// </summary>
public static class EnumExtensions
{
public static int jishu = 0;
/// <summary>
/// 根据控件-》创建枚举类型
/// </summary>
/// <returns></returns>
public static Type CreatEnumType(UIElementCollection list)
{
var currentDomain = AppDomain.CurrentDomain;
var assembly = Assembly.GetExecutingAssembly();
var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly!.GetName(), AssemblyBuilderAccess.Run);
var moduleBuilder = assemblyBuilder.DefineDynamicModule(assembly.GetName().Name!);
var em = moduleBuilder.DefineEnum($"Control_{((Convert.ToInt32(jishu) + 1).ToString().PadLeft(4, '0'))}", TypeAttributes.Public, typeof(string));
foreach (var item in list)
{
if (item is System.Windows.Controls.Control e)
{
if (e.Tag != null)
{
em.DefineLiteral(e.Tag.ToString(), e.Tag.ToString());
}
}
}
em.DefineLiteral("空", "空");
Type finished = em.CreateType()!;
return finished;
//foreach (object o in Enum.GetValues(finished))
//{
// Console.WriteLine($"{finished}.{o} = {(int)o};");
//}
}


/// <summary>
/// 根据枚举int值获取枚举名称
/// </summary>
/// <typeparam name="T">枚举类型</typeparam>
/// <param name="status">枚举值</param>
/// <returns></returns>
public static string GetEnumName<T>(this int status)
{
return Enum.GetName(typeof(T), status);
}


/// <summary>
/// 获取枚举变量值的 Description 属性
/// </summary>
/// <param name="obj">枚举变量</param>
/// <returns>如果包含 Description 属性,则返回 Description 属性的值,否则返回枚举变量值的名称</returns>
public static string GetDescription(this Enum obj)
{
return GetDescription(obj, false);
}

/// <summary>
/// 获取枚举变量值的 Description 属性
/// </summary>
/// <param name="obj">枚举变量</param>
/// <param name="isTop">是否改变为返回该类、枚举类型的头 Description 属性,而不是当前的属性或枚举变量值的 Description 属性</param>
/// <returns>如果包含 Description 属性,则返回 Description 属性的值,否则返回枚举变量值的名称</returns>
public static string GetDescription(this Enum obj, bool isTop)
{
if (obj == null)
{
return string.Empty;
}
Type enumType = obj.GetType();
DescriptionAttribute dna;

if (isTop)
{
dna = (DescriptionAttribute)Attribute.GetCustomAttribute(enumType, typeof(DescriptionAttribute));
}
else
{
FieldInfo fi = enumType.GetField(System.Enum.GetName(enumType, obj));
dna = (DescriptionAttribute)Attribute.GetCustomAttribute(
fi, typeof(DescriptionAttribute));
}
if ((dna != null)
&& (string.IsNullOrEmpty(dna.Description) == false))
{
return dna.Description;
}
return obj.ToString();
}
}
}

BPASmartClient.MessageName/Enum/运行状态/RunEnum.cs → BPASmartClient.MessageName/EnumHelp/RunEnum.cs Ver arquivo

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

namespace BPASmartClient.MessageName.Enum.运行状态
namespace BPASmartClient.MessageName.EnumHelp
{
/// <summary>
/// 运行状态-枚举

+ 32
- 0
BPASmartClient.MessageName/MessageName.cs Ver arquivo

@@ -1,4 +1,6 @@
using System.ComponentModel;
using System.Reflection;
using System.Reflection.Emit;

namespace BPASmartClient.MessageName
{
@@ -71,9 +73,39 @@ namespace BPASmartClient.MessageName
/// </summary>
ConveyorBeltRunStatus,

}

/// <summary>
/// 消息基类
/// </summary>
public class MessageBase
{
/// <summary>
/// 消息号
/// </summary>
public string MeaageID { get; set; }
// <summary>
/// 消息名称:枚举
/// </summary>
public MessageNameEnum MeaageName { get; set; }

public MessageBase()
{
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(8, '0'));
}
}

}

+ 61
- 0
BPASmartClient.MessageName/发送消息Model/EventSendMessage.cs Ver arquivo

@@ -0,0 +1,61 @@
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 EventSendMessage: MessageBase
{
/// <summary>
/// 控件类型
/// </summary>
public ControlEventType EventType { get; set; }
/// <summary>
/// 控件名称
/// </summary>
public object ControlName { get; set; }
/// <summary>
/// 控件标题
/// </summary>
public string ControlTitle { get; set; }
/// <summary>
/// 控件触发源
/// </summary>
public string ControlSource { get; set; }
/// <summary>
/// 控件状态
/// </summary>
public string ControlStatus { get; set; }
}
/// <summary>
/// 控件类型
/// </summary>
public enum ControlEventType
{
/// <summary>
/// 单击
/// </summary>
Click,
/// <summary>
/// 左键按下
/// </summary>
MouseLeftButtonDown,
/// <summary>
/// 文本改变事件
/// </summary>
TextChanged,
/// <summary>
/// 选中
/// </summary>
Checked,
/// <summary>
/// 取消选中
/// </summary>
Unchecked,
}
}

+ 3
- 29
BPASmartClient.MessageName/接收消息Model/EventReceiveMessage.cs Ver arquivo

@@ -7,43 +7,17 @@ using System.Threading.Tasks;
namespace BPASmartClient.MessageName.接收消息Model
{
/// <summary>
/// 事件消息Model:配置
/// 事件消息[接收端]Model:配置
/// </summary>
public class EventReceiveMessage
public class EventReceiveMessage: MessageBase
{
/// <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'));
}
}
}

+ 6
- 1
BPASmartClient.SCADAControl/BPASmartClient.SCADAControl.csproj Ver arquivo

@@ -3,11 +3,14 @@
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>

<ItemGroup>
<None Remove="Images\借出.png" />
<None Remove="Images\光柱.png" />
<None Remove="Images\退出.png" />
</ItemGroup>

<ItemGroup>
@@ -32,7 +35,9 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Images\借出.png" />
<Resource Include="Images\光柱.png" />
<Resource Include="Images\退出.png" />
</ItemGroup>

</Project>



+ 4
- 4
BPASmartClient.SCADAControl/NewConveyorBelt.xaml.cs Ver arquivo

@@ -2,7 +2,7 @@
using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.EnumHelp;
using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.滚动线;
using Newtonsoft.Json;
@@ -347,7 +347,7 @@ namespace BPASmartClient.SCADAControl
{
EventNameList?.ToList().ForEach(x =>
{
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.Name.ToString(), "EventHandler");
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.MeaageName.ToString(), "EventHandler");
});
}
}
@@ -361,7 +361,7 @@ namespace BPASmartClient.SCADAControl
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{
@@ -371,7 +371,7 @@ namespace BPASmartClient.SCADAControl
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);
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{


+ 11
- 3
BPASmartClient.SCADAControl/Silos.xaml Ver arquivo

@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.SCADAControl"
mc:Ignorable="d"
d:DesignHeight="270" d:DesignWidth="180" >
d:DesignHeight="270" d:DesignWidth="180" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
@@ -18,7 +18,7 @@ d:DesignHeight="270" d:DesignWidth="180" >
FontSize="20"
Foreground="#FF1FD622"
Tag="出料控制"
Text="出料中..." Visibility="Collapsed" />
Text="出料中..." Visibility="Collapsed"/>
<Ellipse Grid.Row="0" Tag="出料圆" Margin="0,40,0,0" Visibility="Collapsed" StrokeThickness="60" Width="150" Height="70" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top">
<Ellipse.RenderTransform>
<TransformGroup>
@@ -37,6 +37,8 @@ d:DesignHeight="270" d:DesignWidth="180" >
</LinearGradientBrush>
</Ellipse.Stroke>
</Ellipse>

<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
@@ -69,6 +71,12 @@ d:DesignHeight="270" d:DesignWidth="180" >
Grid.RowSpan="2"
Source="/BPASmartClient.SCADAControl;component/Images/光柱.png"
Stretch="Fill" />
<ListBox Visibility="Collapsed" ItemsSource="{Binding EventNameList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></ListBox>
<StackPanel Tag="ControlEvent" HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Bottom" >
<Image Margin="10,10,0,0" Tag="出料" Source="/BPASmartClient.SCADAControl;component/Images/借出.png" Cursor="Hand" ToolTip="出料" Width="24" ></Image>
<Image Margin="10,10,0,0" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image>
<Button Margin="10,10,0,0" Tag="出料">出料</Button>
<TextBox Width="50" Tag="文本改变" TextChanged="TextBox_TextChanged" ></TextBox>
<CheckBox Checked="CheckBox_Checked" Tag="是否选中" Unchecked="CheckBox_Unchecked"></CheckBox>
</StackPanel>
</Grid>
</UserControl>

+ 158
- 12
BPASmartClient.SCADAControl/Silos.xaml.cs Ver arquivo

@@ -2,7 +2,8 @@
using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.EnumHelp;
using BPASmartClient.MessageName.发送消息Model;
using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.物料仓;
using Newtonsoft.Json;
@@ -11,6 +12,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -42,6 +44,8 @@ namespace BPASmartClient.SCADAControl

Ellipse ellipseControl = null;
Storyboard storyboard = new Storyboard();

object typeName;
#endregion

public Silos()
@@ -53,10 +57,27 @@ namespace BPASmartClient.SCADAControl
this.Loaded += Silos_Loaded;
}


private void Silos_Loaded(object sender, RoutedEventArgs e)
{
Silos_SizeChanged(null, null);
Loading();
EventNameList.CollectionChanged += EventNameList_CollectionChanged;
EventSendNameList.CollectionChanged += EventSendNameList_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)
@@ -97,7 +118,7 @@ namespace BPASmartClient.SCADAControl
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Silos_SizeChanged(object sender, SizeChangedEventArgs e)
public void Loading()
{
//查找
if (ellipseControl == null)
@@ -136,6 +157,39 @@ namespace BPASmartClient.SCADAControl
}
}
}

foreach (StackPanel tb in FindVisualChildren<StackPanel>(this))
{
// do something with tb here
if (tb.Tag != null)
{
if (tb.Tag.ToString() == "ControlEvent")
{
foreach (var item in tb.Children)
{
if (item is Image)
{
(item as Image).MouseLeftButtonDown += Image_MouseLeftButtonDown;
}
else if (item is Button)
{
(item as Button).Click += Button_Click;
}
else if (item is TextBox)
{
(item as TextBox).TextChanged += TextBox_TextChanged;
}
else if (item is CheckBox)
{
(item as CheckBox).Checked += CheckBox_Checked;
(item as CheckBox).Unchecked += CheckBox_Unchecked;
}
}
//Type _typeName =EnumExtensions.CreatEnumType(tb.Children);
//typeName = _typeName.Assembly.CreateInstance(_typeName.FullName);
}
}
}
}
storyboard.RepeatBehavior = RepeatBehavior.Forever;
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
@@ -146,6 +200,8 @@ namespace BPASmartClient.SCADAControl
animation.KeyFrames.Add(new EasingDoubleKeyFrame(360, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
storyboard.Children.Add(animation);
}


public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
@@ -196,16 +252,16 @@ namespace BPASmartClient.SCADAControl
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(Silos), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));

[Category("消息名称")]
public string EventNameListStr
[Category("名称[自动生成]")]
private string EventNameListStr
{
get { return (string)GetValue(EventNameListStrProperty); }
set { SetValue(EventNameListStrProperty, value); }
}
public static readonly DependencyProperty EventNameListStrProperty =
private static readonly DependencyProperty EventNameListStrProperty =
DependencyProperty.Register("EventNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty));

[Category("消息名称集合")]
[Category("消息接收名称集合")]
public ObservableCollection<EventReceiveMessage> EventNameList
{
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventNameListProperty); }
@@ -215,6 +271,24 @@ namespace BPASmartClient.SCADAControl
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("名称[自动生成]")]
private string EventSendNameListStr
{
get { return (string)GetValue(EventSendNameListStrProperty); }
set { SetValue(EventSendNameListStrProperty, value); }
}
private static readonly DependencyProperty EventSendNameListStrProperty =
DependencyProperty.Register("EventSendNameListStr", typeof(string), typeof(Silos), 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(Silos), new PropertyMetadata(new ObservableCollection<EventSendMessage>(), new PropertyChangedCallback(onEventNameListChanged)));

[Category("值设定")]
public int Direction
{
@@ -244,7 +318,6 @@ namespace BPASmartClient.SCADAControl
}
}


/// <summary>
/// 值变化刷新
/// </summary>
@@ -309,9 +382,21 @@ namespace BPASmartClient.SCADAControl
{
EventNameList?.ToList().ForEach(x =>
{
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.Name.ToString(), "EventHandler");
Class_InnerMessageBus.GetInstance().ListenMessage(this, x.MeaageName.ToString(), "EventHandler");
});
}

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

}
}
}
/// <summary>
/// 统一事件消息处理中心
@@ -327,7 +412,7 @@ namespace BPASmartClient.SCADAControl
if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
{
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
var msg = EventNameList?.ToList().Find(par => par.Name.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg!=null)
{
@@ -336,7 +421,7 @@ namespace BPASmartClient.SCADAControl
}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);
var msg = EventNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
//必对消息号:
if (msg != null)
{
@@ -353,6 +438,67 @@ namespace BPASmartClient.SCADAControl
}
#endregion

}
#region 发送消息事件
/// <summary>
/// 按钮按下
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
try
{
Image image = sender as Image;

}
catch (Exception ex)
{

}
}
/// <summary>
/// 按钮类型
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{

}
/// <summary>
/// 值改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{

}
/// <summary>
/// 选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{

}
/// <summary>
/// 取消选中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{

}
#endregion


}
}

+ 10
- 2
SCADA.Test/MainWindow.xaml.cs Ver arquivo

@@ -1,6 +1,7 @@
using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageName;
using BPASmartClient.MessageName.Enum.运行状态;
using BPASmartClient.MessageName.EnumHelp;
using BPASmartClient.MessageName.接收消息Model;
using BPASmartClient.MessageName.接收消息Model.物料仓;
using Microsoft.Win32;
using System;
@@ -27,7 +28,14 @@ namespace SCADA.Test
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// 控件集合
/// </summary>
List<FrameworkElement> Children = new List<FrameworkElement>();
/// <summary>
/// 接收消息集合
/// </summary>
List<EventReceiveMessage> eventReceiveMessages = new List<EventReceiveMessage>();

public MainWindow()
{
@@ -61,7 +69,7 @@ namespace SCADA.Test
}
if (Children.Count > 0)
{
runCanvas.Run(Children);
eventReceiveMessages = runCanvas.Run(Children);
}
}


+ 10
- 2
SCADA.Test/RunCanvas.xaml.cs Ver arquivo

@@ -1,4 +1,5 @@
using BPASmartClient.Compiler;
using BPASmartClient.MessageName.接收消息Model;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -41,8 +42,9 @@ namespace SCADA.Test
}
}

public void Run(List<FrameworkElement> canvas)
public List<EventReceiveMessage> Run(List<FrameworkElement> canvas)
{
List<EventReceiveMessage> messages=new List<EventReceiveMessage>();
RootCanvas.Children.Clear();
foreach (FrameworkElement element in canvas)
{
@@ -52,11 +54,17 @@ namespace SCADA.Test
}

if (element is IExecutable executable)
{
executable.IsExecuteState = true;

//if (executable.EventNameList != null && executable.EventNameList.Count > 0)
//{
// messages.AddRange(executable.EventNameList);
//}
}
RootCanvas.Children.Add(element);
RegisterJsName(element);
}
return messages;
}

// 注册名称到Js


+ 1
- 1
SmartClient.sln Ver arquivo

@@ -152,7 +152,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Compiler", "
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4.界面加载实例", "4.界面加载实例", "{309D579E-DDA8-4B01-A0AA-0F381BC37801}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCADA.Test", "SCADA.Test\SCADA.Test.csproj", "{1696D557-C908-4136-A5F2-FF59D69E642C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SCADA.Test", "SCADA.Test\SCADA.Test.csproj", "{1696D557-C908-4136-A5F2-FF59D69E642C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution


Carregando…
Cancelar
Salvar