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

添加 称重单组分 添加 竖直排列的 主界面

parent 57b7ac39
...@@ -81,6 +81,9 @@ ...@@ -81,6 +81,9 @@
<Compile Include="UiModule\FlowGraph.xaml.cs"> <Compile Include="UiModule\FlowGraph.xaml.cs">
<DependentUpon>FlowGraph.xaml</DependentUpon> <DependentUpon>FlowGraph.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UiModule\MainGraph2.xaml.cs">
<DependentUpon>MainGraph2.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\MainGraph.xaml.cs"> <Compile Include="UiModule\MainGraph.xaml.cs">
<DependentUpon>MainGraph.xaml</DependentUpon> <DependentUpon>MainGraph.xaml</DependentUpon>
</Compile> </Compile>
...@@ -105,6 +108,9 @@ ...@@ -105,6 +108,9 @@
<Compile Include="UiModule\UcTotalFlow.xaml.cs"> <Compile Include="UiModule\UcTotalFlow.xaml.cs">
<DependentUpon>UcTotalFlow.xaml</DependentUpon> <DependentUpon>UcTotalFlow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UiModule\UcWeighterItem2.xaml.cs">
<DependentUpon>UcWeighterItem2.xaml</DependentUpon>
</Compile>
<Compile Include="UiModule\UcWeighterItem.xaml.cs"> <Compile Include="UiModule\UcWeighterItem.xaml.cs">
<DependentUpon>UcWeighterItem.xaml</DependentUpon> <DependentUpon>UcWeighterItem.xaml</DependentUpon>
</Compile> </Compile>
...@@ -148,6 +154,10 @@ ...@@ -148,6 +154,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UiModule\MainGraph2.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\MainGraph.xaml"> <Page Include="UiModule\MainGraph.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -180,6 +190,10 @@ ...@@ -180,6 +190,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UiModule\UcWeighterItem2.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UiModule\UcWeighterItem.xaml"> <Page Include="UiModule\UcWeighterItem.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
......
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.MainGraph2"
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.Client.UiModule"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Viewbox Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Left">
<Grid Name="root_grid" d:DataContext="{StaticResource unittests_weighters}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<local:UcTotalFlow x:Name="ucTotalFlow" Margin="5" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<local:UcThickness x:Name="ucThickness" Margin="5"/>
<ItemsControl x:Name="itemsControl" Grid.Column="1" ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:UcWeighterItem2 Margin="5" WeightSystemService="{Binding DataContext,ElementName=root_grid}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</Viewbox>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.Common;
using FLY.Weight2.IService;
using MultiLayout;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Globalization;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// Page_Main.xaml 的交互逻辑
/// </summary>
public partial class MainGraph2 : UserControl
{
IWeightSystemService weightSystemService;
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
public MainGraph2()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IWeightSystemService weightSystemService)
{
ucTotalFlow.Init(weightSystemService);
ucThickness.Init(weightSystemService);
this.weightSystemService = weightSystemService;
root_grid.DataContext = this.weightSystemService;
for (int i = 0; i < this.weightSystemService.Items.Count(); i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.weightSystemService.PLCos,
this.weightSystemService.Items[i],
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
if (weightSystemService is WeightSystemServiceClient) {
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
}
}
private void MWeighterCsService_ResetItemsEvent()
{
//把多出来的删除
int remove_cnt = setPlan_items.Count() - weightSystemService.Items.Count();
if (remove_cnt > 0)
{
for (int i = 0; i < remove_cnt; i++)
{
SetPLCUpdatePlan plan = setPlan_items[setPlan_items.Count() - 1 - i];
plan.Dispose();
}
setPlan_items.RemoveRange(setPlan_items.Count() - remove_cnt, remove_cnt);
}
else
{
int start_idx = setPlan_items.Count();
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
weightSystemService.PLCos,
weightSystemService.Items[start_idx+i],
UcWeighterItem.item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
}
public class UiModule2_MainGraph2 : IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "称重单主界(5)";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => true;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
MainGraph2 graph = new MainGraph2();
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)
{
}
}
}
<UserControl x:Class="FLY.Weight2.UI.Client.UiModule.UcWeighterItem2"
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.Client.UiModule"
xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="600" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.Weight2.UI.Client;component/Themes/UcWeighterItemStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Style="{StaticResource BorderStyle_block}" d:DataContext="{StaticResource unittests_weighters}">
<Viewbox Margin="{StaticResource ControlMargin}" d:DataContext="{Binding Items[4]}" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel >
<Border Background="{Binding Color}" Margin="2">
<StackPanel>
<TextBlock Width="100" Height="100" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-20,0,0,0"
FontSize="100" FontWeight="Bold" FontFamily="Arial Black" TextAlignment="Right"
Foreground="{StaticResource Color_background}"
Text="{Binding Number}" >
<TextBlock.Clip>
<RectangleGeometry Rect="20,0,80,100"/>
</TextBlock.Clip>
</TextBlock>
<StackPanel Margin="10" Grid.Column="1" >
<StackPanel >
<TextBlock Text="设定产量" Style="{StaticResource TextBlockStyle_title}" Foreground="{StaticResource Color_background}" Margin="3,0" />
<!--<TextBlock Visibility="{Binding ScrewIsAutoMode,Converter={StaticResource visbilityconv}}">-->
<TextBlock >
<Run Text="{Binding CurrentFlowAuto,StringFormat={}{0:F1}}" Foreground="{StaticResource Color_background}" Style="{StaticResource RunStyle_text}" FontSize="30" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" Foreground="{StaticResource Color_background}"/>
</TextBlock>
</StackPanel>
<TextBlock Text="当前产量" Style="{StaticResource TextBlockStyle_title}" Margin="3,0" />
<Viewbox Width="180" Height="80" HorizontalAlignment="Left">
<TextBlock >
<Run Text="{Binding CurrentFlow,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="60" />
<Run Text="kg/h" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</Viewbox>
</StackPanel>
</StackPanel>
</Border>
<Border x:Name="border_p" Background="{StaticResource Color_background2}" Height="30" Margin="2">
<Rectangle HorizontalAlignment="Left" Fill="{Binding Color}">
<Rectangle.Width>
<MultiBinding Converter="{StaticResource ratioconv}" Mode="OneWay">
<Binding Path="ScrewPDisp" />
<Binding Source="{StaticResource d100}" />
<Binding Path="ActualWidth" ElementName="border_p"/>
</MultiBinding>
</Rectangle.Width>
</Rectangle>
</Border>
<Button Grid.Row="1" Grid.Column="1" Margin="3" Style="{StaticResource ButtonStyle_empty}" Click="button_ratio_Click" Tag="{Binding .}">
<StackPanel>
<StackPanel Margin="3">
<TextBlock Text="当前比例" Style="{StaticResource TextBlockStyle_title}"/>
<TextBlock>
<Run Text="{Binding ScrewPDisp,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text}" FontSize="60" />
<Run Text="%" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="3" >
<TextBlock Text="设置比例" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding ScrewPDispAuto,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text_activity}"/>
<Run Text="%" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</StackPanel>
</Button>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
</Grid>
<StackPanel>
<StackPanel Margin="3" Grid.Row="2" >
<TextBlock Text="当前重量" Style="{StaticResource TextBlockStyle_title}"/>
<TextBlock >
<Run Text="{Binding BinWeight,StringFormat={}{0:F3}}" Style="{StaticResource RunStyle_text}" />
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="1" >
<StackPanel Margin="3" Grid.Row="4" VerticalAlignment="Center" >
<TextBlock Text="螺杆操作" Style="{StaticResource TextBlockStyle_title_activity}"/>
<flyctrl:NoToggleButton
HorizontalAlignment="Left"
IsChecked="{Binding ScrewMotorIsOn}"
OffLabel="关闭" OffBrush="{StaticResource Color_off}"
OnLabel="启动" OnBrush="{StaticResource Color_on}"
>
<i:Interaction.Behaviors>
<flyctrl:ResetBehavior Binding="{Binding ScrewMotorOnSet}"/>
</i:Interaction.Behaviors>
</flyctrl:NoToggleButton>
</StackPanel>
<!--<StackPanel Margin="3" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Visibility="{Binding IsChecked,Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=Hidden, ElementName=togglebutton_screw}">-->
<StackPanel Margin="3" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" >
<TextBlock Text="螺杆模式" Style="{StaticResource TextBlockStyle_title_activity}"/>
<flyctrl:ToggleButtonOnOff
HorizontalAlignment="Left"
IsChecked="{Binding ScrewIsAutoMode}"
OffLabel="手动" OffBrush="{StaticResource Color_off}"
OnLabel="自动" OnBrush="{StaticResource Color_on}"/>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="3" >
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="button_frequency_Click"
Tag="{Binding .}"
>
<StackPanel Margin="3" >
<TextBlock Text="电机频率" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding ScrewMotorFreq,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text_activity}" />
<Run Text="Hz" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
</Grid>
</StackPanel>
</Viewbox>
</Border>
</UserControl>
using FLY.OBJComponents.Client;
using FLY.Weight2.Client;
using FLY.Weight2.IService;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
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;
using Unity;
namespace FLY.Weight2.UI.Client.UiModule
{
/// <summary>
/// UcWeighterItem.xaml 的交互逻辑
/// </summary>
public partial class UcWeighterItem2 : UserControl
{
public IWeightSystemService WeightSystemService
{
get { return (IWeightSystemService)GetValue(WeightSystemServiceProperty); }
set { SetValue(WeightSystemServiceProperty, value); }
}
// Using a DependencyProperty as the backing store for WeightSystemService. This enables animation, styling, binding, etc...
public static readonly DependencyProperty WeightSystemServiceProperty =
DependencyProperty.Register("WeightSystemService", typeof(IWeightSystemService), typeof(UcWeighterItem2), new PropertyMetadata(null));
List<SetPLCUpdatePlan> setPlan_items = new List<SetPLCUpdatePlan>();
int Index = 0;
public UcWeighterItem2()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
int id,
IWeightSystemService weightSystemService)
{
this.WeightSystemService = weightSystemService;
//查找参数
if (WeighterItemParams.Current.Indexs.ContainsKey(id))
{
Index = WeighterItemParams.Current.Indexs[id];
}
else
{
for (int i = 0; i < this.WeightSystemService.Items.Count(); i++)
{
if (!WeighterItemParams.Current.Indexs.ContainsValue(i))
{
WeighterItemParams.Current.Indexs.Add(id, i);
Index = i;
break;
}
}
}
int idx = Index;
if (idx >= this.WeightSystemService.Items.Count())
idx = this.WeightSystemService.Items.Count() - 1;
else if (idx < 0)
idx = 0;
this.DataContext = this.WeightSystemService.Items[idx];
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[idx],
item_update_propertynames);
setPlan_items.Add(plan);
}
public static string[] item_update_propertynames = new string[] {
nameof(Common.WeighterC.CurrentFlow),
nameof(Common.WeighterC.ScrewPDisp),
nameof(Common.WeighterC.CurrentFlowAuto),
nameof(Common.WeighterC.ScrewPDispAuto),
nameof(Common.WeighterC.BinWeight),
nameof(Common.WeighterC.ScrewMotorFreq),
nameof(Common.WeighterC.ScrewManualFreq),
nameof(Common.WeighterC.ScrewManualFreqIsSet),
nameof(Common.WeighterC.ScrewIsAutoMode),
nameof(Common.WeighterC.ScrewMotorIsOn),
nameof(Common.WeighterC.ScrewMotorOnSet)
};
private async void button_frequency_Click(object sender, RoutedEventArgs e)
{
WdFrequency w = new WdFrequency();
var weight = ((Button)sender).Tag as FLY.Weight2.Common.WeighterC;
w.FrequencySet = weight.ScrewManualFreq;
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
//TODO
weight.ScrewManualFreq = (float)w.FrequencySet;
weight.ScrewManualFreqIsSet = true;
//不用写下降沿!!!!!
}
}
private void button_ratio_Click(object sender, RoutedEventArgs e)
{
WdRatioSet w = new WdRatioSet();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.Init(WeightSystemService);
w.ShowDialog();
}
}
public class UiModule2_UcWeighterItem2 : MultiLayout.UiModule.IUiModule2
{
/// <summary>
/// 控件标题
/// 它的值取决于culture
/// </summary>
public string Title => "单组份称重层控制(5)";
public ComponentType Type => ComponentType.Graph;
public bool IsUnique => false;
/// <summary>
/// 控件
/// 创建时,需要给它唯一ID,让加载自己的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FrameworkElement GetComponent(int id, IUnityContainer container)
{
UcWeighterItem2 graph = new UcWeighterItem2();
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)
{
}
}
}
...@@ -413,7 +413,7 @@ ...@@ -413,7 +413,7 @@
{ {
"DeviceIndex": 0, "DeviceIndex": 0,
"Mode": "4", "Mode": "4",
"Addr": 1204, "Addr": 1206,
"Type": "uint16", "Type": "uint16",
"Scale": 0.1, "Scale": 0.1,
"OwnerName": "Items[0]", "OwnerName": "Items[0]",
......
...@@ -683,7 +683,7 @@ ...@@ -683,7 +683,7 @@
{ {
"DeviceIndex": 0, "DeviceIndex": 0,
"Mode": "4", "Mode": "4",
"Addr": 1204, "Addr": 1206,
"Type": "uint16", "Type": "uint16",
"Scale": 0.1, "Scale": 0.1,
"OwnerName": "Items[0]", "OwnerName": "Items[0]",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
<register type="IUiModule2" mapTo="UiModule2_DynAreaWeight" name="weighter2_da" /> <register type="IUiModule2" mapTo="UiModule2_DynAreaWeight" name="weighter2_da" />
<register type="IUiModule2" mapTo="UiModule2_FlowGraph" name="weighter2_fg" /> <register type="IUiModule2" mapTo="UiModule2_FlowGraph" name="weighter2_fg" />
<register type="IUiModule2" mapTo="UiModule2_MainGraph" name="weighter2_mg" /> <register type="IUiModule2" mapTo="UiModule2_MainGraph" name="weighter2_mg" />
<register type="IUiModule2" mapTo="UiModule2_MainGraph2" name="weighter2_mg2" />
</container> </container>
</unity> </unity>
</configuration> </configuration>
\ No newline at end of file
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