Ejemplo n.º 1
0
 private void onHrDataReceived(HRData p_hrData)
 {
     Application.Current.Dispatcher.Invoke((Action) delegate
     {
         processHrData(p_hrData);
     });
 }
Ejemplo n.º 2
0
        private void onTimerTick(object sender, ElapsedEventArgs e)
        {
            int    bpm    = (int)getRandomNumber(m_uiConfig.MinValue, m_uiConfig.MaxValue);
            HRData hrData = new HRData(bpm, DateTime.Now);

            m_hrSubject.OnNext(hrData);
        }
Ejemplo n.º 3
0
 private void startListening()
 {
     if (HRData.Count > 0)
     {
         HRData.Clear();
         HRData = new ObservableCollection <HRData>();
     }
     CanStartExecute = false;
     CanStopExecute  = true;
     m_heartRateListener.Start();
     m_timer.Start();
 }
Ejemplo n.º 4
0
        private void processHrData(HRData p_hrData)
        {
            ObservableCollection <HRData> hrDataList = new ObservableCollection <HRData>();
            int index = 0;
            int firstCollectionIndex = 0;

            if (HRData.Count == m_uiConfig.NumOfVisibleItems)
            {
                firstCollectionIndex = 1;
            }

            for (int i = firstCollectionIndex; i < HRData.Count; i++)
            {
                hrDataList.Add(new HRData(HRData[i].Bpm, HRData[i].Time, index++));
            }

            hrDataList.Add(new HRData(p_hrData.Bpm, p_hrData.Time, index));

            HRData.Clear();

            HRData       = hrDataList;
            LastBpmValue = HRData.Last().Bpm;
        }
Ejemplo n.º 5
0
        private void onDataRecieved(object p_sender, SerialDataReceivedEventArgs p_e)
        {
            if (m_serialPort.IsOpen)
            {
                m_isReading = true;
                byte[] totalMessageBytes = new byte[12];
                byte[] timeBytes         = new byte[8];
                byte[] valueBytes        = new byte[4];
                (p_sender as SerialPort).Read(totalMessageBytes, 0, 12);

                for (int i = 0; i < 8; i++)
                {
                    timeBytes[i] = totalMessageBytes[i];
                }

                int index = 0;
                for (int i = 8; i < 12; i++)
                {
                    valueBytes[index] = totalMessageBytes[i];
                    index++;
                }

                int      value    = BitConverter.ToInt16(valueBytes, 0);
                long     timeLong = BitConverter.ToInt64(timeBytes, 0);
                DateTime dateTime = DateTime.FromBinary(timeLong);

                HRData hrData = new HRData(value, dateTime);
                m_hrSubject.OnNext(hrData);
                m_isReading = false;
                if (m_shallClose)
                {
                    m_serialPort.Close();
                    m_shallClose = false;
                }
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            HRData hrData = (HRData)value;

            return(hrData.Time.Hour.ToString() + ":" + hrData.Time.Minute.ToString() + "." + hrData.Time.Second.ToString());
        }