public void GetAllPropertiesTest() { var tThing = new TheThing(); tThing.SetProperty("Prop1", "v1"); var prop2 = tThing.SetProperty("Prop2", "v2"); var prop2_1 = prop2.SetProperty("Prop2_1", "v2_1"); prop2_1.SetProperty("Prop2_1_1", "v2_1_1"); prop2.SetProperty("Prop2_2", "v2_2"); var allProps = tThing.GetAllProperties(10); var expectedProps = new List <string> { "Prop1", "Prop2", "[Prop2].[Prop2_1]", "[Prop2].[Prop2_1].[Prop2_1_1]", "[Prop2].[Prop2_2]" }.OrderBy(n => n); Assert.IsTrue(allProps.Select(p => cdeP.GetPropertyPath(p)).OrderBy(n => n).SequenceEqual(expectedProps)); }
private async Task StartPlaybackAsync(bool bFromAutoStart) { try { lock (startLock) { if (_isStarting || IsStarted || playbackCancel?.IsCancellationRequested == false || playbackTasks?.Count > 0) { MyBaseThing.LastMessage = "Playback already started"; return; } _isStarting = true; } } catch { } try { if (_kpiTimer == null) { _kpiTimer = new Timer(OnKpiUpdate, null, 0, (int)_kpiInterval.TotalMilliseconds); } else { _kpiTimer.Change(0, (int)_kpiInterval.TotalMilliseconds); } sw = new Stopwatch(); sw.Start(); MyBaseThing.LastMessage = "Loading data..."; var thingUpdates = await LoadThingUpdatesAsync(InputFileName); ItemCount = thingUpdates.Count(); LoadDuration = sw.Elapsed; MyBaseThing.LastMessage = $"Data loaded: {ItemCount} items in {LoadDuration}. Starting playback..."; sw.Restart(); var propCountBefore = Gen_Stats_PropertyCounter; playbackTasks.Clear(); playbackCancel?.Cancel(); playbackCancel = new CancellationTokenSource(); var cancelCombined = CancellationTokenSource.CreateLinkedTokenSource(playbackCancel.Token, TheBaseAssets.MasterSwitchCancelationToken); var startupDelayRange = new TimeSpan(0, 0, 0); var tThingWithAllProperties = new TheThing { FriendlyName = "ignored", ID = "ignored", EngineName = PlaybackEngineName, DeviceType = PlaybackDeviceType, }; _ = new CDMyMeshManager.Contracts.MsgReportTestStatus { NodeId = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID, PercentCompleted = 0, SuccessRate = 0, Status = CDMyMeshManager.Contracts.eTestStatus.Running, TestRunId = TheCommonUtils.CGuid(TheBaseAssets.MySettings.GetSetting("TestRunID")), Timestamp = DateTimeOffset.Now, ResultDetails = new Dictionary <string, object> { { "Message", "Starting playback " }, }, }.Publish().Result; if (bFromAutoStart && AutoStartDelay > 0) { TheBaseAssets.MySYSLOG.WriteToLog(700, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseThing.EngineName, $"Playback gathering all properties from the data file.", eMsgLevel.l6_Debug)); await PlaybackLoop(tThingWithAllProperties, cancelCombined.Token, thingUpdates, startupDelayRange, bFromAutoStart); TheBaseAssets.MySYSLOG.WriteToLog(700, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseThing.EngineName, $"Playback gathered all properties from the data file. Found {tThingWithAllProperties.MyPropertyBag.Count} properties.", eMsgLevel.l6_Debug)); } var allProperties = tThingWithAllProperties.GetAllProperties(10).Where(p => p.Name != nameof(TheThing.ID) && p.Name != nameof(TheThing.FriendlyName) && p.Name != nameof(TheThing.EngineName) && p.Name != nameof(TheThing.DeviceType)); _ = new CDMyMeshManager.Contracts.MsgReportTestStatus { NodeId = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID, PercentCompleted = 0, SuccessRate = 0, Status = CDMyMeshManager.Contracts.eTestStatus.Running, TestRunId = TheCommonUtils.CGuid(TheBaseAssets.MySettings.GetSetting("TestRunID")), Timestamp = DateTimeOffset.Now, ResultDetails = new Dictionary <string, object> { { "Message", "Starting playback loops" }, { "UniquePropertyCount", allProperties.Count() }, { "NumberThings", ParallelPlaybackCount }, }, }.Publish().Result; _ = RunPlaybackAsync(allProperties, thingUpdates, startupDelayRange, bFromAutoStart, propCountBefore); } catch (Exception e) { IsStarted = false; MyBaseThing.StatusLevel = 2; MyBaseThing.LastMessage = $"Error starting playback: {e.Message}"; } finally { lock (startLock) { _isStarting = false; } } }