Commit 0733b593 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 LCUS1 无法报警

2.添加 全局报警 可以从 左下角的 【枫莱尔】 进入
parent 54881a0a
using MultiLayout.UiModule;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
using FLY.Thick.Base.UI;
using Unity;
using MultiLayout;
namespace FLY.Thick.Base.UI.CustomMenu
{
public class WarningMenu : IMenu
{
public string Title => "全局报警";
public Brush Brush { get; set; }
IUnityContainer container;
public WarningMenu(IUnityContainer container)
{
this.container = container;
Brush = Brushes.Red;
}
public void OnClick()
{
var p = this.container.Resolve<PgErrorsTable>();
FlyLayoutManager.NavigationService.Navigate(p);
}
}
}
......@@ -94,7 +94,9 @@
</StackPanel>
</StackPanel>
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="{Binding LCUS1.ErrMsg}" />
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" >
状态:<Run Text="{Binding LCUS1.ErrMsg,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</GroupBox>
......
......@@ -10,33 +10,12 @@ namespace FLY.Thick.Base.UI
public class LCUS1_dependOn:LCUS1
{
ParamDictionary paramDictionary;
FLY.OBJComponents.IService.IWarningSystem2Service warningService;
public LCUS1_dependOn(
ParamDictionary paramDictionary,
FLY.OBJComponents.IService.IWarningSystem2Service warningService)
ParamDictionary paramDictionary)
{
this.paramDictionary = paramDictionary;
this.warningService = warningService;
//绑定 this.PortName 与 this.paramDictionary.LCUS1_PortName
this.paramDictionary.SetBinding(this, nameof(PortName), ParamDistItemKeys.LCUS1_PortName, "COM1");
this.warningService.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(this.warningService.IsRinging))
{
if (this.paramDictionary.GetValue(ParamDistItemKeys.LCUS1_Enable, false))
{
if (this.warningService.IsRinging)
{
On();
}
else
{
Off();
}
}
}
};
}
}
}
......@@ -123,6 +123,7 @@
<Compile Include="CtMicroGage\CtMircoGageVmUt.cs" />
<Compile Include="CustomMenu\AdrMenu.cs" />
<Compile Include="CustomMenu\CustomMenu.cs" />
<Compile Include="CustomMenu\WarningMenu.cs" />
<Compile Include="CustomMenu\PwMenu.cs" />
<Compile Include="CustomSection\UcSectionScanGraph.xaml.cs">
<DependentUpon>UcSectionScanGraph.xaml</DependentUpon>
......
......@@ -37,6 +37,7 @@ namespace FLY.Thick.Base.UI.OnInit
this.container = container;
this.paramDictionary = paramDictionary;
this.warningService = warningService;
}
public void OnInit()
{
......@@ -45,7 +46,10 @@ namespace FLY.Thick.Base.UI.OnInit
warningService.PropertyChanged += WarningService_PropertyChanged;
updateErrCodesOfTip();
}
private void WarningService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
......
......@@ -28,18 +28,22 @@ namespace FLY.Thick.Base.UI.OnInit
FlyLayoutManager flyLayoutManager;
DispatcherTimer timer_error;
int reason_list_index = -1;
ParamDictionary paramDictionary;
LCUS1 lcus1;
public OnInitWarnings(
IUnityContainer container,
FlyLayoutManager flyLayoutManager,
WarningSystemManager warningSystemManager,
ParamDictionary paramDictionary,
LCUS1 lcus1,
int lv = 1)
{
Level = lv;
this.container = container;
this.flyLayoutManager = flyLayoutManager;
this.warningSystemManager = warningSystemManager;
this.lcus1 = lcus1;
this.paramDictionary = paramDictionary;
if (warningSystemManager.Warnings.Count() == 0)
return;
......@@ -64,6 +68,21 @@ namespace FLY.Thick.Base.UI.OnInit
UpdateError();
};
UpdateError();
warningSystemManager.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(warningSystemManager.IsRinging))
{
if (this.paramDictionary.GetValue(ParamDistItemKeys.LCUS1_Enable, false))
{
if (warningSystemManager.IsRinging)
lcus1.On();
else
lcus1.Off();
}
}
};
}
private void WarningSystemManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
......@@ -107,7 +126,7 @@ namespace FLY.Thick.Base.UI.OnInit
public List<ErrorWithName> Errors { get; private set; } = new List<ErrorWithName>();
public bool IsRinging { get; set; }
[InjectionMethod]
public void Init(IUnityContainer container)
{
......@@ -119,6 +138,7 @@ namespace FLY.Thick.Base.UI.OnInit
//获取全部报警管理器
Warnings = warning_container.ResolveAll<WarningSystem2ServiceClientWithName>().ToList();
IsRinging = Warnings.Any(w => w.IsRinging);
foreach (var warning in Warnings)
{
......@@ -129,10 +149,13 @@ namespace FLY.Thick.Base.UI.OnInit
private void WarningService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if ((e.PropertyName == nameof(WarningSystem2ServiceClientWithName.ReasonList))
||(e.PropertyName == nameof(WarningSystem2ServiceClientWithName.IsConnected)))
|| (e.PropertyName == nameof(WarningSystem2ServiceClientWithName.IsConnected)))
{
updateErrors();
}
else if (e.PropertyName == nameof(WarningSystem2ServiceClientWithName.IsRinging)) {
IsRinging = Warnings.Any(w => w.IsRinging);
}
}
void updateErrors()
......
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