make groups hardcoded, ugly for now until we get map
This commit is contained in:
parent
0ca165c6bb
commit
a6ffcd9585
@ -7,12 +7,42 @@ using System.Threading.Tasks;
|
|||||||
namespace BenchtopParser {
|
namespace BenchtopParser {
|
||||||
public class Program {
|
public class Program {
|
||||||
public String? ProgramNumber { get; set; }
|
public String? ProgramNumber { get; set; }
|
||||||
public Dictionary<String, Dictionary<String, Configuration>> Group { get; set; }
|
|
||||||
|
|
||||||
public Program() {
|
// Config Groups. TODO: rename to w/e the heck they are.
|
||||||
this.Group = new Dictionary<String, Dictionary<String, Configuration>>();
|
public Dictionary<String, Configuration> A = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> I = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> M = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> O = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> P = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> R = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> S = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> T = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> U = new Dictionary<String, Configuration>();
|
||||||
|
public Dictionary<String, Configuration> X = new Dictionary<String, Configuration>();
|
||||||
|
|
||||||
|
public void AddToGroup(String group, Configuration config) {
|
||||||
|
// UGLY - but helpful later.
|
||||||
|
// TODO: Find out what the config names are and MAKE A MAP
|
||||||
|
var name = config.name;
|
||||||
|
if (name == null) {
|
||||||
|
throw new Exception("Name is null, adding before Config has set name");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (group.ToUpper()) {
|
||||||
|
case "A": this.A.Add(name, config); break;
|
||||||
|
case "I": this.I.Add(name, config); break;
|
||||||
|
case "M": this.M.Add(name, config); break;
|
||||||
|
case "O": this.O.Add(name, config); break;
|
||||||
|
case "P": this.P.Add(name, config); break;
|
||||||
|
case "R": this.R.Add(name, config); break;
|
||||||
|
case "S": this.S.Add(name, config); break;
|
||||||
|
case "T": this.T.Add(name, config); break;
|
||||||
|
case "U": this.U.Add(name, config); break;
|
||||||
|
case "X": this.X.Add(name, config); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
public String? name { get; set; }
|
public String? name { get; set; }
|
||||||
public String? value { get; set; }
|
public String? value { get; set; }
|
||||||
@ -80,15 +110,8 @@ namespace BenchtopParser {
|
|||||||
Configuration lineConfig = new Configuration(configLine, data);
|
Configuration lineConfig = new Configuration(configLine, data);
|
||||||
|
|
||||||
// Deal with this group logic
|
// Deal with this group logic
|
||||||
var group = programnumber_group_data[1];
|
if (current != null) {
|
||||||
if (current != null && !current.Group.ContainsKey(group)) {
|
current.AddToGroup(programnumber_group_data[1], lineConfig);
|
||||||
current.Group.Add(group, new Dictionary<String, Configuration> {
|
|
||||||
{ lineConfig.name, lineConfig }
|
|
||||||
});
|
|
||||||
} else if (current != null) {
|
|
||||||
current.Group[group].Add(lineConfig.name, lineConfig);
|
|
||||||
} else {
|
|
||||||
throw new Exception("Config list is null, something broke");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: What if multiple configs how to handle start and stop?
|
// TODO: What if multiple configs how to handle start and stop?
|
||||||
@ -96,6 +119,4 @@ namespace BenchtopParser {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,12 @@ namespace BenchtopParserTests {
|
|||||||
Assert.IsNotNull(programConfigs);
|
Assert.IsNotNull(programConfigs);
|
||||||
|
|
||||||
// Check that group collecting works -
|
// Check that group collecting works -
|
||||||
Assert.That(programConfigs.programs["P1"].Group["I"]["3"].value, Is.EqualTo("Unassigned"));
|
Assert.That(programConfigs.programs["P1"].I["3"].value, Is.EqualTo("Unassigned"));
|
||||||
Assert.That(programConfigs.programs["P1"].Group["O"]["3"].value, Is.EqualTo("Test Passed"));
|
Assert.That(programConfigs.programs["P1"].O["3"].value, Is.EqualTo("Test Passed"));
|
||||||
|
|
||||||
Assert.That(programConfigs.programs["P1"].Group["P"]["Minimum Pressure"].value, Is.EqualTo("95.000"));
|
Assert.That(programConfigs.programs["P1"].P["Minimum Pressure"].value, Is.EqualTo("95.000"));
|
||||||
Assert.That(programConfigs.programs["P1"].Group["P"]["Minimum Pressure"].unit, Is.EqualTo("mbar"));
|
Assert.That(programConfigs.programs["P1"].P["Minimum Pressure"].unit, Is.EqualTo("mbar"));
|
||||||
Assert.That(programConfigs.programs["P1"].Group["P"]["Minimum Pressure"].type, Is.EqualTo("f"));
|
Assert.That(programConfigs.programs["P1"].P["Minimum Pressure"].type, Is.EqualTo("f"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Loading…
Reference in New Issue
Block a user