239 lines
17 KiB
XML
239 lines
17 KiB
XML
<Window x:Class="TabletTester2025.MainWindow"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:oxy="http://oxyplot.org/wpf"
|
|
xmlns:helpers="clr-namespace:TabletTester2025.Helpers"
|
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
|
Title="片剂四用仪 (中国药典2025) 上海程斯智能科技"
|
|
Height="900" Width="1400" WindowStartupLocation="CenterScreen" WindowState="Maximized"
|
|
Background="#F0F2F5">
|
|
<Window.Resources>
|
|
<helpers:BasketOffsetConverter x:Key="BasketOffsetConverter"/>
|
|
<helpers:PassToTextConverter x:Key="PassToTextConverter"/>
|
|
<helpers:BoolToColorConverter x:Key="BoolToColorConverter"/>
|
|
<helpers:StatusColorConverter x:Key="StatusColorConverter"/>
|
|
<sys:Double x:Key="MaxOffset">120</sys:Double>
|
|
|
|
<!-- 全局样式 -->
|
|
<Style TargetType="Button" x:Key="PrimaryButton">
|
|
<Setter Property="Background" Value="#2196F3"/>
|
|
<Setter Property="Foreground" Value="White"/>
|
|
<Setter Property="BorderThickness" Value="0"/>
|
|
<Setter Property="Padding" Value="12,6"/>
|
|
<Setter Property="Margin" Value="5"/>
|
|
<Setter Property="FontWeight" Value="Bold"/>
|
|
<Setter Property="Cursor" Value="Hand"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="Button">
|
|
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
</Border>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style TargetType="TextBlock" x:Key="ParamLabel">
|
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
|
<Setter Property="FontSize" Value="12"/>
|
|
<Setter Property="Foreground" Value="#555"/>
|
|
</Style>
|
|
|
|
<Style TargetType="TextBlock" x:Key="ParamValue">
|
|
<Setter Property="FontSize" Value="14"/>
|
|
<Setter Property="FontWeight" Value="Normal"/>
|
|
<Setter Property="Foreground" Value="#000"/>
|
|
</Style>
|
|
|
|
<DataTemplate x:Key="StationCardTemplate">
|
|
<Border BorderBrush="#E0E0E0" BorderThickness="1" CornerRadius="12" Margin="8" Padding="12"
|
|
Background="White" >
|
|
<StackPanel>
|
|
<TextBlock Text="{Binding StationId, StringFormat='工位 {0}'}" FontSize="20" FontWeight="Bold"
|
|
Margin="0,0,0,10" Foreground="#1976D2"/>
|
|
|
|
<TabControl FontSize="12" BorderThickness="0" Background="Transparent">
|
|
<TabItem Header="硬度" FontWeight="SemiBold">
|
|
<Border BorderBrush="#DDD" BorderThickness="1" CornerRadius="6" Padding="10" Margin="0,5">
|
|
<StackPanel>
|
|
<Grid Margin="0,0,0,10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel Grid.Column="0">
|
|
<TextBlock Text="当前硬度(N)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding HardnessValue, StringFormat=F1}" FontSize="28" Foreground="#FF9800"/>
|
|
<TextBlock Text="平均值(N)" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding HardnessAvg, StringFormat=F1}" FontSize="18"/>
|
|
<TextBlock Text="RSD(%)" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding HardnessRSD, StringFormat=F1}" FontSize="18"/>
|
|
</StackPanel>
|
|
<StackPanel Grid.Column="1">
|
|
<TextBlock Text="测试次数" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding HardnessTestCount, FallbackValue=6}" FontSize="14"/>
|
|
<TextBlock Text="合格判定" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding HardnessPass, Converter={StaticResource PassToTextConverter}}"
|
|
Foreground="{Binding HardnessPass, Converter={StaticResource BoolToColorConverter}}"
|
|
FontWeight="Bold"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
<oxy:PlotView Model="{Binding HardnessPlotModel}" Height="120" Margin="0,5"/>
|
|
<Button Command="{Binding StartHardnessCommand}" Content="启动硬度测试" Style="{StaticResource PrimaryButton}"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</TabItem>
|
|
|
|
<TabItem Header="脆碎度">
|
|
<Border BorderBrush="#DDD" BorderThickness="1" CornerRadius="6" Padding="10" Margin="0,5">
|
|
<StackPanel>
|
|
<Grid Margin="0,0,0,10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel Grid.Column="0">
|
|
<TextBlock Text="前重(g)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding WeightBefore, StringFormat=F3}" FontSize="16"/>
|
|
<TextBlock Text="后重(g)" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding WeightAfter, StringFormat=F3}" FontSize="16"/>
|
|
</StackPanel>
|
|
<StackPanel Grid.Column="1">
|
|
<TextBlock Text="失重率(%)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding LossPercent, StringFormat=F2}" FontSize="20" Foreground="#FF5722"/>
|
|
<TextBlock Text="转鼓圈数" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<ProgressBar Value="{Binding FriabilityRemainingRounds, FallbackValue=100}" Minimum="0" Maximum="100" Height="10"/>
|
|
<TextBlock Text="{Binding FriabilityRemainingRounds, StringFormat='剩余 {0} 圈'}" FontSize="10"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
<Button Command="{Binding StartFriabilityCommand}" Content="启动脆碎度测试" Style="{StaticResource PrimaryButton}"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</TabItem>
|
|
|
|
<TabItem Header="崩解">
|
|
<Border BorderBrush="#DDD" BorderThickness="1" CornerRadius="6" Padding="10" Margin="0,5">
|
|
<StackPanel>
|
|
<Grid Margin="0,0,0,10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
<Canvas Width="80" Height="150" Background="LightBlue" Grid.Column="0">
|
|
<Rectangle Width="30" Height="15" Fill="Brown" Canvas.Left="25">
|
|
<Rectangle.RenderTransform>
|
|
<TranslateTransform Y="{Binding IsBasketMovingUp, Converter={StaticResource BasketOffsetConverter}, ConverterParameter={StaticResource MaxOffset}}"/>
|
|
</Rectangle.RenderTransform>
|
|
</Rectangle>
|
|
</Canvas>
|
|
<StackPanel Grid.Column="1" Margin="10,0,0,0">
|
|
<TextBlock Text="温度(℃)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding DisintegrationTemp, StringFormat=F1}" Foreground="#E91E63"/>
|
|
<TextBlock Text="计时(秒)" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding DisintegrationSeconds}" FontSize="20" FontWeight="Bold"/>
|
|
<TextBlock Text="合格标准: ≤15分钟" FontSize="10" Foreground="Gray"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
<TextBlock Text="崩解管状态" Style="{StaticResource ParamLabel}" Margin="0,5,0,5"/>
|
|
<UniformGrid Columns="6" Rows="1" Margin="0,5,0,10">
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[0], Converter={StaticResource BoolToColorConverter}}"/>
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[1], Converter={StaticResource BoolToColorConverter}}"/>
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[2], Converter={StaticResource BoolToColorConverter}}"/>
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[3], Converter={StaticResource BoolToColorConverter}}"/>
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[4], Converter={StaticResource BoolToColorConverter}}"/>
|
|
<Ellipse Width="20" Height="20" Fill="{Binding TubesCompleted[5], Converter={StaticResource BoolToColorConverter}}"/>
|
|
</UniformGrid>
|
|
<Button Command="{Binding StartDisintegrationCommand}" Content="启动崩解测试" Style="{StaticResource PrimaryButton}"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</TabItem>
|
|
|
|
<TabItem Header="溶出">
|
|
<Border BorderBrush="#DDD" BorderThickness="1" CornerRadius="6" Padding="10" Margin="0,5">
|
|
<StackPanel>
|
|
<Grid Margin="0,0,0,10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel Grid.Column="0">
|
|
<TextBlock Text="转速(rpm)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding DissolutionRpm, StringFormat=F0}" FontSize="16"/>
|
|
<TextBlock Text="溶出度(%)" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="{Binding DissolutionPercent, StringFormat=F1}" FontSize="24" Foreground="#4CAF50"/>
|
|
</StackPanel>
|
|
<StackPanel Grid.Column="1">
|
|
<TextBlock Text="水浴温度(℃)" Style="{StaticResource ParamLabel}"/>
|
|
<TextBlock Text="{Binding DisintegrationTemp, FallbackValue=37.0, StringFormat=F1}"/>
|
|
<TextBlock Text="判定标准" Style="{StaticResource ParamLabel}" Margin="0,10,0,0"/>
|
|
<TextBlock Text="30min ≥ 80%" FontSize="12"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
<oxy:PlotView Model="{Binding DissolutionPlotModel}" Height="140" Margin="0,5"/>
|
|
<Button Command="{Binding StartDissolutionCommand}" Content="启动溶出测试" Style="{StaticResource PrimaryButton}"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</TabItem>
|
|
</TabControl>
|
|
<Button Command="{Binding ExportHistoryCommand}" Content="📊 导出历史数据" Margin="0,10,0,0"
|
|
Style="{StaticResource PrimaryButton}" Background="#607D8B"/>
|
|
</StackPanel>
|
|
</Border>
|
|
</DataTemplate>
|
|
</Window.Resources>
|
|
|
|
<Grid Margin="10">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- 标题栏 -->
|
|
<Border Background="#1976D2" CornerRadius="8" Margin="0,0,0,16" Padding="12">
|
|
<Grid>
|
|
<TextBlock Text="片剂四用仪 (硬度·脆碎度·崩解·溶出) 符合《中国药典》2025年版" FontSize="22" FontWeight="Bold" Foreground="White"
|
|
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
|
<Button Content="⚙ 参数设置" x:Name="SettingsButton" Margin="5,0" Style="{StaticResource PrimaryButton}" Background="#FF9800"/>
|
|
<Button Content="📜 历史记录" x:Name="HistoryButton" Margin="5,0" Style="{StaticResource PrimaryButton}" Background="#9C27B0"/>
|
|
<Button Content="🔧 校准" x:Name="CalibrationButton" Margin="5,0" Style="{StaticResource PrimaryButton}" Background="#795548"/>
|
|
<Button Content="📁 导出全部" Command="{Binding ExportAllCommand}" Margin="5,0" Style="{StaticResource PrimaryButton}"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- 三工位容器 -->
|
|
<UniformGrid Grid.Row="1" Columns="3" Rows="1" Margin="0,0,0,16">
|
|
<ContentControl Content="{Binding Stations[0]}" ContentTemplate="{StaticResource StationCardTemplate}"/>
|
|
<ContentControl Content="{Binding Stations[1]}" ContentTemplate="{StaticResource StationCardTemplate}"/>
|
|
<ContentControl Content="{Binding Stations[2]}" ContentTemplate="{StaticResource StationCardTemplate}"/>
|
|
</UniformGrid>
|
|
|
|
<!-- 修复后的状态栏 -->
|
|
<StatusBar Grid.Row="2" Background="#FFF" BorderBrush="#DDD" BorderThickness="0,1,0,0" Padding="8">
|
|
<StatusBarItem>
|
|
<StackPanel Orientation="Horizontal">
|
|
<Ellipse Width="10" Height="10" Fill="{Binding PlcStatus, Converter={StaticResource StatusColorConverter}}" Margin="0,0,5,0"/>
|
|
<TextBlock Text="PLC: "/>
|
|
<TextBlock Text="{Binding PlcStatus}"/>
|
|
</StackPanel>
|
|
</StatusBarItem>
|
|
<Separator/>
|
|
<StatusBarItem>
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Text="当前时间: "/>
|
|
<TextBlock Text="{Binding CurrentTime}"/>
|
|
</StackPanel>
|
|
</StatusBarItem>
|
|
<Separator/>
|
|
<StatusBarItem>
|
|
<StackPanel Orientation="Horizontal">
|
|
<TextBlock Text="⚠ " Foreground="#FF5722"/>
|
|
<TextBlock Text="{Binding GlobalAlarm}" Foreground="Red"/>
|
|
</StackPanel>
|
|
</StatusBarItem>
|
|
</StatusBar>
|
|
</Grid>
|
|
</Window> |