This commit is contained in:
tfarcraw 2026-08-07 12:38:01 +08:00
parent 86f6b6fdaa
commit 4d0753eb32
11 changed files with 535 additions and 277 deletions

View File

@ -10,11 +10,11 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<!--自定义样式类-->
<ResourceDictionary Source="Styles.xaml"/>
<!--加载语言(默认英文)-->
<!-- 自定义样式类 -->
<ResourceDictionary Source="Styles.xaml" />
<!-- 加载语言(默认英文) -->
<!--<ResourceDictionary Source="./Language/zh-cn.xaml"/>-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@ -1,32 +1,54 @@
<mah:MetroWindow xmlns:Vision="clr-namespace:Views.Vision;assembly=Views" x:Class="FeiYu.MainWindow"
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:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:MyNamespace="clr-namespace:Views;assembly=Views"
xmlns:Motion="clr-namespace:Views.Motion;assembly=Views"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="{Binding SystemPar.MachineName}" Name="mywd" Height="1080" Width="1920" WindowStartupLocation="CenterScreen" Icon="Resources/logo1.ico" WindowState="Maximized" Closing="MetroWindow_Closing" >
<mah:MetroWindow xmlns:Vision="clr-namespace:Views.Vision;assembly=Views"
x:Class="FeiYu.MainWindow"
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:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:MyNamespace="clr-namespace:Views;assembly=Views"
xmlns:Motion="clr-namespace:Views.Motion;assembly=Views"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="{Binding SystemPar.MachineName}"
Name="mywd"
Height="1080" Width="1920"
WindowStartupLocation="CenterScreen"
Icon="Resources/logo1.ico"
WindowState="Maximized"
Closing="MetroWindow_Closing">
<mah:MetroWindow.Background>
<!--<ImageBrush ImageSource="Resources/3.jpg"/>-->
<ImageBrush ImageSource="{Binding SystemPar.SystemBackgroundPath}"/>
<ImageBrush ImageSource="{Binding SystemPar.SystemBackgroundPath}" />
</mah:MetroWindow.Background>
<!--FontFamily="方正宋一繁体"-->
<!-- FontFamily="方正宋一繁体" -->
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<!--<CheckBox Content="空跑模式" IsChecked="{Binding RunningMode}"></CheckBox>-->
<Label Content="当前机种:" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"></Label>
<Label Content="{Binding CurrentMachine.MachineName}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"></Label>
<Button Content="切换主题" Click="SubjectSwitch" ></Button>
<Button Content="切换背景" Click="BackgroundSwitch" ></Button>
<Label Content="当前机种:" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White">
</Label>
<Label Content="{Binding CurrentMachine.MachineName}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White">
</Label>
<Button Content="切换主题" Click="SubjectSwitch">
</Button>
<Button Content="切换背景" Click="BackgroundSwitch">
</Button>
<Menu Background="{x:Null}">
<MenuItem Header="帮助" FontFamily="楷体" Background="{x:Null}" Foreground="White">
<!--<MenuItem Header="用户登入" Name="SwitchUser" Background="AliceBlue" Foreground="Black" Click="SwitchUser_Click"></MenuItem>-->
<MenuItem Name="menSystemSet" Header="{Binding PermissionButtonName}" Click="menSystemSet_Click" Background="AliceBlue" Foreground="Black"/>
<MenuItem Name="menPwdAlter" Header="修改密码" Click="menPwdAlter_Click" Background="AliceBlue" Foreground="Black"/>
<MenuItem Header="生产数据清零" Background="AliceBlue" Foreground="Black" Visibility="{Binding AllVis}" Command="{Binding CountClearedCommand}"/>
<MenuItem Name="menSystemSet"
Header="{Binding PermissionButtonName}"
Click="menSystemSet_Click"
Background="AliceBlue"
Foreground="Black" />
<MenuItem Name="menPwdAlter"
Header="修改密码" Click="menPwdAlter_Click"
Background="AliceBlue"
Foreground="Black" />
<MenuItem Header="生产数据清零" Background="AliceBlue"
Foreground="Black"
Visibility="{Binding AllVis}"
Command="{Binding CountClearedCommand}" />
<!--<CheckBox Content="启用MES" Background="AliceBlue" IsChecked="{Binding ERPVM.ERP.Enableing}" FontFamily="楷体" Visibility="{Binding AllVis}"></CheckBox>-->
<!--<CheckBox Content="手动上传" Background="AliceBlue" IsChecked="{Binding CurrentMachine.MyPar.CheckUpload}" FontFamily="楷体" Visibility="{Binding AllVis}"></CheckBox>-->
<!--<CheckBox Content="空跑模式" Background="AliceBlue" IsChecked="{Binding CurrentMachine.RunningMode}" FontFamily="楷体" Visibility="{Binding AllVis}"></CheckBox>-->
@ -42,11 +64,13 @@
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*"></ColumnDefinition>
<ColumnDefinition Width="70*">
</ColumnDefinition>
<!--<ColumnDefinition Width="1"></ColumnDefinition >-->
<!--<ColumnDefinition Width="{Binding GridWidth}"></ColumnDefinition>-->
</Grid.ColumnDefinitions>
<TabControl Background="Transparent" ItemsSource="{Binding TabItemList}" SelectedItem="{Binding SelectTabItem}" SelectedIndex="{Binding SelectedIndex}"></TabControl>
<TabControl Background="Transparent" ItemsSource="{Binding TabItemList}" SelectedItem="{Binding SelectTabItem}" SelectedIndex="{Binding SelectedIndex}">
</TabControl>
<!--<GridSplitter Grid.Column="1" Background="Transparent"></GridSplitter>-->
<!--<Border Grid.Column="2">
<MyNamespace:ControlPanel />

