GenericTest and RecordProessing modifications for Laser in Nanjing, ver. 3.0.1
This commit is contained in:
parent
2eaf2b044c
commit
d42ad8c5cf
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Drawing;
|
||||
@ -11,7 +11,7 @@ namespace GenericTest
|
||||
Undefined = 0, /// Undefined (only used in OnActivity(..) when start/stop info message is issued)
|
||||
SNisMissing, /// S/N is missing in the parsed record
|
||||
SNisInvalid, /// S/N in the parsed record is invalid
|
||||
NoRecordAtAll, /// No record with this S/N in tracing DB
|
||||
NoRefRecordOrNoMatchingWorkflow, /// No record with this S/N in tracing DB or no matching workflow for this record
|
||||
VerificationIsDisabled, /// ...
|
||||
NoVerificationForThisProcess,
|
||||
VerificationPassed, /// Verification of a previous record passed
|
||||
|
||||
@ -20,17 +20,22 @@
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;RF_TEST_400_900</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;LASER_NANJING</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;RF_TEST_400_900</DefineConstants>
|
||||
<DefineConstants>TRACE;LASER_NANJING</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>GenericTest.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentNHibernate">
|
||||
|
||||
34
GenericTest/GenericTestDlg.Designer.cs
generated
34
GenericTest/GenericTestDlg.Designer.cs
generated
@ -35,12 +35,12 @@
|
||||
this.vertSplitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.resultsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.activityListView = new System.Windows.Forms.ListView();
|
||||
this.logoutButton = new System.Windows.Forms.Button();
|
||||
this.startButton = new System.Windows.Forms.Button();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.filteredSensorValueLabel = new System.Windows.Forms.Label();
|
||||
this.sensorNameLabel = new System.Windows.Forms.Label();
|
||||
this.immediateSensorValueLabel = new System.Windows.Forms.Label();
|
||||
this.logoutButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit();
|
||||
this.horizSplitContainer.Panel1.SuspendLayout();
|
||||
this.horizSplitContainer.Panel2.SuspendLayout();
|
||||
@ -63,7 +63,7 @@
|
||||
this.settingsButton.Name = "settingsButton";
|
||||
this.settingsButton.Size = new System.Drawing.Size(90, 30);
|
||||
this.settingsButton.TabIndex = 0;
|
||||
this.settingsButton.Text = "Nastavenia";
|
||||
this.settingsButton.Text = "Settings";
|
||||
this.settingsButton.UseVisualStyleBackColor = true;
|
||||
this.settingsButton.Click += new System.EventHandler(this.settingsButton_Click);
|
||||
//
|
||||
@ -130,7 +130,7 @@
|
||||
this.vertSplitContainer.Panel2.Controls.Add(this.startButton);
|
||||
this.vertSplitContainer.Panel2.Controls.Add(this.stopButton);
|
||||
this.vertSplitContainer.Size = new System.Drawing.Size(1033, 151);
|
||||
this.vertSplitContainer.SplitterDistance = 939;
|
||||
this.vertSplitContainer.SplitterDistance = 942;
|
||||
this.vertSplitContainer.SplitterWidth = 1;
|
||||
this.vertSplitContainer.TabIndex = 2;
|
||||
//
|
||||
@ -140,7 +140,7 @@
|
||||
this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.resultsGroupBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.resultsGroupBox.Name = "resultsGroupBox";
|
||||
this.resultsGroupBox.Size = new System.Drawing.Size(939, 151);
|
||||
this.resultsGroupBox.Size = new System.Drawing.Size(942, 151);
|
||||
this.resultsGroupBox.TabIndex = 1;
|
||||
this.resultsGroupBox.TabStop = false;
|
||||
this.resultsGroupBox.Text = "Aktivita";
|
||||
@ -152,11 +152,22 @@
|
||||
this.activityListView.Location = new System.Drawing.Point(3, 16);
|
||||
this.activityListView.Name = "activityListView";
|
||||
this.activityListView.Scrollable = false;
|
||||
this.activityListView.Size = new System.Drawing.Size(933, 132);
|
||||
this.activityListView.Size = new System.Drawing.Size(936, 132);
|
||||
this.activityListView.TabIndex = 0;
|
||||
this.activityListView.UseCompatibleStateImageBehavior = false;
|
||||
this.activityListView.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// logoutButton
|
||||
//
|
||||
this.logoutButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.logoutButton.Location = new System.Drawing.Point(1, 116);
|
||||
this.logoutButton.Name = "logoutButton";
|
||||
this.logoutButton.Size = new System.Drawing.Size(90, 30);
|
||||
this.logoutButton.TabIndex = 13;
|
||||
this.logoutButton.Text = "Logout";
|
||||
this.logoutButton.UseVisualStyleBackColor = true;
|
||||
this.logoutButton.Click += new System.EventHandler(this.logoutButton_Click);
|
||||
//
|
||||
// startButton
|
||||
//
|
||||
this.startButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
@ -164,7 +175,7 @@
|
||||
this.startButton.Name = "startButton";
|
||||
this.startButton.Size = new System.Drawing.Size(90, 30);
|
||||
this.startButton.TabIndex = 1;
|
||||
this.startButton.Text = "Štart";
|
||||
this.startButton.Text = "Start";
|
||||
this.startButton.UseVisualStyleBackColor = true;
|
||||
this.startButton.Click += new System.EventHandler(this.startButton_Click);
|
||||
//
|
||||
@ -221,17 +232,6 @@
|
||||
this.immediateSensorValueLabel.TabIndex = 1;
|
||||
this.immediateSensorValueLabel.Text = "60.7 °C";
|
||||
//
|
||||
// logoutButton
|
||||
//
|
||||
this.logoutButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.logoutButton.Location = new System.Drawing.Point(1, 116);
|
||||
this.logoutButton.Name = "logoutButton";
|
||||
this.logoutButton.Size = new System.Drawing.Size(90, 30);
|
||||
this.logoutButton.TabIndex = 13;
|
||||
this.logoutButton.Text = "Logout";
|
||||
this.logoutButton.UseVisualStyleBackColor = true;
|
||||
this.logoutButton.Click += new System.EventHandler(this.logoutButton_Click);
|
||||
//
|
||||
// GenericTestDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
@ -33,46 +34,46 @@ namespace GenericTest
|
||||
|
||||
#if RF_TEST
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.RF_Test;
|
||||
public const string WorkflowStep = "RF_Power";
|
||||
public const string WorkflowStep = "rf_power";
|
||||
public const string DfltWorkplaceName = "RF Test";
|
||||
#elif RF_TEST_400_900
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.RF_Test_400_900;
|
||||
public const string WorkflowStep = "RF_Power";
|
||||
public const string WorkflowStep = "rf_power";
|
||||
public const string DfltWorkplaceName = "RF Test";
|
||||
#elif COMM_TEST
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.CommTest;
|
||||
public const string WorkflowStep = "Comm_Test";
|
||||
public const string WorkflowStep = "comm_test";
|
||||
public const string DfltWorkplaceName = "Comm Test";
|
||||
#elif FLOWTUBE_TEST_HE
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.FlowtubeTestHe;
|
||||
public const string WorkflowStep = "Helium_Test";
|
||||
public const string WorkflowStep = "helium_test";
|
||||
public const string DfltWorkplaceName = "Helium Test";
|
||||
#elif FLOWTUBE_TEST_AIR
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.FlowtubeTestAir;
|
||||
public const string WorkflowStep = "Helium_Test";
|
||||
public const string WorkflowStep = "helium_test";
|
||||
public const string DfltWorkplaceName = "Helium Test";
|
||||
#elif LASER_NANJING
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.LaserNanjing;
|
||||
public const string WorkflowStep = "laser";
|
||||
public const string DfltWorkplaceName = "Laser 1";
|
||||
#else
|
||||
public RecordProcessing.RecordType RcrdType = RecordType.None;
|
||||
public const string WorkflowStep = "Generic_Test";
|
||||
public const string WorkflowStep = "generic_test";
|
||||
public const string DfltWorkplaceName = "Generic Test";
|
||||
#endif
|
||||
|
||||
const int ActivityMsgsCount = 7;
|
||||
ActivityEventArgs[] activityEvents; /// Activity messages displayed in the main window
|
||||
ActivityEventArgs[] activityEvents; /// Activity messages displayed in the main window
|
||||
|
||||
|
||||
NHibernate.ISession dbSession; /// MySQL database session
|
||||
static OracleConnection oracleConn; /// Oracle database connection (server is in Stara Tura)
|
||||
NHibernate.ISession dbSession; /// MySQL database session
|
||||
static OracleConnection oracleConn; /// Oracle database connection (server is in Stara Tura)
|
||||
#if RF_TEST_400_900
|
||||
static OracleConnection oracleConn2; /// Oracle database connection for Flexnet ID (server is in Ludwigshafen)
|
||||
static OracleConnection oracleConn2; /// Oracle database connection for Flexnet ID (server is in Ludwigshafen)
|
||||
#endif
|
||||
|
||||
IList<Process> processes; /// Processes from the database
|
||||
Dictionary<int, Process> processDictionary; /// Maps a process Id to a process
|
||||
Dictionary<int, IList<Workstep>> workstepsDictionary; /// Maps a process Id to worksteps with name "RF_Power" (Count = 0 or 1)
|
||||
static Dictionary<int, ScanVerificationInfo> verificationInfos;
|
||||
/// Maps process Id to verification info
|
||||
DateTime lastUpdateOfProcesses;
|
||||
|
||||
IList<WorkflowSummary> workflowSummaries; /// Workflows from the database with last step verification information
|
||||
DateTime lastUpdateOfWorkflows;
|
||||
|
||||
RecordProcessing.RecordProcessing recordProcessing;
|
||||
|
||||
@ -94,13 +95,29 @@ namespace GenericTest
|
||||
/// </summary>
|
||||
public GenericTestDlg()
|
||||
{
|
||||
/// Open a modeless form that is closed after initialization and loading the main window
|
||||
new Thread(() => Application.Run(new Common.Forms.ModelessForm("Načítavanie procesov z databázy"))).Start();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
try
|
||||
{
|
||||
string culture = Program.LocalSettings.Language.Replace('_', '-');
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
|
||||
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string msg = exc.Message;
|
||||
MessageBox.Show("Selected language is not supported.\nUsing English.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
|
||||
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
|
||||
}
|
||||
|
||||
Localize();
|
||||
UpdateTitle();
|
||||
|
||||
/// Open a modeless form that is closed after initialization and loading the main window
|
||||
new Thread(() => Application.Run(new Common.Forms.ModelessForm("Loading workflows from a database"))).Start();
|
||||
|
||||
|
||||
activityEvents = new ActivityEventArgs[ActivityMsgsCount];
|
||||
activityListView.Columns.Add(Strings.Time, 60);
|
||||
#if FLOWTUBE_TEST_AIR || FLOWTUBE_TEST_HE
|
||||
@ -123,6 +140,15 @@ namespace GenericTest
|
||||
ReadProcesses_RegisterWorkplace_Etc();
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
messageLabel.Text = string.IsNullOrEmpty(Program.LocalSettings.Workplace) ? "Laser" : Program.LocalSettings.Workplace;
|
||||
startButton.Text = Strings.Start;
|
||||
stopButton.Text = Strings.Stop;
|
||||
settingsButton.Text = Strings.Settings;
|
||||
logoutButton.Text = Strings.Logout;
|
||||
}
|
||||
|
||||
private void GenericTestDlg_Load(object sender, EventArgs e)
|
||||
{
|
||||
Settings2UI();
|
||||
@ -569,8 +595,8 @@ namespace GenericTest
|
||||
try
|
||||
{
|
||||
dbSession = TracingDB.CreateSession(Program.LocalSettings.ConnectionString);
|
||||
processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos);
|
||||
lastUpdateOfProcesses = DateTime.Now;
|
||||
workflowSummaries = TracingDB.ReadWorkflowSummariesFromDB(dbSession, WorkflowStep);
|
||||
lastUpdateOfWorkflows = DateTime.Now;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@ -733,6 +759,13 @@ namespace GenericTest
|
||||
Program.LocalSettings.ArchiveFolder, true);
|
||||
break;
|
||||
|
||||
case RecordType.LaserNanjing:
|
||||
recordProcessing = new RecordProcessing.RecordProcessing(RecordType.LaserNanjing,
|
||||
RecordPostproc.Move,
|
||||
Program.LocalSettings.TestResultsFolder, false, "*.csv",
|
||||
Program.LocalSettings.ArchiveFolder, true);
|
||||
break;
|
||||
|
||||
case RecordType.None:
|
||||
default:
|
||||
recordProcessing = null;
|
||||
@ -798,7 +831,9 @@ namespace GenericTest
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Program.LocalSettings.DoCheckSNsValidity && (Program.LocalSettings.ValidSNPrefixes != null) && !Program.LocalSettings.ValidSNPrefixes.Contains(testerRecord.SN.Substring(0, 3)))
|
||||
if (Program.LocalSettings.DoCheckSNsValidity &&
|
||||
(Program.LocalSettings.ValidSNPrefixes != null)
|
||||
&& !Program.LocalSettings.ValidSNPrefixes.Contains(testerRecord.SN.Substring(0, 3)))
|
||||
{
|
||||
/// PCB number did not pass a validity check (is not on a list of valid PCB numbers)
|
||||
verifState = VerifState.SNisInvalid;
|
||||
@ -810,9 +845,6 @@ namespace GenericTest
|
||||
/// A valid serial number is available => proceed
|
||||
///
|
||||
ITransaction transaction = null;
|
||||
string proc = null;
|
||||
string 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)
|
||||
|
||||
@ -824,110 +856,55 @@ namespace GenericTest
|
||||
transaction = dbSession.BeginTransaction();
|
||||
|
||||
/// Get a process of the last reference record with this PCB number
|
||||
proc = TracingDB.GetWorkflow(dbSession, testerRecord.SN, 1, out order);
|
||||
var refRecord = TracingDB.FindReferenceRecord(dbSession, testerRecord.SN, 1);
|
||||
WorkflowSummary wSum = (refRecord == null) ? null :
|
||||
workflowSummaries.FirstOrDefault(x => x.Workflow.Name == refRecord.Workflow);
|
||||
|
||||
/// Check if a record from the previous workplace exists
|
||||
if (proc == null)
|
||||
if (refRecord == null || wSum == null)
|
||||
{
|
||||
/// Any previous reference record with this s/n is missing => process cannot be determined
|
||||
verifState = VerifState.NoRecordAtAll;
|
||||
}
|
||||
else if (!Program.LocalSettings.DoCheckPreviousTracingRecords)
|
||||
{
|
||||
/// The process was determined but checking previous records is disbled => everything is OK so far
|
||||
verifState = VerifState.VerificationIsDisabled;
|
||||
verifState = VerifState.NoRefRecordOrNoMatchingWorkflow;
|
||||
verificationFailed = true;
|
||||
savingToTracingDBFailed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Process is known AND the system is checking previous records => verify previous step
|
||||
|
||||
/// Get an appropriate verification info
|
||||
ScanVerificationInfo verInfo;
|
||||
bool verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo);
|
||||
if (!verInfoObtained && (DateTime.Now - lastUpdateOfProcesses) > new TimeSpan(0, 5, 0))
|
||||
if (!Program.LocalSettings.DoCheckPreviousTracingRecords)
|
||||
{
|
||||
/// No verification info was obtained and more then 5 minutes elapsed => read processes again
|
||||
processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos);
|
||||
lastUpdateOfProcesses = DateTime.Now;
|
||||
verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo);
|
||||
}
|
||||
|
||||
if (!verInfoObtained)
|
||||
{
|
||||
/// No verification info for the process obtained from the reference record found
|
||||
verifState = VerifState.NoVerificationForThisProcess;
|
||||
/// The process was determined but checking previous records is disbled => everything is OK so far
|
||||
verifState = VerifState.VerificationIsDisabled;
|
||||
verificationFailed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verInfo.VerifyReferencePart)
|
||||
{
|
||||
/// Fetch all GOOD reference records with given code
|
||||
IList<ReferenceRecord> refRecords = dbSession.QueryOver<ReferenceRecord>()
|
||||
.Where(rr => ((rr.Code1 == testerRecord.SN) && (rr.Result == 0)))
|
||||
.And(rr => (rr.Workstep == verInfo.Workstep))
|
||||
.JoinQueryOver<Workstep>(rr => rr.Workstep)
|
||||
.Where(ws => (ws.ReferencePart.Id == verInfo.Part.Id))
|
||||
.List();
|
||||
/// Process is known AND the system is checking previous records => verify previous step
|
||||
|
||||
verifState = (refRecords.Count > 0) ? VerifState.VerificationPassed : VerifState.VerificationFailed;
|
||||
}
|
||||
else
|
||||
{
|
||||
IList<Record> records = dbSession.QueryOver<Record>()
|
||||
.Where(rec => (rec.Code == testerRecord.SN))
|
||||
.And(rec => (rec.Part == verInfo.Part))
|
||||
.List();
|
||||
|
||||
verifState = (records.Count > 0) ? VerifState.VerificationPassed : VerifState.VerificationFailed;
|
||||
}
|
||||
StepRecord prevStep = refRecord.StepRecords.FirstOrDefault(x => (x.Workstep == wSum.PreviousWorkstepName && x.Result == 0));
|
||||
verificationFailed = (prevStep == null);
|
||||
verifState = (prevStep != null) ? VerifState.VerificationPassed : VerifState.VerificationFailed;
|
||||
}
|
||||
}
|
||||
|
||||
verificationFailed = verifState == VerifState.NoRecordAtAll ||
|
||||
verifState == VerifState.NoVerificationForThisProcess ||
|
||||
verifState == VerifState.VerificationFailed;
|
||||
///
|
||||
savingToTracingDBFailed = true;
|
||||
if ((proc != null) && (verifState != VerifState.NoRecordAtAll))
|
||||
{
|
||||
IList<Workstep> worksteps;
|
||||
if (workstepsDictionary.TryGetValue(proc.Id, out worksteps) && (worksteps.Count == 1))
|
||||
{
|
||||
/// Save a new reference record to the production tracing DB
|
||||
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(order, proc, null, testerRecord.SN,
|
||||
GlobalData.GetCurrentUserName(),
|
||||
Program.LocalSettings.Workplace,
|
||||
verificationFailed ? 2 : ((testerRecord.Status == Status.Passed) ? 0 : 1)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// 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, null, testerRecord.SN,
|
||||
GlobalData.GetCurrentUserName(),
|
||||
Program.LocalSettings.Workplace,
|
||||
(testerRecord.Status == Status.Passed) ? 0 : 1));
|
||||
}
|
||||
/// result: 0=OK, 1=test failed, 2=OK but previous step is missing, 3=failed and previous step is missing
|
||||
int result = ((testerRecord.Status == Status.Passed) ? 0 : 1) + ((verifState == VerifState.VerificationFailed) ? 2 : 0);
|
||||
string workplace = Program.LocalSettings.Workplace;
|
||||
string user = "user";
|
||||
///
|
||||
StepRecord stepRecord = new StepRecord(refRecord, wSum.WorkstepName, workplace, user, result);
|
||||
refRecord.Timestamp = stepRecord.Timestamp;
|
||||
refRecord.StepRecords.Add(stepRecord);
|
||||
dbSession.SaveOrUpdate(stepRecord);
|
||||
dbSession.SaveOrUpdate(refRecord);
|
||||
|
||||
transaction.Commit();
|
||||
savingToTracingDBFailed = false;
|
||||
transaction.Commit();
|
||||
|
||||
savingToTracingDBFailed = false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
readingFromTracingDBFailed = !savingToTracingDBFailed;
|
||||
if ((transaction != null) && !transaction.WasCommitted) transaction.Rollback();
|
||||
savingToTracingDBFailed = true;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Write the test result to Oracle DB
|
||||
///
|
||||
@ -955,8 +932,8 @@ namespace GenericTest
|
||||
///
|
||||
bool printingFailed = false;
|
||||
if (Program.LocalSettings.DoPrintLabels && testerRecord.CanPrintRecord()
|
||||
&& (!Program.LocalSettings.DoPrintGoodLabelsOnly || !(readingFromTracingDBFailed || savingToTracingDBFailed || verificationFailed
|
||||
|| savingToOracleDBFailed || (testerRecord.Status != Status.Passed))))
|
||||
&& (!Program.LocalSettings.DoPrintGoodLabelsOnly ||
|
||||
!(savingToTracingDBFailed || verificationFailed || savingToOracleDBFailed || testerRecord.Status != Status.Passed)))
|
||||
{
|
||||
/// Conditions for printing results are satisfied
|
||||
|
||||
@ -1005,11 +982,7 @@ namespace GenericTest
|
||||
/// Display the test result and related activity on the screen.
|
||||
/// Process the most severe errors first.
|
||||
///
|
||||
if (readingFromTracingDBFailed)
|
||||
{
|
||||
OnActivity(null, new ActivityEventArgs(testerRecord.SN, Strings.Reading_from_Tracing_DB_failed, ActivityCode.Failed, Color.Orange, 5000, Color.Wheat));
|
||||
}
|
||||
else if (verificationFailed)
|
||||
if (verificationFailed)
|
||||
{
|
||||
/// Verification is enabled, but a record from the previous workplace is missing
|
||||
OnActivity(null, new ActivityEventArgs(testerRecord.SN, Strings.Previous_workflow_step_is_missing_or_failed, ActivityCode.Failed, Color.Blue, 5000, Color.LightBlue));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2019-2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2019-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
@ -13,7 +13,7 @@ namespace GenericTest
|
||||
/// <summary>
|
||||
/// Class to be serialized to an XML file...
|
||||
/// </summary>
|
||||
[XmlRootAttribute("GenericTesterTracer")]
|
||||
[XmlRootAttribute("GenericTest")]
|
||||
public class LocalSettings
|
||||
{
|
||||
static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0];
|
||||
@ -25,6 +25,7 @@ namespace GenericTest
|
||||
|
||||
public string Workplace;
|
||||
public bool IsUserLoginRequired;
|
||||
public string Language;
|
||||
|
||||
public string ConnectionString;
|
||||
public string UsersDBConnString;
|
||||
@ -64,18 +65,19 @@ namespace GenericTest
|
||||
{
|
||||
/// Default settings
|
||||
Workplace = GenericTestDlg.DfltWorkplaceName;
|
||||
Language = "en";
|
||||
|
||||
ConnectionString = "SERVER=10.42.128.24; DATABASE=sledovanie2019; UID=vyroba2019; PASSWORD=qwerty; CHARSET=utf8";
|
||||
UsersDBConnString = "SERVER=10.42.128.24; DATABASE=st_wr_shared_config; UID=u9305784; PASSWORD=p89344390; CHARSET=utf8;";
|
||||
ConnectionString = "SERVER=10.116.192.200; DATABASE=nanjingshared; UID=nanjingshared; PASSWORD=C1ern4V0d4; CHARSET=utf8;";
|
||||
UsersDBConnString = "SERVER=10.116.192.200; DATABASE=nanjingshared; UID=nanjingshared; PASSWORD=C1ern4V0d4; CHARSET=utf8;";
|
||||
TestResultsFolder = "C:\\FTS\\HookSpool\\Filemover";
|
||||
ArchiveFolder = "C:\\FTS\\HookSpool\\Filemover";
|
||||
DoCheckSNsValidity = false;
|
||||
ValidSNPrefixes = "297,298,299,300,301,302";
|
||||
DoCheckPreviousTracingRecords = true;
|
||||
DoSaveTestResultToOracle = true;
|
||||
DoSaveTestResultToOracle = false;
|
||||
OracleMode = Mode.Production;
|
||||
DoPrintLabels = true;
|
||||
DoPrintGoodLabelsOnly = true;
|
||||
DoPrintGoodLabelsOnly = false;
|
||||
MaximizeWindowOnError = false;
|
||||
|
||||
MainWndMaximized = false;
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.1.134.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.134.0")]
|
||||
[assembly: AssemblyVersion("3.0.1")]
|
||||
[assembly: AssemblyFileVersion("3.0.1")]
|
||||
|
||||
36
GenericTest/Resources/Strings.Designer.cs
generated
36
GenericTest/Resources/Strings.Designer.cs
generated
@ -105,6 +105,15 @@ namespace GenericTest.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Logout.
|
||||
/// </summary>
|
||||
internal static string Logout {
|
||||
get {
|
||||
return ResourceManager.GetString("Logout", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Message.
|
||||
/// </summary>
|
||||
@ -258,6 +267,15 @@ namespace GenericTest.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Settings.
|
||||
/// </summary>
|
||||
internal static string Settings {
|
||||
get {
|
||||
return ResourceManager.GetString("Settings", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Something failed.
|
||||
/// </summary>
|
||||
@ -267,6 +285,24 @@ namespace GenericTest.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start.
|
||||
/// </summary>
|
||||
internal static string Start {
|
||||
get {
|
||||
return ResourceManager.GetString("Start", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Stop.
|
||||
/// </summary>
|
||||
internal static string Stop {
|
||||
get {
|
||||
return ResourceManager.GetString("Stop", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Test failed {0}.
|
||||
/// </summary>
|
||||
|
||||
@ -132,6 +132,9 @@
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>Error</value>
|
||||
</data>
|
||||
<data name="Logout" xml:space="preserve">
|
||||
<value>Logout</value>
|
||||
</data>
|
||||
<data name="Message" xml:space="preserve">
|
||||
<value>Message</value>
|
||||
</data>
|
||||
@ -183,9 +186,18 @@
|
||||
<data name="Serial_number_is_missing" xml:space="preserve">
|
||||
<value>Serial number is missing</value>
|
||||
</data>
|
||||
<data name="Settings" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="Something_failed" xml:space="preserve">
|
||||
<value>Something failed</value>
|
||||
</data>
|
||||
<data name="Start" xml:space="preserve">
|
||||
<value>Start</value>
|
||||
</data>
|
||||
<data name="Stop" xml:space="preserve">
|
||||
<value>Stop</value>
|
||||
</data>
|
||||
<data name="Test_failed_0" xml:space="preserve">
|
||||
<value>Test failed {0}</value>
|
||||
</data>
|
||||
|
||||
@ -132,6 +132,9 @@
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>Chyba</value>
|
||||
</data>
|
||||
<data name="Logout" xml:space="preserve">
|
||||
<value>Odhlásiť</value>
|
||||
</data>
|
||||
<data name="Message" xml:space="preserve">
|
||||
<value>Správa</value>
|
||||
</data>
|
||||
@ -180,9 +183,18 @@
|
||||
<data name="Serial_number_is_missing" xml:space="preserve">
|
||||
<value>Sériové číslo chýba</value>
|
||||
</data>
|
||||
<data name="Settings" xml:space="preserve">
|
||||
<value>Nastavenia</value>
|
||||
</data>
|
||||
<data name="Something_failed" xml:space="preserve">
|
||||
<value>Niečo sa nepodarilo</value>
|
||||
</data>
|
||||
<data name="Start" xml:space="preserve">
|
||||
<value>Štart</value>
|
||||
</data>
|
||||
<data name="Stop" xml:space="preserve">
|
||||
<value>Stop</value>
|
||||
</data>
|
||||
<data name="Test_failed_0" xml:space="preserve">
|
||||
<value>Test neprešiel {0}</value>
|
||||
</data>
|
||||
|
||||
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RFPowerCommon")]
|
||||
[assembly: AssemblyTitle("RecordProcessing")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RFPowerCommon")]
|
||||
[assembly: AssemblyProduct("RecordProcessing")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -20,6 +20,7 @@ namespace RecordProcessing
|
||||
CommTest, /// Communication test of water meter
|
||||
FlowtubeTestHe, /// Flowtube test with Helium
|
||||
FlowtubeTestAir, /// Flowtube test with air
|
||||
LaserNanjing, /// Laser markig in Xylem Nanjing
|
||||
Count
|
||||
}
|
||||
|
||||
@ -226,7 +227,8 @@ namespace RecordProcessing
|
||||
case RecordType.CommTest: record = CommTestRecord.FromFile(fileName); break;
|
||||
case RecordType.FlowtubeTestHe: record = FlowtubeTestHeRecord.FromFile(fileName); break;
|
||||
case RecordType.FlowtubeTestAir: record = FlowtubeTestAirRecord.FromFile(fileName); break;
|
||||
default: record = null; break;
|
||||
case RecordType.LaserNanjing: record = LaserNanjingRecord.FromFile(fileName); break;
|
||||
default: record = null; break;
|
||||
}
|
||||
|
||||
/// Process data extracted from the file
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<ProjectGuid>{67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>RFPowerCommon</RootNamespace>
|
||||
<RootNamespace>RecordProcessing</RootNamespace>
|
||||
<AssemblyName>RFPowerCommon</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@ -61,6 +61,7 @@
|
||||
<Compile Include="Records\CommTestRecord.cs" />
|
||||
<Compile Include="Records\FlowtubeTestAirRecord.cs" />
|
||||
<Compile Include="Records\FlowtubeTestHeRecord.cs" />
|
||||
<Compile Include="Records\LaserNanjingRecord.cs" />
|
||||
<Compile Include="Records\RFTestPrintDocument.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
91
RecordProcessing/Records/LaserNanjingRecord.cs
Normal file
91
RecordProcessing/Records/LaserNanjingRecord.cs
Normal file
@ -0,0 +1,91 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
|
||||
namespace RecordProcessing.Records
|
||||
{
|
||||
public class LaserNanjingRecord : IRecord
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(LaserNanjingRecord));
|
||||
|
||||
public bool CanSaveRecordToOracle() { return false; }
|
||||
public bool SaveRecordToOracle(Oracle.DataAccess.Client.OracleConnection oraConn) { return false; }
|
||||
public bool CanPrintRecord() { return false; }
|
||||
public bool PrintRecord() { return false; }
|
||||
|
||||
public static string Path;
|
||||
|
||||
public string FileName { get { return fileName; } }
|
||||
public string SN { get { return sn; } set { sn = value; } }
|
||||
public DateTime TimeStamp { get { return timeStamp; } }
|
||||
public Status Status { get { return status; } }
|
||||
public string Remark { get { return string.Empty; } }
|
||||
public string ResultStr { get { return string.Empty; } }
|
||||
|
||||
string fileName;
|
||||
string sn;
|
||||
DateTime timeStamp;
|
||||
Status status;
|
||||
string remark;
|
||||
|
||||
public LaserNanjingRecord()
|
||||
{
|
||||
sn = null;
|
||||
status = Status.Interrupted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a record from an xml-file
|
||||
/// </summary>
|
||||
/// <param name="fileName">xml-filename</param>
|
||||
/// <returns>Record or null</returns>
|
||||
public static LaserNanjingRecord FromFile(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string bareFileName = System.IO.Path.GetFileName(fileName).Replace(".csv", "");
|
||||
LaserNanjingRecord record = new LaserNanjingRecord();
|
||||
record.fileName = bareFileName;
|
||||
record.timeStamp = DateTime.Now;
|
||||
|
||||
using (StreamReader iStream = new StreamReader(fileName))
|
||||
{
|
||||
string firstLine = iStream.ReadLine();
|
||||
while (true)
|
||||
{
|
||||
string nextLine = iStream.ReadLine();
|
||||
|
||||
if (nextLine == null) break;
|
||||
|
||||
string[] fields = nextLine.Split(',');
|
||||
if (fields.Length >= 6)
|
||||
{
|
||||
record.sn = fields[1];
|
||||
record.status = (fields[5] == "OK") ? Status.Passed : Status.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.InfoFormat("Succesfully parsed: {0}", record);
|
||||
return record;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.ErrorFormat("Cannot open or parse file {0}: {1}", fileName, exc.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("File={0} Housing s/n={1}, Rslt={2}", fileName, sn, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,15 +2,12 @@
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using Gma.QrCodeNet.Encoding;
|
||||
using log4net;
|
||||
using NHibernate;
|
||||
using Oracle.DataAccess.Client;
|
||||
using System.Drawing;
|
||||
|
||||
namespace RecordProcessing.Records
|
||||
{
|
||||
|
||||
@ -205,17 +205,13 @@ namespace SharedDatabase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates processes, processDictionary and workstepsDictionary
|
||||
/// </summary>
|
||||
/// <param name="session">DB session</param>
|
||||
public static IList<Process> ReadWorkflowsFromDB(ISession session,
|
||||
string thisWorkstepName,
|
||||
out Dictionary<int, Process> workflowDict,
|
||||
out Dictionary<int, IList<Workstep>> workflowStepsDict,
|
||||
out Dictionary<int, ScanVerificationInfo> verifInfos,
|
||||
bool readDeactivatedWorkflows = false)
|
||||
public static IList<WorkflowSummary> ReadWorkflowSummariesFromDB(ISession session,
|
||||
string workstepPattern,
|
||||
bool readDeactivatedWorkflows = false)
|
||||
{
|
||||
IList<Process> workflows;
|
||||
if (readDeactivatedWorkflows)
|
||||
@ -234,30 +230,31 @@ namespace SharedDatabase
|
||||
)).List();
|
||||
}
|
||||
|
||||
workflowDict = new Dictionary<int, Process>();
|
||||
workflowStepsDict = new Dictionary<int, IList<Workstep>>();
|
||||
verifInfos = new Dictionary<int, ScanVerificationInfo>();
|
||||
var listOfWFSummaries = new List<WorkflowSummary>();
|
||||
|
||||
foreach (var wf in workflows)
|
||||
{
|
||||
IList<Workstep> steps = session.QueryOver<Workstep>()
|
||||
.Where(ws => ((ws.Workflow == wf) && (ws.Name == thisWorkstepName)))
|
||||
.List();
|
||||
workflowDict.Add(wf.Id, wf);
|
||||
workflowStepsDict.Add(wf.Id, steps);
|
||||
var wSum = new WorkflowSummary(wf);
|
||||
|
||||
ScanVerificationInfo info;
|
||||
if ((steps.Count == 1) && ((info = TracingDB.AnalyzeProcess(session, wf, steps[0])) != null))
|
||||
var workstep = wf.Worksteps.FirstOrDefault(x => x.Name.ToLower().Contains(workstepPattern.ToLower()));
|
||||
if (workstep != null)
|
||||
{
|
||||
verifInfos.Add(wf.Id, info);
|
||||
log.WarnFormat("Workflow {0} :: Verified step={1} part={2} verify ref. part={3}", wf, info.Workstep, info.Part, info.VerifyReferencePart);
|
||||
wSum.WorkstepName = workstep.Name;
|
||||
int previousStepNr = workstep.WorkstepNr - 1;
|
||||
var previousStep = (previousStepNr < 1) ? null : wf.Worksteps.FirstOrDefault(x => x.WorkstepNr == previousStepNr);
|
||||
if (previousStep != null) wSum.PreviousWorkstepName = previousStep.Name;
|
||||
}
|
||||
var part1 = wf.Parts.FirstOrDefault(x => x.StepNumber == 1);
|
||||
var part2 = wf.Parts.FirstOrDefault(x => x.StepNumber == 2);
|
||||
if (part1 != null) wSum.Part1Name = part1.Name;
|
||||
if (part2 != null) wSum.Part2Name = part2.Name;
|
||||
|
||||
listOfWFSummaries.Add(wSum);
|
||||
}
|
||||
|
||||
return workflows;
|
||||
return listOfWFSummaries;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds a workstep and a part to be verified (typically a previous workstep and one of its parts).
|
||||
/// Updates this.verifiedWorkstep, this.verifiedPart and this.verifyReferencePart.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user