Пример #1
0
        /// <summary>
        /// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
        /// object.
        /// </summary>
        /// <remarks>
        /// Call <see cref="Dispose"/> when you are finished using the
        /// <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>. The
        /// <see cref="Dispose"/> method leaves the
        /// <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/> in an
        /// unusable state. After calling <see cref="Dispose"/>, you must release
        /// all references to the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
        /// so the garbage collector can reclaim the memory that
        /// the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/> was occupying.
        /// </remarks>
        public override void Dispose()
        {
            if (base.IsDisposed)
            {
                return;
            }

            if (this._relay != null)
            {
                this._relay.Dispose();
                this._relay = null;
            }

            if (this._sensor != null)
            {
                this._sensor.Dispose();
                this._sensor = null;
            }

            if (this._lock == null)
            {
                this._lock.Dispose();
                this._lock = null;
            }
            base.Dispose();
        }
 public Application(IRelay r, IHandler h, IPost p, IScenario s)
 {
     _relay    = r;
     _handler  = h;
     _post     = p;
     _scenario = s;
 }
        private void InitGrovePi()
        {
            System.Diagnostics.Debug.WriteLine(DeviceFactory.Build.GrovePi().GetFirmwareVersion());

            GroveRotary = DeviceFactory.Build.RotaryAngleSensor(Pin.AnalogPin0);
            GroveSound  = DeviceFactory.Build.SoundSensor(Pin.AnalogPin1);
            GroveLight  = DeviceFactory.Build.LightSensor(Pin.AnalogPin2);

            GroveRelay    = DeviceFactory.Build.Relay(Pin.DigitalPin2);
            GroveTempHumi = DeviceFactory.Build.DHTTemperatureAndHumiditySensor(Pin.DigitalPin3, DHTModel.Dht11);
            GroveRanger   = DeviceFactory.Build.UltraSonicSensor(Pin.DigitalPin4);
            GroveLedBar   = DeviceFactory.Build.BuildLedBar(Pin.DigitalPin5);
            GroveBuzzer   = DeviceFactory.Build.Buzzer(Pin.DigitalPin6);
            GroveButton   = DeviceFactory.Build.ButtonSensor(Pin.DigitalPin7);
            GroveLCD      = DeviceFactory.Build.RgbLcdDisplay();

            GroveLedBar.Initialize(GrovePi.Sensors.Orientation.GreenToRed);
            GroveLCD.SetBacklightRgb(255, 50, 255);

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin2, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin6, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();
        }
 public void Construct()
 {
     _relay    = _componentBuilder.CreateRelay();
     _post     = _componentBuilder.CreatePost();
     _handler  = _componentBuilder.CreateHandler();
     _scenario = _componentBuilder.CreateScenario();
 }
Пример #5
0
        public void SetUp()
        {
            _relay         = Substitute.For <IRelay>();
            _area          = Substitute.For <IArea>();
            _conflict      = Substitute.For <IConflict>();
            _speed         = Substitute.For <ISpeed>();
            _compasscourse = Substitute.For <ICompassCourse>();
            _eventdetector = Substitute.For <IEventDetector>();
            _relay         = Substitute.For <IRelay>();
            _results       = new TrackEventArgs();

            // Arbitrary List og tracks
            t = new List <Track>();
            t.Add(new Track("A", 500, DateTime.Now, new Position(1, 1)));

            // Make event on controller class with above made List<Track>
            args = new TrackEventArgs()
            {
                Tracks = t
            };

            // Make methods return data
            _compasscourse.CalcCourse(t).Returns(t);
            _area.CheckArea(t).Returns(t);
            _speed.CalcSpeed(t).Returns(t);
            _conflict.DetectConflict(t).Returns(t);

            // Make uut
            _uut = new Controller(_relay, _area, _compasscourse, _conflict, _speed, _eventdetector);

            // Make "fake" listener on Controller class, that has the TrackEventArgs, that can be Asserted on, also an event needs to have a listener to not break the code
            _uut.ControllerEvent += (sender, output) => _results = output;
        }
