Esempio n. 1
0
        private void OnDataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            var sensorData = sp.ReadLine();
            var eventArgs  = new SensorUSBEventArgs();

            eventArgs.sensorData = sensorData;
            sensorDataReceived?.Invoke(this, eventArgs);
            eventArgs = null;
        }
Esempio n. 2
0
 private void frontSensorDataHandler(object sender, SensorUSBEventArgs USBeventArgs)
 {
     sensorDataProcessor(frontClassifier, frontSensorQty, ref frontReadings, "front");
 }
Esempio n. 3
0
 private void leftHandSensorDataHandler(object sender, SensorUSBEventArgs USBeventArgs)
 {
     sensorDataProcessor(leftHandClassifier, leftHandSensorQty, ref leftHandReadings, "leftHand");
 }
Esempio n. 4
0
 private void rightSideHeadSensorDataHandler(object sender, SensorUSBEventArgs USBeventArgs)
 {
     sensorDataProcessor(rightSideHeadClassifier, rightSideHeadSensorQty, ref rightSideHeadReadings, "rightSideHead");
 }
Esempio n. 5
0
 private void topHeadSensorDataHandler(object sender, SensorUSBEventArgs USBeventArgs)
 {
     sensorDataProcessor(topHeadClassifier, topHeadSensorQty, ref topHeadReadings, "topHead");
 }
Esempio n. 6
0
        public void sensorDataHandler(object sender, SensorUSBEventArgs USBeventArgs)
        {
            var data = USBeventArgs.sensorData.Split(' ').Select(d => Convert.ToInt16(d)).ToArray();

            // return;

            short[] topHeadData       = { data[0], data[1], data[2], data[3] };
            short[] leftSideHeadData  = { data[6], data[7] };
            short[] rightSideHeadData = { data[4], data[5] };
            short[] rightHandData     = { data[10], data[11] };
            short[] leftHandData      = { data[8], data[9] };
            short[] frontData         = { data[12], data[13] };

            topHeadReadings       = topHeadReadings.Append(topHeadData).Skip(1).ToArray();
            leftSideHeadReadings  = leftSideHeadReadings.Append(leftSideHeadData).Skip(1).ToArray();
            rightSideHeadReadings = rightSideHeadReadings.Append(rightSideHeadData).Skip(1).ToArray();
            rightHandReadings     = rightHandReadings.Append(rightHandData).Skip(1).ToArray();
            leftHandReadings      = leftHandReadings.Append(leftHandData).Skip(1).ToArray();
            frontReadings         = frontReadings.Append(frontData).Skip(1).ToArray();

            // Console.WriteLine(USBeventArgs.sensorData);

            // return;

            if (
                topHeadReadings.ToArray()[0].All(d => d == 0) &&
                topHeadReadings.ToArray()[1].Any(d => d != 0)
                // readings.ToArray()[readings.ToArray().Length - 1].All(d => d == 0)
                // && readings.ToArray()[readings.ToArray().Length - 2].Any(d => d != 0)
                )
            {
                if (topHeadReadings.All(r => r.All(rr => rr < 40)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // topHeadDataSetWriter.writeData(topHeadReadings);

                    topHeadSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }

            if (
                leftSideHeadReadings.ToArray()[0].All(d => d == 0) &&
                leftSideHeadReadings.ToArray()[1].Any(d => d != 0)
                )
            {
                if (leftSideHeadReadings.All(r => r.All(rr => rr < 40)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // leftSideHeadDataSetWriter.writeData(leftSideHeadReadings);

                    leftSideHeadSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }

            if (
                rightSideHeadReadings.ToArray()[0].All(d => d == 0) &&
                rightSideHeadReadings.ToArray()[1].Any(d => d != 0)
                )
            {
                if (rightSideHeadReadings.All(r => r.All(rr => rr < 40)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // rightSideHeadDataSetWriter.writeData(rightSideHeadReadings);

                    rightSideHeadSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }

            if (
                rightHandReadings.ToArray()[0].All(d => d == 0) &&
                rightHandReadings.ToArray()[1].Any(d => d != 0)
                )
            {
                if (rightHandReadings.All(r => r.All(rr => rr < 100)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // rightHandDataSetWriter.writeData(rightHandReadings);

                    rightHandSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }

            if (
                leftHandReadings.ToArray()[0].All(d => d == 0) &&
                leftHandReadings.ToArray()[1].Any(d => d != 0)
                )
            {
                if (leftHandReadings.All(r => r.All(rr => rr < 100)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // leftHandDataSetWriter.writeData(leftHandReadings);

                    leftHandSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }

            if (
                frontReadings.ToArray()[0].All(d => d == 0) &&
                frontReadings.ToArray()[1].Any(d => d != 0)
                )
            {
                if (frontReadings.All(r => r.All(rr => rr < 100)))
                {
                    Console.WriteLine("Drop");
                }
                else
                {
                    // frontDataSetWriter.writeData(frontReadings);

                    frontSensorDataArrived.Invoke(this, USBeventArgs);
                }
            }
        }