示例#1
0
        public void Check_MotionSensor_Reports_NoMotion_Data()
        {
            // Arrange
            var cmd = Helpers
                      .CreateCommand("report", "motion", "158d00011c0", 52754,
                                     new Dictionary <string, object>
            {
                { "no_motion", "120" }
            });

            // Act
            MotionSensor device = _fixture.GetDeviceByCommand <MotionSensor>(cmd);

            var noMotionRaised  = false;
            var moMotionSeconds = 0;

            device.OnNoMotion += (_, args) =>
            {
                noMotionRaised  = true;
                moMotionSeconds = args.Seconds;
            };

            device.ParseData(ResponseCommand.FromString(cmd).Data);

            // Assert
            Assert.Equal("motion", device.Type);
            Assert.Equal("158d00011c0", device.Sid);
            Assert.Equal("no motion", device.Status);
            Assert.True(noMotionRaised);
            Assert.Equal(120, device.NoMotion);
        }
示例#2
0
        public void Check_MotionSensor_Reports_Motion_Data()
        {
            // Arrange
            var cmd = Helpers
                      .CreateCommand("report", "motion", "158d00011c0", 52754,
                                     new Dictionary <string, object>
            {
                { "status", "motion" }
            });

            // Act
            MotionSensor device = _fixture.GetDeviceByCommand <MotionSensor>(cmd);

            var motionRaised = false;

            device.OnMotion += (_, args) =>
            {
                motionRaised = true;
            };

            var timeDiff = DateTime.Now - device.MotionDate.Value;

            device.ParseData(ResponseCommand.FromString(cmd).Data);

            // Assert
            Assert.Equal("motion", device.Type);
            Assert.Equal("158d00011c0", device.Sid);
            Assert.Equal("motion", device.Status);
            Assert.True(timeDiff <= TimeSpan.FromSeconds(1));
            Assert.True(motionRaised);
        }
        public async Task SimulateMotionEvents()
        {
            deviceId = "2";

            RegisterDeviceAsync().Wait();
            bool deviceActivated = await ActivateDeviceAsync();

            if (deviceActivated)
            {
                InitDeviceClient();

                stopWatch.Restart();
                numEventsSent = 0;
                LogStatus("Sending Motion Events...");

                SensorBase sensor = new MotionSensor(deviceId, TransmitEvent);
                sensor.InitSchedule(10);
                Console.WriteLine("Generated {0:###,###,###} Events", sensor.CountOfDataPoints);
                sensor.Start().Wait();
                FlushIoTHubBuffer();
                stopWatch.Stop();

                Console.WriteLine("Completed transmission in {0} seconds. Sent {1:###,###,###} events.", stopWatch.Elapsed.TotalSeconds, numEventsSent);
            }
            else
            {
                LogError("Device Not Activated.");
            }
        }
            public void TestThatGetLocationReturnsNull()
            {
                MotionSensor sensor   = new MotionSensor();
                string       location = sensor.GetLocation();

                Assert.AreEqual(string.Empty, location);
            }
示例#5
0
    void OnSceneGUI()
    {
        AngleRotator angleRotator = (AngleRotator)target;
        Transform    transform    = angleRotator.transform;

        float rangeSize = 1f;

        // if this rotator is attached to a motion sensor, show the range of the motion sensor instead of the default 1.0
        MotionSensor motionSensor = angleRotator.GetComponent <MotionSensor>();

        if (motionSensor != null)
        {
            rangeSize = motionSensor.GetMaxDistance;
        }

        // use arcs and lines to draw the angle range
        Handles.color = angleRotator.GetReverseInitialDirection ? Color.black : Color.white;
        DrawArcRange(transform, angleRotator.GetAngleRange, rangeSize);
        Handles.color = angleRotator.GetReverseInitialDirection ? Color.white : Color.black;
        DrawArcRange(transform, -angleRotator.GetAngleRange, rangeSize);

        // draw starting angle
        Handles.color = Color.blue;
        Handles.DrawLine(
            transform.position,
            transform.position + Quaternion.AngleAxis(angleRotator.GetInitialAngle, transform.up) * transform.forward * rangeSize
            );
    }
            public void TestThatGetSensorTypeReturnsNull()
            {
                MotionSensor sensor     = new MotionSensor();
                string       sensorType = sensor.GetSensorType();

                Assert.AreNotEqual(string.Empty, sensorType);
            }
