Fixes some exceptions when setting stream debugging mode. Changes stream debugging to clear both rx and tx flags before setting mode again.

This commit is contained in:
Alex Johnson
2020-10-15 16:30:54 -04:00
parent 0453546d13
commit 3d7bc32b8a
2 changed files with 16 additions and 10 deletions

View File

@@ -81,9 +81,14 @@ namespace PepperDash.Core
if (DebugExpiryPeriod != null)
{
DisableDebugging();
DebugExpiryPeriod.Stop();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
}
RxStreamDebuggingIsEnabled = false;
TxStreamDebuggingIsEnabled = false;
DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs);
if ((setting & eStreamDebuggingSetting.Rx) == eStreamDebuggingSetting.Rx)
@@ -92,7 +97,7 @@ namespace PepperDash.Core
if ((setting & eStreamDebuggingSetting.Tx) == eStreamDebuggingSetting.Tx)
TxStreamDebuggingIsEnabled = true;
Debug.SetDeviceDebugSettings(ParentDeviceKey, setting);
Debug.SetDeviceDebugSettings(ParentDeviceKey, setting.ToString());
}
@@ -101,14 +106,17 @@ namespace PepperDash.Core
/// </summary>
private void DisableDebugging()
{
DebugExpiryPeriod.Stop();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
if (DebugExpiryPeriod != null)
{
DebugExpiryPeriod.Stop();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
}
RxStreamDebuggingIsEnabled = false;
TxStreamDebuggingIsEnabled = false;
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off);
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off.ToString());
}
}

View File

@@ -68,11 +68,9 @@ namespace PepperDash.Core.DebugThings
/// <returns></returns>
public void SetDebugSettingsForKey(string deviceKey, object settings)
{
var existingSettings = DeviceDebugSettings[deviceKey];
if (existingSettings != null)
if(DeviceDebugSettings.ContainsKey(deviceKey))
{
existingSettings = settings;
DeviceDebugSettings[deviceKey] = settings;
}
else
DeviceDebugSettings.Add(deviceKey, settings);