Commit e1ca07f5 authored by 潘栩锋's avatar 潘栩锋 🚴

Merge remote-tracking branch 'remotes/origin/dev7.0-blowing' into dev7.0-filmCasting

parents 572c2c5e 909dd72a
......@@ -88,6 +88,7 @@
<DependentUpon>PieChart.xaml</DependentUpon>
</Compile>
<Compile Include="ResetAction.cs" />
<Compile Include="Set1Action.cs" />
<Compile Include="ToggleAction.cs" />
<Compile Include="UI.OSK\IVirtualKeyboard.cs" />
<Compile Include="UI.OSK\KeyboardBehavior.cs" />
......
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace FLY.ControlLibrary
{
/// <summary>
/// 后台添加功能,按钮 click事件 属性=true
/// </summary>
public class Set1Action : IDisposable
{
/// <summary>
/// 对象
/// </summary>
public object obj;
/// <summary>
/// bool 属性
/// </summary>
public string propertyname;
/// <summary>
/// 按下时为 true
/// </summary>
public bool pressIsTrue;
UIElement uIElement;
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="obj"></param>
/// <param name="propertyname"></param>
public Set1Action(UIElement uIElement, object obj, string propertyname)
{
this.uIElement = uIElement;
this.obj = obj;
this.propertyname = propertyname;
uIElement.PreviewMouseDown += UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown += UIElement_PreviewTouchDown;
}
/// <summary>
///
/// </summary>
/// <param name="uIElement"></param>
/// <param name="propertyname"></param>
public Set1Action(UIElement uIElement, string propertyname) : this(uIElement, null, propertyname)
{
}
public void Dispose()
{
uIElement.PreviewMouseDown -= UIElement_PreviewMouseDown;
uIElement.PreviewTouchDown -= UIElement_PreviewTouchDown;
}
private void UIElement_PreviewTouchDown(object sender, TouchEventArgs e)
{
Down();
}
private void UIElement_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
Down();
}
bool IsObjNull()
{
if (obj == null)
{
if (uIElement is FrameworkElement)
{
obj = (uIElement as FrameworkElement).DataContext;
if (obj == null)
return true;
}
else
{
return true;
}
}
return false;
}
void Down()
{
if (IsObjNull()) return;
Misc.PropertiesManager.SetValue(obj, propertyname, true);
}
}
/// <summary>
/// Set1Action 的 XAML 版 ,附加行为。
/// </summary>
public class Set1Behavior : Behavior<UIElement>
{
public System.Windows.Data.Binding Binding { get; set; }
Set1Action set1Action = null;
public Set1Behavior()
{
}
protected override void OnAttached()
{
base.OnAttached();
UIElement dobj = AssociatedObject;
if (Binding != null && Binding.Path != null)
{
if (Binding.Source != null)
{
set1Action = new Set1Action(dobj, Binding.Source, Binding.Path.Path);
}
else
{
var obj = COMMON.GetDataContext(dobj);
if (obj == null)
{
set1Action = new Set1Action(dobj, Binding.Path.Path);
}
else
{
set1Action = new Set1Action(dobj, obj, Binding.Path.Path);
}
}
}
}
protected override void OnDetaching()
{
base.OnDetaching();
if (set1Action != null)
{
set1Action.Dispose();
set1Action = null;
}
}
}
}
......@@ -2,9 +2,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors2.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!-- 标准间隔 -->
<Thickness x:Key="ControlMargin">5</Thickness>
<!--Microsoft Sans Serif-->
<FontFamily x:Key="FontFamily.Field">Microsoft Sans Serif</FontFamily>
<!--<FontFamily x:Key="FontFamily.Field">YouYuan</FontFamily>-->
</ResourceDictionary>
\ No newline at end of file
......@@ -47,7 +47,7 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldHeader}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
......@@ -76,7 +76,7 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<!--<Setter Property="FontWeight" Value="Bold" />-->
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
</Style>
......@@ -86,7 +86,7 @@
<Setter Property="Foreground" Value="#FF3B3B3B" />
<!--<Setter Property="FontWeight" Value="Bold" />-->
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="MinWidth" Value="30" />
</Style>
......@@ -108,7 +108,7 @@
<Style TargetType="TextBlock" x:Key="Styles.Text.FieldContent.Unit">
<Setter Property="Foreground" Value="#FF888888" />
<Setter Property="FontSize" Value="{StaticResource FontSize.FieldContent.Small}" />
<Setter Property="FontFamily" Value="Microsoft Sans Serif" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily.Field}" />
<Setter Property="TextAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
......
......@@ -15,6 +15,11 @@ namespace FLY.Modbus
{
public class PLCDevice
{
/// <summary>
/// PLC 名称 用于报警时,能有提示
/// </summary>
public string PlcName;
[JsonConverter(typeof(IPEndPointJsonConverter))]
public IPEndPoint EP;
}
......
......@@ -16,7 +16,8 @@ namespace FLY.OBJComponents.Server
#region 延时推送 MARKNO
const int MARKNO_DELAY_ISCONNECTED = 4;
#endregion
string plcName;
List<string> plcNames;
/// <summary>
/// 需要设置
/// </summary>
......@@ -30,9 +31,17 @@ namespace FLY.OBJComponents.Server
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcName = plcName;
plcNames = new List<string>();
plcNames.Add(plcName);
}
public ErrorConf(PLCProxySystem PLCos, WarningSystem2 mWarning, string[] plcNames)
{
this.PLCos = PLCos;
this.mWarning = mWarning;
this.plcNames = new List<string>();
if (plcNames.All(s => !string.IsNullOrEmpty(s)))
this.plcNames.AddRange(plcNames);
}
#region 报警
public class ErrorAction
{
......@@ -109,11 +118,7 @@ namespace FLY.OBJComponents.Server
ERRNO errno = PlcErrNos.Instance.ERRNO_PLC_DISCONNECTED;
UInt16 errcode = (UInt16)(errno.Code - i);
string description;
if (PLCos.PLCs.Count() > 1)
description = $"{plcName} No.{i+1} " + errno.Descrption;
else
description = $"{plcName} " + errno.Descrption;
string description = $"{GetPlcName(i)} " + errno.Descrption;
mWarning.Add(errcode, description, state);
}
......@@ -150,7 +155,22 @@ namespace FLY.OBJComponents.Server
// }
// }, TimeSpan.FromSeconds(1));
}
string GetPlcName(int index)
{
if (PLCos.PLCs.Count() == 1)
{
return plcNames[0];
}
//多个PLC
if (PLCos.PLCs.Count() != plcNames.Count())
{
//没有定义全部名字
return $"{plcNames[0]} No.{index + 1}";
}
return plcNames[index];
}
public void ResetError(INotifyPropertyChanged sender)
{
var type = sender.GetType();
......
......@@ -9,7 +9,7 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="GroupBox" />
</ResourceDictionary>
</Application.Resources>
</Application>
......@@ -404,6 +404,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\DynAreaErrorStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\GraphStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Button" x:Key="DynAreaErrorStyle" BasedOn="{StaticResource Styles.Button.Empty}">
<Setter Property="Command" Value="{Binding OpenWarningCmd}"/>
<Setter Property="Visibility" Value="{Binding IsError,Converter={StaticResource visbilityconv}}"/>
<Setter Property="Content">
<Setter.Value>
<Border Style="{StaticResource Styles.Module.Border}" Background="{StaticResource Brushes.Validation}" >
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="{StaticResource ControlMargin}" Fill="White" Stretch="Uniform" Width="60" Height="60" SnapsToDevicePixels="True" Data="{StaticResource Geometry_alert-circle-outline}" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="00:00:01" />
<DoubleAnimation BeginTime="0:0:1" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:01" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<TextBlock Grid.Column="1" Margin="5" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="22" Foreground="White" Text="{Binding ErrMsg}"/>
</Grid>
</Border>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--<Style TargetType="GroupBox" />-->
</ResourceDictionary>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
<ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Themes/DynAreaErrorStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="Rectangle" x:Key="IOStyle">
......@@ -26,7 +27,8 @@
</Style>
<local:DynAreaIOVmUt x:Key="ioVm" />
<local:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开"/>
<local:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/>
</ResourceDictionary>
</UserControl.Resources>
<Grid Height="100" >
......@@ -113,42 +115,7 @@
</Border>
</Grid>
</Button>
<Button x:Name="grid_error" Style="{StaticResource Styles.Button.Empty}" Command="{Binding OpenWarningCmd}"
Visibility="{Binding IsError,Converter={StaticResource visbilityconv}}"
d:DataContext="{StaticResource errorVm}"
>
<Border Style="{StaticResource Styles.Module.Border}" Background="Red" >
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="{StaticResource ControlMargin}" Fill="White" Stretch="Uniform" Width="60" Height="60" SnapsToDevicePixels="True" Data="{StaticResource Geometry_alert-circle-outline}" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever" >
<DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="00:00:01" />
<DoubleAnimation BeginTime="0:0:1" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="00:00:01" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
<Viewbox Grid.Column="1" Margin="{StaticResource ControlMargin}" MaxWidth="190" MaxHeight="80">
<TextBlock VerticalAlignment="Center" MaxWidth="190" TextWrapping="Wrap" FontSize="30" Foreground="White" Text="{Binding ErrMsg}"/>
</Viewbox>
</Grid>
</Border>
</Button>
<Button x:Name="grid_error" Style="{StaticResource DynAreaErrorStyle}" d:DataContext="{StaticResource errorVm}"/>
</Grid>
</UserControl>
......@@ -258,6 +258,124 @@ namespace FLY.Thick.Base.UI.UiModule
}
public class DynAreaErrorVm2 : INotifyPropertyChanged
{
/// <summary>
/// 有异常
/// </summary>
public bool IsError { get; set; }
/// <summary>
/// 异常消息
/// </summary>
public string ErrMsg { get; set; }
public RelayCommand OpenWarningCmd { get; }
public event PropertyChangedEventHandler PropertyChanged;
IWarningSystem2Service warningSystem;
IUnityContainer container;
string serverName;
DispatcherTimer timer_error;
private int reason_list_index = -1;
public DynAreaErrorVm2()
{
OpenWarningCmd = new RelayCommand(OpenWarning);
}
public void Init(
IUnityContainer container,
IWarningSystem2Service warningSystem,
string serverName)
{
this.container = container;
this.warningSystem = warningSystem;
this.serverName = serverName;
//报警原因轮流显示
timer_error = new DispatcherTimer();
timer_error.Interval = TimeSpan.FromSeconds(3);
timer_error.Tick += (s, e) =>
{
reason_list_index--;
if (reason_list_index < 0)
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
reason_list_index = warningSystem.ReasonList.Count();
else
reason_list_index = -1;
UpdateError();
};
warningSystem.PropertyChanged += WarningSystem_PropertyChanged;
UpdateError();
}
private void WarningSystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Reflect_SeviceClient.IsConnected))
{
UpdateError();
}
else if (e.PropertyName == nameof(warningSystem.ReasonList))
{
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
reason_list_index = warningSystem.ReasonList.Count() - 1;
else
reason_list_index = -1;
UpdateError();
}
}
void UpdateError()
{
if (this.warningSystem is FObjBase.FObjServiceClient)
{
var client = this.warningSystem as FObjBase.FObjServiceClient;
if (!client.IsConnected)
{
ErrMsg = $"{serverName}服务器连接断开";
IsError = true;
reason_list_index = -1;
timer_error.Stop();
return;
}
}
if (warningSystem.ReasonList != null && warningSystem.ReasonList.Count() > 0)
{
if (reason_list_index >= warningSystem.ReasonList.Count())
reason_list_index = warningSystem.ReasonList.Count() - 1;
else if (reason_list_index < 0)
reason_list_index = 0;
ErrMsg = warningSystem.ReasonList[reason_list_index].Description;
IsError = true;
timer_error.Start();
}
else
{
IsError = false;
ErrMsg = "";
reason_list_index = -1;
timer_error.Stop();
}
}
private void OpenWarning()
{
if (!WdPassword.Authorize("Warning"))
return;
PgErrorTable2 p = new PgErrorTable2();
p.Init(container, warningSystem);
FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class UiModule2_DynAreaIO : IUiModule2
{
public string Title => "测厚.IO状态(报警)";
......
......@@ -98,15 +98,6 @@
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Column="2" Grid.RowSpan="2">
<StackPanel.Resources>
<Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
<Setter Property="Fill" Value="{StaticResource Color_theme_activity}"/>
<Setter Property="Stretch" Value="Uniform"/>
<Setter Property="Width" Value="40"/>
<Setter Property="Height" Value="40"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
</StackPanel.Resources>
<Button Click="button_pause_Click" >
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Styles.Button.Icon.Rectangle}">
......
<UserControl x:Class="FLY.Thick.Base.UI.Client.UiModule.MenuProfile"
<UserControl x:Class="FLY.Thick.Base.UI.UiModule.MenuProfile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
......
......@@ -4,7 +4,7 @@ using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Base.UI.Client.UiModule
namespace FLY.Thick.Base.UI.UiModule
{
......
<UserControl x:Class="FLY.Thick.Base.UI.Client.UiModule.MenuSetting"
<UserControl x:Class="FLY.Thick.Base.UI.UiModule.MenuSetting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
......
......@@ -17,7 +17,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Unity;
namespace FLY.Thick.Base.UI.Client.UiModule
namespace FLY.Thick.Base.UI.UiModule
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment