|
|
@@ -33,11 +33,11 @@ namespace BPASmartClient.SCADAControl |
|
|
|
/// Silos.xaml 的交互逻辑 |
|
|
|
/// 物料仓 |
|
|
|
/// </summary> |
|
|
|
public partial class Silos : UserControl, IExecutable |
|
|
|
public partial class Silos :UserControl, IExecutable |
|
|
|
{ |
|
|
|
#region 临时变量 |
|
|
|
TextBlock textBlockCLKZ = null; |
|
|
|
TextBlock textBlockValue=null; |
|
|
|
TextBlock textBlockValue = null; |
|
|
|
TextBlock textBlockText = null; |
|
|
|
TextBlock textBlockTitle = null; |
|
|
|
|
|
|
@@ -54,18 +54,18 @@ namespace BPASmartClient.SCADAControl |
|
|
|
this.DataContext = this; |
|
|
|
Width = 180; |
|
|
|
Height = 270; |
|
|
|
this.SizeChanged += Silos_SizeChanged; ; |
|
|
|
this.Loaded += Silos_Loaded; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Silos_Loaded(object sender, RoutedEventArgs e) |
|
|
|
private void Silos_Loaded(object sender,RoutedEventArgs e) |
|
|
|
{ |
|
|
|
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; |
|
|
|
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; |
|
|
|
Loading(); |
|
|
|
//Loading(); |
|
|
|
} |
|
|
|
|
|
|
|
private void EventSendNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
|
|
|
private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
|
|
|
{ |
|
|
|
if (EventSendNameList.Count > 0) |
|
|
|
{ |
|
|
@@ -79,7 +79,7 @@ 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 (EventReceiveNameList.Count > 0) |
|
|
|
{ |
|
|
@@ -115,7 +115,7 @@ namespace BPASmartClient.SCADAControl |
|
|
|
/// <summary> |
|
|
|
/// 加载内部变量 |
|
|
|
/// </summary> |
|
|
|
public void Loading() |
|
|
|
private void Silos_SizeChanged(object sender,SizeChangedEventArgs e) |
|
|
|
{ |
|
|
|
//查找 |
|
|
|
if (ellipseControl == null) |
|
|
@@ -128,6 +128,14 @@ namespace BPASmartClient.SCADAControl |
|
|
|
if (tb.Tag.ToString() == "出料圆") |
|
|
|
{ |
|
|
|
ellipseControl = tb; |
|
|
|
storyboard.RepeatBehavior = RepeatBehavior.Forever; |
|
|
|
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames(); |
|
|
|
Storyboard.SetTarget(animation,ellipseControl); |
|
|
|
Storyboard.SetTargetProperty(animation,new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)")); |
|
|
|
animation.KeyFrames.Add(new EasingDoubleKeyFrame(0,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)))); |
|
|
|
animation.KeyFrames.Add(new EasingDoubleKeyFrame(180,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)))); |
|
|
|
animation.KeyFrames.Add(new EasingDoubleKeyFrame(360,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2)))); |
|
|
|
storyboard.Children.Add(animation); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -140,7 +148,8 @@ namespace BPASmartClient.SCADAControl |
|
|
|
if (tb.Tag.ToString() == "出料控制") |
|
|
|
{ |
|
|
|
textBlockCLKZ = tb; |
|
|
|
}else if (tb.Tag.ToString() == "Value") |
|
|
|
} |
|
|
|
else if (tb.Tag.ToString() == "Value") |
|
|
|
{ |
|
|
|
textBlockValue = tb; |
|
|
|
} |
|
|
@@ -182,20 +191,11 @@ namespace BPASmartClient.SCADAControl |
|
|
|
(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(); |
|
|
|
Storyboard.SetTarget(animation, ellipseControl); |
|
|
|
Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)")); |
|
|
|
animation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)))); |
|
|
|
animation.KeyFrames.Add(new EasingDoubleKeyFrame(180, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)))); |
|
|
|
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 |
|
|
@@ -204,7 +204,7 @@ namespace BPASmartClient.SCADAControl |
|
|
|
{ |
|
|
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) |
|
|
|
{ |
|
|
|
DependencyObject child = VisualTreeHelper.GetChild(depObj, i); |
|
|
|
DependencyObject child = VisualTreeHelper.GetChild(depObj,i); |
|
|
|
if (child != null && child is T) |
|
|
|
{ |
|
|
|
yield return (T)child; |
|
|
@@ -224,74 +224,74 @@ namespace BPASmartClient.SCADAControl |
|
|
|
public string Value |
|
|
|
{ |
|
|
|
get { return (string)GetValue(ValueProperty); } |
|
|
|
set { SetValue(ValueProperty, value); } |
|
|
|
set { SetValue(ValueProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty ValueProperty = |
|
|
|
DependencyProperty.Register("Value", typeof(string), typeof(Silos), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); |
|
|
|
private static void onTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.TargetRefresh(); |
|
|
|
|
|
|
|
DependencyProperty.Register("Value",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); |
|
|
|
private static void onTargetChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.TargetRefresh(); |
|
|
|
|
|
|
|
[Category("值设定")] |
|
|
|
public string Text |
|
|
|
{ |
|
|
|
get { return (string)GetValue(TextProperty); } |
|
|
|
set { SetValue(TextProperty, value); } |
|
|
|
set { SetValue(TextProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty TextProperty = |
|
|
|
DependencyProperty.Register("Text", typeof(string), typeof(Silos), new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); |
|
|
|
DependencyProperty.Register("Text",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); |
|
|
|
|
|
|
|
[Category("值设定")] |
|
|
|
public string Title |
|
|
|
{ |
|
|
|
get { return (string)GetValue(TitleProperty); } |
|
|
|
set { SetValue(TitleProperty, value); } |
|
|
|
set { SetValue(TitleProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty TitleProperty = |
|
|
|
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("名称[自动生成]")] |
|
|
|
public string EventReceiveNameListStr |
|
|
|
{ |
|
|
|
get { return (string)GetValue(EventReceiveNameListStrProperty); } |
|
|
|
set { SetValue(EventReceiveNameListStrProperty, value); } |
|
|
|
set { SetValue(EventReceiveNameListStrProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty EventReceiveNameListStrProperty = |
|
|
|
DependencyProperty.Register("EventReceiveNameListStr", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty)); |
|
|
|
DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); |
|
|
|
[Category("消息接收名称集合")] |
|
|
|
public ObservableCollection<EventReceiveMessage> EventReceiveNameList |
|
|
|
{ |
|
|
|
get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventReceiveNameListProperty); } |
|
|
|
set { SetValue(EventReceiveNameListProperty, value); } |
|
|
|
set { SetValue(EventReceiveNameListProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty EventReceiveNameListProperty = |
|
|
|
DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(Silos), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), new PropertyChangedCallback(onEventNameListChanged))); |
|
|
|
DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(),new PropertyChangedCallback(onEventNameListChanged))); |
|
|
|
[Category("名称[自动生成]")] |
|
|
|
public string EventSendNameListStr |
|
|
|
{ |
|
|
|
get { return (string)GetValue(EventSendNameListStrProperty); } |
|
|
|
set { SetValue(EventSendNameListStrProperty, value); } |
|
|
|
set { SetValue(EventSendNameListStrProperty,value); } |
|
|
|
} |
|
|
|
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("消息发送名称集合")] |
|
|
|
public ObservableCollection<EventSendMessage> EventSendNameList |
|
|
|
{ |
|
|
|
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } |
|
|
|
set { SetValue(EventSendNameListProperty, value); } |
|
|
|
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))); |
|
|
|
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("值设定")] |
|
|
|
public int Direction |
|
|
|
{ |
|
|
|
get { return (int)GetValue(DirectionProperty); } |
|
|
|
set { SetValue(DirectionProperty, value); } |
|
|
|
set { SetValue(DirectionProperty,value); } |
|
|
|
} |
|
|
|
public static readonly DependencyProperty DirectionProperty = |
|
|
|
DependencyProperty.Register("Direction", typeof(int), typeof(Silos), |
|
|
|
new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); |
|
|
|
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|
|
|
DependencyProperty.Register("Direction",typeof(int),typeof(Silos), |
|
|
|
new PropertyMetadata(0,new PropertyChangedCallback(OnPropertyChanged))); |
|
|
|
private static void OnPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) |
|
|
|
{ |
|
|
|
(d as Silos)?.Refresh(); |
|
|
|
} |
|
|
@@ -338,7 +338,7 @@ namespace BPASmartClient.SCADAControl |
|
|
|
storyboard.Stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -354,11 +354,12 @@ namespace BPASmartClient.SCADAControl |
|
|
|
/// </summary> |
|
|
|
public void DataNameRefresh() |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 运行事件 |
|
|
|
List<string> MessageNameL = null; |
|
|
|
public void Register() |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(EventReceiveNameListStr)) |
|
|
@@ -383,17 +384,21 @@ namespace BPASmartClient.SCADAControl |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
EventReceiveNameList?.ToList().ForEach(x => |
|
|
|
List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); |
|
|
|
if (MessageNameL==null || !MessageNameNew.SequenceEqual(MessageNameL)) |
|
|
|
{ |
|
|
|
Class_InnerMessageBus.GetInstance().ListenMessage(this,x.MeaageName.ToString(),"EventHandler"); |
|
|
|
}); |
|
|
|
MessageNameL?.ForEach(o => Class_InnerMessageBus.GetInstance().RemoveMessage(o,"SliosEventHandler")); |
|
|
|
MessageNameNew?.ForEach(x => Class_InnerMessageBus.GetInstance().ListenMessage(this,x,"SliosEventHandler")); |
|
|
|
MessageNameL = MessageNameNew; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 统一事件消息处理中心 |
|
|
|
/// </summary> |
|
|
|
/// <param name="sender"></param> |
|
|
|
/// <param name="e"></param> |
|
|
|
public void EventHandler(object sender, InnerMessageEventArgs e) |
|
|
|
public void SliosEventHandler(object sender,InnerMessageEventArgs e) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@@ -404,11 +409,12 @@ namespace BPASmartClient.SCADAControl |
|
|
|
RunEnumModel mode = (RunEnumModel)e.obj_MessageObj; |
|
|
|
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID); |
|
|
|
//必对消息号: |
|
|
|
if (msg!=null) |
|
|
|
if (msg != null) |
|
|
|
{ |
|
|
|
Direction = mode.Run == RunEnum.Run ? 1 : 2; |
|
|
|
} |
|
|
|
}else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型 |
|
|
|
} |
|
|
|
else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型 |
|
|
|
{ |
|
|
|
SilosMessageModel mode = (SilosMessageModel)e.obj_MessageObj; |
|
|
|
var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID); |
|
|
@@ -417,6 +423,7 @@ namespace BPASmartClient.SCADAControl |
|
|
|
{ |
|
|
|
Title = mode.Title; |
|
|
|
Value = mode.Value; |
|
|
|
Text = mode.Text; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -434,7 +441,7 @@ namespace BPASmartClient.SCADAControl |
|
|
|
/// </summary> |
|
|
|
/// <param name="sender"></param> |
|
|
|
/// <param name="e"></param> |
|
|
|
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|
|
|
private void Image_MouseLeftButtonDown(object sender,MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@@ -446,44 +453,44 @@ namespace BPASmartClient.SCADAControl |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 按钮类型 |
|
|
|
/// </summary> |
|
|
|
/// <param name="sender"></param> |
|
|
|
/// <param name="e"></param> |
|
|
|
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
|
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) |
|
|
|
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) |
|
|
|
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) |
|
|
|
private void CheckBox_Unchecked(object sender,RoutedEventArgs e) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|