Show a warning if an incorrect sensor DIP switch is detected.
This commit is contained in:
parent
6d0820f495
commit
6d370ee092
@ -286,6 +286,9 @@ struct SMXSensorTestModeData
|
||||
|
||||
// The DIP switch settings on each panel. This is used for diagnostics displays.
|
||||
int iDIPSwitchPerPanel[9];
|
||||
|
||||
// Bad sensor selection DIP indication for each panel.
|
||||
bool iBadSensorDIP[9][4];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -486,7 +486,10 @@ void SMX::SMXDevice::HandleSensorTestDataResponse(const string &sReadBuffer)
|
||||
int16_t sensors[4];
|
||||
|
||||
uint8_t dip:4;
|
||||
uint8_t dummy2:4;
|
||||
uint8_t bad_sensor_dip_0:1;
|
||||
uint8_t bad_sensor_dip_1:1;
|
||||
uint8_t bad_sensor_dip_2:1;
|
||||
uint8_t bad_sensor_dip_3:1;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
@ -496,6 +499,7 @@ void SMX::SMXDevice::HandleSensorTestDataResponse(const string &sReadBuffer)
|
||||
memset(output.sensorLevel, 0, sizeof(output.sensorLevel));
|
||||
memset(output.bBadSensorInput, 0, sizeof(output.bBadSensorInput));
|
||||
memset(output.iDIPSwitchPerPanel, 0, sizeof(output.iDIPSwitchPerPanel));
|
||||
memset(output.iBadSensorDIP, 0, sizeof(output.iBadSensorDIP));
|
||||
|
||||
for(int iPanel = 0; iPanel < 9; ++iPanel)
|
||||
{
|
||||
@ -519,6 +523,10 @@ void SMX::SMXDevice::HandleSensorTestDataResponse(const string &sReadBuffer)
|
||||
output.bBadSensorInput[iPanel][2] = pad_data.bad_sensor_2;
|
||||
output.bBadSensorInput[iPanel][3] = pad_data.bad_sensor_3;
|
||||
output.iDIPSwitchPerPanel[iPanel] = pad_data.dip;
|
||||
output.iBadSensorDIP[iPanel][0] = pad_data.bad_sensor_dip_0;
|
||||
output.iBadSensorDIP[iPanel][1] = pad_data.bad_sensor_dip_1;
|
||||
output.iBadSensorDIP[iPanel][2] = pad_data.bad_sensor_dip_2;
|
||||
output.iBadSensorDIP[iPanel][3] = pad_data.bad_sensor_dip_3;
|
||||
|
||||
for(int iSensor = 0; iSensor < 4; ++iSensor)
|
||||
output.sensorLevel[iPanel][iSensor] = pad_data.sensors[iSensor];
|
||||
|
@ -54,7 +54,8 @@ namespace smx_config
|
||||
Pressed = args.controller[SelectedPad].inputs[PanelIndex];
|
||||
|
||||
Warning = !args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex] ||
|
||||
args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex);
|
||||
args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex) ||
|
||||
args.controller[SelectedPad].test_data.AnyBadDIPSwitchSettingsOnPanel(PanelIndex);
|
||||
|
||||
});
|
||||
onConfigChange.RefreshOnInputChange = true;
|
||||
@ -146,6 +147,7 @@ namespace smx_config
|
||||
private FrameImage ExpectedDIP;
|
||||
private FrameworkElement NoResponseFromPanel;
|
||||
private FrameworkElement NoResponseFromSensors;
|
||||
private FrameworkElement BadSensorDIPSwitches;
|
||||
private FrameworkElement P1Diagnostics, P2Diagnostics;
|
||||
private FrameworkElement DIPLabelLeft, DIPLabelRight;
|
||||
|
||||
@ -173,6 +175,7 @@ namespace smx_config
|
||||
ExpectedDIP = Template.FindName("ExpectedDIP", this) as FrameImage;
|
||||
NoResponseFromPanel = Template.FindName("NoResponseFromPanel", this) as FrameworkElement;
|
||||
NoResponseFromSensors = Template.FindName("NoResponseFromSensors", this) as FrameworkElement;
|
||||
BadSensorDIPSwitches = Template.FindName("BadSensorDIPSwitches", this) as FrameworkElement;
|
||||
P1Diagnostics = Template.FindName("P1Diagnostics", this) as FrameworkElement;
|
||||
P2Diagnostics = Template.FindName("P2Diagnostics", this) as FrameworkElement;
|
||||
|
||||
@ -250,11 +253,16 @@ namespace smx_config
|
||||
ExpectedDIP.Frame = PanelIndex;
|
||||
|
||||
// Show or hide the sensor error text.
|
||||
bool AnySensorsNotResponding = false;
|
||||
bool AnySensorsNotResponding = false, HaveIncorrectSensorDIP = false;
|
||||
if(args.controller[SelectedPad].test_data.bHaveDataFromPanel[PanelIndex])
|
||||
{
|
||||
AnySensorsNotResponding = args.controller[SelectedPad].test_data.AnySensorsOnPanelNotResponding(PanelIndex);
|
||||
NoResponseFromSensors.Visibility = AnySensorsNotResponding? Visibility.Visible:Visibility.Collapsed;
|
||||
|
||||
// Don't show both warnings.
|
||||
HaveIncorrectSensorDIP = !AnySensorsNotResponding && args.controller[SelectedPad].test_data.AnyBadDIPSwitchSettingsOnPanel(PanelIndex);
|
||||
}
|
||||
NoResponseFromSensors.Visibility = AnySensorsNotResponding? Visibility.Visible:Visibility.Collapsed;
|
||||
BadSensorDIPSwitches.Visibility = HaveIncorrectSensorDIP? Visibility.Visible:Visibility.Collapsed;
|
||||
// Adjust the DIP labels to match the PCB.
|
||||
SMX.SMXConfig config = ActivePad.GetFirstActivePadConfig(args);
|
||||
bool DIPLabelsOnLeft = config.masterVersion < 4;
|
||||
|
@ -591,6 +591,25 @@ Use if the platform is too sensitive.</clr:String>
|
||||
Text="Some sensors on this panel aren't responding correctly."
|
||||
/>
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel
|
||||
x:Name="BadSensorDIPSwitches"
|
||||
Width="200"
|
||||
>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Center"
|
||||
Foreground="#FFFF0000" FontSize="20"
|
||||
FontFamily="{StaticResource WarningMarkFont}"
|
||||
Text="!"
|
||||
/>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
TextWrapping="Wrap" TextAlignment="Center"
|
||||
Text="Some sensors on this panel have incorrect DIP switch selections."
|
||||
/>
|
||||
</DockPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Margin="10,10,0,0"
|
||||
|
@ -229,6 +229,9 @@ namespace SMX
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
|
||||
public int[] iDIPSwitchPerPanel;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, ArraySubType=UnmanagedType.I1, SizeConst = 9*4)]
|
||||
public bool[] iBadSensorDIP;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
SMXSensorTestModeData other = (SMXSensorTestModeData) obj;
|
||||
@ -236,10 +239,11 @@ namespace SMX
|
||||
Helpers.SequenceEqual(bHaveDataFromPanel, other.bHaveDataFromPanel) &&
|
||||
Helpers.SequenceEqual(sensorLevel, other.sensorLevel) &&
|
||||
Helpers.SequenceEqual(bBadSensorInput, other.bBadSensorInput) &&
|
||||
Helpers.SequenceEqual(iDIPSwitchPerPanel, other.iDIPSwitchPerPanel);
|
||||
Helpers.SequenceEqual(iDIPSwitchPerPanel, other.iDIPSwitchPerPanel) &&
|
||||
Helpers.SequenceEqual(iBadSensorDIP, other.iBadSensorDIP);
|
||||
}
|
||||
|
||||
// Dummy override to silence a bad warning. We don't use these in containers to need
|
||||
// Dummy override to silence a bad warning. We don't use these in containers that need
|
||||
// a hash code implementation.
|
||||
public override int GetHashCode() { return base.GetHashCode(); }
|
||||
|
||||
@ -254,6 +258,17 @@ namespace SMX
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AnyBadDIPSwitchSettingsOnPanel(int panel)
|
||||
{
|
||||
if(!bHaveDataFromPanel[panel])
|
||||
return false;
|
||||
for(int sensor = 0; sensor < 4; ++sensor)
|
||||
if(iBadSensorDIP[panel*4+sensor])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public static class SMX
|
||||
|
Loading…
x
Reference in New Issue
Block a user