IperLogger.ProcParams (DesigMode, DesigType), etc.
This commit is contained in:
@@ -103,6 +103,17 @@ namespace Common
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test designation mode for IperlLogger and IperlHead opto data files
|
||||
/// </summary>
|
||||
public enum DesigMode
|
||||
{
|
||||
Auto,
|
||||
Based_on_procedure,
|
||||
As_specified,
|
||||
Count
|
||||
}
|
||||
|
||||
public enum LoginMethod
|
||||
{
|
||||
UserName, /// = alias, abbreviation
|
||||
|
||||
@@ -41,17 +41,6 @@ namespace TBF.Rig.Output.DB.SensusOracle
|
||||
Count
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test/Q designation mode for IperlLogger and IperlHead opto data files
|
||||
/// </summary>
|
||||
public enum DesigMode
|
||||
{
|
||||
Auto,
|
||||
Based_on_procedure,
|
||||
As_specified,
|
||||
Count
|
||||
}
|
||||
|
||||
|
||||
public class Database : ComponentBase, IOperation, GenericDevices.IResultsWriter, GenericDevices.IStartInfoReader, Generic.IDevice
|
||||
{
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
///
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using log4net;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.Output.FileWriters.IperlLogger
|
||||
{
|
||||
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ProcParams));
|
||||
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public DesigMode DesigMode; /// 0
|
||||
public Results.Output.LogType DesigType; /// 1
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
DesigMode = DesigMode.Based_on_procedure; /// 0
|
||||
DesigType = Results.Output.LogType.Just_Q3Q2Q1; /// 1
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
"Designation Mode", /// 0
|
||||
"Designation when mode is 'As_specified'", /// 1
|
||||
};
|
||||
public override string ParamName(int i) { return paramNames[i]; }
|
||||
public override int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public override ICollection<string> ParamValues(int i)
|
||||
{
|
||||
IList<string> retVal = new List<string>();
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (DesigMode md = 0; md < DesigMode.Count; md++) retVal.Add(md.ToString());
|
||||
return retVal;
|
||||
|
||||
case 1:
|
||||
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++) retVal.Add(wm.ToString());
|
||||
return retVal;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return DesigMode.ToString();
|
||||
case 1: return DesigType.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves parameters from UI controls
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (DesigMode db = 0; db < DesigMode.Count; db++)
|
||||
{
|
||||
if (db.ToString() == strValue)
|
||||
{
|
||||
DesigMode = db;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++)
|
||||
{
|
||||
if (wm.ToString() == strValue)
|
||||
{
|
||||
DesigType = wm;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
/// Verifies whether strings in UI controls represent valid parameters
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (DesigMode db = 0; db < DesigMode.Count; db++)
|
||||
{
|
||||
if (db.ToString() == strValue) return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++)
|
||||
{
|
||||
if (wm.ToString() == strValue) return true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(ProcParams prms)
|
||||
{
|
||||
prms.DesigMode = DesigMode;
|
||||
prms.DesigType = DesigType;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
ProcParams pars = new ProcParams();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
||||
{
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
log.ErrorFormat("Failed to UpdateFromDbEntity({0}): {1}", dbEntity, exc.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ProcParams()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcParams(bool initialize)
|
||||
{
|
||||
if (initialize) InitializeAll();
|
||||
}
|
||||
|
||||
public ProcParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
|
||||
{
|
||||
this.procedureParamsEntity = procedureParamsEntity;
|
||||
this.componentName = componentName;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger
|
||||
|
||||
|
||||
WriterCfg writerCfg;
|
||||
public DesigMode DesigMode { get { return (writerCfg == null || writerCfg.ProcParams == null) ? DesigMode.Based_on_procedure : writerCfg.ProcParams.DesigMode; } }
|
||||
public LogType DesigType { get { return (writerCfg == null || writerCfg.ProcParams == null) ? LogType.Just_Q3Q2Q1 : writerCfg.ProcParams.DesigType; } }
|
||||
|
||||
enum CurrentOp
|
||||
{
|
||||
@@ -215,8 +217,7 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger
|
||||
///
|
||||
Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos;
|
||||
///
|
||||
if ((ProcessData.OracleDB != null && ProcessData.OracleDB.DesigMode == Output.DB.SensusOracle.DesigMode.Based_on_procedure) ||
|
||||
(testInfos == null && StateMachine.Procedure != null))
|
||||
if (DesigMode == DesigMode.Based_on_procedure && StateMachine.Procedure != null)
|
||||
{
|
||||
testInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ using TBF.Resources;
|
||||
|
||||
namespace TBF.Rig.Output.FileWriters.IperlLogger
|
||||
{
|
||||
public class WriterCfg : ComponentCfgBase, Generic.IComponentCfg, IParamsProvider
|
||||
public class WriterCfg : ComponentCfgBase, IComponentCfg, IParamsProvider
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(WriterCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
@@ -23,11 +23,17 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger
|
||||
public bool MonthFolders;
|
||||
public bool DayFolders;
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
public ProcParams ProcParams;
|
||||
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
|
||||
public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); }
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
WriterCfg()
|
||||
{
|
||||
}
|
||||
ProcParams = new ProcParams(true);
|
||||
}
|
||||
|
||||
public WriterCfg(string name, IComponentFactory factory)
|
||||
: this()
|
||||
|
||||
@@ -744,7 +744,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
///
|
||||
Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos;
|
||||
///
|
||||
if ((ProcessData.OracleDB != null && ProcessData.OracleDB.DesigMode == Output.DB.SensusOracle.DesigMode.Based_on_procedure) ||
|
||||
if ((ProcessData.OracleDB != null && ProcessData.OracleDB.DesigMode == DesigMode.Based_on_procedure) ||
|
||||
(testInfos == null && StateMachine.Procedure != null))
|
||||
{
|
||||
testInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
|
||||
|
||||
@@ -1064,6 +1064,7 @@
|
||||
<Compile Include="Rig\Output\FileWriters\ImageArchiver\ArchiverCfgCtrl.designer.cs">
|
||||
<DependentUpon>ArchiverCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Rig\Output\FileWriters\IperlLogger\ProcParams.cs" />
|
||||
<Compile Include="Rig\Output\FileWriters\IperlLogger\Writer.cs" />
|
||||
<Compile Include="Rig\Output\FileWriters\IperlLogger\WriterCfg.cs" />
|
||||
<Compile Include="Rig\Output\FileWriters\IperlLogger\Factory.cs" />
|
||||
|
||||
@@ -1058,7 +1058,7 @@ namespace TBF.UI.Procedures
|
||||
sb.AppendFormat("Read start info = {0} ", pp.ReadStartInfo);
|
||||
sb.AppendFormat("Start info is required = {0} ", pp.StartInfoIsRequired);
|
||||
sb.AppendFormat("Designation mode = {0}", pp.DesigMode);
|
||||
if (pp.DesigMode == TBF.Rig.Output.DB.SensusOracle.DesigMode.As_specified)
|
||||
if (pp.DesigMode == DesigMode.As_specified)
|
||||
{
|
||||
sb.AppendFormat(" Designation type = {0}", pp.DesigType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user