NeuralPi bug fixes.

This commit is contained in:
Robin Davies
2022-02-11 11:22:20 -05:00
parent 01b6f801e9
commit 5cf10b0154
29 changed files with 3314 additions and 193 deletions
+21 -1
View File
@@ -224,7 +224,7 @@ export class UiControl implements Deserializable<UiControl> {
} else {
if (this.min_value === 0 && this.max_value === 1)
{
if (this.toggled_property || this.enumeration_property || this.integer_property)
if (this.toggled_property || this.integer_property)
{
this.controlType = ControlType.OnOffSwitch;
}
@@ -267,6 +267,26 @@ export class UiControl implements Deserializable<UiControl> {
port_group: string = "";
units: Units = Units.none;
// Return the value of the closest scale_point.
clampSelectValue(value: number): number{
if (this.scale_points.length !== 0)
{
let minError = 1.0E100;
let bestValue = value;
for (let i = 0; i < this.scale_points.length; ++i)
{
let error = Math.abs(this.scale_points[i].value-value);
if (error < minError)
{
minError = error;
bestValue = this.scale_points[i].value;
}
}
return bestValue;
} else {
return value;
}
}
isOnOffSwitch() : boolean {
return this.controlType === ControlType.OnOffSwitch;
}