Start
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
|
||||
<appSettings>
|
||||
<add key="Mode" value="2" /> <!--1 = EOL ; 2 = Picking-->
|
||||
<add key="SirtComport433" value="14" /> <!--Individual for Thomas-->
|
||||
<add key="SirtComport868" value="15" /> <!--Individual for Thomas-->
|
||||
<add key="SirtBoxNr" value="2" /> <!--Roland and Thomas, box for development, box at shipping station is 1-->
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Windows;
|
||||
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel
|
||||
@@ -10,9 +11,24 @@ namespace Xylem.Common.Production.ProductionUiCordonel
|
||||
{
|
||||
private void Application_Startup(Object sender, StartupEventArgs e)
|
||||
{
|
||||
switch (ConfigurationManager.AppSettings[$"Mode"])
|
||||
{
|
||||
case "1":
|
||||
|
||||
var mainWindow = new FinalTest();
|
||||
mainWindow.Show();
|
||||
break;
|
||||
case "2":
|
||||
var Picking = new Picking();
|
||||
Picking.Show();
|
||||
break;
|
||||
default:
|
||||
var mainWindowDef = new FinalTest();
|
||||
mainWindowDef.Show();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
var mainWindow = new FinalTest();
|
||||
mainWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<Window
|
||||
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"
|
||||
x:Class="Xylem.Common.Production.ProductionUiCordonel.Picking"
|
||||
mc:Ignorable="d"
|
||||
Title="FinalTest" MinHeight="730" MinWidth="820" Height="730" Width="820" Initialized="Window_Initialized" Closing="Window_Closing" ResizeMode="CanMinimize" HorizontalAlignment="Right" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded">
|
||||
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="2,2,2,2">
|
||||
<!--Tool Panel-->
|
||||
<!--ToolBarTray DockPanel.Dock="Top" Visibility="Visible" Background="#FFF0F0F0" HorizontalAlignment="Stretch" -->
|
||||
<Menu DockPanel.Dock="Top" Visibility="Visible" Background="#FFF0F0F0" HorizontalAlignment="Stretch">
|
||||
<Menu.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<DockPanel HorizontalAlignment="Stretch"></DockPanel>
|
||||
</ItemsPanelTemplate>
|
||||
</Menu.ItemsPanel>
|
||||
<MenuItem x:Name="optionsMenu" HorizontalAlignment="Right" Height="30" Width="60" Header="_Options" >
|
||||
<MenuItem x:Name="optionsMenuLogin" Header="_Login" HorizontalAlignment="Left" Click="OnLogin_Click"/>
|
||||
<MenuItem x:Name="optionsMenuLogout" Header="L_ogout" HorizontalAlignment="Left" Click="OnLogout_Click"/>
|
||||
<MenuItem x:Name="optionsMenuChangePassword" Header="Change Password" HorizontalAlignment="Left" Click="OnChangePassword_Click"/>
|
||||
</MenuItem>
|
||||
<Label Content="Slot: " Margin="2,2,2,2" Visibility="Hidden"/>
|
||||
<ComboBox x:Name="cbxSlotBox" Margin="2,2,2,2" SelectionChanged="CbxSlotBox_SelectionChanged" Visibility="Hidden"/>
|
||||
<Label x:Name="lblApprovalText" Margin="110,1,1,1" Content="SPECIAL APPROVAL - Id.Ver: 10.07" Foreground="#FFFB0808" FontSize="16" MouseDown="LblApprovalText_Click" HorizontalAlignment="Center"/>
|
||||
<MenuItem x:Name="hlpMenu" HorizontalAlignment="Right" Height="30" Width="40" FontSize="12" Header="Help" Click="HlpMenu_Click" />
|
||||
<!--Special approval / requirement-->
|
||||
</Menu>
|
||||
<!--/-->
|
||||
|
||||
<!--Status Panel-->
|
||||
<StatusBar DockPanel.Dock="Bottom" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="2,2,2,2">
|
||||
<StatusBar.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="60" />
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
</ItemsPanelTemplate>
|
||||
</StatusBar.ItemsPanel>
|
||||
<StatusBarItem Grid.Column="0" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Label Content="PcbID:" Margin="2,2,0,2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Grid.Column="1" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Label x:Name="lblPcbIdValue" Content="-" Margin="2,2,2,2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
</StatusBarItem>
|
||||
<Separator Grid.Column="2" />
|
||||
<StatusBarItem x:Name="lblOperator" Grid.Column="4" Margin="-1,1,-109,3" HorizontalAlignment="Center" VerticalAlignment="Stretch" />
|
||||
<Separator Grid.Column="7" />
|
||||
<StatusBarItem Grid.Column="8" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<TextBlock x:Name="lblTimeText" Text="Elapsed Time [min:s]:" Margin="2,2,2,2" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Grid.Column="9" Margin="0,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Stretch">
|
||||
<Label x:Name="lblTimeValue" Content="0:00" Margin="2,2,2,2" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
|
||||
<!--Grid Design-->
|
||||
<Grid Background="AliceBlue" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="2,2,2,2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="17"/>
|
||||
<ColumnDefinition Width="113"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition Width="40"/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--Cordonel information-->
|
||||
<Label x:Name="lblSerialNumberTxt" Content="SerialNumber:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="0" Grid.Column="2"/>
|
||||
<Label x:Name="lblOrderNumberText" Content="OrderNumber:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="1" Grid.Column="2"/>
|
||||
<Label Content="Region:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="2" Grid.Column="2"/>
|
||||
<Label x:Name="lblRadioAddressText" Content="RadioAddress:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="3" Grid.Column="2"/>
|
||||
<Label Content="Firmware:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="0" Grid.Column="5"/>
|
||||
<Label x:Name="lblLutText" Content="LUT CRC:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="1" Grid.Column="5"/>
|
||||
<Label x:Name="lblMeterSizeText" Content="Meter Size:" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="2" Grid.Column="5"/>
|
||||
|
||||
<Label Content="" x:Name="lblSerialNumberValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="0" Grid.Column="3"/>
|
||||
<Label Content="" x:Name="lblOrderNumberValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="1" Grid.Column="3"/>
|
||||
<Label Content="" x:Name="lblRegionValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="2" Grid.Column="3"/>
|
||||
<Label Content="" x:Name="lblRadioAddressValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="3" Grid.Column="3"/>
|
||||
<Label Content="" x:Name="lblFwValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="0" Grid.Column="6"/>
|
||||
<Label Content="" x:Name="lblLutValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="1" Grid.Column="6"/>
|
||||
<Label Content="" x:Name="lblMeterSizeValue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="2" Grid.Column="6"/>
|
||||
|
||||
<!--Pictures-->
|
||||
<Border Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Margin="2,2,2,2" BorderThickness="1" BorderBrush="Black" Grid.ColumnSpan="2">
|
||||
<Image Margin="0,0,-1,-1" Source="/Resources/Cordonel With Display small.JPG" Stretch="Fill" />
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.RowSpan="2" Grid.Column="9" Grid.ColumnSpan="2" Margin="2,2,2,2" BorderThickness="1" BorderBrush="Black" >
|
||||
<Image Margin="0,0,-1,-1" Source="/Resources/SensusLogoXylem.JPG" Stretch="Fill" />
|
||||
</Border>
|
||||
|
||||
<!--Process Information-->
|
||||
<DataGrid x:Name="dgTotalProcess" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="4" Grid.RowSpan="11" Grid.Column="0" Grid.ColumnSpan="4" ItemsSource="{Binding}"
|
||||
AutoGenerateColumns="True" SelectionMode="Single" IsReadOnly="True" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" IsEnabled="True" />
|
||||
<StackPanel x:Name="dpSubProcess" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="4" Grid.RowSpan="11" Grid.Column="5" Grid.ColumnSpan="3" />
|
||||
<GroupBox Header="Info" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="15" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="11" >
|
||||
<RichTextBox x:Name="rtbLog" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
|
||||
</GroupBox>
|
||||
|
||||
<!--Progress Bars and Info-->
|
||||
<ProgressBar x:Name="pbSubProgress" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,4,2,4" Grid.Row="19" Grid.Column="2" Grid.ColumnSpan="8" />
|
||||
<ProgressBar x:Name="pbTotalProgress" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,4,2,4" Grid.Row="20" Grid.Column="2" Grid.ColumnSpan="8" />
|
||||
<Label x:Name="lblSubProgressValue" HorizontalAlignment="Right" VerticalAlignment="Stretch" Margin="0,0,2,0" Grid.Row="19" Grid.Column="10" Content="0,0 %"/>
|
||||
<Label x:Name="lblTotalProgressValue" HorizontalAlignment="Right" VerticalAlignment="Stretch" Margin="0,0,2,0" Grid.Row="20" Grid.Column="10" Content="0,0 %"/>
|
||||
<Label x:Name="lblSingleProcessText" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="19" Grid.Column="0" Content="Single Process:" Grid.ColumnSpan="2" />
|
||||
<Label x:Name="lblTotalProcessText" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2,2,2,2" Grid.Row="20" Grid.Column="0" Content="Total Process:" Grid.ColumnSpan="2" />
|
||||
|
||||
<!--Buttons-->
|
||||
<Button x:Name="btnStart" HorizontalAlignment="Stretch" Margin="2,4,2,4" VerticalAlignment="Stretch" Grid.Column="9" Grid.ColumnSpan="2" Grid.Row="2" Grid.RowSpan="2" IsEnabled="false" Click="BtnStart_Click" Content="Start" />
|
||||
<Button x:Name="btnStop" HorizontalAlignment="Stretch" Margin="2,4,2,4" VerticalAlignment="Stretch" Grid.Column="9" Grid.ColumnSpan="2" Grid.Row="4" Grid.RowSpan="2" IsEnabled="false" Click="BtnStop_Click" Content="Stop" />
|
||||
</Grid>
|
||||
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -0,0 +1,927 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using LaaPackages.Features.Cordonel.Models;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EventArgs;
|
||||
using Xylem.Common.Utils.Logging;
|
||||
using Xylem.Common.Utils.UserAccessCtrl;
|
||||
using Control = System.Windows.Forms.Control;
|
||||
using TextBox = System.Windows.Controls.TextBox;
|
||||
using UserControl = System.Windows.Controls.UserControl;
|
||||
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Picking.xaml
|
||||
/// </summary>
|
||||
public sealed partial class Picking
|
||||
{
|
||||
#region variables and properties
|
||||
private readonly ILogger _logger;
|
||||
// remind manually changed culture setting
|
||||
private static readonly CultureInfo _cultureInfo = Thread.CurrentThread.CurrentCulture;
|
||||
private static readonly AssemblyName _assemblyName = Assembly.GetExecutingAssembly().GetName();
|
||||
private static readonly String _assemblyExecRootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
private static readonly Version _version = _assemblyName.Version;
|
||||
private readonly String _strSoftwareNameVersion;
|
||||
private RegisterLDAPUser _registerForm;
|
||||
|
||||
private Int32 Slot
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
// maximum processing steps for calculation of progress bar
|
||||
private Int32 _maxOverallProcessSteps;
|
||||
private Int32 _maxSingleProcessSteps;
|
||||
private FinalProcessController _processCtrl;
|
||||
private DateTimeOffset _startTime;
|
||||
private DispatcherTimer _timer;
|
||||
private String _lastLoggingTextToAvoidRepetition;
|
||||
private CordonelRequirements _productionRequirements;
|
||||
private UserAccessWindow _userAccessWindow;
|
||||
|
||||
#endregion
|
||||
|
||||
public Picking()
|
||||
{
|
||||
_logger = NLogHelper.CreateOrGetLogger("ProductionUiCordonel");
|
||||
|
||||
String msg;
|
||||
try
|
||||
{
|
||||
// returns true in DEBUG configuration
|
||||
if (!Logic.SoftwareAccessHelper.Access.HasAccess(_assemblyName))
|
||||
{
|
||||
msg = $"{Properties.Resources.StrStartMessageSwLicenseExpired} {_version}";
|
||||
_logger.Error(msg);
|
||||
MessageBox.Show(msg, Properties.Resources.StrProcessStateError,
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
msg = Properties.Resources.StrErrorMsgMissingNetworkConnetction + " " + e.Message ;
|
||||
_logger.Error(msg);
|
||||
MessageBox.Show(msg,
|
||||
Properties.Resources.StrProcessStateError,
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
// Log version to files for debug purposes
|
||||
_strSoftwareNameVersion = $"{Properties.Resources.StrSoftwareNameVersion} {_version}";
|
||||
_logger.Info(_strSoftwareNameVersion);
|
||||
|
||||
Title = _strSoftwareNameVersion;
|
||||
|
||||
//static labels
|
||||
UpdateContentControl(lblSerialNumberTxt, Properties.Resources.StrLblSerialNumberTxt + ":");
|
||||
UpdateContentControl(lblRadioAddressText, Properties.Resources.StrLblRadioAddressTxt + ":");
|
||||
UpdateContentControl(lblOrderNumberText, Properties.Resources.StrLblOrderNumberTxt + ":");
|
||||
UpdateContentControl(lblMeterSizeText, Properties.Resources.StrLblMeterSizeTxt + ":");
|
||||
UpdateContentControl(lblSingleProcessText, Properties.Resources.StrLblSingleProcessText + ":");
|
||||
UpdateContentControl(lblTotalProcessText, Properties.Resources.StrLblTotalProcessText + ":");
|
||||
optionsMenu.Header = Properties.Resources.StrMenuOptionsText;
|
||||
optionsMenuChangePassword.Header = Properties.Resources.StrMenuChangePasswordText;
|
||||
hlpMenu.Header = Properties.Resources.StrMenuHelpText;
|
||||
UpdateUi(lblApprovalText, "");
|
||||
UpdateUi(lblTimeText, Properties.Resources.StrLblTimeText + ":");
|
||||
|
||||
// buttons
|
||||
UpdateContentControl(btnStart, Properties.Resources.StrBtnStart);
|
||||
UpdateContentControl(btnStop, Properties.Resources.StrBtnStop);
|
||||
|
||||
InitializeFormState();
|
||||
|
||||
}
|
||||
|
||||
private ApplicationSettings Settings
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the FinalTest GUI:
|
||||
/// - Read the configuration file for slot and port assignments and settings,
|
||||
/// - Dispatch slots to slot combobox,
|
||||
/// - Read setting from "ProductionUiConfig.json" file for GUI and slot setup,
|
||||
/// - Create final process controller and install events,
|
||||
/// - Create a dispatch timer to display the elapsed time of the process.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Window_Initialized(Object sender, EventArgs e)
|
||||
{
|
||||
var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
nameof(Hardware.WaterMeter.Genesis), ProgramConfig.SerialConfigFileName);
|
||||
|
||||
if (!File.Exists(configFile))
|
||||
{
|
||||
var msg = Properties.Resources.StrErrorMsgMissingConfigurationFile;
|
||||
MessageBox.Show(msg,
|
||||
Properties.Resources.StrProcessStateError,
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
_logger.Error(msg);
|
||||
throw new ApplicationException(msg);
|
||||
}
|
||||
var tr = new StreamReader(configFile);
|
||||
var meterConfigList = JsonConvert.DeserializeObject<SlotConfig[]>(tr.ReadToEnd());
|
||||
|
||||
cbxSlotBox.Items.Clear();
|
||||
if (meterConfigList != null)
|
||||
{
|
||||
foreach (var item in meterConfigList.OrderBy(s => s.Slot))
|
||||
{
|
||||
cbxSlotBox.Items.Add(item.Slot);
|
||||
}
|
||||
}
|
||||
|
||||
cbxSlotBox.SelectedIndex = 0;
|
||||
Settings = new ApplicationSettings("ProductionUiConfig.json");
|
||||
|
||||
UseSetting(true);
|
||||
|
||||
if (cbxSlotBox.SelectedItem == null || string.IsNullOrEmpty(cbxSlotBox.SelectedItem.ToString()) ||
|
||||
!int.TryParse(cbxSlotBox.SelectedItem.ToString(), out var slot))
|
||||
{
|
||||
Slot = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Slot = slot;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_processCtrl = new FinalProcessController(Slot);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex.Message);
|
||||
MessageBox.Show(ex.Message,
|
||||
Properties.Resources.StrProcessStateError,
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
throw new ApplicationException(ex.Message);
|
||||
}
|
||||
|
||||
//install the process changed event handler for single processes
|
||||
_processCtrl.OnSingleProcessStateChanged += SingleProcessStateChanged_Handler;
|
||||
_processCtrl.OnProcessLogRequest += ProcessLog_Handler;
|
||||
_processCtrl.OnProcessProgressChanged += ProcessProgress_Handler;
|
||||
_processCtrl.OnOverallProcessStateChanged += ProcessStateChange_Handler;
|
||||
|
||||
_timer = new DispatcherTimer();
|
||||
_timer.Tick += TmrProgressUpdate_Tick;
|
||||
_timer.Interval = TimeSpan.FromMilliseconds(500);
|
||||
|
||||
UpdateStatusGrid();
|
||||
}
|
||||
|
||||
private void Window_Closing(Object sender, CancelEventArgs e)
|
||||
{
|
||||
_userAccessWindow?.Close();
|
||||
_processCtrl.OnSingleProcessStateChanged -= SingleProcessStateChanged_Handler;
|
||||
_processCtrl.OnProcessLogRequest -= ProcessLog_Handler;
|
||||
_processCtrl.OnProcessProgressChanged -= ProcessProgress_Handler;
|
||||
_processCtrl.OnOverallProcessStateChanged -= ProcessStateChange_Handler;
|
||||
_userAccessWindow = null;
|
||||
|
||||
_processCtrl.Dispose();
|
||||
_processCtrl = null;
|
||||
_timer.Stop();
|
||||
_timer.Tick -= TmrProgressUpdate_Tick;
|
||||
_timer = null;
|
||||
_registerForm = null;
|
||||
}
|
||||
private void UseSetting(Boolean setSlot = false)
|
||||
{
|
||||
//tblkAutodetectState.Text = "Off";
|
||||
//if (Settings.AutoDetect)
|
||||
//{
|
||||
// tblkAutodetectState.Text = "On";
|
||||
//}
|
||||
if (setSlot)
|
||||
{
|
||||
cbxSlotBox.SelectedValue = Settings.Slot;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeFormState()
|
||||
{
|
||||
if (Software.IsRegistrationPending)
|
||||
{
|
||||
_registerForm = new RegisterLDAPUser();
|
||||
_registerForm.OnCancellation += OnUserAccessControlCancellation;
|
||||
UiElmEnable(optionsMenu, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiElmEnable(optionsMenu, true);
|
||||
UiElmEnable(optionsMenuChangePassword, Software.IsAutenticated);
|
||||
UiElmEnable(optionsMenuLogout, Software.IsAutenticated);
|
||||
UiElmEnable(optionsMenuLogin, !Software.IsAutenticated);
|
||||
UiElmEnable(btnStart, Software.IsAutenticated);
|
||||
UiElmEnable(btnStop, false);
|
||||
UpdateContentControl(lblOperator,
|
||||
Software.IsAutenticated
|
||||
? $"{Properties.Resources.StrLblOperatorNameText}: {Software.UserName}"
|
||||
: $"{Properties.Resources.StrLblOperatorNameText}: ?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the user access window with login form or password change form.
|
||||
/// </summary>
|
||||
/// <param name="visible"></param>
|
||||
/// <param name="control">Windows forms control</param>
|
||||
/// <param name="headerTxt"></param>
|
||||
/// <remarks date="2025-Mar-25" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private void ShowUserAccessWindow(Boolean visible = true, Control control = null, String headerTxt = "")
|
||||
{
|
||||
if (visible && control != null)
|
||||
{
|
||||
UiElmEnable(optionsMenu, false);
|
||||
|
||||
if (_userAccessWindow == null)
|
||||
_userAccessWindow = new UserAccessWindow(control, headerTxt);
|
||||
// View the user access window as container for the windows forms password change and login
|
||||
_userAccessWindow.OnCloseWindow += OnUserAccessWindowClosed_Handler;
|
||||
_userAccessWindow.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_userAccessWindow != null)
|
||||
{
|
||||
_userAccessWindow.OnCloseWindow -= OnUserAccessWindowClosed_Handler;
|
||||
try
|
||||
{
|
||||
_userAccessWindow.Close();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
_userAccessWindow = null;
|
||||
}
|
||||
|
||||
if (_registerForm != null)
|
||||
_registerForm.OnCancellation -= OnUserAccessControlCancellation;
|
||||
|
||||
UiElmEnable(optionsMenu, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close event handler of the user access window with login form or password change form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <remarks date="2025-Mar-25" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private void OnUserAccessWindowClosed_Handler(Object sender, EventArgs eventArgs)
|
||||
{
|
||||
ShowUserAccessWindow(false);
|
||||
InitializeFormState();
|
||||
}
|
||||
|
||||
private void UpdateUi(ContentControl c, String content, Brush color = null)
|
||||
{
|
||||
if (color == null)
|
||||
color = Brushes.Black;
|
||||
|
||||
c.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
c.Content = content;
|
||||
c.Foreground = color;
|
||||
}));
|
||||
}
|
||||
|
||||
private void UpdateUi(TextBox c, String content, Brush color = null)
|
||||
{
|
||||
if (color == null)
|
||||
color = Brushes.Black;
|
||||
|
||||
c.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
c.Text = content;
|
||||
c.Foreground = color;
|
||||
}));
|
||||
}
|
||||
private void UpdateUi(TextBlock c, String content, Brush color = null)
|
||||
{
|
||||
if (color == null)
|
||||
color = Brushes.Black;
|
||||
|
||||
c.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
c.Text = content;
|
||||
c.Foreground = color;
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the elapsed time as information
|
||||
/// </summary>
|
||||
/// <returns>information attached to process depending on region</returns>
|
||||
/// <remarks date="2024-Jul-11" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void SetTimeDisplay()
|
||||
{
|
||||
var time = DateTimeOffset.UtcNow;
|
||||
var timeSpan = time - _startTime;
|
||||
UpdateContentControl(lblTimeValue, $@"{(UInt32)timeSpan.TotalMinutes}:{timeSpan.Seconds:00}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Common routine for state change:
|
||||
/// - Log state change,
|
||||
/// - Execute stop procedure on error.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks date="2020-Dec-12" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-Aug-30" author="Thomas Wiedebusch">
|
||||
/// - Extended.
|
||||
/// </remarks>
|
||||
private void ProcessStateChange_Handler(Object sender, ProcessStateArgs e)
|
||||
{
|
||||
_logger.Debug($"Slot:{Slot} - Final test state: {e.State}");
|
||||
|
||||
// Nothing to display
|
||||
if (e.State == ProcessState.Idle)
|
||||
{
|
||||
// Update progress bars
|
||||
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
|
||||
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
|
||||
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
|
||||
ProcessProgressArgs.ProcessProgressType.ActualProcessSteps));
|
||||
}
|
||||
// Stop all procedures
|
||||
if (e.State == ProcessState.Stop)
|
||||
{
|
||||
_timer?.Stop();
|
||||
UiElmEnable(btnStart, true);
|
||||
UiElmEnable(btnStop, false);
|
||||
// update progress bars
|
||||
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
|
||||
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
|
||||
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
|
||||
ProcessProgressArgs.ProcessProgressType.ActualProcessSteps));
|
||||
// remove user control
|
||||
SetNewUserControl(null);
|
||||
}
|
||||
// Repeat failed tests
|
||||
if (e.State == ProcessState.RepeatFailedTests)
|
||||
{
|
||||
UiElmEnable(btnStart, false);
|
||||
UiElmEnable(btnStop, true);
|
||||
_timer?.Start();
|
||||
}
|
||||
// Stop time for manual operation and visual inspection as this is not part of the configuration
|
||||
if (e.State == ProcessState.CheckOrderNumber)
|
||||
{
|
||||
_timer?.Stop();
|
||||
}
|
||||
// Prepare shipping
|
||||
if (e.State == ProcessState.PrepareShippingMode)
|
||||
{
|
||||
_timer?.Stop();
|
||||
UiElmEnable(btnStart, false);
|
||||
UiElmEnable(btnStop, false);
|
||||
}
|
||||
// Ready for shipping
|
||||
if (e.State == ProcessState.ReadyForShipping)
|
||||
{
|
||||
StoreSuccessNote(out _);
|
||||
BtnStop_Click(this, null);
|
||||
}
|
||||
// Print return report
|
||||
if (e.State == ProcessState.PrintReturnReport)
|
||||
{
|
||||
PrintErrorNote();
|
||||
BtnStop_Click(this, null);
|
||||
}
|
||||
// Print success report
|
||||
if (e.State == ProcessState.PrintSuccessReport)
|
||||
{
|
||||
PrintSuccessNote();
|
||||
BtnStop_Click(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable UI elements
|
||||
/// </summary>
|
||||
/// <param name="elm"></param>
|
||||
/// <param name="isEnabled"></param>
|
||||
/// <param name="isVisible"></param>
|
||||
private void UiElmEnable(UIElement elm, Boolean isEnabled, Boolean isVisible = true)
|
||||
{
|
||||
elm.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
elm.Visibility = isVisible ? Visibility.Visible : Visibility.Hidden;
|
||||
elm.IsEnabled = isEnabled;
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill logging window with information
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks date="????" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-07-06" author="Thomas Wiedebusch">
|
||||
/// - Changed to rich text edit with colored output.
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-08-28" author="Thomas Wiedebusch">
|
||||
/// - Avoid output of repeated text or useless empty text.
|
||||
/// </remarks>
|
||||
private void ProcessLog_Handler(Object sender, ProcessLogArgs e)
|
||||
{
|
||||
rtbLog.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// remove unacceptable spacing between the lines
|
||||
rtbLog.Document.LineHeight = 1;
|
||||
|
||||
var color = e.Color ?? Brushes.Black;
|
||||
var text = e.Data;
|
||||
if (!string.IsNullOrEmpty(text) && !text.Equals(_lastLoggingTextToAvoidRepetition))
|
||||
{
|
||||
var tr = new TextRange(rtbLog.Document.ContentEnd, rtbLog.Document.ContentEnd)
|
||||
{
|
||||
Text = text
|
||||
};
|
||||
tr.ApplyPropertyValue(TextElement.ForegroundProperty, color);
|
||||
rtbLog.ScrollToEnd();
|
||||
rtbLog.AppendText(Environment.NewLine);
|
||||
}
|
||||
|
||||
_lastLoggingTextToAvoidRepetition = text;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set values for progress bar, maximum and actual for single process and overall process.
|
||||
/// - Limit values to 0.0..100.0.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks date="????" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-07-18" author="Thomas Wiedebusch">
|
||||
/// - Introduced multi line text with center alignment.
|
||||
/// </remarks>
|
||||
private void ProcessProgress_Handler(Object sender, ProcessProgressArgs e)
|
||||
{
|
||||
if (e.ProgressType == ProcessProgressArgs.ProcessProgressType.MaxOverallProcessSteps)
|
||||
{
|
||||
_maxOverallProcessSteps = e.Progress;
|
||||
}
|
||||
else if (e.ProgressType == ProcessProgressArgs.ProcessProgressType.MaxActualProcessSteps)
|
||||
{
|
||||
_maxSingleProcessSteps = e.Progress;
|
||||
}
|
||||
if (e.ProgressType == ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps)
|
||||
{
|
||||
pbTotalProgress.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
// limit output to progress bar to 0..100 as integer for process bar
|
||||
var progress = _maxOverallProcessSteps <= 0 ? 0.0 : e.Progress * 100.0 / _maxOverallProcessSteps;
|
||||
progress = progress > 100.0 ? 100.0 : progress < 0.0 ? 0.0 : progress;
|
||||
pbTotalProgress.Value = (Int32)progress;
|
||||
UpdateContentControl(lblTotalProgressValue, $@"{progress:##0.0} %");
|
||||
}
|
||||
));
|
||||
}
|
||||
else if (e.ProgressType == ProcessProgressArgs.ProcessProgressType.ActualProcessSteps)
|
||||
{
|
||||
pbSubProgress.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
// limit output to progress bar to 0..100 as integer for process bar
|
||||
var progress = _maxSingleProcessSteps <= 0 ? 0.0 : e.Progress * 100.0 / _maxSingleProcessSteps;
|
||||
progress = progress > 100.0 ? 100.0 : progress < 0.0 ? 0.0 : progress;
|
||||
pbSubProgress.Value = (Int32)progress;
|
||||
UpdateContentControl(lblSubProgressValue, $@"{progress:##0.0} %");
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output message to control without access violation.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="????" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-07-11" author="Thomas Wiedebusch">
|
||||
/// - Introduced multi line text with center alignment.
|
||||
/// </remarks>
|
||||
private static void UpdateContentControl(ContentControl ctl, String text)
|
||||
{
|
||||
ctl.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
ctl.Content = new TextBlock()
|
||||
{
|
||||
Text = text,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
TextAlignment = TextAlignment.Center
|
||||
};
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Status grid update for all single processes
|
||||
/// </summary>
|
||||
private void UpdateStatusGrid()
|
||||
{
|
||||
var dt = new DataTable();
|
||||
dt.Columns.Add(Properties.Resources.StrDataTableColumnProcess);
|
||||
dt.Columns.Add(Properties.Resources.StrDataTableColumnState);
|
||||
var i = 0;
|
||||
if (_processCtrl?.Processes == null)
|
||||
return;
|
||||
foreach (var item in _processCtrl.Processes)
|
||||
{
|
||||
dt.Rows.Add();
|
||||
dt.Rows[i][0] = item.ProcessName;
|
||||
dt.Rows[i][1] = ProductionProcessStateHelper.GetTextFromProductionProcessState(item.SingleProcessState);
|
||||
i++;
|
||||
}
|
||||
|
||||
dgTotalProcess.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
dgTotalProcess.DataContext = dt;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatch new user control to main screen
|
||||
/// </summary>
|
||||
/// <param name="uc"></param>
|
||||
private void SetNewUserControl(UserControl uc)
|
||||
{
|
||||
dgTotalProcess.Dispatcher.Invoke(DispatcherPriority.Normal,
|
||||
new Action(() =>
|
||||
{
|
||||
// remove last userControl
|
||||
dpSubProcess.Children.Clear();
|
||||
if (uc != null)
|
||||
{
|
||||
dpSubProcess.Children.Add(uc);
|
||||
DockPanel.SetDock(uc, Dock.Top); // & Dock.Left);
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
#region TimerControls
|
||||
/// <summary>
|
||||
/// Handle timing depending updates.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2024-07-11" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private void TmrProgressUpdate_Tick(Object sender, EventArgs e)
|
||||
{
|
||||
SetTimeDisplay();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Update of status grid with information returned by user control.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks date="????" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-08-28" author="Thomas Wiedebusch">
|
||||
/// - Activate new user control on start of process.
|
||||
/// </remarks>
|
||||
private void SingleProcessStateChanged_Handler(Object sender, SingleProcessStateArgs e)
|
||||
{
|
||||
if (sender is IProductionProcess productionProcess)
|
||||
{
|
||||
if (e.SingleProcessState == SingleProcessState.Running)
|
||||
{
|
||||
// Set new user control
|
||||
SetNewUserControl(productionProcess.GetUserControl());
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove user control on idle, skipped, abort or error
|
||||
SetNewUserControl(null);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateStatusGrid();
|
||||
UpdateGuiWithProductInfos();
|
||||
}
|
||||
|
||||
private void OnUserAccessControlCancellation(Control control)
|
||||
{
|
||||
OnUserAccessWindowClosed_Handler(this, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set labels of device information and order number
|
||||
/// </summary>
|
||||
/// <remarks date="????" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2024-07-15" author="Thomas Wiedebusch">
|
||||
/// - Additional info of Cordonel.
|
||||
/// </remarks>
|
||||
private void UpdateGuiWithProductInfos()
|
||||
{
|
||||
var genesisMeter = _processCtrl?.GetGenesisMeter();
|
||||
_productionRequirements = _processCtrl?.GetProductionRequirements();
|
||||
|
||||
if (genesisMeter == null)
|
||||
return;
|
||||
|
||||
UpdateContentControl(lblOrderNumberValue,
|
||||
genesisMeter.OrderNumber != 0 ? genesisMeter.OrderNumber.ToString() : "?");
|
||||
|
||||
UpdateContentControl(lblRadioAddressValue,
|
||||
genesisMeter.RadioAddress != 0 ? genesisMeter.RadioAddress.ToString() : "");
|
||||
UpdateContentControl(lblRadioAddressText,
|
||||
genesisMeter.RadioAddress != 0 ? Properties.Resources.StrLblRadioAddressTxt + ":" : "");
|
||||
|
||||
UpdateContentControl(lblFwValue,
|
||||
!string.IsNullOrEmpty(genesisMeter.FwVersion) ? genesisMeter.FwVersion : "?");
|
||||
|
||||
UpdateContentControl(lblMeterSizeValue,
|
||||
!string.IsNullOrEmpty(genesisMeter.MeterSize) ? genesisMeter.MeterSize : "?");
|
||||
|
||||
UpdateContentControl(lblLutValue,
|
||||
!string.IsNullOrEmpty(genesisMeter.LutCrc) ? genesisMeter.LutCrc : "?");
|
||||
|
||||
|
||||
UpdateContentControl(lblSerialNumberValue,
|
||||
!string.IsNullOrEmpty(genesisMeter.CustomerSerialNumber) ? genesisMeter.CustomerSerialNumber : "?");
|
||||
|
||||
UpdateContentControl(lblRegionValue,
|
||||
!string.IsNullOrEmpty(genesisMeter.Region) ? genesisMeter.Region : "?");
|
||||
|
||||
UpdateUi(lblPcbIdValue, !string.IsNullOrEmpty(genesisMeter.PcbId) ? genesisMeter.PcbId : "?");
|
||||
|
||||
var msg = "";
|
||||
var color = Brushes.Black;
|
||||
if (_productionRequirements?.IsSpecialActive != null && (Boolean)_productionRequirements.IsSpecialActive &&
|
||||
_productionRequirements?.IsSpecialApproved != null && (Boolean)_productionRequirements.IsSpecialApproved)
|
||||
{
|
||||
msg = $"{Properties.Resources.StrLblSpecialRequirement} - Id.Ver: {_productionRequirements.SpecialId}." +
|
||||
$"{_productionRequirements.SpecialVersion}";
|
||||
color = Brushes.Red;
|
||||
}
|
||||
else if (_productionRequirements?.IsStandardActive != null && (Boolean)_productionRequirements.IsStandardActive &&
|
||||
_productionRequirements?.IsStandardApproved != null && (Boolean)_productionRequirements.IsStandardApproved)
|
||||
{
|
||||
msg = $"{Properties.Resources.StrLblStandardRequirement} - Id.Ver: {_productionRequirements.StandardId}." +
|
||||
$"{_productionRequirements.StandardVersion}";
|
||||
}
|
||||
|
||||
UpdateUi(lblApprovalText, msg, color);
|
||||
}
|
||||
|
||||
//private void BtnSwitchAutoDetect_Click(Object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// //Settings.AutoDetect = !Settings.AutoDetect;
|
||||
// //StoreSetting();
|
||||
// //UseSetting();
|
||||
//}
|
||||
|
||||
private void OnLogout_Click(Object sender, EventArgs e)
|
||||
{
|
||||
Software.Logout();
|
||||
InitializeFormState();
|
||||
}
|
||||
|
||||
private void OnLogin_Click(Object sender, EventArgs args)
|
||||
{
|
||||
ShowUserAccessWindow(true, new LoginForm(OnUserAccessControlCancellation),
|
||||
Properties.Resources.StrLoginMsg);
|
||||
}
|
||||
|
||||
private void OnChangePassword_Click(Object _, EventArgs _1)
|
||||
{
|
||||
ShowUserAccessWindow(true, new ChangePassword(OnUserAccessControlCancellation),
|
||||
Properties.Resources.StrChangePasswordMsg);
|
||||
}
|
||||
|
||||
private void CbxSlotBox_SelectionChanged(Object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void StoreSetting()
|
||||
{
|
||||
Settings.Update("ProductionUiConfig.json");
|
||||
}
|
||||
|
||||
//private void BtnConnect_Click(Object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// Settings.Slot = (Int32)cbxSlotBox.SelectedValue;
|
||||
// StoreSetting();
|
||||
//}
|
||||
|
||||
private void BtnStart_Click(Object sender, RoutedEventArgs e)
|
||||
{
|
||||
UiElmEnable(btnStart, false);
|
||||
UiElmEnable(btnStop, true);
|
||||
|
||||
_startTime = DateTimeOffset.UtcNow;
|
||||
_timer?.Start();
|
||||
|
||||
// remove last userControl
|
||||
dpSubProcess.Children.Clear();
|
||||
rtbLog.Document.Blocks.Clear();
|
||||
_processCtrl?.SetProcessState(ProcessState.DetectCordonel);
|
||||
}
|
||||
|
||||
private void PrintErrorNote()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("========================================================================");
|
||||
sb.AppendLine(Properties.Resources.StrInstructionReturnPapers);
|
||||
sb.AppendLine("========================================================================");
|
||||
CreateFile(sb, out var fileName);
|
||||
Process.Start(fileName);
|
||||
}
|
||||
|
||||
private void StoreSuccessNote(out String fileName)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("========================================================================");
|
||||
sb.AppendLine(Properties.Resources.StrInfoSuccessPapers);
|
||||
sb.AppendLine("========================================================================");
|
||||
CreateFile(sb, out fileName);
|
||||
}
|
||||
|
||||
private void PrintSuccessNote()
|
||||
{
|
||||
StoreSuccessNote(out var fileName);
|
||||
Process.Start(fileName);
|
||||
}
|
||||
|
||||
private void CreateFile(StringBuilder sb, out String fileName)
|
||||
{
|
||||
if (sb == null)
|
||||
sb = new StringBuilder();
|
||||
|
||||
var genesisMeter = _processCtrl.GetGenesisMeter();
|
||||
var loggingPath = $"C:\\GenesisLog\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\";
|
||||
fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}_Report_{genesisMeter.PcbId}.txt";
|
||||
|
||||
sb.AppendLine(_strSoftwareNameVersion);
|
||||
sb.AppendLine("------------------------------------------------------------------------");
|
||||
sb.AppendLine($"{Properties.Resources.StrDateTime}: {DateTime.Now}");
|
||||
sb.AppendLine("------------------------------------------------------------------------");
|
||||
sb.AppendLine($"PcbId: {genesisMeter.PcbId}");
|
||||
sb.AppendLine($"{Properties.Resources.StrPrintOrderNumberTxt}: {genesisMeter.OrderNumber}");
|
||||
sb.AppendLine($"{Properties.Resources.StrLblSerialNumberTxt}: {genesisMeter.CustomerSerialNumber}");
|
||||
sb.AppendLine($"{Properties.Resources.StrLblOperatorNameText}: {Software.UserName}");
|
||||
sb.AppendLine("------------------------------------------------------------------------");
|
||||
var rtbText = new TextRange(
|
||||
rtbLog.Document.ContentStart,
|
||||
rtbLog.Document.ContentEnd
|
||||
);
|
||||
sb.Append($"{rtbText.Text}");
|
||||
File.WriteAllText(fileName, sb.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop button as user interaction to kill the finalization process
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void BtnStop_Click(Object sender, RoutedEventArgs e)
|
||||
{
|
||||
//set the process state to the state machine
|
||||
_processCtrl?.SetProcessState(ProcessState.Stop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open requirement in Web-Browser.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LblApprovalText_Click(Object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
var requirementId = 0;
|
||||
var requirementWebPageLink = ServiceUrls.InspectCordonelRequirementInfoServiceUrl();
|
||||
if (_productionRequirements?.SpecialId != null &&
|
||||
_productionRequirements?.IsSpecialApproved != null &&
|
||||
_productionRequirements.SpecialId != 0)
|
||||
{
|
||||
requirementId = (Int32)_productionRequirements.SpecialId;
|
||||
requirementWebPageLink += $"SpecialRequirements#{requirementId}";
|
||||
}
|
||||
else if (_productionRequirements?.StandardId != null &&
|
||||
_productionRequirements?.IsStandardApproved != null &&
|
||||
_productionRequirements.StandardId != 0)
|
||||
{
|
||||
requirementId = (Int32)_productionRequirements.StandardId;
|
||||
requirementWebPageLink += $"StandardRequirements#{requirementId}";
|
||||
}
|
||||
|
||||
if (requirementId != 0)
|
||||
{
|
||||
Process.Start(requirementWebPageLink);
|
||||
}
|
||||
}
|
||||
|
||||
private void HlpMenu_Click(Object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var filename = "";
|
||||
if (Thread.CurrentThread.CurrentCulture.Name.Contains("de"))
|
||||
{
|
||||
filename = Path.Combine(_assemblyExecRootPath, "Docu", @"Handbuch Cordonel Versandfertigmachen (VFM).pdf");
|
||||
}
|
||||
else if (Thread.CurrentThread.CurrentCulture.Name.Contains("en"))
|
||||
{
|
||||
filename = Path.Combine(_assemblyExecRootPath, "Docu", @"Manual Cordonel End of Line Test (EOL).pdf");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filename))
|
||||
{
|
||||
Process.Start(filename);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(Object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!Software.IsAutenticated)
|
||||
OnLogin_Click(this, null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,8 +312,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
|
||||
exitProcessStateObjects[2] = breakExitState;
|
||||
|
||||
var processExec = new ProcessExec();
|
||||
processExec.NewProcess(InitProcess, PreExecuteProcess, ExecuteProcess, FinalizeProcess,
|
||||
processExec.NewProcess(InitProcess, PreExecuteProcess, ExecuteProcess, FinalizeProcess,
|
||||
_cultureInfo, exitProcessStateObjects, CancellationToken);
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IProductionProcess"/>
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// Genesis meter final test states
|
||||
/// </summary>
|
||||
public enum PickingProcessState
|
||||
{
|
||||
/// <summary>
|
||||
/// Idle (nothing to do)
|
||||
/// </summary>
|
||||
Idle,
|
||||
|
||||
/// <summary>
|
||||
/// Idle (nothing to do)
|
||||
/// </summary>
|
||||
ScanOrder,
|
||||
/// <summary>
|
||||
/// New meter detected for marker to clear all process contents like production status
|
||||
/// and programming parameters.
|
||||
/// </summary>
|
||||
CheckNewMeter,
|
||||
/// <summary>
|
||||
/// Error handling
|
||||
/// </summary>
|
||||
Error,
|
||||
/// <summary>
|
||||
/// Abort final test execution
|
||||
/// </summary>
|
||||
Abort,
|
||||
/// <summary>
|
||||
/// Repeat the entire final test
|
||||
/// </summary>
|
||||
RepeatFailedTests,
|
||||
/// <summary>
|
||||
/// Final test failed
|
||||
/// </summary>
|
||||
PickingFailed,
|
||||
/// <summary>
|
||||
/// User stopped process
|
||||
/// </summary>
|
||||
Stop,
|
||||
/// <summary>
|
||||
/// Check the actual production state if all steps are executed
|
||||
/// </summary>
|
||||
DetectCordonel,
|
||||
/// <summary>
|
||||
/// Connect to Cordonel
|
||||
/// </summary>
|
||||
ConnectCordonel,
|
||||
/// <summary>
|
||||
/// Request the serial number and radio address from DB
|
||||
/// </summary>
|
||||
GetPickingParameters,
|
||||
/// <summary>
|
||||
/// Check the radio functionality
|
||||
/// </summary>
|
||||
CompareMeterDetails,
|
||||
InstallLut,
|
||||
//todo ad excisting processstates
|
||||
|
||||
|
||||
|
||||
PrintReturnReport,
|
||||
/// <summary>
|
||||
/// Print success report
|
||||
/// </summary>
|
||||
PrintSuccessReport,
|
||||
/// <summary>
|
||||
/// Delimiter for list
|
||||
/// </summary>
|
||||
StateListDelimiter
|
||||
}
|
||||
}
|
||||
@@ -283,6 +283,9 @@
|
||||
<Compile Include="ctls\ctlMultiModePressure.xaml.cs">
|
||||
<DependentUpon>ctlMultiModePressure.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Picking.xaml.cs">
|
||||
<DependentUpon>Picking.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Model\EOLHandler.cs" />
|
||||
<Compile Include="ProductionProcesses\EolProcesses\VisualInspection.cs" />
|
||||
<Compile Include="ProductionProcesses\EolProcesses\ErrorHandler.cs" />
|
||||
@@ -371,6 +374,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Picking.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="FinalTest.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -610,6 +617,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Enum\" />
|
||||
<Folder Include="ProductionProcesses\PickingProcesses\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ProcessStateChange_Handler
|
||||
Reference in New Issue
Block a user