View File

@ -1,44 +1,46 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FeiYu">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:FeiYu">
<!--程序自带字体-->
<FontFamily x:Key="ziti1" >../Resources/#方正宋一繁体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti2" >../Resources/#苹果丽黑w36,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti3" >../Resources/#微软繁宋体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti4" >../Resources/#宋体-粗体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti5" >../Resources/#行楷体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<!-- 基础圆形样式 -->
<!-- 程序自带字体 -->
<FontFamily x:Key="ziti1">../Resources/#方正宋一繁体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti2">../Resources/#苹果丽黑w36,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti3">../Resources/#微软繁宋体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti4">../Resources/#宋体-粗体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<FontFamily x:Key="ziti5">../Resources/#行楷体,Segoe UI,Lucida Sans Unicode,Verdana</FontFamily>
<!-- 基础圆形样式 -->
<Style x:Key="LightCircle" TargetType="Ellipse">
<Setter Property="Width" Value="60"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Stroke" Value="White"/>
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="Width" Value="60" />
<Setter Property="Height" Value="60" />
<Setter Property="Stroke" Value="White" />
<Setter Property="StrokeThickness" Value="1" />
</Style>
<!-- Fill Brushes -->
<!-- Fill Brushes -->
<LinearGradientBrush x:Key="WindowBrush" StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#ecf5fc" Offset="0.0"/>
<GradientStop Color="#92cbf8" Offset="1.0"/>
<GradientStop Color="#ecf5fc" Offset="0.0" />
<GradientStop Color="#92cbf8" Offset="1.0" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
<!--输入信号Label样式-->
<!-- 输入信号Label样式 -->
<Style x:Key="LabelStyle" TargetType="{x:Type Label}">
<Setter Property="Content" Value="Black"/>
<Setter Property="Content" Value="Black" />
<Setter Property="Template">
<Setter.Value>
<!--设置样式 -->
<!-- 设置样式 -->
<ControlTemplate TargetType="{x:Type Label}">
<Grid>
<!--设置背景透明度-->
<Rectangle x:Name="Rectangle" Fill="{TemplateBinding Background}" Opacity="0.8"></Rectangle>
<!--显示原有文字内容-->
<ContentPresenter x:Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
<!-- 设置背景透明度 -->
<Rectangle x:Name="Rectangle" Fill="{TemplateBinding Background}" Opacity="0.8">
</Rectangle>
<!-- 显示原有文字内容 -->
<ContentPresenter x:Name="ContentPresenter"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True" />
</Grid>
</ControlTemplate>
</Setter.Value>
@ -46,15 +48,15 @@
</Style>
<!--定义按钮样式-->
<Style x:Key="RoundedButton" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="Black"/>
<!--修改模板属性-->
<!-- 定义按钮样式 -->
<Style x:Key="RoundedButton" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="Black" />
<!-- 修改模板属性 -->
<Setter Property="Template">
<Setter.Value>
<!--控件模板-->
<!-- 控件模板 -->
<ControlTemplate TargetType="Button">
<!--背景色-->
<!-- 背景色 -->
<Border x:Name="back" Opacity="0.8" CornerRadius="3">
<Border.BitmapEffect>
<OuterGlowBitmapEffect Opacity="0.7" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" />
@ -63,43 +65,53 @@
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0"/>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4"/>
<GradientStop Color="#FFF" Offset="1"/>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0" />
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4" />
<GradientStop Color="#FFF" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<!--前景色及边框-->
<!-- 前景色及边框 -->
<Border x:Name="fore" BorderThickness="2" CornerRadius="3" BorderBrush="#5555">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#6FFF" Offset="0.5"/>
<GradientStop Color="#1111" Offset="0.51"/>
<GradientStop Color="#6FFF" Offset="0.5" />
<GradientStop Color="#1111" Offset="0.51" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<!--按钮内容-->
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}">
<!-- 按钮内容 -->
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}">
<ContentPresenter.BitmapEffect>
<DropShadowBitmapEffect Color="#000" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" />
<DropShadowBitmapEffect Color="#000"
Direction="-90" ShadowDepth="2"
Softness="0.1" Opacity="0.3" />
</ContentPresenter.BitmapEffect>
</ContentPresenter>
</Border>
</Border>
<!--触发器-->
<!-- 触发器 -->
<ControlTemplate.Triggers>
<!--鼠标移入移出-->
<!-- 鼠标移入移出 -->
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="6" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />
<ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />
<ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />
<ColorAnimation To="#AFFF"
BeginTime="0:0:0.2"
Duration="0:0:0.2"
Storyboard.TargetName="fore"
Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />
<ColorAnimation To="#3FFF"
BeginTime="0:0:0.2"
Duration="0:0:0.2"
Storyboard.TargetName="fore"
Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
@ -113,7 +125,7 @@
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!--按钮按下弹起-->
<!-- 按钮按下弹起 -->
<Trigger Property="IsPressed" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
@ -134,9 +146,9 @@
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!--按钮失效-->
<!-- 按钮失效 -->
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#B444"/>
<Setter Property="Foreground" Value="#B444" />
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
@ -170,41 +182,52 @@
</Setter>
</Style>
<!--自定义checkBox控件-->
<!-- 自定义checkBox控件 -->
<Style x:Key="CheckBoxStyle" TargetType="{x:Type CheckBox}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="False" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisual}" />
<Setter Property="Height" Value="25"/>
<Setter Property="IsChecked" Value="False"/>
<Setter Property="Margin" Value="0,20"/>
<Setter Property="Height" Value="25" />
<Setter Property="IsChecked" Value="False" />
<Setter Property="Margin" Value="0,20" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Height}">
<Rectangle x:Name="CheckBoxRectangle" Fill="{TemplateBinding Background}" Opacity="1" RadiusY="5" RadiusX="5"/>
<Rectangle x:Name="CheckBoxRectangleOut" Stroke="#FF06DAD1" StrokeThickness="1" RadiusY="5" RadiusX="5"/>
<Rectangle x:Name="CheckBoxRectangle"
Fill="{TemplateBinding Background}"
Opacity="1" RadiusY="5" RadiusX="5" />
<Rectangle x:Name="CheckBoxRectangleOut"
Stroke="#FF06DAD1" StrokeThickness="1"
RadiusY="5" RadiusX="5" />
<Grid x:Name="CheckedMark" Width="20" Height="20" Visibility="Collapsed">
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M1,9 L10,17" Stroke="White"/>
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M8,17 L20,4" Stroke="White"/>
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M1,9 L10,17" Stroke="White" />
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M8,17 L20,4" Stroke="White" />
</Grid>
</Grid>
<TextBlock Grid.Column="1" Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBlock Grid.Column="1"
Text="{TemplateBinding Content}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
VerticalAlignment="Center"
Margin="10,0,0,0" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
<Setter TargetName="CheckedMark" Property="Visibility" Value="Visible">
</Setter>
<!--<Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#FF00A8E0"></Setter> -->
<!--Value="#FF00A8E0"-->
<!-- Value="#FF00A8E0" -->
<!--
<Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1"></Setter>-->
<Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent"></Setter>
<Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent">
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -216,31 +239,42 @@
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="False" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource CheckBoxFocusVisual}" />
<Setter Property="Height" Value="25"/>
<Setter Property="IsChecked" Value="False"/>
<Setter Property="Margin" Value="1"/>
<Setter Property="Height" Value="25" />
<Setter Property="IsChecked" Value="False" />
<Setter Property="Margin" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Height="{TemplateBinding Height}" Width="{TemplateBinding Height}">
<Rectangle x:Name="CheckBoxRectangle" Fill="{TemplateBinding Background}" Opacity="1" RadiusY="5" RadiusX="5"/>
<Rectangle x:Name="CheckBoxRectangleOut" Stroke="#FF06DAD1" StrokeThickness="1" RadiusY="5" RadiusX="5"/>
<Rectangle x:Name="CheckBoxRectangle"
Fill="{TemplateBinding Background}"
Opacity="1" RadiusY="5" RadiusX="5" />
<Rectangle x:Name="CheckBoxRectangleOut"
Stroke="#FF06DAD1" StrokeThickness="1"
RadiusY="5" RadiusX="5" />
<Grid x:Name="CheckedMark" Width="20" Height="20" Visibility="Collapsed">
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M1,9 L10,17" Stroke="{TemplateBinding BorderBrush}"/>
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M8,17 L20,4" Stroke="{TemplateBinding BorderBrush}"/>
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M1,9 L10,17" Stroke="{TemplateBinding BorderBrush}" />
<Path SnapsToDevicePixels="False" StrokeThickness="3" Data="M8,17 L20,4" Stroke="{TemplateBinding BorderBrush}" />
</Grid>
</Grid>
<TextBlock Grid.Column="1" Text="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" Margin="10,0,0,0"/>
<TextBlock Grid.Column="1"
Text="{TemplateBinding Content}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
VerticalAlignment="Center"
Margin="10,0,0,0" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="CheckedMark" Property="Visibility" Value="Visible"></Setter>
<Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent"></Setter>
<Setter TargetName="CheckedMark" Property="Visibility" Value="Visible">
</Setter>
<Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent">
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -248,30 +282,31 @@
</Setter>
</Style>
<!--*************************************************************************datagrid样式1********************************************************************************************-->
<!-- *************************************************************************datagrid样式1******************************************************************************************** -->
<Style TargetType="DataGrid">
<!--网格线颜色-->
<Setter Property="CanUserResizeColumns" Value="false"/>
<!-- 网格线颜色 -->
<Setter Property="CanUserResizeColumns" Value="false" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="#FF9BBED6" />
<Setter Property="HorizontalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#FF7FAABD"/>
<SolidColorBrush Color="#FF7FAABD" />
</Setter.Value>
</Setter>
<Setter Property="VerticalGridLinesBrush">
<Setter.Value>
<SolidColorBrush Color="#FF7FAABD"/>
<SolidColorBrush Color="#FF7FAABD" />
</Setter.Value>
</Setter>
<Setter Property="AlternatingRowBackground" Value="AliceBlue"></Setter>
<Setter Property="AlternatingRowBackground" Value="AliceBlue">
</Setter>
</Style>
<!--Datagrid标题栏样式-->
<!-- Datagrid标题栏样式 -->
<Style TargetType="DataGridColumnHeader">
<!--标题居中-->
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<!-- 标题居中 -->
<Setter Property="HorizontalContentAlignment" Value="Center" />
<!--<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="MinHeight" Value="28" />
@ -281,18 +316,18 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1"
BorderBrush="#FF7FAABD"
<Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1"
BorderBrush="#FF7FAABD"
Width="Auto">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter Margin="0,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Grid.Column="2" Width="8" Height="6" Fill="White" Margin="0,0,50,0"
<Path x:Name="SortArrow" Visibility="Collapsed" Data="M0,0 L1,0 0.5,1 z" Stretch="Fill" Grid.Column="2" Width="8" Height="6" Fill="White" Margin="0,0,50,0"
VerticalAlignment="Center" RenderTransformOrigin="1,1" />
<Rectangle Width="1" Fill="#FF9BBED6" HorizontalAlignment="Right" Grid.ColumnSpan="1" />
</Grid>
</Border>
</ControlTemplate>
@ -301,37 +336,49 @@
</Style>
<!--*************************************************************************datagrid样式1********************************************************************************************-->
<!-- *************************************************************************datagrid样式1******************************************************************************************** -->
<!--*************************************************************************datagrid样式2********************************************************************************************-->
<!-- *************************************************************************datagrid样式2******************************************************************************************** -->
<Style x:Key="DataGridStyle" TargetType="{x:Type DataGrid}">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Background" Value="Transparent">
</Setter>
<Setter Property="BorderBrush" Value="#FF9BBED6" />
<Setter Property="AlternatingRowBackground" Value="AliceBlue"></Setter>
<Setter Property="HorizontalGridLinesBrush" Value="#FF7FAABD"></Setter>
<Setter Property="VerticalGridLinesBrush" Value="#FF7FAABD"></Setter>
<!--不显示最左边的白框-->
<Setter Property="HeadersVisibility" Value="Column"></Setter>
<!--不显示边框-->
<Setter Property="BorderThickness" Value="0"></Setter>
<!--不自动生成列-->
<Setter Property="AutoGenerateColumns" Value="False"></Setter>
<!--不自动生成行-->
<Setter Property="CanUserAddRows" Value="False"></Setter>
<Setter Property="Margin" Value="0"></Setter>
<Setter Property="SelectionMode" Value="Single"></Setter>
<Setter Property="AlternatingRowBackground" Value="AliceBlue">
</Setter>
<Setter Property="HorizontalGridLinesBrush" Value="#FF7FAABD">
</Setter>
<Setter Property="VerticalGridLinesBrush" Value="#FF7FAABD">
</Setter>
<!-- 不显示最左边的白框 -->
<Setter Property="HeadersVisibility" Value="Column">
</Setter>
<!-- 不显示边框 -->
<Setter Property="BorderThickness" Value="0">
</Setter>
<!-- 不自动生成列 -->
<Setter Property="AutoGenerateColumns" Value="False">
</Setter>
<!-- 不自动生成行 -->
<Setter Property="CanUserAddRows" Value="False">
</Setter>
<Setter Property="Margin" Value="0">
</Setter>
<Setter Property="SelectionMode" Value="Single">
</Setter>
</Style>
<!--行样式-->
<!-- 行样式 -->
<Style x:Key="DataGridRowStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
</Style>
<!--标题样式-->
<!-- 标题样式 -->
<Style x:Key="DataGridHadeStyle" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="Height" Value="20"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center">
</Setter>
<Setter Property="Height" Value="20">
</Setter>
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
@ -339,22 +386,22 @@
<Setter Property="BorderBrush" Value="AliceBlue" />
</Style>
<!--DataGrid的行样式居中显示-->
<!-- DataGrid的行样式居中显示 -->
<Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<!--*************************************************************************datagrid样式2********************************************************************************************-->
<!-- *************************************************************************datagrid样式2******************************************************************************************** -->
<!--透明按钮2-->
<!-- 透明按钮2 -->
<Style x:Key="commBtn" TargetType="Button">
<Setter Property="Foreground" Value="White"/>
<!--修改模板属性-->
<Setter Property="Foreground" Value="White" />
<!-- 修改模板属性 -->
<Setter Property="Template">
<Setter.Value>
<!--控件模板-->
<!-- 控件模板 -->
<ControlTemplate TargetType="Button">
<!--背景色-->
<!-- 背景色 -->
<Border x:Name="back" Opacity="1" CornerRadius="3">
<Border.BitmapEffect>
<OuterGlowBitmapEffect Opacity="0.7" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" />
@ -363,29 +410,29 @@
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1.5" Opacity="0.5">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0"/>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4"/>
<GradientStop Color="#FFF" Offset="1"/>
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0" />
<GradientStop Color="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" Offset="0.4" />
<GradientStop Color="#FFF" Offset="1" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<!--前景色及边框-->
<!-- 前景色及边框 -->
<Border x:Name="fore" BorderThickness="1" CornerRadius="3" BorderBrush="#5555">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#6FFF" Offset="0.1"/>
<GradientStop Color="#1111" Offset="0.9"/>
<GradientStop Color="#6FFF" Offset="0.1" />
<GradientStop Color="#1111" Offset="0.9" />
</GradientStopCollection>
</GradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<!--按钮内容-->
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}">
<!-- 按钮内容 -->
<ContentPresenter x:Name="content" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}">
<ContentPresenter.BitmapEffect>
<!--文字阴影效果-->
<!-- 文字阴影效果 -->
<!--<DropShadowBitmapEffect Color="White" Direction="-90" ShadowDepth="2" Softness="0.1" Opacity="0.3" />-->
<OuterGlowBitmapEffect Opacity="0.7" GlowSize="0" GlowColor="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Button.Background).(SolidColorBrush.Color)}" />
</ContentPresenter.BitmapEffect>
@ -393,16 +440,24 @@
</Border>
</Border>
<!--触发器-->
<!-- 触发器 -->
<ControlTemplate.Triggers>
<!--鼠标移入移出-->
<!-- 鼠标移入移出 -->
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="6" Duration="0:0:0.2" Storyboard.TargetName="back" Storyboard.TargetProperty="(Border.BitmapEffect).(OuterGlowBitmapEffect.GlowSize)" />
<ColorAnimation To="#AFFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />
<ColorAnimation To="#3FFF" BeginTime="0:0:0.2" Duration="0:0:0.2" Storyboard.TargetName="fore" Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />
<ColorAnimation To="#AFFF"
BeginTime="0:0:0.2"
Duration="0:0:0.2"
Storyboard.TargetName="fore"
Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[0].(GradientStop.Color)" />
<ColorAnimation To="#3FFF"
BeginTime="0:0:0.2"
Duration="0:0:0.2"
Storyboard.TargetName="fore"
Storyboard.TargetProperty="(Border.Background).(LinearGradientBrush.GradientStops)[1].(GradientStop.Color)" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
@ -416,7 +471,7 @@
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!--按钮按下弹起-->
<!-- 按钮按下弹起 -->
<Trigger Property="IsPressed" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
@ -437,9 +492,9 @@
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!--按钮失效-->
<!-- 按钮失效 -->
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#B444"/>
<Setter Property="Foreground" Value="#B444" />
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
@ -475,8 +530,8 @@
</Setter>
</Style>
<!--按钮样式1-->
<Style x:Key="styleButton" TargetType="Button">
<!-- 按钮样式1 -->
<Style x:Key="styleButton" TargetType="Button">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
@ -484,7 +539,11 @@
<Setter.Value>
<ControlTemplate>
<Border>
<Rectangle Margin="4" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
<Rectangle Margin="4"
SnapsToDevicePixels="True"
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
StrokeThickness="1"
StrokeDashArray="1 2" />
</Border>
</ControlTemplate>
</Setter.Value>
@ -492,18 +551,29 @@
</Style>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderBrush" Value="#00000000"/>
<Setter Property="BorderThickness" Value="3"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="0,0,1,1"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="BorderBrush" Value="#00000000" />
<Setter Property="BorderThickness" Value="3" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="0,0,1,1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="ContentContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="3" CornerRadius="5" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<Border x:Name="ContentContainer"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="3" CornerRadius="5"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
@ -511,14 +581,15 @@
</Setter>
</Style>
<!--字体随控件大小变化的label自定义控件-->
<!-- 字体随控件大小变化的label自定义控件 -->
<Style x:Key="Mylabel1" TargetType="{x:Type Label}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Label">
<Border Background="{TemplateBinding Background}" >
<Border Background="{TemplateBinding Background}">
<Viewbox>
<ContentControl Content="{TemplateBinding Content }" Foreground="{TemplateBinding Foreground}"></ContentControl>
<ContentControl Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}">
</ContentControl>
</Viewbox>
</Border>
</ControlTemplate>
@ -526,31 +597,36 @@
</Setter>
</Style>
<!--文本框样式-->
<!-- 文本框样式 -->
<Style x:Key="TextBox" TargetType="TextBox">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="IsEnabled" Value="False"/>
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Border Name="border" Background="{TemplateBinding Background}" BorderBrush="Transparent" Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
<ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
<Border Name="border"
Background="{TemplateBinding Background}"
BorderBrush="Transparent"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<ScrollViewer Margin="0" x:Name="PART_ContentHost" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Background" Value="Transparent"/>
<Setter TargetName="border" Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@ -457,7 +457,7 @@ namespace Model.HSL
/// <param name="address"></param>
/// <param name="val"></param>
/// <returns></returns>
public abstract bool Write(string address, params bool[] val);
public abstract bool Write(string address, bool b);
#endregion

