Commit 9d6035ff authored by 潘栩锋's avatar 潘栩锋 🚴

添加 称重状态V4 UI模块

parent f9d5c1c4
......@@ -644,27 +644,27 @@ namespace FLY.Thick.BlowingScan.Server
}
});
ErrNoForCheckItems.Add(//限位
new ErrNoForCheckItem()
{
errno = FLY.Thick.Base.Common.ERRNOs.BASE_ERRNO_LIMIT,
cnt = 2,
conditional = delegate ()
{
return ((Misc.MyBase.CHECKBIT(dynArea.IStatus, 3 - 1) == true) || (Misc.MyBase.CHECKBIT(dynArea.IStatus, 4 - 1) == true));
}
});
ErrNoForCheckItems.Add(//急停
new ErrNoForCheckItem()
{
errno = FLY.Thick.Base.Common.ERRNOs.BASE_ERRNO_EMERGENCY,
cnt = 2,
conditional = delegate ()
{
return ((Misc.MyBase.CHECKBIT(dynArea.IStatus, 7 - 1) == false) || (Misc.MyBase.CHECKBIT(dynArea.IStatus, 8 - 1) == false));
}
});
//ErrNoForCheckItems.Add(//限位
// new ErrNoForCheckItem()
// {
// errno = FLY.Thick.Base.Common.ERRNOs.BASE_ERRNO_LIMIT,
// cnt = 2,
// conditional = delegate ()
// {
// return ((Misc.MyBase.CHECKBIT(dynArea.IStatus, 3 - 1) == true) || (Misc.MyBase.CHECKBIT(dynArea.IStatus, 4 - 1) == true));
// }
// });
//ErrNoForCheckItems.Add(//急停
// new ErrNoForCheckItem()
// {
// errno = FLY.Thick.Base.Common.ERRNOs.BASE_ERRNO_EMERGENCY,
// cnt = 2,
// conditional = delegate ()
// {
// return ((Misc.MyBase.CHECKBIT(dynArea.IStatus, 7 - 1) == false) || (Misc.MyBase.CHECKBIT(dynArea.IStatus, 8 - 1) == false));
// }
// });
foreach (ErrNoForCheckItem item in ErrNoForCheckItems)
{
......
......@@ -88,6 +88,9 @@
<Compile Include="PgReduce.xaml.cs">
<DependentUpon>PgReduce.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\DynAreaWeightV4.xaml.cs">
<DependentUpon>DynAreaWeightV4.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\DynAreaWeight.xaml.cs">
<DependentUpon>DynAreaWeight.xaml</DependentUpon>
</Compile>
......@@ -199,6 +202,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UiModule\DynAreaWeightV4.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\DynAreaWeight.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -66,6 +66,26 @@
</Viewbox>
</Grid>
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Text="平均厚度" FontSize="12" FontWeight="Bold" FontFamily="YouYuan" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF3B3B3B" />
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Text="{Binding Accessory.Thickness, StringFormat={}{0:F1}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource Color_theme_activity}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="um" FontSize="12" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="2" >
<TextBlock Text="边料" FontSize="12" FontWeight="Bold" FontFamily="YouYuan" TextAlignment="Center" HorizontalAlignment="Center" Foreground="#FF3B3B3B" />
<StackPanel Orientation="Horizontal" Margin="5,0">
<TextBlock Text="{Binding Accessory.RimCharge, StringFormat={}{0:F1}}" FontSize="24" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource Color_theme_activity}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="kg/h" FontSize="12" />
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<Border Style="{StaticResource BorderStyle_module}" Background="Red"
......
......@@ -76,6 +76,12 @@ namespace FLY.Weight.UI.Client.UiModule
grid_error.DataContext = props;
//注册属性更新计划
setPlan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Accessory,
new string[] {
nameof(Common.WeighterAccessory.Thickness),
nameof(Common.WeighterAccessory.RimCharge)});
this.weightSystemService.PropertyChanged += (s, e) =>
{
......
<UserControl x:Class="FLY.Weight.UI.Client.UiModule.DynAreaWeightV4"
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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Weight.UI.Client.UiModule"
xmlns:control="clr-namespace:FLY.Weight.UI.Client.Control"
mc:Ignorable="d"
d:DesignWidth="292" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
<Setter Property="Fill" Value="White"/>
<Setter Property="Stretch" Value="Uniform"/>
<Setter Property="Width" Value="30"/>
<Setter Property="Height" Value="30"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
<local:DynAreaViewModelParams x:Key="unitests_props" IsError="False" Error="报警MSG"/>
</ResourceDictionary>
</UserControl.Resources>
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="Button_Click">
<Grid>
<Grid x:Name="grid_weighter" d:DataContext="{StaticResource unittests_weighters}"/>
<Grid x:Name="grid_error" d:DataContext="{StaticResource unitests_props}"/>
<Border Style="{StaticResource BorderStyle_module}"
Background="{StaticResource Color_background}"
DataContext="{Binding DataContext,ElementName=grid_weighter}"
>
<StackPanel >
<Grid Name="grid_flow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<control:PieChart Grid.RowSpan="2" Width="60" Height="60" Margin="10"
ItemValueBinding="CurrentFlow" ItemColorBinding="Color"
ItemsSource="{Binding Items}"
/>
<TextBlock Grid.Column="1" Text="总流量" Style="{StaticResource TextBlockStyle_title}" />
<Viewbox Grid.Column="1" Grid.Row="1" MaxHeight="80" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="4" >
<Run Text="{Binding Accessory.TotalFlow,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="60" />
</TextBlock>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="kg/h" FontSize="20" />
</StackPanel>
</Viewbox>
</Grid>
</StackPanel>
</Border>
<Border Style="{StaticResource BorderStyle_module}" Background="Red"
DataContext="{Binding DataContext,ElementName=grid_error}"
Visibility="{Binding IsError,Converter={StaticResource visbilityconv}}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Path Margin="5" 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="30" Foreground="White" Text="{Binding Error}"/>
</Grid>
</Border>
</Grid>
</Button>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.OBJComponents.Common;
using FLY.OBJComponents.IService;
using FLY.Thick.Base.UI;
using FLY.Weight.Client;
using FLY.Weight.IService;
using FObjBase;
using MultiLayout;
using MultiLayout.UiModule;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Threading;
using Unity;
namespace FLY.Weight.UI.Client.UiModule
{
/// <summary>
/// DynAreaWeight.xaml 的交互逻辑
/// </summary>
public partial class DynAreaWeightV4 : UserControl
{
#region 延时推送 MARKNO
const int MARKNO_UPDATEERROR = 1;
#endregion
IUnityContainer container;
IWeightSystemService weightSystemService;
WarningReasonWindow warningReasonWindow;
IWarningService warningService;
DispatcherTimer timer_error;
DynAreaViewModelParams props = new DynAreaViewModelParams();
//SetPLCUpdatePlan setPlan;
public DynAreaWeightV4()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
[Dependency("weighterWarningReasonWindow")] WarningReasonWindow warningReasonWindow,
[Dependency("weighterWarningService")]IWarningService warningService,
IWeightSystemService weightSystemService
)
{
this.container = container;
this.weightSystemService = weightSystemService;
//创建窗口观察 报警原因列表
this.warningReasonWindow = warningReasonWindow;
this.warningService = warningService;
//报警原因轮流显示
timer_error = new DispatcherTimer();
timer_error.Interval = TimeSpan.FromSeconds(3);
timer_error.Tick += (s, e) =>
{
reason_list_index--;
if (reason_list_index < 0)
reason_list_index = this.warningReasonWindow.Record.Count();
updateError();
};
this.warningReasonWindow.Record.CollectionChanged += Record_CollectionChanged;
grid_weighter.DataContext = this.weightSystemService;
grid_error.DataContext = props;
//注册属性更新计划
//setPlan = new SetPLCUpdatePlan(
// this.weightSystemService.PLCos,
// this.weightSystemService.Accessory,
// new string[] {
// nameof(Common.WeighterAccessory.Thickness),
// nameof(Common.WeighterAccessory.RimCharge)});
this.weightSystemService.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(FObjServiceClient.IsConnected))
{
updateError();
}
};
updateError();
}
private void Record_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
FObjBase.PollModule.Current.Poll_JustOnce(
new FObjBase.PollModule.PollHandler(delegate ()
{
reason_list_index = warningReasonWindow.Record.Count() - 1;
updateError();
}), this, MARKNO_UPDATEERROR);
}
void updateError()
{
if (weightSystemService is FObjServiceClient)
{
var objClient = weightSystemService as FObjServiceClient;
if (!objClient.IsConnected) {
props.Error = "称重服务器连接断开";
props.IsError = true;
reason_list_index = -1;
timer_error.Stop();
return;
}
}
if (warningReasonWindow.Record.Count == 0) {
props.IsError = false;
props.Error = "";
reason_list_index = -1;
timer_error.Stop();
return;
}
if (reason_list_index >= warningReasonWindow.Record.Count)
reason_list_index = warningReasonWindow.Record.Count - 1;
else if (reason_list_index < 0)
reason_list_index = 0;
props.Error = warningReasonWindow.Record[reason_list_index].Description;
props.IsError = true;
timer_error.Start();
}
private int reason_list_index = -1;
private void Button_Click(object sender, RoutedEventArgs e)
{
PgErrorTable2 p = new PgErrorTable2();
p.Init(container, warningService, warningReasonWindow);
FlyLayoutManager.NavigationService.Navigate(p);
}
}
public class UiModule2_DynAreaWeightV4 : MultiLayout.UiModule.IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title=> "称重状态V4";
public ComponentType Type => ComponentType.DynArea;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
DynAreaWeightV4 graph = new DynAreaWeightV4();
container.BuildUp(graph);
return graph;
}
/// <summary>
/// 控件缩略图,用于编辑界面时,大致看看
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetThumbnail()
{
return new System.Windows.Controls.Grid();
}
/// <summary>
/// 给出全部控件ID, 控件自行删除没有的参数
/// </summary>
/// <param name="IDs"></param>
public void MatchParam(int[] IDs)
{
}
}
}
......@@ -11,6 +11,7 @@
<register type="IUiModule2" mapTo="UiModule2_MenuSetting" name="weighter_ms" />
<register type="IUiModule2" mapTo="UiModule2_MenuSettingV4" name="weighter_msV4" />
<register type="IUiModule2" mapTo="UiModule2_DynAreaWeight" name="weighter_da" />
<register type="IUiModule2" mapTo="UiModule2_DynAreaWeightV4" name="weighter_daV4" />
<register type="IUiModule2" mapTo="UiModule2_FlowGraph" name="weighter_fg" />
<register type="IUiModule2" mapTo="UiModule2_MainGraph" name="weighter_mg" />
<register type="IUiModule2" mapTo="UiModule2_UcThickness" name="weighter_thk" />
......
......@@ -11,6 +11,7 @@
<register type="IUiModule2" mapTo="UiModule2_MenuSetting" name="weighter_ms" />
<register type="IUiModule2" mapTo="UiModule2_MenuSettingV4" name="weighter_msV4" />
<register type="IUiModule2" mapTo="UiModule2_DynAreaWeight" name="weighter_da" />
<register type="IUiModule2" mapTo="UiModule2_DynAreaWeightV4" name="weighter_daV4" />
<register type="IUiModule2" mapTo="UiModule2_FlowGraph" name="weighter_fg" />
<register type="IUiModule2" mapTo="UiModule2_MainGraph" name="weighter_mg" />
<register type="IUiModule2" mapTo="UiModule2_UcThickness" name="weighter_thk" />
......
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