Changes for Xylem Nanjing, ver. 3.1.1676

This commit is contained in:
Milan Hanajik
2021-06-18 15:35:46 +02:00
parent f1ef16e1a3
commit 827a9f7c58
837 changed files with 46518 additions and 5851 deletions
+140 -75
View File
@@ -1,9 +1,10 @@
///
/// Copyright (c) 2018 Sensus Slovensko a.s.
/// Copyright (c) 2018-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Common;
using Config.Entities;
using TBF.Rig.Generic;
@@ -12,7 +13,7 @@ namespace TBF.Rig.DataContainer.BenchInfo
/// <summary>
/// Holds information identifying the test bench - serializable configuration.
/// </summary>
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@@ -22,17 +23,23 @@ namespace TBF.Rig.DataContainer.BenchInfo
///
/// Serialized parameters
///
public string TestBenchName;
public int TestBenchId;
public string Address1;
public string Address2;
public string Address3;
public string Address4;
public string Address5;
public string ApprovalId;
public string ApprovalDate;
public string ApprovedBy;
public RemoteDBUse RemoteDBUse;
public string TestBenchName; /// 0
public int TestBenchId; /// 1
public string Address1; /// 2
public string Address2; /// 3
public string Address3; /// 4
public string Address4; /// 5
public string Address5; /// 6
public string ApprovalId; /// 7
public string ApprovalDate; /// 8
public string ApprovedBy; /// 9
public int WaterMetersCount; /// 10
public int LinesCount; /// 11
public int CompoundMetersCount; /// 12
public ProcedureSelection Source1; /// 13
public ProcedureSelection Source2; /// 14
public ProcedureSelection Source3; /// 15
public ProcedureSelection Source4; /// 16
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
@@ -52,57 +59,75 @@ namespace TBF.Rig.DataContainer.BenchInfo
{
TestBenchName = "1";
TestBenchId = 1;
Address1 = string.Empty;
Address2 = string.Empty;
Address3 = string.Empty;
Address4 = string.Empty;
Address5 = string.Empty;
ApprovalId = string.Empty;
ApprovalDate = string.Empty;
ApprovedBy = string.Empty;
RemoteDBUse = RemoteDBUse.LocalDBOnly;
WaterMetersCount = 20;
LinesCount = 2;
CompoundMetersCount = 1;
Source1 = ProcedureSelection.FromLocalDB;
Source2 = ProcedureSelection.None;
Source3 = ProcedureSelection.None;
Source4 = ProcedureSelection.None;
}
string[] paramNames = new string[]
{
"Test bench name",
"Test bench ID",
"Address 1",
"Address 2",
"Address 3",
"Address 4",
"Address 5",
"Approval",
"Approval date",
"Approved by",
"Remote DB use",
"Test bench name", /// 0
"Test bench ID", /// 1
"Address 1", /// 2
"Address 2", /// 3
"Address 3", /// 4
"Address 4", /// 5
"Address 5", /// 6
"Approval", /// 7
"Approval date", /// 8
"Approved by", /// 9
"Water meters count", /// 10
"Lines count", /// 11
"Compound meters count", /// 12
"Procedure selection source 1", /// 13
"Procedure selection source 2", /// 14
"Procedure selection source 3", /// 15
"Procedure selection source 4", /// 16
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public ICollection<string> ParamValues(int i)
{
if (i == 10)
switch (i)
{
return new string[] { RemoteDBUse.LocalDBOnly.ToString(),
RemoteDBUse.RemoteDBOnly.ToString(),
RemoteDBUse.BothDBsLocalFirst.ToString(),
RemoteDBUse.BothDBsRemoteFirst.ToString() };
}
case 10:
return new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "10", "12", "14", "16", "18", "20" };
case 11:
return new string[] { "1", "2", "3", "4" };
case 12:
return new string[] { "0", "1", "2", "3" };
case 13:
case 14:
case 15:
case 16:
IList<string> items = new List<string>();
for (ProcedureSelection src = 0; src < ProcedureSelection.Count; src++)
{
items.Add(src.ToDescription());
}
return items;
return null;
default:
return null;
}
}
public string ToString(int i)
{
if (i == -1)
{
return string.Format("{0}: Bench name={1}, Bench Id={2}, Procedures={3}", Name, TestBenchName, TestBenchId, RemoteDBUse.ToDescription());
}
switch (i)
{
case 0: return TestBenchName;
@@ -115,49 +140,71 @@ namespace TBF.Rig.DataContainer.BenchInfo
case 7: return ApprovalId;
case 8: return ApprovalDate;
case 9: return ApprovedBy;
case 10: return RemoteDBUse.ToDescription();
default: return string.Empty;
case 10: return WaterMetersCount.ToString();
case 11: return LinesCount.ToString();
case 12: return CompoundMetersCount.ToString();
case 13: return Source1.ToDescription();
case 14: return Source2.ToDescription();
case 15: return Source3.ToDescription();
case 16: return Source4.ToDescription();
default:
return string.Format("{0}: Bench={1}, ID={2}, Mtrs={3}, Lines={4}, Compund mtrs={5}, S1={6}, S2={7}, S3={8}, S4={9}",
Name, TestBenchName, TestBenchId, WaterMetersCount, LinesCount, CompoundMetersCount, Source1, Source2, Source3, Source4);
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
public CfgUpdateFlags UpdateParam(int i, string str)
{
switch (i)
{
case 0: TestBenchName = strValue; return CfgUpdateFlags.RestartRqrd;
case 1: TestBenchId = int.Parse(strValue); return CfgUpdateFlags.RestartRqrd;
case 2: Address1 = strValue; return CfgUpdateFlags.RestartRqrd;
case 3: Address2 = strValue; return CfgUpdateFlags.RestartRqrd;
case 4: Address3 = strValue; return CfgUpdateFlags.RestartRqrd;
case 5: Address4 = strValue; return CfgUpdateFlags.RestartRqrd;
case 6: Address5 = strValue; return CfgUpdateFlags.RestartRqrd;
case 7: ApprovalId = strValue; return CfgUpdateFlags.RestartRqrd;
case 8: ApprovalDate = strValue; return CfgUpdateFlags.RestartRqrd;
case 9: ApprovedBy = strValue; return CfgUpdateFlags.RestartRqrd;
case 0: TestBenchName = str; return CfgUpdateFlags.RestartRqrd;
case 1: TestBenchId = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
case 2: Address1 = str; return CfgUpdateFlags.RestartRqrd;
case 3: Address2 = str; return CfgUpdateFlags.RestartRqrd;
case 4: Address3 = str; return CfgUpdateFlags.RestartRqrd;
case 5: Address4 = str; return CfgUpdateFlags.RestartRqrd;
case 6: Address5 = str; return CfgUpdateFlags.RestartRqrd;
case 7: ApprovalId = str; return CfgUpdateFlags.RestartRqrd;
case 8: ApprovalDate = str; return CfgUpdateFlags.RestartRqrd;
case 9: ApprovedBy = str; return CfgUpdateFlags.RestartRqrd;
case 10: WaterMetersCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
case 11: LinesCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
case 12: CompoundMetersCount = int.Parse(str); return CfgUpdateFlags.RestartRqrd;
case 10:
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++)
case 13:
for (ProcedureSelection source = 0; source < ProcedureSelection.Count; source++)
{
if (strValue == rdbu.ToDescription())
{
if (RemoteDBUse != rdbu)
{
RemoteDBUse = rdbu;
return CfgUpdateFlags.RestartRqrd;
}
else
{
return CfgUpdateFlags.None;
}
}
if (str == source.ToDescription()) { Source1 = source; return CfgUpdateFlags.RestartRqrd; }
}
return CfgUpdateFlags.Error;
break;
case 14:
for (ProcedureSelection source = 0; source < ProcedureSelection.Count; source++)
{
if (str == source.ToDescription()) { Source2 = source; return CfgUpdateFlags.RestartRqrd; }
}
break;
case 15:
for (ProcedureSelection source = 0; source < ProcedureSelection.Count; source++)
{
if (str == source.ToDescription()) { Source3 = source; return CfgUpdateFlags.RestartRqrd; }
}
break;
case 16:
for (ProcedureSelection source = 0; source < ProcedureSelection.Count; source++)
{
if (str == source.ToDescription()) { Source4 = source; return CfgUpdateFlags.RestartRqrd; }
}
break;
default: return CfgUpdateFlags.None;
}
return CfgUpdateFlags.Error;
}
public bool ValidateParam(int i, string strValue, out string message)
public bool ValidateParam(int i, string str, out string message)
{
message = string.Empty;
int idummy;
@@ -175,14 +222,26 @@ namespace TBF.Rig.DataContainer.BenchInfo
case 9:
return true;
case 1:
if (int.TryParse(strValue, out idummy) && (idummy >= 0)) return true;
if (int.TryParse(str, out idummy) && (idummy >= 0)) return true;
break;
case 10:
for (RemoteDBUse rdbu = 0; rdbu < RemoteDBUse.Count; rdbu++)
if (int.TryParse(str, out idummy) && idummy >= 1 && idummy <= 20) return true;
break;
case 11:
if (int.TryParse(str, out idummy) && idummy >= 1 && idummy <= 4) return true;
break;
case 12:
if (int.TryParse(str, out idummy) && idummy >= 0 && idummy <= 3) return true;
break;
case 13:
case 14:
case 15:
case 16:
for (ProcedureSelection source = 0; source < ProcedureSelection.Count; source++)
{
if (strValue == rdbu.ToDescription()) return true;
if (str == source.ToDescription()) return true;
}
return false;
break;
default:
message = "Invalid index";
return false;
@@ -204,10 +263,16 @@ namespace TBF.Rig.DataContainer.BenchInfo
prms.ApprovalId = this.ApprovalId;
prms.ApprovalDate = this.ApprovalDate;
prms.ApprovedBy = this.ApprovedBy;
prms.RemoteDBUse = this.RemoteDBUse;
prms.WaterMetersCount = this.WaterMetersCount;
prms.LinesCount = this.LinesCount;
prms.CompoundMetersCount = this.CompoundMetersCount;
prms.Source1 = this.Source1;
prms.Source2 = this.Source2;
prms.Source3 = this.Source3;
prms.Source4 = this.Source4;
}
public Config.Entities.IParamsProvider Clone()
public IParamsProvider Clone()
{
ComponentCfg pars = new ComponentCfg();
CopyContentTo(pars);