Inheritance: HA4IoT.Hardware.GenericIOBoard.IOBoardController, IBinaryInputController
Ejemplo n.º 1
0
        public void CCTools_Read_HSPE16InputOnly_State()
        {
            // The hardware board contains pull-up resistors. This means that the inputs are inverted internally
            // and the test must respect this.
            var i2CBus = new TestI2CBusService();
            i2CBus.I2CDevice.BufferForNextRead = new byte[] { 255, 255 };

            var hspe16 = new HSPE16InputOnly(DeviceIdFactory.EmptyId, new I2CSlaveAddress(32), i2CBus);

            hspe16.FetchState();

            Assert.AreEqual(new I2CSlaveAddress(32), i2CBus.LastUsedI2CSlaveAddress);
            Assert.AreEqual(BinaryState.Low, hspe16[HSPE16Pin.GPIO0].Read());

            i2CBus.I2CDevice.BufferForNextRead = new byte[] { 0, 255 };
            hspe16.FetchState();

            Assert.AreEqual(new I2CSlaveAddress(32), i2CBus.LastUsedI2CSlaveAddress);
            Assert.AreEqual(BinaryState.High, hspe16[HSPE16Pin.GPIO0].Read());

            i2CBus.I2CDevice.BufferForNextRead = new byte[] { 255, 127 };
            hspe16.FetchState();

            Assert.AreEqual(new I2CSlaveAddress(32), i2CBus.LastUsedI2CSlaveAddress);
            Assert.AreEqual(BinaryState.Low, hspe16[HSPE16Pin.GPIO0].Read());
            Assert.AreEqual(BinaryState.High, hspe16[HSPE16Pin.GPIO15].Read());
        }
        public HSPE16InputOnly CreateHSPE16InputOnly(Enum id, int address)
        {
            var device = new HSPE16InputOnly(id.ToString(), address, _i2CBus, _notificationHandler) { AutomaticallyFetchState = true };
            _ioBoardManager.Add(id, device);

            return device;
        }
Ejemplo n.º 3
0
        public HSPE16InputOnly CreateHSPE16InputOnly(Enum id, I2CSlaveAddress address)
        {
            var device = new HSPE16InputOnly(DeviceIdFactory.CreateIdFrom(id), address, _i2CBus)
            {
                AutomaticallyFetchState = true
            };

            _controller.AddDevice(device);

            return(device);
        }
Ejemplo n.º 4
0
        public HSPE16InputOnly RegisterHSPE16InputOnly(Enum id, I2CSlaveAddress address)
        {
            var device = new HSPE16InputOnly(DeviceIdFactory.CreateIdFrom(id), address, _i2CBusService)
            {
                AutomaticallyFetchState = true
            };

            _deviceService.AddDevice(device);

            return(device);
        }
Ejemplo n.º 5
0
        public HSPE16InputOnly RegisterHSPE16InputOnly(string id, I2CSlaveAddress address)
        {
            var device = new HSPE16InputOnly(id, address, _i2CBusService, _deviceMessageBrokerService, _log)
            {
                AutomaticallyFetchState = true
            };

            _deviceService.AddDevice(device);

            return(device);
        }
        public HSPE16InputOnly RegisterHSPE16InputOnly(Enum id, I2CSlaveAddress address)
        {
            var device = new HSPE16InputOnly(DeviceIdFactory.CreateIdFrom(id), address, _i2CBusService)
            {
                AutomaticallyFetchState = true
            };

            _deviceService.AddDevice(device);

            return device;
        }