示例#7
0
        public int AddMotionSensorHistory(MotionSensor sensor)
        {
            if (sensor == null)
            {
                throw new Exception("Sensore object cannot be null");
            }

            sensorHistory = new SensorHistory
            {
                HouseId  = sensor.HouseId,
                SensorId = sensor.SensorId,
                Type     = sensor.Type,
                Name     = sensor.Name,
                IsMove   = sensor.IsMove,
                IsOn     = sensor.IsOn
            };

            try
            {
                _databaseContext.SensorHistories.Add(sensorHistory);
                _databaseContext.SaveChanges();
            }

            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }


            return(sensorHistory.SensorHistoryId);
        }
示例#8
0
 public OutdoorCamFacade()
 {
     ImgP      = new ImageProcessor();
     CamDriver = new CameraDriver();
     CamLight  = new CameraLight();
     MotSensor = new MotionSensor();
 }
            public void TestThatIsTriggeredReturnsTrue()
            {
                MotionSensor sensor          = new MotionSensor();
                bool         isTriggeredTrue = sensor.Trigger() == true ? true : true;

                Assert.AreEqual(true, isTriggeredTrue);
            }
            public void TestThatIsTriggeredReturnsFalse()
            {
                MotionSensor sensor           = new MotionSensor();
                bool         isTriggeredFalse = sensor.Trigger() == true ? false : false;

                Assert.AreEqual(false, isTriggeredFalse);
            }
            public void TestThatGetSensorTypeReturnsType()
            {
                MotionSensor sensor     = new MotionSensor();
                string       sensorType = sensor.GetSensorType();

                Assert.AreEqual("Motion sensor", sensorType);
            }
示例#12
0
    // Token: 0x06000C8E RID: 3214 RVA: 0x00050218 File Offset: 0x0004E418
    public void SetText(MotionSensor sensor)
    {
        if (!this.Sensors.Contains(sensor))
        {
            this.Sensors.Add(sensor);
            sensor.id = this.Sensors.Count - 1;
        }
        switch (sensor.id)
        {
        case 0:
            this.sensor_1_Text.text = this.Sensors[0].roomName;
            return;

        case 1:
            this.sensor_2_Text.text = this.Sensors[1].roomName;
            return;

        case 2:
            this.sensor_3_Text.text = this.Sensors[2].roomName;
            return;

        case 3:
            this.sensor_4_Text.text = this.Sensors[3].roomName;
            return;

        default:
            return;
        }
    }
示例#13
0
 public Camera(int id)
 {
     this.Id   = id;
     ImgP      = new ImageProcessor();
     SoundP    = new SoundProcessor();
     CamDriver = new CameraDriver();
     CamLight  = new CameraLight();
     MotSensor = new MotionSensor();
 }
            public void TestThatSetLocationReturnsLocation()
            {
                MotionSensor sensor = new MotionSensor();

                sensor.SetLocation("Main Door");
                Assert.AreEqual("Main Door", sensor.GetLocation());
                sensor.SetLocation("I have changed...change is inevitable");
                Assert.AreNotEqual("Main Door", sensor.GetLocation());
            }
