Skip to content
Merged

Dev #43

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/app/bin/Debug/net9.0/vicon",
"args": ["--interactive"],
"args": ["--interactive", "--check"],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,5 +364,5 @@ This project is licensed under the MIT license. For more details please refer to
[LICENSE](./LICENSE). This software depends on the following third party
components:

- Spectre.Console (https://github.com/spectreconsole/spectre.console/LICENSE.md)
- Spectre.Console (https://github.com/spectreconsole/spectre.console/blob/main/LICENSE.md)
- HidSharp (https://github.com/IntergatedCircuits/HidSharp/blob/master/License.txt)
3 changes: 3 additions & 0 deletions app/AliasedDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class AliasedDevice
[JsonPropertyName("serial")]
public string Serial { get; set; } = string.Empty;

[JsonPropertyName("config")]
public ConfiguredState? Config { get; set; }

public override string ToString()
{
if (Alias == string.Empty)
Expand Down
56 changes: 56 additions & 0 deletions app/ConfiguredState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System.Text.Json.Serialization;
using System.Security.Cryptography;
using LibDP100;

namespace PowerSupplyApp
{
public class ConfiguredState
{
[JsonPropertyName("hash")]
public string Hash { get; set; } = string.Empty;

[JsonPropertyName("system-params")]
public PowerSupplySystemParams SystemParams { get; set; } = new();

[JsonPropertyName("presets")]
public List<PowerSupplySetpoint> Presets { get; set; } = [];

/// <summary>
/// The number of presets available on the device.
/// </summary>
public const byte NumPresets = 10;

public void Print()
{
SystemParams.Print();
foreach (var preset in Presets)
{
preset.Print();
}
}

public string ComputeConfiguredHash()
{
using var sha256 = SHA256.Create();
var sb = new System.Text.StringBuilder();

// Include settings critical for safe operation.
sb.Append(SystemParams.OPP);
sb.Append(SystemParams.OTP);
sb.Append(SystemParams.RPP);
sb.Append(SystemParams.AutoOn);
foreach (var preset in Presets)
{
sb.Append(preset.Voltage);
sb.Append(preset.Current);
sb.Append(preset.OVP);
sb.Append(preset.OCP);
}

// Compute the hash
var hashBytes = sha256.ComputeHash(System.Text.Encoding.UTF8.GetBytes(sb.ToString()));
return Convert.ToHexString(hashBytes);
}

}
}
1 change: 1 addition & 0 deletions app/Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace PowerSupplyApp
public enum Operation
{
None,
Delay,
ReadOutput,
ReadActState,
ReadSystem,
Expand Down
6 changes: 6 additions & 0 deletions app/PowerControllerApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="vicon.settings.schema.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
184 changes: 140 additions & 44 deletions app/ProcessArgs.cs

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion app/ProcessArgsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ public enum ProcessArgsResult
NotImplemented,
MissingParameter,
InvalidParameter,
UnsupportedOption
UnsupportedOption,
SerialNumberRequired,
DeviceNotPresent,
ConfigurationMismatch,
InitializationFailed,
NoAliasedDeviceFound,
NoConfigurationPresent,
StoreError
}
}
Loading
Loading