View File

@ -652,7 +652,7 @@ namespace Model.HSL
/// <param name="address"></param>
/// <param name="val"></param>
/// <returns></returns>
public override bool Write(string address, params bool[] val)
public override bool Write(string address, bool val)
{
return ConnectionType == 1 ? NetworkConn.Write(address, val).IsSuccess: SerialConn.Write(address, val).IsSuccess;
}

View File

@ -649,7 +649,7 @@ namespace Model.HSL
/// <param name="address"></param>
/// <param name="val"></param>
/// <returns></returns>
public override bool Write(string address, params bool[] val)
public override bool Write(string address, bool val)
{
return ConnectionType == 1 ? NetworkConn.Write(address, val).IsSuccess : SerialConn.Write(address, val).IsSuccess;
}

View File

@ -661,7 +661,7 @@ namespace Model.HSL
/// <param name="address"></param>
/// <param name="val"></param>
/// <returns></returns>
public override bool Write(string address, params bool[] val)
public override bool Write(string address, bool val)
{
return ConnectionType == 1 ? NetworkConn.Write(address, val).IsSuccess : SerialConn.Write(address, val).IsSuccess;
}

View File

@ -1,48 +1,30 @@
using Community;
using ControlzEx.Theming;
using DAL;
using HalconDotNet;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using Microsoft.Win32;
using Model;
using Model.HSL;
using Model.MotionControl;
using Model.Vision;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Data;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Net;
using System.Reflection;
using System.ServiceProcess;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Hosting;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using ViewModel.MotionControl;
using ViewModel.Robots;
using ViewModel.Vision;
using Views;
using Views.Vision;
namespace ViewModel
{
@ -62,6 +44,40 @@ namespace ViewModel
}
}
private DelegateCommand _OpenDoor;
public DelegateCommand OpenDoor =>
_OpenDoor = _OpenDoor ?? new DelegateCommand() { ExecuteAction = ExecuteOpenDoor };
void ExecuteOpenDoor(object obj)
{
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
if (Door != "未锁")
{
if (RunStatu == RunStatuEnum.Normal) return;
MyPLC.PLC.Write("Y2", false);
Door = "未锁";
}
else
{
MyPLC.PLC.Write("Y2", true);
Door = "已锁";
}
}
}
private string _Door = "未锁";
public string Door
{
get { return _Door; }
set
{
_Door = value;
this.RaisePropertyChanged("Door");
}
}
#region 通讯服务器对象
private CommunicationServerVM serverComm;
/// <summary>
@ -582,35 +598,92 @@ namespace ViewModel
ShowStatu.StatusBackground = ColorStr.Yellow;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "准备中";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", true);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", false);
}
break;
case RunStatuEnum.Prepareations:
ShowStatu.StatusBackground = ColorStr.Green;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "准备就绪";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", true);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", false);
}
break;
case RunStatuEnum.Normal:
ShowStatu.StatusBackground = ColorStr.Green;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "运行中";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", false);
MyPLC.PLC.Write("Y14", true);
MyPLC.PLC.Write("Y15", false);
}
break;
case RunStatuEnum.Stop:
ShowStatu.StatusBackground = ColorStr.Yellow;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "停止中";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", true);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", false);
}
break;
case RunStatuEnum.EmgStop:
ShowStatu.StatusBackground = ColorStr.Yellow;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "紧急停止中";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", true);
MyPLC.PLC.Write("Y13", false);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", false);
}
break;
case RunStatuEnum.Exceptional:
ShowStatu.StatusBackground = ColorStr.Red;
ShowStatu.StatusForeground = ColorStr.White;
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", true);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", true);
}
break;
case RunStatuEnum.Unknown:
ShowStatu.StatusBackground = ColorStr.Yellow;
ShowStatu.StatusForeground = ColorStr.Black;
ShowStatu.StatuInfo = "状态未知";
if (MyPLC != null && MyPLC.PLC != null && MyPLC.PLC.PlcStatus.StatusBackground == ColorStr.Green)
{
//Y12红灯,Y13黄灯,Y14绿灯,Y15蜂鸣器
MyPLC.PLC.Write("Y12", false);
MyPLC.PLC.Write("Y13", false);
MyPLC.PLC.Write("Y14", false);
MyPLC.PLC.Write("Y15", false);
}
break;
}
@ -1930,7 +2003,7 @@ namespace ViewModel
private void Run()
{
while (true)
{
{
if (RunStatu == RunStatuEnum.Normal)
{
if (!fir)
@ -1941,14 +2014,32 @@ namespace ViewModel
if (MyPLC.PLC.PlcStatus.StatusBackground != ColorStr.Green)
{
ExcepStop("PLC未连接");
return;
}
if (MyPLC.PLC.ReadBool("X0") == false)
{
if (powerTime.AddSeconds(1) < DateTime.Now)
{
ExcepStop("测试电源未开");
}
}
else
{
powerTime = DateTime.Now;
}
LogicDispatch(LogicDispatchFlow);
}
}
}
private DateTime powerTime = DateTime.Now;
#endregion
#region 大总管
@ -1989,6 +2080,8 @@ namespace ViewModel
TimeSpan ts = DateTime.Now.Subtract(RunStartTime).Duration();
TestTimeSpan = (ts + TempTimeSpan);
RunTimeShow.StatuInfo = string.Format("{0}:{1}:{2}", TestTimeSpan.Hours, TestTimeSpan.Minutes, TestTimeSpan.Seconds);
}
else
{
@ -1996,12 +2089,14 @@ namespace ViewModel
}
switch (MyFlow.RunStep)
{
case GengralProcessEnum.Start:
//老化柜温度要到达
if (CurrHeatShow.StatusForeground == ColorStr.Green || CurrentMachine.RunningMode)
{
if (!Testing)
{
RunStartTime = DateTime.Now;
@ -2013,8 +2108,13 @@ namespace ViewModel
//老化时间到 测试结束
if (TestTimeSpan.TotalMinutes >= CurrentMachine.MyPar.TestTime || GrayCount >= AllGrouhandList.Count)
{
Testing = false;
if (Door != "未锁")
{
MyPLC.PLC.Write("Y2", false);//开门
Door = "未锁";
}
Testing = false;
RunStatu = RunStatuEnum.Prepareations;
ShowStatu.StatuInfo = "测试完成";
@ -2026,7 +2126,7 @@ namespace ViewModel
foreach (var item in AllGrouhandList)
{
CurrentMachine.Quantitys++;
//产品测试测次数等于NG次数 直接判定产品NG 变大红色
if (item.State.TestCount > 0 && item.State.TestCount <= item.State.TestCountNG)
{
@ -2039,10 +2139,8 @@ namespace ViewModel
item.State.StatusBackground = Colors.Green.ToString();
item.TestData += "OK";
CurrentMachine.Produce++;
}
}
}
try
{
//最后结算 是否为终极不良 记录日志
@ -2066,16 +2164,20 @@ namespace ViewModel
}
else
{
MyHand = AllGrouhandList.Where(w => w.State.StatusBackground == ColorStr.Blue).FirstOrDefault();
if (MyHand != null)
{
MyPLC.PLC.Write("Y2", true); //锁门
Door = "已锁";
MyFlow.RunStep++;
MyFlow.RunTime = DateTime.Now;
}
else
{
AllGrouhandList.ForEach(w => { w.State.StatusBackground = w.State.StatusBackground != ColorStr.Gray ? ColorStr.Blue : ColorStr.Gray; });
}
}
}
@ -2186,7 +2288,7 @@ namespace ViewModel
CurrentMachine.Quantitys++;
CurrentMachine.Produce++;
}
try
{
TestResultLog(MyHand, ShowDataList, resStr);
@ -2997,6 +3099,9 @@ namespace ViewModel
/// <param name="showMag"></param>
public void ExcepStop(string showMag)
{
if (RunStatu != RunStatuEnum.Stop && RunStatu != RunStatuEnum.EmgStop && RunStatu != RunStatuEnum.Exceptional)
{
TempTimeSpan = TestTimeSpan;//记录缓存时间
@ -3561,7 +3666,7 @@ namespace ViewModel
{
sb.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")).Append(",").Append(item.TestData).Append(",\r\n");
}
//将字符串流数据写入文件
sw.WriteLine(sb);
//刷新文件流

View File

@ -7,8 +7,6 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ViewModel
{
@ -486,7 +484,7 @@ namespace ViewModel
break;
case 2:
//bool
MessShow = SelestHsl.PLC.Write(WriteAddress, new bool[] { Convert.ToBoolean(WriteValue) }) == true ? "写入成功" : "写入失败";
MessShow = SelestHsl.PLC.Write(WriteAddress, Convert.ToBoolean(WriteValue)) == true ? "写入成功" : "写入失败";
break;
case 3:
//short

View File

@ -1,48 +1,66 @@
<UserControl x:Class="Views.MainInterface"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:local="clr-namespace:Views"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
mc:Ignorable="d"
d:DesignHeight="1080"
d:DesignWidth="1920">
<Grid>
<Grid.RowDefinitions>
<RowDefinition ></RowDefinition>
<RowDefinition ></RowDefinition>
<RowDefinition>
</RowDefinition>
<RowDefinition>
</RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition ></ColumnDefinition>
<ColumnDefinition ></ColumnDefinition>
<ColumnDefinition ></ColumnDefinition>
<ColumnDefinition>
</ColumnDefinition>
<ColumnDefinition>
</ColumnDefinition>
<ColumnDefinition>
</ColumnDefinition>
</Grid.ColumnDefinitions>
<local:StandWindow />
<Border Grid.Column="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition>
</RowDefinition>
<RowDefinition>
</RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="实时数据" Padding="0">
<DataGrid ItemsSource="{Binding ShowDataList}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserSortColumns="False" CanUserDeleteRows="False">
<GroupBox Header="实时数据" Padding="0">
<DataGrid ItemsSource="{Binding ShowDataList}"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserSortColumns="False"
CanUserDeleteRows="False">
<DataGrid.Columns>
<DataGridTextColumn Header="名称" Width="1.5*" IsReadOnly="True" Binding="{Binding NameStr}"></DataGridTextColumn>
<DataGridTextColumn Header="标准值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.BaseValue}"></DataGridTextColumn>
<DataGridTextColumn Header="最大值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.MaxValue,Mode=TwoWay, UpdateSourceTrigger=LostFocus}"></DataGridTextColumn>
<DataGridTextColumn Header="最小值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.MinValue,Mode=TwoWay, UpdateSourceTrigger=LostFocus}"></DataGridTextColumn>
<DataGridTextColumn Header="测量值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.ActualValue, StringFormat={}{0:F3}}"></DataGridTextColumn>
<DataGridTextColumn Header="结果" Width="0.5*" IsReadOnly="True" Binding="{Binding MyValue.ResultStr}" >
<DataGridTextColumn Header="名称" Width="1.5*" IsReadOnly="True" Binding="{Binding NameStr}">
</DataGridTextColumn>
<DataGridTextColumn Header="标准值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.BaseValue}">
</DataGridTextColumn>
<DataGridTextColumn Header="最大值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.MaxValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}">
</DataGridTextColumn>
<DataGridTextColumn Header="最小值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.MinValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}">
</DataGridTextColumn>
<DataGridTextColumn Header="测量值" Width="*" IsReadOnly="True" Binding="{Binding MyValue.ActualValue, StringFormat={}{0:F3}}">
</DataGridTextColumn>
<DataGridTextColumn Header="结果" Width="0.5*" IsReadOnly="True" Binding="{Binding MyValue.ResultStr}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"></Setter>
<Setter Property="TextAlignment" Value="Center">
</Setter>
<Style.Triggers>
<Trigger Property="Text" Value="OK">
<Setter Property="Background" Value="Lime"/>
<Setter Property="Background" Value="Lime" />
</Trigger>
<Trigger Property="Text" Value="NG">
<Setter Property="Background" Value="Red"/>
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
@ -52,47 +70,76 @@
</DataGrid>
</GroupBox>
<!--<GroupBox Grid.Row="1" Header="实时温度" Padding="0" >-->
<lvc:CartesianChart Grid.Row="1" DataContext="{Binding CVM1}" LegendLocation="Top" Foreground="White" FontSize="20" Background="Black" Hoverable="True" DataTooltip="{x:Null}" DisableAnimations="False">
<lvc:CartesianChart.AxisX >
<lvc:Axis FontSize="12" Labels="{Binding Labels}" >
<lvc:Axis.Separator>
<!--Step柱间隔-->
<lvc:Separator Step="5" Stroke="#33ffffff" StrokeDashArray="10"/>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY >
<lvc:Axis FontSize="12" LabelFormatter="{Binding Formatter}">
<lvc:Axis.Separator>
<!--Step柱间隔-->
<lvc:Separator Stroke="#33ffffff" StrokeDashArray="10"/>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.Series >
<!--StackedColumnSeries要比较的其中一类 MaxColumnWidth柱状图宽度 DataLabels是否显示柱状图数值 Title图例中名称-->
<lvc:LineSeries FontSize="12" Foreground="White" DataLabels="False" LineSmoothness="2" StrokeThickness="1" Values="{Binding V1}" PointGeometry="{x:Null}" Fill="Transparent" Stroke="AliceBlue" Title="目标温度" />
<lvc:LineSeries FontSize="12" Foreground="White" DataLabels="False" LineSmoothness="2" Values="{Binding V2}" PointGeometry="{x:Null}" Fill="Transparent" Stroke="{Binding ColorV2}" Title="实时温度" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.ChartLegend>
<!--BulletSize图例中圆点尺寸-->
<lvc:DefaultLegend BulletSize="12" />
</lvc:CartesianChart.ChartLegend>
</lvc:CartesianChart>
<lvc:CartesianChart Grid.Row="1"
DataContext="{Binding CVM1}"
LegendLocation="Top" Foreground="White"
FontSize="20" Background="Black"
Hoverable="True"
DataTooltip="{x:Null}"
DisableAnimations="False">
<lvc:CartesianChart.AxisX>
<lvc:Axis FontSize="12" Labels="{Binding Labels}">
<lvc:Axis.Separator>
<!-- Step柱间隔 -->
<lvc:Separator Step="5" Stroke="#33ffffff" StrokeDashArray="10" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis FontSize="12" LabelFormatter="{Binding Formatter}">
<lvc:Axis.Separator>
<!-- Step柱间隔 -->
<lvc:Separator Stroke="#33ffffff" StrokeDashArray="10" />
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.Series>
<!-- StackedColumnSeries要比较的其中一类 MaxColumnWidth柱状图宽度 DataLabels是否显示柱状图数值 Title图例中名称 -->
<lvc:LineSeries FontSize="12" Foreground="White"
DataLabels="False" LineSmoothness="2"
StrokeThickness="1"
Values="{Binding V1}"
PointGeometry="{x:Null}"
Fill="Transparent" Stroke="AliceBlue"
Title="目标温度" />
<lvc:LineSeries FontSize="12" Foreground="White"
DataLabels="False" LineSmoothness="2"
Values="{Binding V2}"
PointGeometry="{x:Null}"
Fill="Transparent"
Stroke="{Binding ColorV2}"
Title="实时温度" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.ChartLegend>
<!-- BulletSize图例中圆点尺寸 -->
<lvc:DefaultLegend BulletSize="12" />
</lvc:CartesianChart.ChartLegend>
</lvc:CartesianChart>
<!--</GroupBox>-->
</Grid>
</Border>
<GroupBox Grid.Row="1" Grid.ColumnSpan="3" Header="结果展示 灰色:无料 蓝色:待测试 绿色:OK 红色:NG">
<GroupBox Grid.Row="1" Grid.ColumnSpan="3" Header="结果展示 灰色:无料 蓝色:待测试 绿色:OK 红色:NG">
<TabControl Background="Transparent">
<TabItem Header="第一层" Content="{Binding GroupGrid1}"></TabItem>
<TabItem Header="第二层" Content="{Binding GroupGrid2}"></TabItem>
<TabItem Header="第三层" Content="{Binding GroupGrid3}"></TabItem>
<TabItem Header="第四层" Content="{Binding GroupGrid4}"></TabItem>
<TabItem Header="第五层" Content="{Binding GroupGrid5}"></TabItem>
<TabItem Header="第一层" Content="{Binding GroupGrid1}">
</TabItem>
<TabItem Header="第二层" Content="{Binding GroupGrid2}">
</TabItem>
<TabItem Header="第三层" Content="{Binding GroupGrid3}">
</TabItem>
<TabItem Header="第四层" Content="{Binding GroupGrid4}">
</TabItem>
<TabItem Header="第五层" Content="{Binding GroupGrid5}">
</TabItem>
</TabControl>
</GroupBox>
<GroupBox Grid.Column="2" Header="实时信息" Padding="0">
<TextBox FontSize="20" TextWrapping="Wrap" Text="{Binding ShowStr}" ScrollViewer.VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Background="#4CFFFFFF" ClipToBounds="True" Foreground="White" ></TextBox>
<GroupBox Grid.Column="2" Header="实时信息" Padding="0">
<TextBox FontSize="20" TextWrapping="Wrap"
Text="{Binding ShowStr}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
AcceptsReturn="True"
Background="#4CFFFFFF"
ClipToBounds="True" Foreground="White">
</TextBox>
</GroupBox>
</Grid>

View File

@ -24,6 +24,7 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
@ -32,10 +33,17 @@
</Grid.ColumnDefinitions>
<Label Style="{DynamicResource Mylabel1}" Grid.ColumnSpan="3" DataContext="{Binding MyPLC.PLC}" Content="{Binding PlcStatus.StatuInfo}" Background="{Binding PlcStatus.StatusBackground}" Margin="2"></Label>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="1" Grid.ColumnSpan="3" Margin="2" DataContext="{Binding ShowStatu}" Background="{Binding StatusBackground}" Content="{Binding StatuInfo}" ></Label>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="2" Content="实时温度:" Foreground="White"></Label>
<Label Style="{DynamicResource Mylabel1}" DataContext="{Binding CurrHeatShow}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding StatuValue}" Foreground="{Binding StatusForeground}"></Label>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="3" Content="测试时间:" Foreground="White"></Label>
<Label Style="{DynamicResource Mylabel1}" DataContext="{Binding RunTimeShow}" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding StatuInfo}" Foreground="{Binding StatusForeground}"></Label>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding Door}" Foreground="White"></Label>
<Button Style="{DynamicResource commBtn}" Grid.Row="2" Grid.Column="0" Background="{Binding ElementName=GBST,Path=BorderBrush}" FontFamily="楷体" FontSize="50" Margin="1" Command="{Binding OpenDoor}" FontWeight="Bold" >
<Viewbox>
<ContentControl Content="开关锁" ></ContentControl>
</Viewbox>
</Button>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="3" Content="实时温度:" Foreground="White"></Label>
<Label Style="{DynamicResource Mylabel1}" DataContext="{Binding CurrHeatShow}" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding StatuValue}" Foreground="{Binding StatusForeground}"></Label>
<Label Style="{DynamicResource Mylabel1}" Grid.Row="4" Content="测试时间:" Foreground="White"></Label>
<Label Style="{DynamicResource Mylabel1}" DataContext="{Binding RunTimeShow}" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding StatuInfo}" Foreground="{Binding StatusForeground}"></Label>
</Grid>
</Border>
<!--<Border Grid.Row="1" Grid.ColumnSpan="2" DataContext="{Binding TodayData}">