<Feat>: Add universal NLog diagnostics and improve AppDiagnostic UI
Cause: - Live diagnostics required logging from multiple applications without blocking TBF. - Shared nlog.config files caused configuration conflicts. - The original viewer lacked configurable colors and practical log controls. - Inconsistent diagnostic deployment caused log transfer failures and locked shared DLLs during builds. Solution: 1. Added universal diagnostic transport - Added AppDiagnostic.Logging with an NLog target and named-pipe communication. - Added background buffering and automatic reconnection. - Registered the diagnostic connector programmatically. 2. Separated diagnostic window lifecycle - Run AppDiagnostic as an independent process. - Activate the existing window on repeated launches. - Keep TBF running when the diagnostic window closes. 3. Corrected diagnostic deployment - Copy the complete diagnostic output into a dedicated AppDiagnostic subdirectory during build. - Overwrite existing deployment files to prevent inconsistent versions. - Validate and launch the executable from that subdirectory with an explicit working directory. 4. Improved the log viewer - Added configurable substring colors with a palette and live preview. - Added text, level and application filters. - Added line wrapping, clipboard actions and log export. - Added Pause/Resume, Refresh, Clear, auto-scroll and Always on top. - Added connection and log counters. - Persist color rules between sessions. 5. Removed legacy dependencies - Replaced LiveLogCache with structured diagnostic storage. - Removed AppDiagnostic dependencies on log4net and SharedComponents. Validation: - Confirmed successful log transfer when launching AppDiagnostic from TBF.
This commit is contained in:
+189
-169
@@ -22,6 +22,8 @@ using SharedComponents;
|
||||
using System.Diagnostics;
|
||||
using TBF.Rig.TestMethods.iPerlCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.UI
|
||||
{
|
||||
@@ -31,6 +33,7 @@ namespace TBF.UI
|
||||
public partial class MainWnd : Form
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(MainWnd));
|
||||
private static readonly NLog.Logger diagnosticLogger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// Used when re-scaling the dialog: 100% = 96dpi, 125% = 120dpi, 150% = 144dpi
|
||||
public static int Dpi;
|
||||
@@ -49,7 +52,7 @@ namespace TBF.UI
|
||||
IList<SharedDatabase.Entities.OrderInfo> tracingDBOrders; /// Production orders loaded from the production tracing DB
|
||||
IList<TBF.Rig.Output.DB.SensusOracle.OrderDetails> oracleOrders; /// Production orders loaded from the Oracle DB
|
||||
IList<ProcedureInfo> procedureInfos; /// Composed procedure infos
|
||||
///
|
||||
///
|
||||
public ProcedureInfo SelectedProcedure;
|
||||
public Procedure CurrentProcedure;
|
||||
|
||||
@@ -58,7 +61,7 @@ namespace TBF.UI
|
||||
/// </summary>
|
||||
Shared.ModelessActivityForm closingTbfMessageForm;
|
||||
|
||||
TestProgressControls testProgressControls;
|
||||
TestProgressControls testProgressControls;
|
||||
|
||||
/// <summary>
|
||||
/// Set when procedures are updated while the ProceduresComboBox is disabled (i.e. during a test).
|
||||
@@ -78,36 +81,36 @@ namespace TBF.UI
|
||||
{
|
||||
Invalid = -1,
|
||||
Hydraulics = 0,
|
||||
Process,
|
||||
Process,
|
||||
Insert,
|
||||
Results,
|
||||
Results,
|
||||
Graphs,
|
||||
Events,
|
||||
Calendar,
|
||||
Camera,
|
||||
TabPagesCount
|
||||
TabPagesCount
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handlers switching between tab pages
|
||||
/// </summary>
|
||||
private void homeTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Hydraulics); }
|
||||
private void processTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Process); }
|
||||
private void resultsTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Results); }
|
||||
private void graphsToolStripMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Graphs); }
|
||||
private void eventsTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Events); }
|
||||
private void processTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Process); }
|
||||
private void resultsTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Results); }
|
||||
private void graphsToolStripMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Graphs); }
|
||||
private void eventsTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Events); }
|
||||
private void calendarTSMenuItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Calendar); }
|
||||
|
||||
#if CAMERA
|
||||
private System.Windows.Forms.ToolStripMenuItem cameraTSMItem;
|
||||
private void cameraTSMItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Camera); }
|
||||
private System.Windows.Forms.ToolStripMenuItem cameraTSMItem;
|
||||
private void cameraTSMItem_Click(object sender, EventArgs e) { mainTabControl.SelectTab((int)MainTabPageId.Camera); }
|
||||
#endif
|
||||
|
||||
/// DB entities of components loaded in the MainWnd constructor
|
||||
IList<Config.Entities.Component> cmpntEntities;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public MainWnd()
|
||||
@@ -130,24 +133,24 @@ namespace TBF.UI
|
||||
procedureInfos = new List<ProcedureInfo>();
|
||||
SelectedProcedure = null;
|
||||
CurrentProcedure = null;
|
||||
|
||||
///
|
||||
/// Customize menu items
|
||||
///
|
||||
#if CAMERA
|
||||
/// Add 'Camera' menu item
|
||||
cameraTSMItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
||||
cameraTSMItem.Name = "cameraTSMItem";
|
||||
cameraTSMItem.Text = Strings.Camera;
|
||||
cameraTSMItem.Click += new System.EventHandler(this.cameraTSMItem_Click);
|
||||
|
||||
mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.cameraTSMItem});
|
||||
///
|
||||
/// Customize menu items
|
||||
///
|
||||
#if CAMERA
|
||||
/// Add 'Camera' menu item
|
||||
cameraTSMItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
||||
cameraTSMItem.Name = "cameraTSMItem";
|
||||
cameraTSMItem.Text = Strings.Camera;
|
||||
cameraTSMItem.Click += new System.EventHandler(this.cameraTSMItem_Click);
|
||||
|
||||
mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.cameraTSMItem });
|
||||
#endif
|
||||
UpdateMenuItemsVisibility();
|
||||
|
||||
optoHeadsToolStripMenuItem.Visible = true;
|
||||
optoHeadsToolStripMenuItem.Enabled = false;
|
||||
optoHeadsToolStripMenuItem.Enabled = false;
|
||||
|
||||
IsShutdownDisabled = true;
|
||||
IsShutdownPCAfterClosingTbf = false;
|
||||
@@ -166,11 +169,11 @@ namespace TBF.UI
|
||||
|
||||
Rig.StateMachine.MachineState = TBF.DB.CurrentBench.IsRealBench ? Rig.MachineState.StartingUp : Rig.MachineState.Disabled;
|
||||
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
//define always valid for printer test - BUMI
|
||||
Rig.StateMachine.MachineState = Rig.MachineState.StartingUp;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
///
|
||||
if (Rig.StateMachine.MachineState == Rig.MachineState.StartingUp)
|
||||
{
|
||||
@@ -230,20 +233,20 @@ namespace TBF.UI
|
||||
}
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
void Localize()
|
||||
{
|
||||
///
|
||||
/// Menu
|
||||
///
|
||||
benchTSMenuItem.Text = Strings.Bench;
|
||||
benchComponentsTSMenuItem.Text = Strings.Components;
|
||||
benchPathsTSMenuItem.Text = Strings.Paths;
|
||||
benchTransitionsToolStripMenuItem.Text = Strings.Transitions;
|
||||
benchMetrologyTSMenuItem.Text = Strings.Metrology;
|
||||
benchUncertaintyTSMItem.Text = Strings.Uncertainty;
|
||||
benchTestProfilesTSMItem.Text = Strings.Test_profiles;
|
||||
editSchDrawingTSMItem.Text = Strings.Edit_schematic_drawing;
|
||||
exitToolStripMenuItem.Text = Strings.Exit;
|
||||
benchComponentsTSMenuItem.Text = Strings.Components;
|
||||
benchPathsTSMenuItem.Text = Strings.Paths;
|
||||
benchTransitionsToolStripMenuItem.Text = Strings.Transitions;
|
||||
benchMetrologyTSMenuItem.Text = Strings.Metrology;
|
||||
benchUncertaintyTSMItem.Text = Strings.Uncertainty;
|
||||
benchTestProfilesTSMItem.Text = Strings.Test_profiles;
|
||||
editSchDrawingTSMItem.Text = Strings.Edit_schematic_drawing;
|
||||
exitToolStripMenuItem.Text = Strings.Exit;
|
||||
proceduresToolStripMenuItem.Text = Strings.Procedures;
|
||||
homeTSMenuItem.Text = Strings.Home;
|
||||
processToolStripMenuItem.Text = Strings.Process;
|
||||
@@ -252,31 +255,31 @@ namespace TBF.UI
|
||||
eventLogsTSMenuItem.Text = Strings.Event_logs;
|
||||
calendarTSMenuItem.Text = Strings.Calendar;
|
||||
settingsTSMenuItem.Text = Strings.Settings;
|
||||
usersTSMenuItem.Text = Strings.Users;
|
||||
languageTSMItem.Text = Strings.Language;
|
||||
databaseSettingsTSMenuItem.Text = Strings.Database;
|
||||
backUpTSMItem.Text = Strings.Backup;
|
||||
backUpConfigTSMItem.Text = Strings.Configuration;
|
||||
backUpResultsTSMItem.Text = Strings.Results;
|
||||
passwdTSMItem.Text = Strings.Password;
|
||||
upgradeTSMenuItem.Text = Strings.Upgrade_DB;
|
||||
usersTSMenuItem.Text = Strings.Users;
|
||||
languageTSMItem.Text = Strings.Language;
|
||||
databaseSettingsTSMenuItem.Text = Strings.Database;
|
||||
backUpTSMItem.Text = Strings.Backup;
|
||||
backUpConfigTSMItem.Text = Strings.Configuration;
|
||||
backUpResultsTSMItem.Text = Strings.Results;
|
||||
passwdTSMItem.Text = Strings.Password;
|
||||
upgradeTSMenuItem.Text = Strings.Upgrade_DB;
|
||||
appDiagnosticMenuItem.Text = Strings.Application_Diagnostic;
|
||||
optoHeadsToolStripMenuItem.Text = Strings.Optical_heads;
|
||||
clearCountersToolStripMenuItem.Text = Strings.Clear_counters;
|
||||
clearCountersToolStripMenuItem.Text = Strings.Clear_counters;
|
||||
helpTSMenuItem.Text = Strings.Help;
|
||||
aboutTSMenuItem.Text = Strings.About;
|
||||
|
||||
aboutTSMenuItem.Text = Strings.About;
|
||||
|
||||
procedureGroupBox.Text = Strings.Procedure;
|
||||
activityGroupBox.Text = Strings.Activity;
|
||||
progressGroupBox.Text = Strings.Progress;
|
||||
}
|
||||
activityGroupBox.Text = Strings.Activity;
|
||||
progressGroupBox.Text = Strings.Progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this window and its controls
|
||||
/// </summary>
|
||||
private void MainWnd_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
Localize();
|
||||
|
||||
TBF.LocalSettings ls = Program.LocalSettings;
|
||||
WindowState = (ls.MainWndMaximized ? FormWindowState.Maximized : FormWindowState.Normal);
|
||||
@@ -297,23 +300,23 @@ namespace TBF.UI
|
||||
|
||||
if (TBF.Rig.StateMachine.MachineState == TBF.Rig.MachineState.StartingUp)
|
||||
{
|
||||
var form = new Shared.ModelessActivityForm()
|
||||
{
|
||||
Message = Strings.Starting_system,
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.OliveDrab, /// or Color.YellowGreen
|
||||
StartActivityHandler = true,
|
||||
};
|
||||
Thread formThread = new Thread(() => form.ShowDialog());
|
||||
formThread.Start();
|
||||
var form = new Shared.ModelessActivityForm()
|
||||
{
|
||||
Message = Strings.Starting_system,
|
||||
FontFamily = "Arial",
|
||||
FontSize = 24,
|
||||
FontStyle = FontStyle.Regular,
|
||||
BackgroundColor = Color.OliveDrab, /// or Color.YellowGreen
|
||||
StartActivityHandler = true,
|
||||
};
|
||||
Thread formThread = new Thread(() => form.ShowDialog());
|
||||
formThread.Start();
|
||||
|
||||
try
|
||||
{
|
||||
string message = Rig.StateMachine.InitializeDevices();
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
#if !DEBUG
|
||||
if (message != null)
|
||||
{
|
||||
@@ -324,43 +327,43 @@ namespace TBF.UI
|
||||
}
|
||||
#endif
|
||||
|
||||
Bridge.ButtonsEtcHandler += delegate(object sndr, ButtonsEtcEventArgs args)
|
||||
Bridge.ButtonsEtcHandler += delegate (object sndr, ButtonsEtcEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<ButtonsEtcEventArgs>(OnButtonsEtc), sndr, args); }
|
||||
else OnButtonsEtc(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.ActivityHandler += delegate(object sndr, UiBridge.ActivityEventArgs args)
|
||||
Bridge.ActivityHandler += delegate (object sndr, UiBridge.ActivityEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.ActivityEventArgs>(OnActivity), sndr, args); }
|
||||
else OnActivity(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.StateChangedHandler += delegate(object sndr, UiBridge.StateChangedEventArgs args)
|
||||
Bridge.StateChangedHandler += delegate (object sndr, UiBridge.StateChangedEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.StateChangedEventArgs>(OnStateChanged), sndr, args); }
|
||||
else OnStateChanged(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.StateMachineTickHandler += delegate(object sndr, UiBridge.StateMachineTickEventArgs args)
|
||||
Bridge.StateMachineTickHandler += delegate (object sndr, UiBridge.StateMachineTickEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.StateMachineTickEventArgs>(OnStateMachineTick), sndr, args); }
|
||||
else OnStateMachineTick(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.TestProgressHandler += delegate(object sndr, UiBridge.TestProgressEventArgs args)
|
||||
Bridge.TestProgressHandler += delegate (object sndr, UiBridge.TestProgressEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.TestProgressEventArgs>(OnTestProgress), sndr, args); }
|
||||
else OnTestProgress(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.ProcedureSelectedHandler += delegate(object sndr, UiBridge.ProcedureSelectedEventArgs args)
|
||||
Bridge.ProcedureSelectedHandler += delegate (object sndr, UiBridge.ProcedureSelectedEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.ProcedureSelectedEventArgs>(OnProcedureSelected), sndr, args); }
|
||||
else OnProcedureSelected(sndr, args);
|
||||
};
|
||||
|
||||
Bridge.SaveSettingsHandler += delegate(object sndr, UiBridge.SaveSettingsEventArgs args)
|
||||
Bridge.SaveSettingsHandler += delegate (object sndr, UiBridge.SaveSettingsEventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<UiBridge.SaveSettingsEventArgs>(OnSaveSettings), sndr, args); }
|
||||
else OnSaveSettings(sndr, args);
|
||||
@@ -370,10 +373,10 @@ namespace TBF.UI
|
||||
{
|
||||
TBF.Rig.StateMachine.MachineState = TBF.Rig.MachineState.FailedToStart;
|
||||
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
form.CloseForm(null, new EventArgs());
|
||||
formThread.Join();
|
||||
|
||||
string errMsg = string.Format(Strings.Failed_to_initialize_device_0_1_2,
|
||||
string errMsg = string.Format(Strings.Failed_to_initialize_device_0_1_2,
|
||||
Rig.StateMachine.CurrentlyInitializedComponentName,
|
||||
Environment.NewLine,
|
||||
exc.Message);
|
||||
@@ -390,26 +393,26 @@ namespace TBF.UI
|
||||
SelectedProcedure = new ProcedureInfo(ls.LastProcedureSource, ls.LastProcedureNr, ls.LastProcedureName, signature);
|
||||
procedureComboBox.Text = SelectedProcedure.ToString();
|
||||
|
||||
rightHorizSplitContainer.SplitterDistance = Program.LocalSettings.RightPaneHorizSplitterDistance;
|
||||
topVerticalSplitContainer.SplitterDistance = Program.LocalSettings.TopPaneVerticalSplitterDistance;
|
||||
rightHorizSplitContainer.SplitterDistance = Program.LocalSettings.RightPaneHorizSplitterDistance;
|
||||
topVerticalSplitContainer.SplitterDistance = Program.LocalSettings.TopPaneVerticalSplitterDistance;
|
||||
|
||||
/// Initialize bench control user interface(s)
|
||||
BenchControlPanel = new BenchControlPanel();
|
||||
/// Initialize bench control user interface(s)
|
||||
BenchControlPanel = new BenchControlPanel();
|
||||
BenchControlPanel.BalancesCount = TBF.Rig.StateMachine.Tank3 != null ? 3
|
||||
: TBF.Rig.StateMachine.Tank2 != null ? 2
|
||||
: TBF.Rig.StateMachine.Tank1 != null ? 1
|
||||
: 0;
|
||||
new System.ComponentModel.ComponentResourceManager(typeof(MainWnd)).ApplyResources(BenchControlPanel, "benchControlPanel");
|
||||
BenchControlPanel.Name = "benchControlPanel";
|
||||
rightHorizSplitContainer.Panel2.Controls.Add(BenchControlPanel);
|
||||
new System.ComponentModel.ComponentResourceManager(typeof(MainWnd)).ApplyResources(BenchControlPanel, "benchControlPanel");
|
||||
BenchControlPanel.Name = "benchControlPanel";
|
||||
rightHorizSplitContainer.Panel2.Controls.Add(BenchControlPanel);
|
||||
|
||||
ReloadProcedureComboBoxItems();
|
||||
ReloadProcedureComboBoxItems();
|
||||
|
||||
/// Select the initial tab page
|
||||
mainTabControl.SelectTab((int)MainTabPageId.Process); /// This is to load the 'Process screen'
|
||||
mainTabControl.SelectTab((int)MainTabPageId.Calendar); /// This is to load the 'Calendar screen'
|
||||
UpdateUser();
|
||||
mainTabControl.SelectTab((int)MainTabPageId.Hydraulics);
|
||||
mainTabControl.SelectTab((int)MainTabPageId.Hydraulics);
|
||||
|
||||
processTabPageCtrl.Settings2UI();
|
||||
|
||||
@@ -422,10 +425,10 @@ namespace TBF.UI
|
||||
string[] edgesLcfg = null;
|
||||
string[] edgesXLcfg = null;
|
||||
///
|
||||
var schDrawingCmpnts = (TBF.DB.CurrentBench.IsRealBench && Rig.StateMachine.Components != null)
|
||||
var schDrawingCmpnts = (TBF.DB.CurrentBench.IsRealBench && Rig.StateMachine.Components != null)
|
||||
? Rig.StateMachine.Components
|
||||
: TBF.Rig.TbfComponents.LoadComponentsFromDB(cmpntEntities);
|
||||
|
||||
|
||||
foreach (var component in schDrawingCmpnts)
|
||||
{
|
||||
TBF.Rig.Generic.IComponentCfg cmpCfg = component.Cfg;
|
||||
@@ -488,11 +491,11 @@ namespace TBF.UI
|
||||
topVerticalSplitContainer.SplitterDistance = topVerticalSplitContainer.Width / 2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass any pressed keys to the Bench control panel.
|
||||
/// Note that MainWnd.KeyPreview must be set to true.
|
||||
/// </summary>
|
||||
private void MainWnd_KeyPress(object sender, KeyPressEventArgs e)
|
||||
/// <summary>
|
||||
/// Pass any pressed keys to the Bench control panel.
|
||||
/// Note that MainWnd.KeyPreview must be set to true.
|
||||
/// </summary>
|
||||
private void MainWnd_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
#if BADGER_MALA_TRAT || BADGER_STREDNA_TRAT || BADGER_VELKA_TRAT || GENESIS || CEVAK_200 || TURA_SPECIAL || TURA_IPERL || TURA_IPERL_NEW
|
||||
/// Do nothing = do not process keys
|
||||
@@ -514,24 +517,24 @@ namespace TBF.UI
|
||||
/// </summary>
|
||||
void OnActivity(object sender, UiBridge.ActivityEventArgs args)
|
||||
{
|
||||
switch (args.Cmd)
|
||||
{
|
||||
case ActivityEventArgs.Update.Activity:
|
||||
activityLabel.Text = args.Activity;
|
||||
if (string.IsNullOrEmpty(messageLabel.Text)) messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
case ActivityEventArgs.Update.Message:
|
||||
messageLabel.Text = args.Message;
|
||||
if (args.ErrorMsg) messageLabel.ForeColor = Color.Red;
|
||||
else messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
default:
|
||||
activityLabel.Text = args.Activity;
|
||||
messageLabel.Text = args.Message;
|
||||
if (args.ErrorMsg) messageLabel.ForeColor = Color.Red;
|
||||
else messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
}
|
||||
switch (args.Cmd)
|
||||
{
|
||||
case ActivityEventArgs.Update.Activity:
|
||||
activityLabel.Text = args.Activity;
|
||||
if (string.IsNullOrEmpty(messageLabel.Text)) messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
case ActivityEventArgs.Update.Message:
|
||||
messageLabel.Text = args.Message;
|
||||
if (args.ErrorMsg) messageLabel.ForeColor = Color.Red;
|
||||
else messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
default:
|
||||
activityLabel.Text = args.Activity;
|
||||
messageLabel.Text = args.Message;
|
||||
if (args.ErrorMsg) messageLabel.ForeColor = Color.Red;
|
||||
else messageLabel.ForeColor = Color.Black;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -563,7 +566,7 @@ namespace TBF.UI
|
||||
drawingCtrl.MsrmntAvailableFlags = new bool[args.MsrmntAvailableFlags.Length];
|
||||
}
|
||||
for (int i = 0; i < args.MsrmntAvailableFlags.Length; i++) drawingCtrl.MsrmntAvailableFlags[i] = args.MsrmntAvailableFlags[i];
|
||||
|
||||
|
||||
/// Duplicate measured values
|
||||
if (drawingCtrl.MeasuredValues == null || drawingCtrl.MeasuredValues.Length != args.MeasuredValues.Length)
|
||||
{
|
||||
@@ -577,7 +580,7 @@ namespace TBF.UI
|
||||
drawingCtrl.AltStrings = new string[args.AltStrings.Length];
|
||||
}
|
||||
for (int i = 0; i < args.AltStrings.Length; i++) drawingCtrl.AltStrings[i] = args.AltStrings[i];
|
||||
|
||||
|
||||
/// Duplicate setpoints
|
||||
if (drawingCtrl.Setpoints == null || drawingCtrl.Setpoints.Length != args.Setpoints.Length)
|
||||
{
|
||||
@@ -591,7 +594,7 @@ namespace TBF.UI
|
||||
drawingCtrl.CustomBitmaps = new DrawingShape[args.CustomBitmaps.Length];
|
||||
}
|
||||
for (int i = 0; i < args.CustomBitmaps.Length; i++) drawingCtrl.CustomBitmaps[i] = args.CustomBitmaps[i];
|
||||
|
||||
|
||||
drawingCtrl.SupressRedraws = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -602,10 +605,10 @@ namespace TBF.UI
|
||||
}
|
||||
}
|
||||
|
||||
void OnTestProgress(object sender, UiBridge.TestProgressEventArgs args)
|
||||
{
|
||||
mainProgressBar.Value = (int)(100.499f * args.OveralProgress);
|
||||
}
|
||||
void OnTestProgress(object sender, UiBridge.TestProgressEventArgs args)
|
||||
{
|
||||
mainProgressBar.Value = (int)(100.499f * args.OveralProgress);
|
||||
}
|
||||
|
||||
void OnProcedureSelected(object sender, UiBridge.ProcedureSelectedEventArgs args)
|
||||
{
|
||||
@@ -671,18 +674,18 @@ namespace TBF.UI
|
||||
|
||||
public void UpdateUser()
|
||||
{
|
||||
userInfoStatusLabel.Text = string.Format("{0}: {1}{2}, ", Strings.User, CurrentUser.UserName(),
|
||||
(CurrentUser.AuthorizedAs == AuthorizedAs.PowerUser) ? "(S)" :
|
||||
(CurrentUser.AuthorizedAs == AuthorizedAs.LocalUser) ? "(L)" : "(R)");
|
||||
userInfoStatusLabel.Text = string.Format("{0}: {1}{2}, ", Strings.User, CurrentUser.UserName(),
|
||||
(CurrentUser.AuthorizedAs == AuthorizedAs.PowerUser) ? "(S)" :
|
||||
(CurrentUser.AuthorizedAs == AuthorizedAs.LocalUser) ? "(L)" : "(R)");
|
||||
|
||||
UpdateMenuItemsVisibility();
|
||||
}
|
||||
|
||||
void UpdateMenuItemsVisibility()
|
||||
{
|
||||
usersTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) || CurrentUser.IsMemberOf(GID.HeadOfLab);
|
||||
databaseSettingsTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) && CurrentUser.IsPowerUser();
|
||||
upgradeTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) && CurrentUser.IsPowerUser();
|
||||
usersTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) || CurrentUser.IsMemberOf(GID.HeadOfLab);
|
||||
databaseSettingsTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) && CurrentUser.IsPowerUser();
|
||||
upgradeTSMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) && CurrentUser.IsPowerUser();
|
||||
clearCountersToolStripMenuItem.Visible = CurrentUser.IsMemberOf(GID.Administrators) ||
|
||||
CurrentUser.IsMemberOf(GID.HeadOfLab) ||
|
||||
CurrentUser.IsMemberOf(GID.TestingSpecialists) ||
|
||||
@@ -710,14 +713,14 @@ namespace TBF.UI
|
||||
//Rig.StateMachine.Stop();
|
||||
}
|
||||
|
||||
private void benchComponentsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Components.ComponentsManagerDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchPathsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Paths.PathsDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchTransitionsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Transitions.TransitionsDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchMetrologyTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Metrology.MetrologyDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchUncertaintyTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Uncertainties.UncertaintiesDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchTestProfilesTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.TestProfiles.TestProfilesDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void editSchDrawingTSMItem_Click(object sender, EventArgs e){ Cursor = Cursors.WaitCursor; new TBF.UI.Bench.EditSchDrawing.EditSchDrawingDlg().ShowDialog();Cursor = Cursors.Default; }
|
||||
private void proceduresTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Procedures.ProceduresDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchComponentsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Components.ComponentsManagerDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchPathsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Paths.PathsDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchTransitionsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Transitions.TransitionsDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchMetrologyTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Metrology.MetrologyDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchUncertaintyTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.Uncertainties.UncertaintiesDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void benchTestProfilesTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.TestProfiles.TestProfilesDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void editSchDrawingTSMItem_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Bench.EditSchDrawing.EditSchDrawingDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
private void proceduresTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TBF.UI.Procedures.ProceduresDlg().ShowDialog(); Cursor = Cursors.Default; }
|
||||
|
||||
private void usersTSMItem_Click(object s, EventArgs e)
|
||||
{
|
||||
@@ -754,15 +757,15 @@ namespace TBF.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
private void backUpConfigTSMItem_Click(object s, EventArgs e) { BackupConfiguration(); }
|
||||
private void backUpResultsTSMItem_Click(object s, EventArgs e) { BackupResults(); }
|
||||
private void passwdTSMItem_Click(object s, EventArgs e) { new SharedDatabase.Forms.PasswordChangeDlg(CurrentUser.UserName()).ShowDialog(); }
|
||||
private void aboutTSMItem_Click(object s, EventArgs e) { new TBF.UI.Help.AboutDlg().ShowDialog(); }
|
||||
private void backUpConfigTSMItem_Click(object s, EventArgs e) { BackupConfiguration(); }
|
||||
private void backUpResultsTSMItem_Click(object s, EventArgs e) { BackupResults(); }
|
||||
private void passwdTSMItem_Click(object s, EventArgs e) { new SharedDatabase.Forms.PasswordChangeDlg(CurrentUser.UserName()).ShowDialog(); }
|
||||
private void aboutTSMItem_Click(object s, EventArgs e) { new TBF.UI.Help.AboutDlg().ShowDialog(); }
|
||||
|
||||
/// <summary>
|
||||
/// Read the database and re-initialize procedureComboBox items.
|
||||
/// Try to preserve the original selection.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Read the database and re-initialize procedureComboBox items.
|
||||
/// Try to preserve the original selection.
|
||||
/// </summary>
|
||||
public void ReloadProcedureComboBoxItems()
|
||||
{
|
||||
int separPos = procedureComboBox.Text.IndexOf(ProcSeparator);
|
||||
@@ -771,7 +774,7 @@ namespace TBF.UI
|
||||
}
|
||||
|
||||
public void ReloadProcedureComboBoxItems(string procedureNameToSelect)
|
||||
{
|
||||
{
|
||||
if (!procedureComboBox.Enabled)
|
||||
{
|
||||
/// Test cycle in progress, reload combo box items when the session is finished
|
||||
@@ -915,7 +918,7 @@ namespace TBF.UI
|
||||
|
||||
if (SelectedProcedure != null) BenchControlPanel.ReloadTests();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To each unresolved procedure finds the first native procedure that matches teh unresolved procedure
|
||||
@@ -977,8 +980,8 @@ namespace TBF.UI
|
||||
return true;
|
||||
}
|
||||
|
||||
private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
private void procedureComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
foreach (var item in procedureComboBox.Items)
|
||||
{
|
||||
var procInfo = item as ProcedureInfo;
|
||||
@@ -1004,7 +1007,7 @@ namespace TBF.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void procedureComboBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
@@ -1162,39 +1165,56 @@ namespace TBF.UI
|
||||
|
||||
private void appDiagnosticMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
/*diagApi = new DiagApi(liveLogCache);
|
||||
//diagApi.AddLog("ahoj, toto je prvy log");
|
||||
|
||||
ILog loger = LogManager.GetLogger("logCache");
|
||||
log.Debug("ahoj, ideme");*/
|
||||
|
||||
LiveLogCache.Instance.AddLog("=== Live diagnostic entry ===");
|
||||
DiagApi liveDiagApi = new DiagApi();
|
||||
|
||||
/*try
|
||||
try
|
||||
{
|
||||
// Predpoklad�me, �e ApplicationDiagnostic.exe je v rovnakom adres�ri ako hlavn� aplik�cia
|
||||
string exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppDiagnostic.exe");
|
||||
string exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AppDiagnostic", "AppDiagnostic.exe");
|
||||
|
||||
if (File.Exists(exePath))
|
||||
if (!File.Exists(exePath))
|
||||
{
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = exePath,
|
||||
UseShellExecute = true // Spust� aplik�ciu ako samostatn� proces
|
||||
};
|
||||
System.Diagnostics.Process.Start(startInfo);
|
||||
MessageBox.Show($"AppDiagnostic.exe not found:\n{exePath}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
MessageBox.Show("ApplicationDiagnostic.exe not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
FileName = exePath,
|
||||
WorkingDirectory = Path.GetDirectoryName(exePath),
|
||||
UseShellExecute = true
|
||||
});
|
||||
|
||||
// Temporary diagnostic test.
|
||||
SendDiagnosticTestLogs();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Failed to start ApplicationDiagnostic: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}*/
|
||||
MessageBox.Show($"Failed to start AppDiagnostic or send test logs: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendDiagnosticTestLogs()
|
||||
{
|
||||
NLog.Logger deviceLogger = NLog.LogManager.GetLogger("TBF.TestBench.DeviceSimulation");
|
||||
|
||||
deviceLogger.Trace("TRACE: Communication cycle started.");
|
||||
deviceLogger.Debug("DEBUG: Device configuration loaded.");
|
||||
deviceLogger.Info("INFO: Test bench started.");
|
||||
deviceLogger.Warn("WARN: Simulated pressure is approaching the limit.");
|
||||
|
||||
for (int position = 1; position <= 10; position++)
|
||||
{
|
||||
deviceLogger.Debug($"Reading simulated device at position {position}.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw new InvalidOperationException("Simulated device communication failure.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
deviceLogger.Error(ex, "ERROR: Unable to communicate with simulated device.");
|
||||
}
|
||||
|
||||
deviceLogger.Fatal("FATAL: Simulated emergency stop.");
|
||||
}
|
||||
|
||||
private void optoHeadsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -1246,7 +1266,7 @@ namespace TBF.UI
|
||||
MessageBox.Show(Strings.Remote_database_cannot_be_exported, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (MessageBox.Show(Strings.Do_you_want_to_back_up_configuration_qm,
|
||||
string.Empty,
|
||||
MessageBoxButtons.YesNo,
|
||||
|
||||
Reference in New Issue
Block a user