Exemplo n.º 1
0
        public AV760Test(TestParameters parameters, VacuumRig rig, List <IConnection> connections)
        {
            this.parameters               = parameters;
            __rig                         = rig;
            this.connections              = new Dictionary <ISerialNumber, IConnection>();
            rig.onConnectionStateChanged += OnRigConnectionStateChanged;

            foreach (var connection in connections)
            {
                this.connections[connection.serialNumber] = connection;
            }

            InvalidateTestResults();
        }
Exemplo n.º 2
0
        private void HandleNewVrcReading(VacuumRig controller, Scalar lastMeas, Scalar newMeas)
        {
            Log.D(this, "New Vrc reading: " + lastMeas + ", " + newMeas);
            // We got a new VRC reading from the rig. We need to try and record all of the sensor values if testing or resolve
            // and possible state changes.

/*
 *                      if (!isTesting) {
 *                              // We are not currently testing, and can disregard any new values.
 *                              return;
 *                      }
 */

            var tp = parameters.targetPoints[currentTargetPointIndex];

            if (tp.measurement.amount > newMeas.amount)
            {
                // We have a new data point for the target point. Record it.
                foreach (var connection in connections.Values)
                {
                    RecordConnectionMeasurement(connection, currentTargetPointIndex);
                }
                // The new measurement from the rig passed the target point. We can now focus on the next target point.
                currentTargetPointIndex++;
                NotifyTestEvent(TestEvent.EType.NewTestData);
            }

            NotifyTestEvent(TestEvent.EType.NewTestState);

            // Check to make sure that the test is not complete.
            if (currentTargetPointIndex >= parameters.targetPoints.Count)
            {
                // The test is complete.
                CompleteTest();
                return;
            }
        }
Exemplo n.º 3
0
        private void OnBluetoothDeviceFound(BluetoothDevice device, byte[] advertisementPacket)
        {
            lock (addressConnectionLookup) {
                if (device.Name.IsValidSerialNumber())
                {
                    IConnection connection = null;
                    if (!addressConnectionLookup.ContainsKey(device.Address))
                    {
                        var sn = device.Name.ParseSerialNumber();

                        if (sn.rawSerial.StartsWith("S", StringComparison.Ordinal))
                        {
                            connection = new RigadoConnection(this, device, sn);
                            addressConnectionLookup[device.Address] = connection;
                            NotifyNewConnection(connection);
                        }
                        else
                        {
                            connection = new LeConnection(this, device, sn);
                            addressConnectionLookup[device.Address] = connection;
                            NotifyNewConnection(connection);
                        }
                    }
                    else
                    {
                        connection = addressConnectionLookup[device.Address];
                    }

//					connection.ReceivePacket(advertisementPacket);
                }
                else if (device.Name.IsValidRigIdentifier())
                {
                    ERigType rigType;
                    if (device.Name.TryGetRigType(out rigType))
                    {
                        IRig rig;
                        if (!addressRigLookup.TryGetValue(device.Address, out rig))
                        {
                            switch (rigType)
                            {
                            case ERigType.Vacuum:
                                rig = new VacuumRig(this, device);
                                addressRigLookup[device.Address] = rig;
                                break;

                            case ERigType.Pressure:
//									addressRigLookup[device.Address] = rig = new PressureRig(this, device);
                                break;
                            }

                            NotifyNewRig(rig);
                        }
                    }
                    else
                    {
                        Log.E(this, "Failed to find rig type for: " + device.Name);
                    }
                }
                else
                {
                    // The check if the advertisement packet has a serial number.
                    ISerialNumber sn;
                    byte[]        packet;
                    if (RigadoBroadcastParser.ParseBroadcastPacket(advertisementPacket, out sn, out packet))
                    {
                        foreach (var c in addressConnectionLookup.Values)
                        {
                            if (c.serialNumber.Equals(sn))
                            {
                                c.ReceivePacket(packet);
                            }
                        }
                    }
                    else
                    {
                        Log.D(this, "Invalid ION device");
                    }
                }
            }
        }