Merge pull request #66 from PepperDash/bugfix/stream-debugging-fixes

Fixes some exceptions when setting stream debugging mode
This commit is contained in:
Andrew Welker
2020-10-28 11:35:42 -06:00
committed by GitHub
2 changed files with 18 additions and 13 deletions

View File

@@ -79,10 +79,7 @@ namespace PepperDash.Core
_DebugTimeoutInMs = minutes * 60000; _DebugTimeoutInMs = minutes * 60000;
if (DebugExpiryPeriod != null) StopDebugTimer();
{
DisableDebugging();
}
DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs); DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs);
@@ -101,14 +98,24 @@ namespace PepperDash.Core
/// </summary> /// </summary>
private void DisableDebugging() private void DisableDebugging()
{ {
DebugExpiryPeriod.Stop(); StopDebugTimer();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off);
}
private void StopDebugTimer()
{
RxStreamDebuggingIsEnabled = false; RxStreamDebuggingIsEnabled = false;
TxStreamDebuggingIsEnabled = false; TxStreamDebuggingIsEnabled = false;
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off); if (DebugExpiryPeriod == null)
{
return;
}
DebugExpiryPeriod.Stop();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
} }
} }
@@ -123,4 +130,4 @@ namespace PepperDash.Core
Tx = 2, Tx = 2,
Both = Rx | Tx Both = Rx | Tx
} }
} }

View File

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