示例#15
0
 public void Init(IController controller)
 {
     LcdDisplay = new Lmb162Abc(Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D11,                                   //rs and enable
                                Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D2, //data pins, d4-d7
                                16, 2, controller);
     TempSensor   = new IrTempSensor(0x5a, 59, controller, updateInterval: 1000);
     MotionSensor = new MotionSensor(Pins.GPIO_PIN_D8);
     Controller   = controller;
     ((TcpConnectionManager)ConnectionManager).TcpCommandHandler.Init();
 }
    public async Task <Unit> Handle(InstallMotionSensor command, CancellationToken cancellationToken)
    {
        var reservation = MotionSensor.Install(
            command.MotionSensorId
            );

        await repository.Add(reservation, cancellationToken);

        return(Unit.Value);
    }
        public void TestThatPollMotionSensorsSucceeds()
        {
            ILocationProvider FD = new SensorAtFrontDoor();
            ICableSensor      MS = new MotionSensor(FD);

            SCCU_MS = new SecurityControlUnit <ICableSensor>(new List <ICableSensor> {
                MS
            });
            Assert.IsTrue((SCCU_MS.PollSensors() == "Polled AlarmSystem.MotionSensor at the front door successfully\n" || SCCU_MS.PollSensors() == "A AlarmSystem.MotionSensor sensor was triggered at the front door\n" || SCCU_MS.PollSensors() == "Oh oh, I roam the city at night")?true:false, "TestThatPollMotionSensorsSucceeds() FAILED");
        }
示例#18
0
        public IActionResult UpdateMotionSensor([FromBody] MotionSensor sensor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _sensorRepository.UpdateMotionSensor(sensor);

            return(new JsonResult(sensor.SensorId));
        }
            public void TestThatGetLocationReturnsLocation()
            {
                MotionSensor sensor   = new MotionSensor("Main Door");
                string       location = sensor.GetLocation();

                Assert.AreEqual("Main Door", location);
                MotionSensor sensor_2   = new MotionSensor("Back Door");
                string       location_2 = sensor_2.GetLocation();

                Assert.AreEqual("Back Door", location_2);
            }
示例#20
0
        public int UpdateMotionSensor(MotionSensor sensor)
        {
            if (sensor == null)
            {
                throw new Exception("Sensore object cannot be null");
            }

            _databaseContext.Sensors.Update(sensor);
            _databaseContext.SaveChanges();

            return(sensor.SensorId);
        }
            public void TestThatIsTriggeredCanReturnTrue()
            {
                MotionSensor sensor  = new MotionSensor();
                List <bool>  results = new List <bool>();

                for (var i = 0; i <= 1000; i++)
                {
                    results.Add(sensor.Trigger());
                }

                Assert.AreEqual(true, results.Contains(true));
            }
示例#22
0
        public void InsertRecord(int boxId, string deviceName, DateTime dateTime)
        {
            MotionSensor motionSensor = new MotionSensor();

            motionSensor.BoxId       = boxId;
            motionSensor.MeasureTime = dateTime;
            motionSensor.Device      = deviceName;
            motionSensor.DeviceId    = 1234;

            _context.MotionSensors.Add(motionSensor);
            _context.SaveChanges();
        }
        public void  TestThatPollingMotionSensorNotBetween2200To0600Fails()
        {
            ILocationProvider FD = new SensorAtFrontDoor();
            ICableSensor      MS = new MotionSensor(FD);

            SCCU_MS = new SecurityControlUnit <ICableSensor>(new List <ICableSensor> {
                MS
            });
            Assert.IsTrue((SCCU_MS.PollSensors(new TimeSpan(23, 0, 0)) == "Polled AlarmSystem.MotionSensor at the front door successfully\n" || SCCU_MS.PollSensors(new TimeSpan(23, 0, 0)) == "A AlarmSystem.MotionSensor sensor was triggered at the front door\n")?true:false, "TestThatPollingMotionSensorNotBetween2200To0600Fails() FAILED");
            Assert.IsTrue((SCCU_MS.PollSensors(new TimeSpan(01, 0, 0)) == "Polled AlarmSystem.MotionSensor at the front door successfully\n" || SCCU_MS.PollSensors(new TimeSpan(23, 0, 0)) == "A AlarmSystem.MotionSensor sensor was triggered at the front door\n")?true:false, "TestThatPollingMotionSensorNotBetween2200To0600Fails() FAILED");
            Assert.AreEqual("Oh oh, I roam the city at night", SCCU_MS.PollSensors(new TimeSpan(21, 0, 0)));
        }
        public void SimulateMotionEvents()
        {
            stopWatch.Restart();
            numEventsSent = 0;
            LogStatus("Sending Motion Events...");
            SensorBase sensor = new MotionSensor("2", TransmitEvent);

            sensor.InitSchedule(10);
            Console.WriteLine("Generated {0:###,###,###} Events", sensor.CountOfDataPoints);
            sensor.Start().Wait();
            FlushEventHubBuffer();
            stopWatch.Stop();
            Console.WriteLine("Completed transmission in {0} seconds. Sent {1:###,###,###} events.", stopWatch.Elapsed.TotalSeconds, numEventsSent);
        }