Пример #6
0
        public void Stop()
        {
            try
            {
                if (timer != null)
                {
                    timer.Stop();
                    timer.Dispose();
                    timer = null;
                }
                if (_tcpRelay != null)
                {
                    _tcpRelay.Stop();
                    _tcpRelay = null;
                }
                if (_udpRelay != null)
                {
                    _udpRelay.Stop();
                    _udpRelay = null;
                }
                if (KCPTunnelController.IsRunning)
                {
                    KCPTunnelController.Stop();
                }

                TrafficStatistics.Save(_trafficStatistics);
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }
Пример #7
0
 public SetLightForCinema(IRelay lh, IRelay lr,
                          IRelay nl)
 {
     lampInHall = lh;
     lampInRoom = lr;
     NightLamp  = nl;
 }
Пример #8
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
		/// class with the relay, sensor, and the sensor state that indicates
		/// that the opener has opened.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the opener.
		/// </param>
		/// <param name="sensor">
		/// The reading the state of the opener.
		/// </param>
		/// <param name="openState">
		/// The sensor state that indicates the opener has opened.
		/// </param>
		public OpenerDevice(IRelay relay, ISensor sensor, SensorState openState)
			: base() {
			this._relay = relay;
			this._sensor = sensor;
			this._openState = openState;
			this._sensor.StateChanged += this.OnSensorStateChanged;
		}
        private void TurnOff(IRelay relay, List <string> trace)
        {
            var theLastSigh = relay.Off();

            _output.WriteLine(theLastSigh);
            trace.Add(theLastSigh);
        }
Пример #10
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            // Connect the Relay to Digital Pin 5
            // Initialize the relay on Digital Pin 5 (D5)
            IRelay relay = DeviceFactory.Build.Relay(Pin.DigitalPin5);

            // Loop endlessly
            while (true)
            {
                try
                {
                    // Turn the Relay On.
                    relay.ChangeState(SensorStatus.On);                     // Turn the relay on.
                    System.Diagnostics.Debug.WriteLine("Button is On.");    // Write something to debug.
                    Task.Delay(1000).Wait();                                // Delay 1 second

                    // Turn the Relay Off.
                    relay.ChangeState(SensorStatus.Off);                    // Turn the relay off.
                    System.Diagnostics.Debug.WriteLine("Button is Off.");   // Write this fact to debug.
                    Task.Delay(1000).Wait();                                // Delay 1 second
                }
                catch (Exception ex)
                {
                    // NOTE: There are frequent exceptions of the following:
                    // WinRT information: Unexpected number of bytes was transferred. Expected: '. Actual: '.
                    // This appears to be caused by the rapid frequency of writes to the GPIO
                    // These are being swallowed here/

                    // If you want to see the exceptions uncomment the following:
                    // System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }
        }
Пример #11
0
 public Handler(IRelay relay, EndPoint localEP, EndPoint remoteEP, EndPoint socks5EP, bool useProxy)
 {
     _relay    = relay;
     _localEP  = localEP;
     _remoteEP = remoteEP;
     _socks5EP = socks5EP;
     _useProxy = useProxy;
 }
Пример #12
0
 public PickupCollisionHandler(IRelay relay, ClientInfo info, NetId netId, ItemPickup facade)
 {
     _relay  = relay;
     _info   = info;
     _netId  = netId;
     _facade = facade;
     PreInitialize();
 }
Пример #13
0
        public void SetUp()
        {
            _transponderReceiver = Substitute.For <ITransponderReceiver>();

            _uut = new Relay(_transponderReceiver);

            results = new TrackEventArgs(); // "Fake" listener
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
 /// class with the relay, sensor, and the sensor state that indicates
 /// that the opener has opened.
 /// </summary>
 /// <param name="relay">
 /// The relay that controls the opener.
 /// </param>
 /// <param name="sensor">
 /// The reading the state of the opener.
 /// </param>
 /// <param name="openState">
 /// The sensor state that indicates the opener has opened.
 /// </param>
 public OpenerDevice(IRelay relay, ISensor sensor, SensorState openState)
     : base()
 {
     this._relay                = relay;
     this._sensor               = sensor;
     this._openState            = openState;
     this._sensor.StateChanged += this.OnSensorStateChanged;
 }
Пример #15
0
 public CinemaCottadge(IRelay p, IRelay lr,
                       IRelay lh, IEngine w, IEngine wb)
 {
     projector     = p;
     lampInRoom    = lr;
     lampInHall    = lh;
     wall          = w;
     windowBlindes = wb;
 }
Пример #16
0
        public Controller(Config config, ISystemServices ss, IRelay relay)
        {
            m_config = config;
            m_services = ss;
            m_relay = relay;
            m_isDst = config.IsDST;

            ScheduleLights();
        }
Пример #17
0
        public string AddRelay(IRelay relay)
        {
            string code;

            do
            {
                code = DownloadCode.Generate();
            } while (!activeRelays.TryAdd(code, relay));
            return(code);
        }
Пример #18
0
 public UDPPipe(IRelay relay, EndPoint localEP, EndPoint remoteEP)
 {
     _relay           = relay;
     _localEP         = localEP;
     _remoteEP        = remoteEP;
     _timer.AutoReset = true;
     _timer.Enabled   = true;
     _timer.Elapsed  += _timer_Elapsed;
     _timer.Start();
 }
Пример #19
0
        public void Reload()
        {
            try
            {
                if (timer != null)
                {
                    timer.Stop();
                    timer.Dispose();
                    timer = null;
                }
                if (_ssudpRelay != null)
                {
                    _ssudpRelay.Stop();
                    _ssudpRelay = null;
                }
                if (_tcpRelay != null)
                {
                    _tcpRelay.Stop();
                    _tcpRelay = null;
                }
                if (_udpRelay != null)
                {
                    _udpRelay.Stop();
                    _udpRelay = null;
                }
                if (KCPTunnelController.IsRunning)
                {
                    KCPTunnelController.Stop();
                }
                Configuration config = ConfigController.GetCurrentConfiguration();
                Server        server = config.GetCurrentServer();
                traffic = _trafficStatistics.GetTrafficLog(server);
                if (config.enabled)
                {
                    if (server.ss_relay_udp)
                    {
                        RelaySSUDPData(server);
                    }

                    KCPTunnelController.Server     = server;
                    KCPTunnelController.localaddr  = null;
                    KCPTunnelController.remoteaddr = null;
                    if (config.statistics_enabled)
                    {
                        RegistStatistics();
                        StartTrafficLogger();
                    }
                    KCPTunnelController.Start();
                }
            }
            catch (Exception e)
            {
                Logging.LogUsefulException(e);
            }
        }
Пример #20
0
        public Controller(IRelay relay, IArea area, ICompassCourse compassCourse, IConflict conflict, ISpeed speed, IEventDetector eventDetector)
        {
            _relay         = relay;
            _area          = area;
            _conflict      = conflict;
            _speed         = speed;
            _compassCourse = compassCourse;
            _eventDetector = eventDetector;

            _relay.RelayEvent += RelayEventHandler;
        }
Пример #21
0
        /// <summary>
        /// Инициализировать настройки
        /// </summary>
        public void Init()
        {

            if(_settings!=null)
                InitSetiings();
            if (_ioc != null)
            {
                _relay = _ioc(typeof(IRelay), "Relay") as IRelay;
                _discretInputs = _ioc(typeof(IDiscretInputs), "DiscretInput") as IDiscretInputs;
            }
        }
Пример #22
0
 public UDPPipe(IRelay relay, EndPoint localEP, EndPoint remoteEP, EndPoint socks5EP, bool useProxy)
 {
     _relay           = relay;
     _localEP         = localEP;
     _remoteEP        = remoteEP;
     _socks5EP        = socks5EP;
     _useProxy        = useProxy;
     _timer.AutoReset = true;
     _timer.Enabled   = true;
     _timer.Elapsed  += _timer_Elapsed;
     _timer.Start();
 }
Пример #23
0
 public bool Switch(IRelay relay, bool status)
 {
     if (status)
     {
         _currentStatus |= (byte)Math.Pow(2, relay.Index * 2 + 1);
     }
     else
     {
         _currentStatus &= (byte)(255 ^ (byte)Math.Pow(2, relay.Index * 2 + 1));
     }
     return(WriteToDevice(_currentStatus));
 }
Пример #24
0
 private void Connect()
 {
     try
     {
         this.relay           = this.relayFactory.Create("XBee A", "12345");
         this.relayController = new RelayController(this.relay, this.processor, new TransmissionObjectFactory(new NonCompressor()));
     }
     catch (Exception e)
     {
         Debug.WriteLine($"Error while connecting to bluetooth ({e.Message})");
     }
 }
Пример #25
0
        static void Main(string[] args)
        {
            _relay = new Relay();

            _relay.Subscribe(new ConsoleSubscriber("1"));
            _relay.Subscribe(new ConsoleSubscriber("2"));
            _relay.Subscribe(new ConsoleSubscriber("3"));

            Console.WriteLine("Press any key to relay message");
            Console.WriteLine("Press q to quit");

            RunTestLoop();
        }
Пример #26
0
 public SensorController()
 {
     temphumiSensor = DeviceFactory.Build.DHTTemperatureAndHumiditySensor(Pin.DigitalPin2, DHTModel.Dht11);
     pirMotion      = DeviceFactory.Build.PIRMotionSensor(Pin.DigitalPin3);
     button         = DeviceFactory.Build.ButtonSensor(Pin.DigitalPin4);
     relay          = DeviceFactory.Build.Relay(Pin.DigitalPin5);
     soundSensor    = DeviceFactory.Build.SoundSensor(Pin.AnalogPin0);
     lightSensor    = DeviceFactory.Build.LightSensor(Pin.AnalogPin1);
     gasSensor      = DeviceFactory.Build.GasSensorMQ2(Pin.AnalogPin2);
     display        = DeviceFactory.Build.OLEDDisplay128X64();
     motor          = DeviceFactory.Build.MiniMotorDriver();
     lockState      = false;
 }
Пример #27
0
 internal void RequestTrigger(IRelay relay)
 {
     lock (this)
     {
         if (_running)
         {
             Trigger(relay);
         }
         else
         {
             _awaitingTrigger.Add(relay);
         }
     }
 }
Пример #28
0
 private void RelaySSUDPData(Server server)
 {
     try
     {
         IPEndPoint localEP = Utils.ToEndPoint(server.localaddr);
         localEP = new IPEndPoint(IPAddress.Loopback, localEP.Port);
         IPEndPoint remoteEP = Utils.ToEndPoint(server.ss_server);
         _ssudpRelay = new UDPRelay(this, localEP, remoteEP);
         _ssudpRelay.Start();
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
     }
 }
Пример #29
0
        private void RegistLeftStatistics()
        {
            Server     server   = KCPTunnelController.Server;
            IPEndPoint localEP  = Utils.ToEndPoint(server.localaddr);
            IPEndPoint remoteEP = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Tcp, localEP.Port + 1));

            KCPTunnelController.localaddr = remoteEP.ToString();
            Logging.Debug($"Left: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _tcpRelay           = new TCPRelay(this, localEP, remoteEP);
            _tcpRelay.Inbound  += _tcpRelay_Inbound;
            _tcpRelay.Outbound += _tcpRelay_Outbound;
            _tcpRelay.Start();
        }
Пример #30
0
 private void RelaySSUDPData(Server server)
 {
     try
     {
         string[]   localaddr_compns = server.localaddr.Split(':');
         IPEndPoint localEP          = new IPEndPoint(IPAddress.Loopback, Convert.ToInt32(localaddr_compns[1]));
         IPEndPoint remoteEP         = Utils.ToEndPoint(server.ss_server);
         _ssudpRelay = new UDPRelay(this, localEP, remoteEP);
         _ssudpRelay.Start();
     }
     catch (Exception e)
     {
         Logging.LogUsefulException(e);
     }
 }
Пример #31
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/>
		/// class with the relay used to control the fireplace, the
		/// relay state used to consider the fireplace to be "on", the
		/// sensor used to detect the pilot light, and the sensor state
		/// in which to consider the pilot light to be "on".
		/// </summary>
		/// <param name="controlRelay">
		/// The control relay.
		/// </param>
		/// <param name="onRelayState">
		/// The relay state used to consider the fireplace to be "on".
		/// </param>
		/// <param name="pilotLightSensor">
		/// The pilot light sensor.
		/// </param>
		/// <param name="pilotOnState">
		/// The pilot light state used to consider the pilot light to be "on".
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="controlRelay"/> cannot be null.
		/// </exception>
		public FireplaceDevice(IRelay controlRelay, RelayState onRelayState, ISensor pilotLightSensor, SensorState pilotOnState)
			: base() {
			if (controlRelay == null) {
				throw new ArgumentNullException("controlRelay");
			}

			this._controlRelay = controlRelay;
			this._fireplaceOnRelayState = onRelayState;
			this._pilotLightSensor = pilotLightSensor;
			this._pilotLightOnSensorState = pilotOnState;
			this._controlRelay.StateChanged += this.InternalHandleRelayStateChange;
			if (this._pilotLightSensor != null) {
				this._pilotLightSensor.StateChanged += this.InternalHandleSensorStateChange;
			}
		}
        private void Stop()
        {
            if (relay != null)
            {
                relay.Stop();
                relay = null;
            }

            TypeComboBox.Enabled        = true;
            LeftAddressTextBox.ReadOnly = false;
            RightTextBox.ReadOnly       = false;
            StartButton.Enabled         = true;
            StopButton.Enabled          = false;

            AppendLog($"Stop\n");
        }
Пример #33
0
        private void RegistRightStatistics()
        {
            Server server = KCPTunnelController.Server;

            string[]   localaddr_compns = server.localaddr.Split(':');
            IPEndPoint localEP          = new IPEndPoint(
                IPAddress.Loopback,
                Utils.GetFreePort(ProtocolType.Udp, Convert.ToInt32(localaddr_compns[1]) + 1)); // Do not use same TCP port, since shadowsocks maybe send data to this port.
            IPEndPoint remoteEP = Utils.ToEndPoint(server.remoteaddr);

            KCPTunnelController.remoteaddr = localEP.ToString();
            Logging.Debug($"right: localEP={localEP.ToString()}, remoteEP={remoteEP.ToString()}");
            _udpRelay           = new UDPRelay(this, localEP, remoteEP);
            _udpRelay.Inbound  += _udpRelay_Inbound;
            _udpRelay.Outbound += _udpRelay_Outbound;
            _udpRelay.Start();
        }
Пример #34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/>
        /// class with the relay used to control the fireplace, the
        /// relay state used to consider the fireplace to be "on", the
        /// sensor used to detect the pilot light, and the sensor state
        /// in which to consider the pilot light to be "on".
        /// </summary>
        /// <param name="controlRelay">
        /// The control relay.
        /// </param>
        /// <param name="onRelayState">
        /// The relay state used to consider the fireplace to be "on".
        /// </param>
        /// <param name="pilotLightSensor">
        /// The pilot light sensor.
        /// </param>
        /// <param name="pilotOnState">
        /// The pilot light state used to consider the pilot light to be "on".
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="controlRelay"/> cannot be null.
        /// </exception>
        public FireplaceDevice(IRelay controlRelay, RelayState onRelayState, ISensor pilotLightSensor, SensorState pilotOnState)
            : base()
        {
            if (controlRelay == null)
            {
                throw new ArgumentNullException("controlRelay");
            }

            this._controlRelay               = controlRelay;
            this._fireplaceOnRelayState      = onRelayState;
            this._pilotLightSensor           = pilotLightSensor;
            this._pilotLightOnSensorState    = pilotOnState;
            this._controlRelay.StateChanged += this.InternalHandleRelayStateChange;
            if (this._pilotLightSensor != null)
            {
                this._pilotLightSensor.StateChanged += this.InternalHandleSensorStateChange;
            }
        }
Пример #35
0
        public DeviceManager(IRelay relay, IDiscretInputs discretInputs4, IDiscretInputs discretInputs6, IQuestPanel questPanel, IDictionary<string, PortSettings> devicePorts)
        {
            try
            {
                _logger = NLog.LogManager.GetCurrentClassLogger();
            }
            catch
            {
                _logger = null;
            }
            _relay = relay;
            _discretInputs4 = discretInputs4;
            _discretInputs6 = discretInputs6;
            _vem150 = new Vem150Parser();
            _questPanel = questPanel;
            _devicePorts = devicePorts;

            _questPanel.WeightChanged += _questPanel_WeightChanged;
            _questPanel.DiameterChanged += _questPanel_DiameterChanged;
            _questPanel.VoltageChanged += _questPanel_VoltageChanged;
            _questPanel.IsCodeOkChanged += _questPanel_IsCodeOkChanged;
        }
Пример #36
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Garage.GarageDoorOpenerDevice"/>
		/// class with the relay, door sensor, and sensor state that 
		/// indicates that the door is open.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the door.
		/// </param>
		/// <param name="doorSensor">
		/// The sensor that indicates the state of the door.
		/// </param>
		/// <param name="doorSensorOpenState">
		/// The sensor state that indicates the door is open.
		/// </param>
		public GarageDoorOpenerDevice(IRelay relay, ISensor doorSensor, SensorState doorSensorOpenState)
			: base(relay, doorSensor, doorSensorOpenState) {
		}
Пример #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Gate.GateOpenerDevice"/>
 /// class with the relay, gate sensor, and sensor state that 
 /// indicates that the gate is open.
 /// </summary>
 /// <param name="relay">
 /// The relay that controls the gate.
 /// </param>
 /// <param name="gateSensor">
 /// The sensor that indicates the state of the gate.
 /// </param>
 /// <param name="doorSensorOpenState">
 /// The sensor state that indicates the gate is open.
 /// </param>
 public GateOpenerDevice(IRelay relay, ISensor gateSensor, SensorState gateSensorOpenState)
     : base(relay, gateSensor, gateSensorOpenState)
 {
 }
Пример #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Gate.GateOpenerDevice"/>
 /// class with the relay, gate sensor, the sensor state that indicates
 /// that the gate is open, and the switch that controls the lock.
 /// </summary>
 /// <param name="relay">
 /// The relay that controls the gate.
 /// </param>
 /// <param name="doorSensor">
 /// The sensor that indicates the state of the gate.
 /// </param>
 /// <param name="doorSensorOpenState">
 /// The sensor state that indicates the gate is open.
 /// </param>
 /// <param name="lok">
 /// The switch that controls the lock.
 /// </param>
 public GateOpenerDevice(IRelay relay, ISensor gateSensor, SensorState gateSensorOpenState, ISwitch lok)
     : base(relay, gateSensor, gateSensorOpenState, lok)
 {
 }
        private void InitGrovePi()
        {
            System.Diagnostics.Debug.WriteLine(DeviceFactory.Build.GrovePi().GetFirmwareVersion());

            GroveRotary = DeviceFactory.Build.RotaryAngleSensor(Pin.AnalogPin0);
            GroveSound = DeviceFactory.Build.SoundSensor(Pin.AnalogPin1);
            GroveLight = DeviceFactory.Build.LightSensor(Pin.AnalogPin2);

            GroveRelay = DeviceFactory.Build.Relay(Pin.DigitalPin2);
            GroveTempHumi = DeviceFactory.Build.DHTTemperatureAndHumiditySensor(Pin.DigitalPin3, DHTModel.Dht11);
            GroveRanger = DeviceFactory.Build.UltraSonicSensor(Pin.DigitalPin4);
            GroveLedBar = DeviceFactory.Build.BuildLedBar(Pin.DigitalPin5);
            GroveBuzzer = DeviceFactory.Build.Buzzer(Pin.DigitalPin6);
            GroveButton = DeviceFactory.Build.ButtonSensor(Pin.DigitalPin7);
            GroveLCD = DeviceFactory.Build.RgbLcdDisplay();

            GroveLedBar.Initialize(GrovePi.Sensors.Orientation.GreenToRed);
            GroveLCD.SetBacklightRgb(255, 50, 255);

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin2, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();

            DeviceFactory.Build.GrovePi().PinMode(Pin.DigitalPin6, PinMode.Output);
            Delay.Milliseconds(10);
            DeviceFactory.Build.GrovePi().Flush();
        }
Пример #40
0
		/// <summary>
		/// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
		/// object.
		/// </summary>
		/// <remarks>
		/// Call <see cref="Dispose"/> when you are finished using the
		/// <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>. The
		/// <see cref="Dispose"/> method leaves the
		/// <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/> in an
		/// unusable state. After calling <see cref="Dispose"/>, you must release
		/// all references to the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
		/// so the garbage collector can reclaim the memory that
		/// the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/> was occupying.
		/// </remarks>
		public override void Dispose() {
			if (base.IsDisposed) {
				return;
			}

			if (this._relay != null) {
				this._relay.Dispose();
				this._relay = null;
			}

			if (this._sensor != null) {
				this._sensor.Dispose();
				this._sensor = null;
			}

			if (this._lock == null) {
				this._lock.Dispose();
				this._lock = null;
			}
			base.Dispose();
		}
Пример #41
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
		/// class with the relay, sensor, the sensor state that indicates
		/// that the opener has opened, and the switch that controls the lock.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the opener.
		/// </param>
		/// <param name="sensor">
		/// The reading the state of the opener.
		/// </param>
		/// <param name="openState">
		/// The sensor state that indicates the opener has opened.
		/// </param>
		/// <param name="lok">
		/// The switch that controls the lock.
		/// </param>
		public OpenerDevice(IRelay relay, ISensor sensor, SensorState openState, ISwitch lok)
			: this(relay, sensor, openState) {
			this._lock = lok;
			this._lock.StateChanged += this.OnLockStateChanged;
		}
Пример #42
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/>
		/// class with the relay used to control the fireplace and the
		/// sensor used to detect whether or not the pilot light is lit.
		/// </summary>
		/// <param name="controlRelay">
		/// The control relay.
		/// </param>
		/// <param name="pilotLightSensor">
		/// The pilot light sensor.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="controlRelay"/> cannot be null.
		/// </exception>
		public FireplaceDevice(IRelay controlRelay, ISensor pilotLightSensor)
			: this(controlRelay, RelayState.Closed, pilotLightSensor, SensorState.Closed) {
		}
Пример #43
0
		/// <summary>
		/// Releases all resource used by the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/> object.
		/// </summary>
		/// <remarks>Call <see cref="Dispose"/> when you are finished using the
		/// <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/>. The <see cref="Dispose"/> method leaves the
		/// <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/> in an unusable state. After calling
		/// <see cref="Dispose"/>, you must release all references to the
		/// <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/> so the garbage collector can reclaim the memory
		/// that the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/> was occupying.</remarks>
		public override void Dispose() {
			if (base.IsDisposed) {
				return;
			}

			if (this._controlRelay != null) {
				this._controlRelay.Dispose();
				this._controlRelay = null;
			}

			if (this._pilotLightSensor != null) {
				this._pilotLightSensor.Dispose();
				this._pilotLightSensor = null;
			}

			base.Dispose();
		}
Пример #44
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Fireplace.FireplaceDevice"/>
		/// class with the relay used to control the fireplace.
		/// </summary>
		/// <param name="controlRelay">
		/// The control relay.
		/// </param>
		/// <exception cref="ArgumentNullException">
		/// <paramref name="controlRelay"/> cannot be null.
		/// </exception>
		public FireplaceDevice(IRelay controlRelay)
			: this(controlRelay, RelayState.Closed, null, SensorState.Closed) {
		}
Пример #45
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Gate.GateOpenerBase"/>
		/// class with the relay, sensor, the sensor state that indicates
		/// that the opener has opened, and the switch that controls the lock.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the opener.
		/// </param>
		/// <param name="doorSensor">
		/// The reading the state of the opener.
		/// </param>
		/// <param name="doorSensorOpenState">
		/// The sensor state that indicates the opener has opened.
		/// </param>
		/// <param name="lok">
		/// The switch that controls the lock.
		/// </param>
		protected GateOpenerBase(IRelay relay, ISensor doorSensor, SensorState doorSensorOpenState, ISwitch lok)
			: base(relay, doorSensor, doorSensorOpenState, lok) {
		}
Пример #46
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Gate.GateOpenerBase"/>
		/// classwith the relay, sensor, and the sensor state that indicates
		/// that the opener has opened.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the opener.
		/// </param>
		/// <param name="doorSensor">
		/// The reading the state of the opener.
		/// </param>
		/// <param name="doorSensorOpenState">
		/// The sensor state that indicates the opener has opened.
		/// </param>
		protected GateOpenerBase(IRelay relay, ISensor doorSensor, SensorState doorSensorOpenState)
			: base(relay, doorSensor, doorSensorOpenState) {
		}
Пример #47
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Garage.GarageDoorOpenerDevice"/>
		/// class with the relay, door sensor, the sensor state that indicates
		/// that the door is open, and the switch that controls the lock.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the door.
		/// </param>
		/// <param name="doorSensor">
		/// The sensor that indicates the state of the door.
		/// </param>
		/// <param name="doorSensorOpenState">
		/// The sensor state that indicates the door is open.
		/// </param>
		/// <param name="lok">
		/// The switch that controls the lock.
		/// </param>
		public GarageDoorOpenerDevice(IRelay relay, ISensor doorSensor, SensorState doorSensorOpenState, ISwitch lok)
			: base(relay, doorSensor, doorSensorOpenState, lok) {
		}