diff --git a/.gitignore b/.gitignore index 21bfff6a3..3e6385a91 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,8 @@ GemCard/bin/ GemCard/obj/ GenCode128/bin/ GenCode128/obj/ +GenericTest/bin/ +GenericTest/obj/ GraphLib/bin/ GraphLib/obj/ MergeResultsDBs/bin/ diff --git a/GenericTest/GenericTest.csproj b/GenericTest/GenericTest.csproj index 71eb373a1..37942f364 100644 --- a/GenericTest/GenericTest.csproj +++ b/GenericTest/GenericTest.csproj @@ -124,21 +124,21 @@ - - {a3ccf38e-1644-42a2-84d6-432530a56280} - Devices + + {c8939821-ba5c-4988-a3d0-bf53b74865c7} + Common {67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C} RecordProcessing - - {EFEC8A31-3022-4DA7-A8F6-16D30A94C3FF} - TracingDB + + {211b5e3f-9996-48a7-abde-c878dd2d71c2} + SharedDatabase - - {6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B} - Users + + {8648fd92-cda1-4c3a-b5f9-fe547ce1fa48} + TBF diff --git a/GenericTest/GenericTestDlg.cs b/GenericTest/GenericTestDlg.cs index dce9bc2c6..93dff82d4 100644 --- a/GenericTest/GenericTestDlg.cs +++ b/GenericTest/GenericTestDlg.cs @@ -9,9 +9,11 @@ using System.IO.Ports; using System.Threading; using System.Windows.Forms; using log4net; -using TracingDB; -using TracingDB.Entities; -using Devices.Modbus; +using Common; +using SharedDatabase; +using SharedDatabase.Entities; +using SharedDatabase.Forms; +using TBF.Rig.Modbus.Common; using NHibernate; using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider using RecordProcessing; @@ -68,7 +70,7 @@ namespace GenericTest IList processes; /// Processes from the database Dictionary processDictionary; /// Maps a process Id to a process Dictionary> workstepsDictionary; /// Maps a process Id to worksteps with name "RF_Power" (Count = 0 or 1) - static Dictionary verificationInfos; + static Dictionary verificationInfos; /// Maps process Id to verification info DateTime lastUpdateOfProcesses; @@ -93,15 +95,7 @@ namespace GenericTest public GenericTestDlg() { /// Open a modeless form that is closed after initialization and loading the main window - new Thread(() => Application.Run(new TracingDB.Forms.ModelessForm() - { - Title = "", - Message = "Načítavanie procesov z databázy", - BackgroundColor = Color.LightGreen, - FontFamily = "Arial", - FontSize = 14, - FontStyle = FontStyle.Regular, - })).Start(); + new Thread(() => Application.Run(new Common.Forms.ModelessForm("Načítavanie procesov z databázy"))).Start(); InitializeComponent(); @@ -139,7 +133,7 @@ namespace GenericTest StarSensorReading(); } - TracingDB.Forms.ModelessForm.CloseForm(); /// Close the modeless information form + Common.Forms.ModelessForm.CloseForm(); /// Close the modeless information form } private void startButton_Click(object sender, EventArgs e) @@ -156,13 +150,13 @@ namespace GenericTest private void settingsButton_Click(object sender, EventArgs e) { - Users.Entities.User oriUser = Users.GlobalData.CurrentUser; /// Save the original user (= tester) + IUser oriUser = GlobalData.CurrentUser; /// Save the original user (= tester) - if (new Users.Forms.LoginDlg(Program.SettingsAccessLevel).ShowDialog() == DialogResult.OK) + if (new LoginDlg(Program.SettingsAccessLevel).ShowDialog() == DialogResult.OK) { /// Logged in at 'TraceabilityManagement' level - Users.GlobalData.CurrentUser = oriUser; /// Restore the original user (= tester) + GlobalData.CurrentUser = oriUser; /// Restore the original user (= tester) string oriWorkplace = Program.LocalSettings.Workplace; /// @@ -172,14 +166,14 @@ namespace GenericTest { UpdateTitle(); - DB.UnregisterWorkplaceObsolete(dbSession, oriWorkplace); - DB.RegisterWorkplaceObsolete(dbSession, - Program.LocalSettings.Workplace, - Users.GlobalData.GetCurrentUserName(), - "1.2.3.4", - "", - WorkflowStep, - DateTime.Now + new TimeSpan(365, 0, 0, 0)); + TracingDB.UnregisterWorkplaceObsolete(dbSession, oriWorkplace); + TracingDB.RegisterWorkplaceObsolete(dbSession, + Program.LocalSettings.Workplace, + GlobalData.GetCurrentUserName(), + "1.2.3.4", + "", + WorkflowStep, + DateTime.Now + new TimeSpan(365, 0, 0, 0)); dbSession.Flush(); } } @@ -200,7 +194,7 @@ namespace GenericTest StopSensorReading(); } UI2Settings(); - DB.UnregisterWorkplaceObsolete(dbSession, Program.LocalSettings.Workplace); + TracingDB.UnregisterWorkplaceObsolete(dbSession, Program.LocalSettings.Workplace); dbSession.Flush(); StopSpoolProcessing(); } @@ -318,7 +312,6 @@ namespace GenericTest var modbusCfg = new ModbusCfg { Name = "Modbus", - ClassName = "Modbus", ParentName = string.Empty, ComPortNr = ls.SensorComPortNr, BaudRate = 9600, @@ -335,7 +328,7 @@ namespace GenericTest sensorReadTimer.Tick += (Object s, EventArgs e) => { ReadSensor(); }; sensorReadTimer.Start(); - modbus.SendMessage((byte)modbusAddress, (byte)Function.ReadHoldingRegisters, (ushort)0x0030, (ushort)2, "Temperature"); + modbus.SendMessage((byte)modbusAddress, (byte)TBF.Rig.Modbus.Function.ReadHoldingRegisters, (ushort)0x0030, (ushort)2, "Temperature"); isSensorReadRunning = true; } @@ -375,7 +368,7 @@ namespace GenericTest } } - modbus.SendMessage((byte)modbusAddress, (byte)Function.ReadHoldingRegisters, (ushort)0x0030, (ushort)2, "Temperature"); + modbus.SendMessage((byte)modbusAddress, (byte)TBF.Rig.Modbus.Function.ReadHoldingRegisters, (ushort)0x0030, (ushort)2, "Temperature"); } } @@ -564,7 +557,7 @@ namespace GenericTest if (rslt != DialogResult.Yes) { /// Settings ware not changed -> exit - throw new TracingDB.QuitAppException(failedMsg); + throw new QuitAppException(failedMsg); } settingsDR = new SettingsDlg().ShowDialog(); @@ -575,8 +568,8 @@ namespace GenericTest { try { - dbSession = DB.CreateSession(Program.LocalSettings.ConnectionString); - processes = TracingDB.DB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); + dbSession = TracingDB.CreateSession(Program.LocalSettings.ConnectionString); + processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); lastUpdateOfProcesses = DateTime.Now; } catch (Exception exc) @@ -680,7 +673,7 @@ namespace GenericTest MessageBoxIcon.Exclamation); /// Settings were not changed -> exit - throw new QuitAppException("Niečo sa nepodarilo"); + throw new QuitAppException(Strings.Something_failed); } #endif } @@ -690,23 +683,23 @@ namespace GenericTest if (settingsDR == DialogResult.Cancel) { /// Settings were not changed -> exit - throw new QuitAppException("Niečo sa nepodarilo"); + throw new QuitAppException(Strings.Something_failed); } if (!string.IsNullOrEmpty(Program.LocalSettings.UsersDBConnString)) { - Users.GlobalData.UsersDB = new Users.DBSettings(Users.Entities.DBType.MySql, Program.LocalSettings.UsersDBConnString); + GlobalData.LocalUsersDB = new DBSettings(DBType.MySql, Program.LocalSettings.UsersDBConnString); } UpdateTitle(); - DB.RegisterWorkplaceObsolete(dbSession, - Program.LocalSettings.Workplace, - Users.GlobalData.GetCurrentUserName(), - "1.2.3.4", - "", - WorkflowStep, - DateTime.Now + new TimeSpan(15, 0, 0, 0)); /// Registration is valid approx. 2 weeks + TracingDB.RegisterWorkplaceObsolete(dbSession, + Program.LocalSettings.Workplace, + GlobalData.GetCurrentUserName(), + "1.2.3.4", + "", + WorkflowStep, + DateTime.Now + new TimeSpan(15, 0, 0, 0)); /// Registration is valid approx. 2 weeks /// Activate processing of test results created by a thirdparty test program switch (RcrdType) @@ -818,6 +811,7 @@ namespace GenericTest /// ITransaction transaction = null; Process proc = null; + OrderInfo order = null; bool readingFromTracingDBFailed = false; /// Reading form tracing DB failed (equipment error) bool savingToTracingDBFailed = false; /// Writing to tracoing DB failed (equipment error) bool verificationFailed = false; /// Reading/writing from/to tracing DB OK, but verification failed (product error) @@ -830,7 +824,7 @@ namespace GenericTest transaction = dbSession.BeginTransaction(); /// Get a process of the last reference record with this PCB number - proc = DB.GetWorkflow(dbSession, testerRecord.SN); + proc = TracingDB.GetWorkflow(dbSession, testerRecord.SN, out order); /// Check if a record from the previous workplace exists if (proc == null) @@ -848,12 +842,12 @@ namespace GenericTest /// Process is known AND the system is checking previous records => verify previous step /// Get an appropriate verification info - TracingDB.ScanVerificationInfo verInfo; + ScanVerificationInfo verInfo; bool verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo); if (!verInfoObtained && (DateTime.Now - lastUpdateOfProcesses) > new TimeSpan(0, 5, 0)) { /// No verification info was obtained and more then 5 minutes elapsed => read processes again - processes = DB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); + processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); lastUpdateOfProcesses = DateTime.Now; verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo); } @@ -900,26 +894,26 @@ namespace GenericTest if (workstepsDictionary.TryGetValue(proc.Id, out worksteps) && (worksteps.Count == 1)) { /// Save a new reference record to the production tracing DB - dbSession.SaveOrUpdate(new ReferenceRecord(proc, worksteps[0], testerRecord.SN, - Users.GlobalData.GetCurrentUserName(), + dbSession.SaveOrUpdate(new ReferenceRecord(order, proc, worksteps[0], testerRecord.SN, + GlobalData.GetCurrentUserName(), Program.LocalSettings.Workplace, verificationFailed ? 2 : ((testerRecord.Status == Status.Passed) ? 0 : 1))); } else { /// Save a reference record with WORKSTEP=null to the production tracing DB - dbSession.SaveOrUpdate(new ReferenceRecord(proc, null, testerRecord.SN, - Users.GlobalData.GetCurrentUserName(), + dbSession.SaveOrUpdate(new ReferenceRecord(order, proc, null, testerRecord.SN, + GlobalData.GetCurrentUserName(), Program.LocalSettings.Workplace, verificationFailed ? 2 : ((testerRecord.Status == Status.Passed) ? 0 : 1))); } } else { - /// Save a reference record with PROCESS=null and WORKSTEP=null to the production tracing DB + /// Save a reference record with PORDER=null, PROCESS=null and WORKSTEP=null to the production tracing DB savingToTracingDBFailed = true; - dbSession.SaveOrUpdate(new ReferenceRecord(null, null, testerRecord.SN, - Users.GlobalData.GetCurrentUserName(), + dbSession.SaveOrUpdate(new ReferenceRecord(null, null, null, testerRecord.SN, + GlobalData.GetCurrentUserName(), Program.LocalSettings.Workplace, (testerRecord.Status == Status.Passed) ? 0 : 1)); } @@ -1051,7 +1045,7 @@ namespace GenericTest /// while (true) { - if (new Users.Forms.LoginDlg().ShowDialog() == DialogResult.OK) + if (new SharedDatabase.Forms.LoginDlg().ShowDialog() == DialogResult.OK) { break; } @@ -1070,7 +1064,7 @@ namespace GenericTest void UpdateTitle() { - Text = string.Format("{0} v.{1} ({2}, {3})", DfltWorkplaceName, Program.Version, Program.LocalSettings.Workplace, Users.GlobalData.GetCurrentUserName()); + Text = string.Format("{0} v.{1} ({2}, {3})", DfltWorkplaceName, Program.Version, Program.LocalSettings.Workplace, GlobalData.GetCurrentUserName()); } } } diff --git a/GenericTest/LocalSettings.cs b/GenericTest/LocalSettings.cs index 69ed75675..df8a32672 100644 --- a/GenericTest/LocalSettings.cs +++ b/GenericTest/LocalSettings.cs @@ -6,6 +6,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; using System.Xml.Serialization; +using SharedDatabase; namespace GenericTest { @@ -33,7 +34,7 @@ namespace GenericTest public string ValidSNPrefixes; public bool DoCheckPreviousTracingRecords; public bool DoSaveTestResultToOracle; - public TracingDB.Mode OracleMode; + public Mode OracleMode; public bool DoPrintLabels; public bool DoPrintGoodLabelsOnly; public bool MaximizeWindowOnError; @@ -72,7 +73,7 @@ namespace GenericTest ValidSNPrefixes = "297,298,299,300,301,302"; DoCheckPreviousTracingRecords = true; DoSaveTestResultToOracle = true; - OracleMode = TracingDB.Mode.Production; + OracleMode = Mode.Production; DoPrintLabels = true; DoPrintGoodLabelsOnly = true; MaximizeWindowOnError = false; diff --git a/GenericTest/Program.cs b/GenericTest/Program.cs index 900a5af9b..eb4fc9780 100644 --- a/GenericTest/Program.cs +++ b/GenericTest/Program.cs @@ -5,8 +5,8 @@ using System.Reflection; using System.Windows.Forms; using log4net; using NHibernate; -using Users; -using Users.Entities; +using Common; +using SharedDatabase.Entities; using GenericTest.Resources; namespace GenericTest @@ -63,7 +63,7 @@ namespace GenericTest /// Assembly thisAssembly = Assembly.GetExecutingAssembly(); string processName = Path.GetFileNameWithoutExtension(thisAssembly.Location); - if (Process.GetProcessesByName(processName).Length > 1) + if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1) { MessageBox.Show(string.Format("{0}{1}{2}", Strings.Program_GenericTest_is_running_already, Environment.NewLine, @@ -153,9 +153,9 @@ namespace GenericTest { try { - Users.GlobalData.UsersDB = new DBSettings(Users.Entities.DBType.MySql, LocalSettings.UsersDBConnString); + GlobalData.LocalUsersDB = new DBSettings(DBType.MySql, LocalSettings.UsersDBConnString); - if (new Users.Forms.LoginDlg().ShowDialog() != DialogResult.OK) return; + if (new SharedDatabase.Forms.LoginDlg().ShowDialog() != DialogResult.OK) return; } catch (Exception exc) { @@ -172,9 +172,9 @@ namespace GenericTest } catch (Exception exc) { - if (exc is TracingDB.QuitAppException) + if (exc is QuitAppException) { - TracingDB.Forms.ModelessForm.CloseForm(); + Common.Forms.ModelessForm.CloseForm(); log.FatalFormat(Strings.Program_was_not_started_0, exc.Message); MessageBox.Show(exc.Message, Strings.Warning, diff --git a/GenericTest/Resources/Strings.Designer.cs b/GenericTest/Resources/Strings.Designer.cs index d94e1f695..af895a215 100644 --- a/GenericTest/Resources/Strings.Designer.cs +++ b/GenericTest/Resources/Strings.Designer.cs @@ -258,6 +258,15 @@ namespace GenericTest.Resources { } } + /// + /// Looks up a localized string similar to Something failed. + /// + internal static string Something_failed { + get { + return ResourceManager.GetString("Something_failed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Test failed {0}. /// diff --git a/GenericTest/Resources/Strings.resx b/GenericTest/Resources/Strings.resx index c519c67b3..c2bd6499c 100644 --- a/GenericTest/Resources/Strings.resx +++ b/GenericTest/Resources/Strings.resx @@ -183,6 +183,9 @@ Serial number is missing + + Something failed + Test failed {0} diff --git a/GenericTest/Resources/Strings.sk.resx b/GenericTest/Resources/Strings.sk.resx index 55b4ea5c7..ef3ee0a39 100644 --- a/GenericTest/Resources/Strings.sk.resx +++ b/GenericTest/Resources/Strings.sk.resx @@ -180,6 +180,9 @@ Sériové číslo chýba + + Niečo sa nepodarilo + Test neprešiel {0} diff --git a/GenericTest/SettingsDlg.cs b/GenericTest/SettingsDlg.cs index 8583a91dc..c2ef628e2 100644 --- a/GenericTest/SettingsDlg.cs +++ b/GenericTest/SettingsDlg.cs @@ -4,6 +4,7 @@ using System; using System.Windows.Forms; using System.Drawing; +using SharedDatabase; namespace GenericTest { @@ -13,7 +14,7 @@ namespace GenericTest { InitializeComponent(); - for (TracingDB.Mode m = 0; m < TracingDB.Mode.Count; m++) oracleModeComboBox.Items.Add(m.ToString()); + for (Mode m = 0; m < Mode.Count; m++) oracleModeComboBox.Items.Add(m.ToString()); ManageCheckGroupBox(checkSNsValidityCheckBox, validPcbPrefixesGroupBox); ManageCheckGroupBox(saveTestResultToOracleCheckBox, saveRFTestResultGroupBox); @@ -39,7 +40,7 @@ namespace GenericTest checkPreviousTracingRecordsCheckBox.Checked = ls.DoCheckPreviousTracingRecords; saveTestResultToOracleCheckBox.Checked = ls.DoSaveTestResultToOracle; - if (ls.OracleMode >= 0 && ls.OracleMode < TracingDB.Mode.Count) oracleModeComboBox.Text = ls.OracleMode.ToString(); + if (ls.OracleMode >= 0 && ls.OracleMode < Mode.Count) oracleModeComboBox.Text = ls.OracleMode.ToString(); printLabelsCheckBox.Checked = ls.DoPrintLabels; printGoodLabelsOnlyCheckBox.Checked = ls.DoPrintGoodLabelsOnly; @@ -71,7 +72,7 @@ namespace GenericTest ls.DoCheckPreviousTracingRecords = checkPreviousTracingRecordsCheckBox.Checked; ls.DoSaveTestResultToOracle = saveTestResultToOracleCheckBox.Checked; - for (TracingDB.Mode m = 0; m < TracingDB.Mode.Count; m++) + for (Mode m = 0; m < Mode.Count; m++) { if (oracleModeComboBox.Text == m.ToString()) { ls.OracleMode = m; break; } } diff --git a/SharedDatabase/TracingDB.cs b/SharedDatabase/TracingDB.cs index 901d12857..e7c379731 100644 --- a/SharedDatabase/TracingDB.cs +++ b/SharedDatabase/TracingDB.cs @@ -173,8 +173,10 @@ namespace SharedDatabase /// DB session /// Serial number /// Workflow of the specified part - public static Process GetWorkflow(ISession session, string serialNumber) + public static Process GetWorkflow(ISession session, string serialNumber, out OrderInfo order) { + order = null; + if (string.IsNullOrEmpty(serialNumber)) return null; try @@ -187,6 +189,7 @@ namespace SharedDatabase if (referenceRecords.Count == 0) return null; /// Returns an empty list if no such ref. record found + order = referenceRecords[0].POrder; return referenceRecords[0].Workflow; } catch diff --git a/TBF.sln b/TBF.sln index 89dfe4d28..c2d28be47 100644 --- a/TBF.sln +++ b/TBF.sln @@ -88,6 +88,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataMatrix4Net", "DataMatri EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecordProcessing", "RecordProcessing\RecordProcessing.csproj", "{67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenericTest", "GenericTest\GenericTest.csproj", "{1F6B4580-9D4F-43D6-9E76-E063298391E8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -392,6 +394,16 @@ Global {67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}.Release|Mixed Platforms.Build.0 = Release|Any CPU {67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}.Release|x86.ActiveCfg = Release|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Debug|x86.ActiveCfg = Debug|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Release|Any CPU.Build.0 = Release|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1F6B4580-9D4F-43D6-9E76-E063298391E8}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TBF/Rig/Modbus/Common/ModbusCfg.cs b/TBF/Rig/Modbus/Common/ModbusCfg.cs index 5ecb03a0a..079af7f32 100644 --- a/TBF/Rig/Modbus/Common/ModbusCfg.cs +++ b/TBF/Rig/Modbus/Common/ModbusCfg.cs @@ -28,7 +28,7 @@ namespace TBF.Rig.Modbus.Common public Handshake Handshake; /// Private parameterless constructor invoked by all other (public) constructors - ModbusCfg() { } + public ModbusCfg() { } public ModbusCfg(string name, IComponentFactory factory) { diff --git a/clean.bat b/clean.bat index 01de58a40..5a6de1e1c 100644 --- a/clean.bat +++ b/clean.bat @@ -24,6 +24,8 @@ rmdir /s /q GemCard\bin rmdir /s /q GemCard\obj rmdir /s /q GenCode128\bin rmdir /s /q GenCode128\obj +rmdir /s /q GenericTest\bin +rmdir /s /q GenericTest\obj rmdir /s /q GraphLib\bin rmdir /s /q GraphLib\obj rmdir /s /q MergeResultsDBs\bin