示例#25
0
        public IActionResult AddMotionSensor([FromBody] MotionSensor sensor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var house = _houseRepository.GetHouse(sensor.HouseId);

            if (house == null)
            {
                return(NotFound("Cannot find house with provided houseId."));
            }

            _sensorRepository.AddMotionSensor(sensor, house);

            return(new JsonResult(sensor.SensorId));
        }
示例#26
0
        public void Check_MotionSensor_ReadAck_Data()
        {
            // Arrange
            var cmd = Helpers
                      .CreateCommand("read_ack", "motion", "158d0001214e1f", 19149,
                                     new Dictionary <string, object>
            {
                { "voltage", "2985" }
            });

            // Act
            MotionSensor device = _fixture.GetDeviceByCommand <MotionSensor>(cmd);

            // Assert
            Assert.Equal("motion", device.Type);
            Assert.Equal("158d0001214e1f", device.Sid);
            Assert.Equal(2.985f, device.Voltage);
        }
示例#27
0
 // Token: 0x06000C89 RID: 3209 RVA: 0x000500D4 File Offset: 0x0004E2D4
 public void Detected(MotionSensor sensor)
 {
     this.source.Play();
     if (sensor.id == 0)
     {
         this.detected1 = true;
         base.StartCoroutine(this.DisableMotionSensor1Colour());
         if (this.image1)
         {
             this.image1.color = Color.green;
             return;
         }
     }
     else if (sensor.id == 1)
     {
         this.detected2 = true;
         base.StartCoroutine(this.DisableMotionSensor2Colour());
         if (this.image2)
         {
             this.image2.color = Color.green;
             return;
         }
     }
     else if (sensor.id == 2)
     {
         this.detected3 = true;
         base.StartCoroutine(this.DisableMotionSensor3Colour());
         if (this.image3)
         {
             this.image3.color = Color.green;
             return;
         }
     }
     else if (sensor.id == 3)
     {
         this.detected4 = true;
         base.StartCoroutine(this.DisableMotionSensor4Colour());
         if (this.image4)
         {
             this.image4.color = Color.green;
         }
     }
 }
示例#28
0
 void motionSensor_Motion_Sensed(MotionSensor sender, MotionSensor.Motion_SensorState state)
 {
     try
     {
         if (camera.CameraReady)
         {
             camera.TakePicture();
         }
         else
         {
             Debug.Print("Camera not ready, no picutre taken");
         }
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         throw ex;
     }
 }
        public int UpdateMotionSensor(MotionSensor sensor)
        {
            if (sensor == null)
            {
                throw new Exception("Sensore object cannot be null");
            }

            try
            {
                _databaseContext.Sensors.Update(sensor);
                _databaseContext.SaveChanges();
            }

            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }

            return(sensor.SensorId);
        }
        public int AddMotionSensor(MotionSensor sensor, House house)
        {
            if (sensor == null)
            {
                throw new Exception("Sensore object cannot be null");
            }

            if (house == null)
            {
                throw new Exception("House object cannot be null");
            }

            sensor.House   = house;
            sensor.HouseId = house.HouseId;
            sensor.Type    = ConstValues.MOTION;

            _databaseContext.Sensors.Add(sensor);
            _databaseContext.SaveChanges();

            return(sensor.SensorId);
        }