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;
if (DebugExpiryPeriod != null)
{
DisableDebugging();
}
StopDebugTimer();
DebugExpiryPeriod = new CTimer((o) => DisableDebugging(), _DebugTimeoutInMs);
@@ -101,14 +98,24 @@ namespace PepperDash.Core
/// </summary>
private void DisableDebugging()
{
DebugExpiryPeriod.Stop();
DebugExpiryPeriod.Dispose();
DebugExpiryPeriod = null;
StopDebugTimer();
Debug.SetDeviceDebugSettings(ParentDeviceKey, eStreamDebuggingSetting.Off);
}
private void StopDebugTimer()
{
RxStreamDebuggingIsEnabled = 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,
Both = Rx | Tx
}
}
}

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);