Ejemplo n.º 1
0
        private void CreateParts(Ports thirdMotor, Ports distanceColorSensor)
        {
            _motorA     = new Motor(_connection, Ports.PORT_A);
            _motorB     = new Motor(_connection, Ports.PORT_B);
            _motorAB    = new Motor(_connection, Ports.PORT_AB);
            _led        = new LED(_connection, Ports.PORT_LED);
            _tiltSensor = new TiltSensor(_connection, Ports.PORT_TILT_SENSOR);
            _button     = new Button(_connection);

            //creating devices with variable port numbers
            _motor3 = new Motor(_connection, thirdMotor);
            _distanceColorSensor = new DistanceColorSensor(_connection, distanceColorSensor);

            LoggerHelper.Instance.Debug("MotorHub::CreateParts called");
        }
Ejemplo n.º 2
0
        private void HandleShutDown()
        {
            //unsubscribe from events
            _connection.OnChange -= Connection_ValueChanged;

            //we should close everything, because we are shutting down!
            _led                 = null;
            _motorA              = null;
            _motorB              = null;
            _motorAB             = null;
            _motor3              = null;
            _tiltSensor          = null;
            _distanceColorSensor = null;
            _button              = null;
        }