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

完成 称重单组分 V7

parent 252930b2
......@@ -60,9 +60,8 @@ namespace FLY.Weight2.UI.Client
private void button_error_Click(object sender, RoutedEventArgs e)
{
PgErrorTable2 p = new PgErrorTable2();
var warningReasonWindow = container.Resolve<WarningReasonWindow>("weighterWarningReasonWindow");
var warningService = container.Resolve<IWarningService>("weighterWarningService");
p.Init(container, warningService, warningReasonWindow);
var warningService = container.Resolve<IWarningSystem2Service>("weighterWarningService");
p.Init(container, warningService);
NavigationService.Navigate(p);
}
......
......@@ -65,38 +65,38 @@ namespace FLY.Weight2.UI.Client
for (int i = 0; i < weightSystemService.Items.Count(); i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{i}]";
setPlan_items.Add(new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[i],
objname,
new string[] {
"MaxFreq",
"StableTime",
"SampleTime",
"ChargeTime",
"FastStandard",
"BinUpperLimit",
"BinLowerLimit",
"ScrewLowerLimit",
"StableLv",
"AdjustLv",
"HighFactor",
"LowFactor",
"AdjustLimit",
"Pc",
"It",
"Dg",
"Dt",
"Filter",
"FastFreq",
"FastTime",
"Cal",
"Tolerance",
"PIDResult",
"PIDAdjust"
nameof(Common.WeighterC.MaxFreq),
nameof(Common.WeighterC.StableTime),
nameof(Common.WeighterC.SampleTime),
nameof(Common.WeighterC.ChargeTime),
nameof(Common.WeighterC.FastStandard),
nameof(Common.WeighterC.BinUpperLimit),
nameof(Common.WeighterC.BinLowerLimit),
nameof(Common.WeighterC.ScrewLowerLimit),
nameof(Common.WeighterC.StableLv),
nameof(Common.WeighterC.AdjustLv),
nameof(Common.WeighterC.HighFactor),
nameof(Common.WeighterC.LowFactor),
nameof(Common.WeighterC.AdjustLimit),
nameof(Common.WeighterC.Pc),
nameof(Common.WeighterC.It),
nameof(Common.WeighterC.Dg),
nameof(Common.WeighterC.Dt),
nameof(Common.WeighterC.Filter),
nameof(Common.WeighterC.FastFreq),
nameof(Common.WeighterC.FastTime),
nameof(Common.WeighterC.Cal),
nameof(Common.WeighterC.Tolerance),
nameof(Common.WeighterC.PIDResult),
nameof(Common.WeighterC.PIDAdjust)
}));
}
}
......
......@@ -47,14 +47,14 @@ namespace FLY.Weight2.UI.Client
/// </summary>
void RebuildPlans()
{
string objname = nameof(IWeightSystemService.Accessory);
setPlan_accessory = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Accessory,
objname,
new string[] {
"WheelPerimeter",
"WheelPulse",
"Density"
nameof(Common.WeighterAccessory.WheelPerimeter),
nameof(Common.WeighterAccessory.WheelPulse),
nameof(Common.WeighterAccessory.Density)
});
}
......
......@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("自动上料(称重单组分) 客户端")]
[assembly: AssemblyCopyright("Copyright © 2020 FlyAutomation")]
[assembly: AssemblyCopyright("Copyright © 2022 FlyAutomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -51,5 +51,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.0.0.0")]
[assembly: AssemblyFileVersion("6.0.0.0")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
......@@ -21,21 +21,19 @@
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
<local:DynAreaViewModelParams x:Key="unitests_props" IsError="False" Error="报警MSG"/>
</ResourceDictionary>
</UserControl.Resources>
<Button Style="{StaticResource ButtonStyle_empty}" Click="Button_Click">
<Grid Height="150">
<Button Style="{StaticResource Styles.Button.Empty}">
<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}"
<Border Style="{StaticResource Styles.Module.Border}"
DataContext="{Binding DataContext,ElementName=grid_weighter}" Background="{StaticResource Color_background}">
<StackPanel Orientation="Vertical">
<StackPanel >
<Grid Name="grid_flow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
......@@ -57,7 +55,7 @@
</Viewbox>
</StackPanel>
</Grid>
<Grid Margin="2">
<Grid.ColumnDefinitions>
......@@ -81,36 +79,6 @@
</Grid>
</StackPanel>
</Border>
<Border Style="{StaticResource BorderStyle_module}" Background="{StaticResource Brushes.Validation}"
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="22" Foreground="White" Text="{Binding Error}"/>
</Grid>
</Border>
</Grid>
</Button>
......
......@@ -30,11 +30,7 @@ namespace FLY.Weight2.UI.Client.UiModule
IUnityContainer container;
IWeightSystemService weightSystemService;
WarningReasonWindow warningReasonWindow;
IWarningService warningService;
DispatcherTimer timer_error;
DynAreaViewModelParams props = new DynAreaViewModelParams();
SetPLCUpdatePlan setPlan;
public DynAreaWeight()
......@@ -46,126 +42,25 @@ namespace FLY.Weight2.UI.Client.UiModule
[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;
//注册属性更新计划
string objname = nameof(IWeightSystemService.Accessory);
setPlan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Accessory,
objname,
new string[] {
"Thickness",
"RimCharge"});
this.weightSystemService.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "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);
nameof(IWeightSystemService.Accessory.Thickness),
nameof(IWeightSystemService.Accessory.RimCharge)
});
}
}
public class DynAreaViewModelParams : INotifyPropertyChanged
{
/// <summary>
/// 有异常
/// </summary>
public bool IsError { get; set; }
/// <summary>
/// 异常消息
/// </summary>
public string Error { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
public class UiModule2_DynAreaWeight : MultiLayout.UiModule.IUiModule2
{
/// <summary>
......
......@@ -51,9 +51,10 @@ namespace FLY.Weight2.UI.Client.UiModule
for (int i = 0; i < this.weightSystemService.Items.Count(); i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Items[i],
objname,
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
......@@ -82,9 +83,10 @@ namespace FLY.Weight2.UI.Client.UiModule
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{start_idx+i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx+i],
objname,
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
......
......@@ -51,9 +51,10 @@ namespace FLY.Weight2.UI.Client.UiModule
for (int i = 0; i < this.weightSystemService.Items.Count(); i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Items[i],
objname,
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
......@@ -82,9 +83,10 @@ namespace FLY.Weight2.UI.Client.UiModule
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{start_idx+i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx+i],
objname,
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
......
......@@ -37,18 +37,18 @@ namespace FLY.Weight2.UI.Client.UiModule
{
this.weightSystemService = weightSystemService;
this.DataContext = this.weightSystemService;
string objname = nameof(IWeightSystemService.Accessory);
setPlan_accessory = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Accessory,
objname,
new string[] {
"TotalFilmWidth",
"IsRimNoRecycle",
"RimWidth",
"ActFilmWidth",
"SetThickness",
"TargetVelocity",
"CurrentVelocity"
nameof(Common.WeighterAccessory.TotalFilmWidth),
nameof(Common.WeighterAccessory.IsRimNoRecycle),
nameof(Common.WeighterAccessory.RimWidth),
nameof(Common.WeighterAccessory.ActFilmWidth),
nameof(Common.WeighterAccessory.SetThickness),
nameof(Common.WeighterAccessory.TargetVelocity),
nameof(Common.WeighterAccessory.CurrentVelocity)
});
}
......
......@@ -40,32 +40,33 @@ namespace FLY.Weight2.UI.Client.UiModule
{
this.weightSystemService = weightSystemService;
this.DataContext = weightSystemService;
string objname = nameof(IWeightSystemService.Accessory);
setPlan_accessory = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Accessory,
objname,
new string[] {
"TotalFlowSetOut",
"TotalFlowSetIn",
"TotalFlowSetInIsSet",
"TotalFlow",
"ALast",
"ACurrent",
"ACurrentLen",
"AClear",
"BLast",
"BCurrent",
"BCurrentLen",
"BClear"
nameof(Common.WeighterAccessory.TotalFlowSetOut),
nameof(Common.WeighterAccessory.TotalFlowSetIn),
nameof(Common.WeighterAccessory.TotalFlowSetInIsSet),
nameof(Common.WeighterAccessory.TotalFlow),
nameof(Common.WeighterAccessory.ALast),
nameof(Common.WeighterAccessory.ACurrent),
nameof(Common.WeighterAccessory.ACurrentLen),
nameof(Common.WeighterAccessory.AClear),
nameof(Common.WeighterAccessory.BLast),
nameof(Common.WeighterAccessory.BCurrent),
nameof(Common.WeighterAccessory.BCurrentLen),
nameof(Common.WeighterAccessory.BClear)
});
for (int i = 0; i < weightSystemService.Items.Count(); i++)
{
objname = $"{nameof(IWeightSystemService.Items)}[{i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[i],
objname,
item_update_propertynames);
setPlan_items.Add(plan);
}
......@@ -94,16 +95,17 @@ namespace FLY.Weight2.UI.Client.UiModule
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
string objname = $"{nameof(IWeightSystemService.Items)}[{start_idx+i}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx + i],
objname,
item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
string[] item_update_propertynames = new string[] {
"CurrentFlow",
nameof(Common.WeighterC.CurrentFlow),
};
private void button_ratio_Click(object sender, RoutedEventArgs e)
......
......@@ -78,10 +78,10 @@ namespace FLY.Weight2.UI.Client.UiModule
this.DataContext = this.WeightSystemService.Items[idx];
string objname = $"{nameof(IWeightSystemService.Items)}[{idx}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[idx],
objname,
item_update_propertynames);
setPlan_items.Add(plan);
......
......@@ -78,10 +78,10 @@ namespace FLY.Weight2.UI.Client.UiModule
this.DataContext = this.WeightSystemService.Items[idx];
string objname = $"{nameof(IWeightSystemService.Items)}[{idx}]";
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[idx],
objname,
item_update_propertynames);
setPlan_items.Add(plan);
......
......@@ -62,6 +62,15 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="PgLoading.xaml.cs">
<DependentUpon>PgLoading.xaml</DependentUpon>
</Compile>
<Compile Include="PgMain.xaml.cs">
<DependentUpon>PgMain.xaml</DependentUpon>
</Compile>
<Compile Include="WdDRList.xaml.cs">
<DependentUpon>WdDRList.xaml</DependentUpon>
</Compile>
<Compile Include="WdSetup.xaml.cs">
<DependentUpon>WdSetup.xaml</DependentUpon>
</Compile>
......@@ -144,6 +153,18 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgLoading.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PgMain.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WdDRList.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WdSetup.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
<Window x:Class="FLY.Weight2.UI.Server.MainWindow"
<NavigationWindow x:Class="FLY.Weight2.UI.Server.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MinHeight="80" MinWidth="200">
<Grid>
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_WeightSystem"/>
<StackPanel Margin="5">
<StackPanel Orientation="Horizontal">
<StackPanel Margin="4" DataContext="{Binding ElementName=grid_WeightSystem,Path=DataContext}">
<TextBlock Text="当前线速度设置m/min*10" />
<TextBlock FontSize="20">
<Run Text="{Binding Accessory.CurrentVelocitySet,StringFormat=\{0:F0\}, Mode=OneWay}" />
</TextBlock>
</StackPanel>
<StackPanel Margin="4" x:Name="spBDetect">
<TextBlock Text="测厚仪服务器连接状态" />
<TextBlock Text="{Binding IsConnected}" FontSize="20"/>
</StackPanel>
</StackPanel>
<ItemsControl x:Name="itemcontrol">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" >
<TextBlock Text="更新速度" />
<TextBlock FontSize="20">
<Run Text="{Binding ActUpdateInterval,StringFormat=\{0:sfff\}, Mode=OneWay}" />
<Run Text="ms" FontSize="15"/>
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="PLC连接状态" />
<TextBlock Text="{Binding Client.IsConnected}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="异常次数" />
<TextBlock Text="{Binding ErrorCnt}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="寄存器更新数" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DRNeedUpdateCnt}" FontSize="20"/>
<TextBlock Text="/"/>
<TextBlock Text="{Binding DRCnt}" FontSize="20"/>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnSetupClick"></Button>
<!--<StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<TextBlock Text="更新速度" />
<TextBlock Text="{Binding ActUpdateInterval}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" DataContext="{Binding DataContext,ElementName=grid_plcos}">
<TextBlock Text="PLC连接状态" />
<TextBlock Text="{Binding IsRunning}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<TextBlock Text="寄存器更新数" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DRNeedUpdateCnt}" FontSize="20"/>
<TextBlock Text="/"/>
<TextBlock Text="{Binding DRCnt}" FontSize="20"/>
</StackPanel>
</StackPanel>
</StackPanel>-->
</StackPanel>
</Grid>
</Window>
Title="MainWindow" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200"
ShowsNavigationUI="False"
Loaded="NavigationWindow_Loaded">
</NavigationWindow>
using FLY.Weight2.Server;
using System.Windows;
using System.Windows.Navigation;
namespace FLY.Weight2.UI.Server
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow : NavigationWindow
{
FLY.AppHelper.WindowNotifyIconHelper notifyiconhelper;
FLY.Weight2.Server.TDGage gage;
......@@ -14,32 +15,28 @@ namespace FLY.Weight2.UI.Server
public MainWindow()
{
InitializeComponent();
PgLoading p = new PgLoading();
this.Navigate(p);
this.Title = (new Misc.Ver() { SrcType = typeof(MainWindow) }).ToString();
notifyiconhelper = new AppHelper.WindowNotifyIconHelper(this, this.Title);
}
this.Hide();
FObjBase.PollModule.Current.Start();
private async void NavigationWindow_Loaded(object sender, RoutedEventArgs _e)
{
gage = new TDGage("Gage1");
await gage.Init();
oBJProxy = new Weight2.Server.OBJProxy.OBJProxy(0, gage);
//this.DataContext = mTDGage.mData.Items[0];
FLY.OBJComponents.Server.PLCProxySystem plsos =
gage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
//grid_plcos.DataContext = plsos;
//grid_plc.DataContext = plsos.PLCs[0];
grid_WeightSystem.DataContext = gage.mData;
this.itemcontrol.ItemsSource = plsos.PLCs;
spBDetect.DataContext = gage.mBDetect;
}
FObjBase.PollModule.Current.Start();
private void btnSetupClick(object sender, RoutedEventArgs e)
{
WdSetup w = new WdSetup();
w.Owner = this;
w.ShowDialog();
this.Hide();
PgMain p = new PgMain();
p.Init(gage);
this.Navigate(p);
this.NavigationService.RemoveBackEntry();
}
}
}
<Page x:Class="FLY.Weight2.UI.Server.PgLoading"
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.Weight2.UI.Server"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="PgLoading" >
<Grid>
<TextBlock x:Name="message" VerticalAlignment="Center" HorizontalAlignment="Center" Text="初始化中......" FontSize="24"/>
</Grid>
</Page>
using System;
using System.Windows.Controls;
using System.Windows.Threading;
namespace FLY.Weight2.UI.Server
{
/// <summary>
/// PgLoading.xaml 的交互逻辑
/// </summary>
public partial class PgLoading : Page
{
DispatcherTimer timer;
public PgLoading()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Start();
Timer_Tick(null, null);
}
int cnt = 0;
private void Timer_Tick(object sender, EventArgs e)
{
string str = "";
for (int i = 0; i < cnt; i++)
{
str += ".";
}
message.Text = "初始化中" + str;
cnt++;
if (cnt > 6)
cnt = 0;
}
}
}
<Page x:Class="FLY.Weight2.UI.Server.PgMain"
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.Weight2.UI.Server"
mc:Ignorable="d"
Title="PgMain" Height="245" Width="405">
<Page.Resources>
<local:PgMainVmUt x:Key="viewModel"/>
</Page.Resources>
<Grid d:DataContext="{StaticResource viewModel}">
<Grid x:Name="grid_WeightSystem"/>
<StackPanel Margin="5">
<StackPanel Margin="5" DataContext="{Binding ElementName=grid_WeightSystem,Path=DataContext}">
<TextBlock Text="当前线速度设置m/min" />
<TextBlock FontSize="20">
<Run Text="{Binding Accessory.CurrentVelocitySet,StringFormat={}{0:F1}, Mode=OneWay}" />
</TextBlock>
</StackPanel>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" >
<TextBlock Text="更新速度" />
<TextBlock FontSize="20">
<Run Text="{Binding ActUpdateInterval,StringFormat=\{0:sfff\}, Mode=OneWay}" />
<Run Text="ms" FontSize="15"/>
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="{Binding Client.RemoteAddr,Mode=OneWay}" />
<TextBlock >
连接状态[<Run Text="{Binding Client.IsConnected,Mode=OneWay}" FontSize="20"/>]
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="异常次数" />
<TextBlock Text="{Binding ErrorCnt}" FontSize="20"/>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="寄存器更新数" />
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20">
<Run Text="{Binding DRNeedUpdateCnt,Mode=OneWay}"/>/<Run Text="{Binding DRCnt,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</StackPanel>
<Button Margin="4" Padding="5,2" Content="..." Tag="{Binding .}" Click="btnMoreClick"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnSetupClick"></Button>
</StackPanel>
</Grid>
</Page>
using FLY.Weight2.Server;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FLY.Weight2.UI.Server
{
/// <summary>
/// PgMain.xaml 的交互逻辑
/// </summary>
public partial class PgMain : Page
{
public PgMain()
{
InitializeComponent();
}
public void Init(TDGage gage)
{
var plsos = gage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
//grid_plcos.DataContext = plsos;
//grid_plc.DataContext = plsos.PLCs[0];
grid_WeightSystem.DataContext = gage.mData;
this.itemcontrol.ItemsSource = plsos.PLCs;
}
private void btnSetupClick(object sender, RoutedEventArgs e)
{
WdSetup w = new WdSetup();
w.Owner = App.Current.MainWindow;
w.ShowDialog();
}
private void btnMoreClick(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
var plc = button.Tag as Modbus.WithThread.ModbusMapper_Client;
WdDRList w = new WdDRList();
w.Init(plc);
w.ShowDialog();
}
}
public class PgMainVmUt : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public List<ModbusMapperClientView> PLCs { get; set; }
public PgMainVmUt()
{
PLCs = new List<ModbusMapperClientView>() {
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds( 623),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.1:502"
},
DRCnt = 130,
DRNeedUpdateCnt = 30,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(2623),
Client = new TcpClientView(){
IsConnected = false,
RemoteAddr = "127.168.50.2:502"
},
DRCnt = 45,
DRNeedUpdateCnt = 40,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(123),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.3:502"
},
DRCnt = 10,
DRNeedUpdateCnt = 3,
ErrorCnt = 0
}
};
}
}
public class ModbusMapperClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 实际更新间隔
/// </summary>
public TimeSpan ActUpdateInterval { get; set; }
public int ErrorCnt { get; set; }
public int DRNeedUpdateCnt { get; set; }
public int DRCnt { get; set; }
public TcpClientView Client { get; set; }
}
public class TcpClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string RemoteAddr { get; set; }
public bool IsConnected { get; set; }
}
}
......@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("称重服务器-单组分")]
[assembly: AssemblyCopyright("Copyright © 2021 FlyAutomation")]
[assembly: AssemblyCopyright("Copyright © 2022 FlyAutomation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.36.0")]
[assembly: AssemblyFileVersion("6.36.0")]
[assembly: AssemblyVersion("7.0.0.0")]
[assembly: AssemblyFileVersion("7.0.0.0")]
[assembly: Guid("36677B82-A2A3-4748-95E1-8033D55E4D39")]
<Window x:Class="FLY.Weight2.UI.Server.WdDRList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FLY.Weight2.UI.Server"
mc:Ignorable="d"
Title="DRList" Height="450" Width="800">
<Grid>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"/>
</Grid>
</Window>
using FLY.Modbus;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace FLY.Weight2.UI.Server
{
/// <summary>
/// DRList.xaml 的交互逻辑
public class DataToRegsView : INotifyPropertyChanged
{
public DataToRegs dr;
/// <summary>
/// 对应 PLC寄存器区 coil or register
/// </summary>
public PLCAddressArea DataArea { get; set; }
/// <summary>
/// PLC 首地址
/// </summary>
public int Addr { get; set; }
/// <summary>
/// object 的 property 名称, 只能是 数字类型都是double, 剩下就是 bool
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool
/// </summary>
public object Value { get; set; }
/// <summary>
/// 需要从PLC读取数据更新
/// </summary>
public bool IsNeedUpdate { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return PropertyName + " [" + ((int)DataArea).ToString() + "](" + Addr + ")";
}
}
/// </summary>
public partial class WdDRList : Window
{
ObservableCollection<DataToRegsView> dataToRegsViews = new ObservableCollection<DataToRegsView>();
Modbus.WithThread.ModbusMapper_Client plc;
public WdDRList()
{
InitializeComponent();
}
public void Init(Modbus.WithThread.ModbusMapper_Client plc)
{
this.plc = plc;
for (int i = 0; i < plc.DRmap.Count(); i++)
{
var dr = plc.DRmap[i];
//获取描述
var type = dr.owner.GetType();
var propertyInfo = type.GetProperty(dr.propertyName);
var attributes = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
string description = "";
if (attributes.Length > 0)
{
description = (attributes.First() as DescriptionAttribute).Description;
}
dataToRegsViews.Add(new DataToRegsView()
{
dr = dr,
Addr = dr.addr,
DataArea = dr.dataArea,
IsNeedUpdate = dr.isNeedUpdate,
PropertyName = dr.propertyName,
Description = description,
Value = dr.value
});
}
plc.PropertyChanged += Plc_PropertyChanged;
plc.NameDataChanged += Plc_NameDataChanged;
dataGrid.ItemsSource = dataToRegsViews;
}
private void Plc_NameDataChanged(object sender, DataToRegs dr)
{
var drViews = from _drView in dataToRegsViews
where _drView.dr == dr
select _drView;
if (drViews.Count() == 0)
return;
var drView = drViews.First();
drView.Value = dr.value;
}
private void Plc_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(plc.PlanUpdateTime))
{
for (int i = 0; i < plc.DRmap.Count(); i++)
{
var dr = plc.DRmap[i];
dataToRegsViews[i].IsNeedUpdate = dr.isNeedUpdate;
}
}
}
}
/// <summary>
/// 数据映射的类;
/// Data: PC 属性
/// Regs: PLC 对象(寄存器、线圈)
/// </summary>
}
......@@ -112,7 +112,7 @@ namespace FLY.Weight2.Client
for (int i = 0; i < Items.Count(); i++)
objnames2.Add($"{nameof(Items)}[{i}]", Items[i]);
PLCos = new PLCProxySystemServiceClient(mServerID + 2, objnames2);
PLCos = new PLCProxySystemServiceClient(mServerID + 2);
......@@ -212,7 +212,6 @@ namespace FLY.Weight2.Client
for (int i = last_itemcnt; i < Items.Count(); i++)
{
syncPropServiceClient.Add($"{nameof(Items)}[{i}]", Items[i]);
PLCos.ObjNames.Add($"{nameof(Items)}[{i}]", Items[i]);
}
}
else
......@@ -221,7 +220,6 @@ namespace FLY.Weight2.Client
for (int i = Items.Count(); i < last_itemcnt; i++)
{
syncPropServiceClient.Remove($"{nameof(Items)}[{i}]");
PLCos.ObjNames.Remove($"{nameof(Items)}[{i}]");
}
}
......
using FLY.OBJComponents.Server.OBJProxy;
using FLY.OBJComponents.IService;
using FLY.OBJComponents.Server.OBJProxy;
using FLY.Weight2.IService;
using FLY.Weight2.Server.Model;
using System;
......@@ -26,10 +27,10 @@ namespace FLY.Weight2.Server.OBJProxy
typeof(IBulkDbFlowService), gage.mHistoryDb.FlowBuffer);
var mWarnSystemOBJProxy = new WarningSystem_OBJProxy(
var mWarnSystemOBJProxy = new FObjBase.Reflect.Reflect_Proxy(
objsys_idx,
OBJ_INTERFACE.OBJ_INTERFACE.WARNING_OBJ_ID,
gage.mWarning);
typeof(IWarningSystem2Service), gage.mWarning);
weightSystemOBJProxy.CurrObjSys.Start_Conn_Server(
new IPEndPoint(IPAddress.Any, gage.mSysParam.OBJ_Port));
......
......@@ -29,9 +29,9 @@ namespace FLY.Weight2.Server.OBJProxy
//属性同步
Dictionary<string, INotifyPropertyChanged> objnames = new Dictionary<string, INotifyPropertyChanged>();
objnames.Add(".", data);
objnames.Add("Accessory", data.Accessory);
objnames.Add(nameof(data.Accessory), data.Accessory);
for (int i = 0; i < data.Items.Count(); i++)
objnames.Add($"Items[{i}]", data.Items[i]);
objnames.Add($"{nameof(data.Items)}[{i}]", data.Items[i]);
syncProp_OBJProxy = new SyncProp_OBJProxy(
objsys_idx, ID + 1, objnames);
......
......@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Weight2.Server
{
......@@ -25,7 +26,7 @@ namespace FLY.Weight2.Server
/// <summary>
/// 报警系统
/// </summary>
public WarningSystem mWarning;
public WarningSystem2 mWarning;
DbModel mDbModel;
#endregion
......@@ -49,27 +50,41 @@ namespace FLY.Weight2.Server
}
System.Environment.CurrentDirectory = mParamDirectory;
Init1();
mSysParam = new SysParam();
mData = new WeightSystem();
mDbModel = new DbModel();
mHistoryDb = new HistoryDb();
mWarning = new WarningSystem2();
}
/// <summary>
/// 第1步, 加载本地数据
/// </summary>
public void Init1()
public async Task Init()
{
mSysParam = new SysParam();
mData = new WeightSystem();
//---------------------------------------------------------------------------------------------------------------
//数据库
mDbModel = new DbModel();
mDbModel.Init();
mDbModel.KeepDBSize(mSysParam.DBKeepMonth);
mHistoryDb = new HistoryDb();
await Task.Factory.StartNew(() =>
{
//初始数据库(加载 MaxId)
mDbModel.Init();
//删除不需要的备份数据
mDbModel.KeepBackupSize(12);
//备份上一个月之前的数据到 yyyy-MM 文件夹
mDbModel.BackupBbInSize(12);
//当前的数据库只保存上个月与这个月的数据
mDbModel.KeepDBSize(1);
});
mHistoryDb.Init(mDbModel);
mWarning = new WarningSystem();
mWarning.Init(mHistoryDb.ErrorBuffer);
mData.Init(mHistoryDb, mWarning);
......
......@@ -46,7 +46,7 @@ namespace FLY.Weight2.Server
/// <summary>
/// 报警系统
/// </summary>
WarningSystem warning;
WarningSystem2 warning;
/// <summary>
/// 记录到数据库
/// </summary>
......@@ -73,7 +73,7 @@ namespace FLY.Weight2.Server
}
public void Init(HistoryDb historyDb, WarningSystem warning)
public void Init(HistoryDb historyDb, WarningSystem2 warning)
{
this.historyDb = historyDb;
this.warning = warning;
......
......@@ -19,6 +19,50 @@ namespace FLY.Winder.UI.Server
{
/// <summary>
/// DRList.xaml 的交互逻辑
public class DataToRegsView : INotifyPropertyChanged
{
public DataToRegs dr;
/// <summary>
/// 对应 PLC寄存器区 coil or register
/// </summary>
public PLCAddressArea DataArea { get; set; }
/// <summary>
/// PLC 首地址
/// </summary>
public int Addr { get; set; }
/// <summary>
/// object 的 property 名称, 只能是 数字类型都是double, 剩下就是 bool
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool
/// </summary>
public object Value { get; set; }
/// <summary>
/// 需要从PLC读取数据更新
/// </summary>
public bool IsNeedUpdate { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return PropertyName + " [" + ((int)DataArea).ToString() + "](" + Addr + ")";
}
}
/// </summary>
public partial class WdDRList : Window
{
......@@ -94,48 +138,4 @@ namespace FLY.Winder.UI.Server
/// Data: PC 属性
/// Regs: PLC 对象(寄存器、线圈)
/// </summary>
public class DataToRegsView : INotifyPropertyChanged
{
public DataToRegs dr;
/// <summary>
/// 对应 PLC寄存器区 coil or register
/// </summary>
public PLCAddressArea DataArea { get; set; }
/// <summary>
/// PLC 首地址
/// </summary>
public int Addr { get; set; }
/// <summary>
/// object 的 property 名称, 只能是 数字类型都是double, 剩下就是 bool
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// property 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// property 的值, 没有缩小. 只有 double 与 bool
/// </summary>
public object Value { get; set; }
/// <summary>
/// 需要从PLC读取数据更新
/// </summary>
public bool IsNeedUpdate { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return PropertyName + " [" + ((int)DataArea).ToString() + "](" + Addr + ")";
}
}
}
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