public void CollectionDataReady(object sender, ComponentDataReadyEventArgs e)
        {
            int lostPackets = 0;
            int dataPoints  = 0;

            // Check each data point for if it was lost or not, and add it to the sum totals.
            for (int j = 0; j < e.Data.Count(); j++)
            {
                var channelData = e.Data[j];
                Data[j].AddRange(channelData.Data);
                dataPoints += channelData.Data.Count;
                for (int i = 0; i < channelData.Data.Count; i++)
                {
                    if (e.Data[0].IsLostData[i])
                    {
                        lostPackets++;
                    }
                }
            }
            TotalLostPackets += lostPackets;
            TotalDataPoints  += dataPoints;

            // No need to await this; it may affect our total throughput.
            Application.Current.Dispatcher.BeginInvoke(
                new Action(() =>
            {
                tbox_DroppedFrameCounter.Text = TotalLostPackets.ToString() + "/" + TotalDataPoints.ToString();
            }
                           ));
        }
        private void CollectionDataReady(object sender, ComponentDataReadyEventArgs e)
        {
            Console.WriteLine("Data collected: ");
            for (int i = 0; i < e.Data.Length; i++)
            {
                Console.WriteLine("Channel " + e.Data[i].Id);
                for (int k = 0; k < e.Data[i].Data.Count; k++)
                {
                    Console.Write(e.Data[i].Data[k] + " ");
                }
                Console.WriteLine();
            }

            Console.WriteLine("received a data frame (" + datasReadied + ")");
            datasReadied++;
        }
Пример #3
0
        public void CollectionDataReady(object sender, ComponentDataReadyEventArgs e)
        {
            int lostPackets = 0;
            int dataPoints  = 0;

            // Check each data point for if it was lost or not, and add it to the sum totals.
            for (int j = 0; j < e.Data.Count(); j++)
            {
                var channelData = e.Data[j];
                Data[j].AddRange(channelData.Data);
                dataPoints += channelData.Data.Count;
                for (int i = 0; i < channelData.Data.Count; i++)
                {
                    if (e.Data[0].IsLostData[i])
                    {
                        lostPackets++;
                    }
                }
            }
            TotalLostPackets += lostPackets;
            TotalDataPoints  += dataPoints;
        }
Пример #4
0
    public void CollectionDataReady(object sender, ComponentDataReadyEventArgs e)
    {
        APIStatusText.text = "Received data packet with average value: " + e.Data.First().Data.Average().ToString();
        int lostPackets = 0;
        int dataPoints  = 0;

        // Check each data point for if it was lost or not, and add it to the sum totals.
        for (int j = 0; j < e.Data.Count(); j++)
        {
            var channelData = e.Data[j];
            Data[j].AddRange(channelData.Data);
            dataPoints += channelData.Data.Count;
            for (int i = 0; i < channelData.Data.Count; i++)
            {
                if (e.Data[j].IsLostData[i])
                {
                    lostPackets++;
                }
            }
        }
        TotalLostPackets += lostPackets;
        TotalDataPoints  += dataPoints;
    }
Пример #5
0
        public void CollectionDataReady(object sender, ComponentDataReadyEventArgs e)
        {
            TransformData[] tData = new TransformData[e.Data.Length];
            foreach (TransformData td in e.Data)
            {
                tData[_sensorToChannel[_guidToSensor[td.Id]]] = td;
            }
            double[][] data = new double[e.Data.Length][];
            //if (tData.Length >= 2 && tData[0].Data.Count == tData[1].Data.Count)
            //{
            //    var channelData = tData[0];
            //    for (int i = 0; i < channelData.Data.Count; i++)
            //    {
            //        for (int j = 0; j < tData.Length; j++)
            //        {
            //            data[j] = tData[j].Data[i];
            //        }
            //        switch (_calibrationState)
            //        {
            //            case CalibrationState.Calibrating:
            //                Train(data);
            //                OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(null));
            //                break;
            //            case CalibrationState.Calibrated:
            //                OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(Process(data)));
            //                break;
            //            default: //CalibrationState.Uncalibrated
            //                for (int c = 0; c < data.Length; c++)
            //                {
            //                    _signals[c] = new TrignoEmgSignal(data[c]);
            //                }
            //                OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(_signals));
            //                break;
            //        }

            //    }
            //}
            if (tData.Length >= 2 && tData[0].Data.Count == tData[1].Data.Count)
            {
                for (int channel = 0; channel < tData.Length; channel++)
                {
                    data[channel] = new double[tData[channel].Data.Count];
                    for (int sample = 0; sample < tData[channel].Data.Count; sample++)
                    {
                        data[channel][sample] = tData[channel].Data[sample];
                    }
                }
                switch (_calibrationState)
                {
                case CalibrationState.Calibrating:
                    Train(data);
                    OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(null));
                    break;

                case CalibrationState.Calibrated:
                    OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(Process(data)));
                    break;

                default:     //CalibrationState.Uncalibrated
                    for (int c = 0; c < data.Length; c++)
                    {
                        _signals[c] = new TrignoEmgSignal(data[c]);
                    }
                    OnMuscleActivationChanged(new MuscleActivationChangedEventArgs(_signals));
                    break;
                }
            }
            else
            {
                Console.Write("E");
            }
        }