private async void SaveDataAsync()
        {
            if (sessionData.IsSessionTimedOut)
            {
                _ = await dialogCoordinator.ShowMessageAsync(this, "Alert!", "Your RPD session has expired please log in again.", MessageDialogStyle.Affirmative);

                ReturnToLogin();
                return;
            }
            // Calls toString on each Range and separates each group with a newline character
            DocumentIdList <Range> idList = new DocumentIdList <Range>(Ranges);
            CommandResult          result = submitDocumentList.Execute(idList.ToString());

            if (result.IsError)
            {
                // Display error message
                _ = await dialogCoordinator.ShowMessageAsync(this, "Error!", result.ErorrMessage, MessageDialogStyle.Affirmative);

                return;
            }

            // Display success dialog
            _ = await dialogCoordinator.ShowMessageAsync(this, "Information!", $"The following ids were transmitted to RPD:\n{idList.ToString()}", MessageDialogStyle.Affirmative);

            // Reset session timeout
            sessionData.UpdateTimeStamp();

            // Clear list
            Ranges.Clear();

            // Set focus to next textbox
            IsRangeStartFocussed = true;
            IsRangeEndFocussed   = false;
        }
Example #2
0
        /// <summary>
        /// </summary>
        /// <param name="State"></param>
        public void SetAll(bool InState)
        {
            Resize(Size);

            Ranges.Clear();
            Ranges.Add(new Range {
                Start = 0, End = Size - 1, State = InState
            });
        }
        private void Plot(HumanData hd, CancellationToken token)
        {
            CardioPlotLst.Clear();
            TemperaturePlotLst.Clear();
            HeartRatePlotLst.Clear();

            if (token.IsCancellationRequested)
            {
                _timer.Stop();
                Range = null;

                if (Ranges?.Count > 0)
                {
                    Ranges.Clear();
                }
                CardioPlotLst.Clear();
                RaisePropertyChanged(nameof(CardioPlotLst));
                TemperaturePlotLst.Clear();
                RaisePropertyChanged(nameof(TemperaturePlotLst));
                HeartRatePlotLst.Clear();
                RaisePropertyChanged(nameof(HeartRatePlotLst));
                HR = 0;
                return;
            }

            for (int i = 0; i < hd.Data.Count; i++)
            {
                for (int j = 0; j < hd.Data[i].Cardio.Count; j++)
                {
                    CardioPlotLst.Add(new CardioPlot
                    {
                        EventTime = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]),
                        Cardio    = hd.Data[i].Cardio[j]
                    });
                    RaisePropertyChanged(nameof(CardioPlotLst));
                    HeartRatePlotLst.Add(new HeartRatePlot
                    {
                        EventTime = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]),
                        HeartRate = hd.Data[i].HR[j]
                    });
                    RaisePropertyChanged(nameof(HeartRatePlotLst));
                    TemperaturePlotLst.Add(new TemperaturePlot
                    {
                        EventTime   = PatientUtilities.UnixTimeStampToDateTime(hd.Data[i].Ticks[j]),
                        Temperature = hd.Data[i].Temperature[j]
                    });
                    RaisePropertyChanged(nameof(TemperaturePlotLst));
                }
            }
            if (hd.Data?.Count > 0)
            {
                HR = hd.Data.LastOrDefault().HR.LastOrDefault();
            }
            RaisePropertyChanged(nameof(HR));
        }
Example #4
0
        private void ConcatenateRanges()
        {
            var concatenatedRanges = new List <RangeOfValues>();
            var indexesToRemove    = new List <int>();
            var sortedRanges       = Ranges.OrderBy(k => k.Start).ToList();

            for (int idx = sortedRanges.Count() - 1; idx > 0;)
            {
                if (sortedRanges[idx].Start == sortedRanges[idx - 1].End || sortedRanges[idx].Start - sortedRanges[idx - 1].End == 1)
                {
                    concatenatedRanges.Add(new RangeOfValues(sortedRanges[idx - 1].Start, sortedRanges[idx].End));
                    indexesToRemove.Add(idx);
                    indexesToRemove.Add(idx - 1);
                    idx = -1;
                }
                idx--;
            }
            //rebuild _ranges retaining the original order placing the concatenated ranges at the end
            if (concatenatedRanges.Any())
            {
                int idx       = 0;
                var allRanges = new Dictionary <int, RangeOfValues>();
                foreach (var range in Ranges)
                {
                    allRanges.Add(idx++, range);
                }

                indexesToRemove.ForEach(id => sortedRanges.RemoveAt(id));

                var tRanges = new List <RangeOfValues>();
                sortedRanges.ForEach(sr => tRanges.Add(sr));

                concatenatedRanges.ForEach(sr => tRanges.Add(new RangeOfValues(sr.Start, sr.End)));

                Ranges.Clear();
                var removalKeys = allRanges.Keys.Where(k => tRanges.Contains(allRanges[k]));
                foreach (var nk in removalKeys)
                {
                    Ranges.Add(allRanges[nk]);
                    tRanges.Remove(allRanges[nk]);
                }

                tRanges.ForEach(tr => Ranges.Add(tr));
            }
        }
Example #5
0
        public override void Deserialize(BitStream stream)
        {
            Ranges.Clear();

            var count = stream.ReadCompressedUShort();

            for (var i = 0; i < count; i++)
            {
                var equalsMin = stream.ReadBit();

                var min = stream.ReadUInt();
                var max = equalsMin ? min : stream.ReadUInt();

                Ranges.Add(new Range <uint>
                {
                    Min = min,
                    Max = max
                });
            }
        }
Example #6
0
        /// <summary>
        /// </summary>
        /// <param name="Array"></param>
        public void FromArray(bool[] Array, int ArrayLength)
        {
            if (Size != ArrayLength)
            {
                Resize(ArrayLength);
            }

            Ranges.Clear();

            for (int RangeStart = 0; RangeStart < ArrayLength;)
            {
                int RangeEnd = RangeStart;

                for (; RangeEnd < Size; RangeEnd++)
                {
                    if (Array[RangeStart] != Array[RangeEnd])
                    {
                        break;
                    }
                }

                Range Range = new Range
                {
                    Start = RangeStart,
                    End   = RangeEnd - 1,
                    State = Array[RangeStart]
                };

                Ranges.Add(Range);

                RangeStart = RangeEnd;
            }

#if DO_VALIDATION
            Validate();
#endif
        }
 public void Clear()
 {
     Ranges?.Clear();
     //Rneurons.Clear();
     //RneuronIds = null;
 }
 public void Clear()
 {
     Ranges.Clear();
 }