Skip to content

Commit

Permalink
Removed SwitchBoardSensor. RpiVersion: added 64bit OS support (#361)
Browse files Browse the repository at this point in the history
* Removed unused SwitchboardSensor

* RpiVersion: 64 bit support + added cm5-models
  • Loading branch information
LarsWithCA authored Jan 28, 2025
1 parent 33bc43b commit 7319f02
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 108 deletions.
1 change: 0 additions & 1 deletion CA_DataUploaderLib/IOconf/IOconfLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class IOconfLoader : IIOconfLoader
("RPiTemp", (r, l) => new IOconfRPiTemp(r, l)),
("GenericSensor", (r, l) => new IOconfGeneric(r, l)),
("GenericOutput", (r, l) => new IOconfGenericOutput(r, l)),
("SwitchboardSensor", (r, l) => new IOconfSwitchboardSensor(r, l)),
("Node", (r, l) => new IOconfNode(r, l)),
("Code", (r, l) => new IOconfCode(r, l)),
(IOconfCurrent.TypeName, (r, l) => new IOconfCurrent(r, l)),
Expand Down
24 changes: 0 additions & 24 deletions CA_DataUploaderLib/IOconf/IOconfSwitchboardSensor.cs

This file was deleted.

5 changes: 4 additions & 1 deletion CA_DataUploaderLib/RPi_versions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ c03150;?;Compute Module 4S;1.0;4 GB;(Mfg by Sony)
d03150;?;Compute Module 4S;1.0;8 GB;(Mfg by Sony)
b04170;Q4 2023;5;1.0;2GB;(Mfg by Sony)
c04170;Q4 2023;5;1.0;4GB;(Mfg by Sony)
d04170;Q4 2023;5;1.0;8GB;(Mfg by Sony)
d04170;Q4 2023;5;1.0;8GB;(Mfg by Sony)
b04180;Q4 2024;Compute Module 5;1.0;2GB;(Mfg by Sony)
c04180;Q4 2024;Compute Module 5;1.0;4GB;(Mfg by Sony)
d04180;Q4 2024;Compute Module 5;1.0;8GB;(Mfg by Sony)
4 changes: 2 additions & 2 deletions CA_DataUploaderLib/RpiVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static void WriteResourceToFile(string resourceName, string fileName)
private static string? GetCPU()
{
if (_OS.Platform == PlatformID.Unix)
return DULutil.ExecuteShellCommand("cat /proc/cpuinfo | grep 'model name'").SplitNewLine().First().Substring(18).Trim();
return DULutil.ExecuteShellCommand("lscpu | grep 'Model name'").SplitNewLine().First().Substring(18).Trim();

return Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
}
Expand All @@ -182,7 +182,7 @@ private static string GetKernelVersion()
private static int GetNumberOfCores()
{
if (_OS.Platform == PlatformID.Unix)
return DULutil.ExecuteShellCommand("cat /proc/cpuinfo | grep 'model name'").SplitNewLine().Count;
return DULutil.ExecuteShellCommand("cat /proc/cpuinfo | grep 'processor'").SplitNewLine().Count;

return Environment.ProcessorCount;
}
Expand Down
3 changes: 1 addition & 2 deletions CA_DataUploaderLib/SwitchBoardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ private SwitchBoardController(IIOconf ioconf, CommandHandler cmd) : base(cmd, "s
.Concat(ioconf.GetEntries<IOconfOut230Vac>()
.GroupBy(p => p.BoxName)
.Where(g => !g.Any(p => p.PortNumber > 4)) //avoid port 5 board temperature conflict with boards that support 5 or more ports (without temperatures)
.Select(g => g.First().GetBoardTemperatureInputConf()))
.Concat(ioconf.GetEntries<IOconfSwitchboardSensor>().SelectMany(i => i.GetExpandedConf())))
.Select(g => g.First().GetBoardTemperatureInputConf())))
{
//we ignore remote boards and boards missing during the start sequence (as we don't have auto reconnect logic yet for those). Note the BaseSensorBox already reports the missing local boards.
foreach (var port in ioconf.GetEntries<IOconfOut230Vac>().Where(p => p.Map.IsLocalBoard && p.Map.McuBoard != null))
Expand Down
53 changes: 0 additions & 53 deletions UnitTests/IOconfFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,58 +80,5 @@ public void GetBoardStateNames_TemperatureField_Math()
Assert.AreEqual(1, boardStateNames.Count());
Assert.AreEqual("tm01_state", boardStateNames.First());
}

[TestMethod]
public void GetBoardStateNames_SwitchboardSensorExpandedInputField()
{
// Arrange
var ioconf = new IOconfFile(@"
Map; 3900553433511235353736; dc01
SwitchboardSensor; switchboardSensor_dc01; dc01
".SplitNewLine(StringSplitOptions.None));

// Act
var boardStateNames = ioconf.GetBoardStateNames("switchboardSensor_dc01_rms").ToList();

// Assert
Assert.AreEqual(1, boardStateNames.Count());
Assert.AreEqual("dc01_state", boardStateNames.First());
}

[TestMethod]
public void GetBoardStateNames_SwitchboardSensorExpandedInputField_Filter()
{
// Arrange
var ioconf = new IOconfFile(@"
Map; 3900553433511235353736; dc01
SwitchboardSensor; switchboardSensor_dc01; dc01
Filter;switchboardSensor_dc01_rms; Min;600;switchboardSensor_dc01_rms
".SplitNewLine(StringSplitOptions.None));

// Act
var boardStateNames = ioconf.GetBoardStateNames("switchboardSensor_dc01_rms_filter").ToList();

// Assert
Assert.AreEqual(1, boardStateNames.Count());
Assert.AreEqual("dc01_state", boardStateNames.First());
}

[TestMethod]
public void GetBoardStateNames_SwitchboardSensorExpandedInputField_Math()
{
// Arrange
var ioconf = new IOconfFile(@"
Map; 3900553433511235353736; dc01
SwitchboardSensor; switchboardSensor_dc01; dc01
Math; switchboardSensor_dc01_rms_math; switchboardSensor_dc01_rms + 1
".SplitNewLine(StringSplitOptions.None));

// Act
var boardStateNames = ioconf.GetBoardStateNames("switchboardSensor_dc01_rms_math").ToList();

// Assert
Assert.AreEqual(1, boardStateNames.Count());
Assert.AreEqual("dc01_state", boardStateNames.First());
}
}
}
25 changes: 0 additions & 25 deletions UnitTests/IOconfRedundantSensorsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,6 @@ public void ValidateDependencies_PointingToExistingSensor_Ok()

}

[TestMethod]
public void ValidateDependencies_PointingToExpandedInputField_Ok()
{
// Act
_ = new IOconfFile(@"
Map; 3900553433511235353736; dc01
SwitchboardSensor; switchboardSensor_dc01; dc01
RedundantSensors; switchboardSensor_redundant; switchboardSensor_dc01_rms
".SplitNewLine(StringSplitOptions.None));
}

[TestMethod]
public void ValidateDependencies_PointingToBaseExpandableInput_Fail()
{
// Act
var ex = Assert.ThrowsException<FormatException>(() => _ = new IOconfFile(@"
Map; 3900553433511235353736; dc01
SwitchboardSensor; switchboardSensor_dc01; dc01
RedundantSensors; switchboardSensor_redundant; switchboardSensor_dc01
".SplitNewLine(StringSplitOptions.None)));

// Assert
Assert.IsTrue(ex.Message.Contains("Failed to find"));
}

[TestMethod]
public void ValidateDependencies_PointingToMath_Ok()
{
Expand Down

0 comments on commit 7319f02

Please sign in to comment.