Example #1
0
        private static void StartConnectionChecker()
        {
            if (connectionChecker != null)
            {
                return;
            }

            connectionChecker = new DispatcherTimer
            {
                Interval = new TimeSpan(0, 0, 60)
            };
            connectionChecker.Tick += (sender, o) =>
            {
                if (!instance.sentNewValue)
                {
                    Debug.WriteLine(
                        "-------------------------------\nLOST BAND CONNECTION...RECONNECTING\n-------------------------------");
                    var demoInterv = instance.Interval;
                    var demoClass  = instance.classifierAmount;
                    instance.Dispose();
                    instance = null;
                    GetInstance(demoInterv, demoClass).Initialize();
                }
                else
                {
                    Debug.WriteLine(
                        $"-------------------------------\nCONNECTED TO {instance.selectedBand.Name}\n-------------------------------");
                    instance.sentNewValue = false;
                }
            };
            connectionChecker.Start();
        }
Example #2
0
        public static BandManager GetInstance(int interv, int classAmount)
        {
            if (instance == null)
            {
                instance = new BandManager(interv, classAmount);
                return(instance);
            }

            if (instance.Interval == interv && instance.classifierAmount == classAmount)
            {
                return(instance);
            }

            instance.Dispose();
            isFirstCaloriesReading = true;
            isFirstStepsReading    = true;
            instance = new BandManager(interv, classAmount);
            return(instance);
        }