Example #1
0
        public bool IsWorkoutStarted()
        {
            try
            {
                //this has to be done initially to get a connection to the PM
                //fails with PMUSBInterface.PMUSBException if there's no success in connecting the Erg
                if (pm == null)
                {
                    pm = InitErg(0); //always work with the first connected erg (address == 0)
                }

                //Try to get the erg status inited first...
                if (!pm.IsStatusInited)
                {
                    pm.StatusUpdate();
                }

                //high res update to get the current workout state
                pm.HighResolutionUpdate();
            }
            catch (PMUSBInterface.PMUSBException ex)
            {
                //No erg connected yet, so workout is obviously not started...
                return(false);
            }

            var state = pm.WorkoutState;

            if (state != 0)
            {
                return(true);
            }

            return(false);
        }