Only show enabled panels in the diagnostics tab.
This commit is contained in:
parent
b25b363c96
commit
23ef413d91
@ -57,6 +57,9 @@ namespace smx_config
|
|||||||
args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex) ||
|
args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex) ||
|
||||||
args.controller[SelectedPad].test_data.AnyBadJumpersOnPanel(PanelIndex);
|
args.controller[SelectedPad].test_data.AnyBadJumpersOnPanel(PanelIndex);
|
||||||
|
|
||||||
|
// Only show this panel button if the panel's input is enabled.
|
||||||
|
SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args);
|
||||||
|
Visibility = ShouldBeDisplayed(config)? Visibility.Visible:Visibility.Collapsed;
|
||||||
});
|
});
|
||||||
onConfigChange.RefreshOnInputChange = true;
|
onConfigChange.RefreshOnInputChange = true;
|
||||||
onConfigChange.RefreshOnTestDataChange = true;
|
onConfigChange.RefreshOnTestDataChange = true;
|
||||||
@ -67,11 +70,18 @@ namespace smx_config
|
|||||||
base.OnClick();
|
base.OnClick();
|
||||||
|
|
||||||
// Select this panel.
|
// Select this panel.
|
||||||
Console.WriteLine(SelectedPanel + " -> " + Panel);
|
|
||||||
SelectedPanel = Panel;
|
SelectedPanel = Panel;
|
||||||
|
|
||||||
CurrentSMXDevice.singleton.FireConfigurationChanged(this);
|
CurrentSMXDevice.singleton.FireConfigurationChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return true if this button should be displayed.
|
||||||
|
private bool ShouldBeDisplayed(SMX.SMXConfig config)
|
||||||
|
{
|
||||||
|
bool[] enabledPanels = config.GetEnabledPanels();
|
||||||
|
int PanelIndex = Panel % 9;
|
||||||
|
return enabledPanels[PanelIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LevelBar: Control
|
public class LevelBar: Control
|
||||||
@ -244,6 +254,10 @@ namespace smx_config
|
|||||||
|
|
||||||
private void Refresh(LoadFromConfigDelegateArgs args)
|
private void Refresh(LoadFromConfigDelegateArgs args)
|
||||||
{
|
{
|
||||||
|
// First, make sure a valid panel is selected.
|
||||||
|
SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args);
|
||||||
|
SelectValidPanel(config);
|
||||||
|
|
||||||
RefreshSelectedPanel();
|
RefreshSelectedPanel();
|
||||||
|
|
||||||
P1Diagnostics.Visibility = args.controller[0].info.connected? Visibility.Visible:Visibility.Collapsed;
|
P1Diagnostics.Visibility = args.controller[0].info.connected? Visibility.Visible:Visibility.Collapsed;
|
||||||
@ -267,8 +281,8 @@ namespace smx_config
|
|||||||
}
|
}
|
||||||
NoResponseFromSensors.Visibility = AnySensorsNotResponding? Visibility.Visible:Visibility.Collapsed;
|
NoResponseFromSensors.Visibility = AnySensorsNotResponding? Visibility.Visible:Visibility.Collapsed;
|
||||||
BadSensorDIPSwitches.Visibility = HaveIncorrectSensorDIP? Visibility.Visible:Visibility.Collapsed;
|
BadSensorDIPSwitches.Visibility = HaveIncorrectSensorDIP? Visibility.Visible:Visibility.Collapsed;
|
||||||
|
|
||||||
// Adjust the DIP labels to match the PCB.
|
// Adjust the DIP labels to match the PCB.
|
||||||
SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args);
|
|
||||||
bool DIPLabelsOnLeft = config.masterVersion < 4;
|
bool DIPLabelsOnLeft = config.masterVersion < 4;
|
||||||
DIPLabelRight.Visibility = DIPLabelsOnLeft? Visibility.Collapsed:Visibility.Visible;
|
DIPLabelRight.Visibility = DIPLabelsOnLeft? Visibility.Collapsed:Visibility.Visible;
|
||||||
DIPLabelLeft.Visibility = DIPLabelsOnLeft? Visibility.Visible:Visibility.Collapsed;
|
DIPLabelLeft.Visibility = DIPLabelsOnLeft? Visibility.Visible:Visibility.Collapsed;
|
||||||
@ -330,7 +344,18 @@ namespace smx_config
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the selected color picker based on the value of selectedButton.
|
// If the selected panel isn't enabled for input, select another one.
|
||||||
|
private void SelectValidPanel(SMX.SMXConfig config)
|
||||||
|
{
|
||||||
|
bool[] enabledPanels = config.GetEnabledPanels();
|
||||||
|
int SelectedPanelIndex = SelectedPanel % 9;
|
||||||
|
|
||||||
|
// If we're not selected, or this button is visible, we don't need to do anything.
|
||||||
|
if(!enabledPanels[SelectedPanelIndex])
|
||||||
|
SelectedPanel = config.GetFirstEnabledPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the selected diagnostics button based on the value of selectedButton.
|
||||||
private void RefreshSelectedPanel()
|
private void RefreshSelectedPanel()
|
||||||
{
|
{
|
||||||
LoadFromConfigDelegateArgs args = CurrentSMXDevice.singleton.GetState();
|
LoadFromConfigDelegateArgs args = CurrentSMXDevice.singleton.GetState();
|
||||||
|
@ -150,6 +150,20 @@ namespace SMX
|
|||||||
if(panels[8]) enabledSensors[4] |= 0xF0;
|
if(panels[8]) enabledSensors[4] |= 0xF0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the index of the first enabled panel, or 1 (up) if no panels
|
||||||
|
// are enabled.
|
||||||
|
public int GetFirstEnabledPanel()
|
||||||
|
{
|
||||||
|
bool[] enabledPanels = GetEnabledPanels();
|
||||||
|
for(int i = 0; i < 9; ++i)
|
||||||
|
{
|
||||||
|
if(enabledPanels[i])
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// The layout of this structure (and the underlying C struct) matches the firmware configuration
|
// The layout of this structure (and the underlying C struct) matches the firmware configuration
|
||||||
// data. This is a bit inconvenient for the panel thresholds which aren't contiguous, so these
|
// data. This is a bit inconvenient for the panel thresholds which aren't contiguous, so these
|
||||||
// helpers just convert them to and from arrays.
|
// helpers just convert them to and from arrays.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user