public LineSensorWrapper(Cpu.Pin leftSensorPin, Cpu.Pin rightSensorPin, Cpu.Pin backSensorPin) { sensors[0] = new SensorStruct() {Position = LineSensorEnum.Left, Sensor= new LineSensor(leftSensorPin)}; sensors[1] = new SensorStruct() { Position = LineSensorEnum.Right, Sensor = new LineSensor(rightSensorPin) }; sensors[2] = new SensorStruct() { Position = LineSensorEnum.Back, Sensor = new LineSensor(backSensorPin) }; new Thread(SensorLoop).Start(); }
public void activateSensor(String name) { try { int index = searchSurveyForIndex(name); SensorStruct newSensor = _sensors[index]; newSensor.condition = true; _sensors[index] = newSensor; } catch { Console.WriteLine("DoctorPatientSurveyServiceError: index error"); } }
/// <summary> /// Collects sensor data at interval of 1 second. To get data of specific room, do not call this function instead update value to property I2C_Slave_Address and this function will collect data from that slave. /// </summary> public static void CollectData() { if (AlreadyRunning == false) { AlreadyRunning = true; Sensors = new SensorStruct(); Sensors.AmbientLight = new Library.Core.Sensors.AmbientLight(); Sensors.PassiveIR = new Library.Core.Sensors.PassiveIR(); Sensors.Temperature = new Library.Core.Sensors.Temperature(); Task Task_CollectSensorData = new Task(async() => { while (true) { var Response = await Library.Communication.I2C_Helper.WriteRead(I2C_Slave_Address, Library.Communication.I2C_Helper.Mode.Mode0); // Update Ambient Light Sensors.AmbientLight.RawData = (short)Response[0]; //Update PIR State Sensors.PassiveIR.HumanDetected = (((byte)Response[1]) == 1) ? true : false; // Update Temperature Sensors.Temperature.Celsius = (byte)Response[3]; Sensors.Temperature.Celsius *= (((byte)Response[2]) == 0) ? -1 : 1; // Update Temperature Sign. Refer mode 0 for details. Debug.WriteLine(Sensors.AmbientLight.RawData); Debug.WriteLine(Sensors.PassiveIR.HumanDetected.ToString()); Debug.WriteLine(Sensors.Temperature.Celsius); Debug.WriteLine("======================="); await Task.Delay(1000); } }); Task_CollectSensorData.Start(); Task_CollectSensorData.Wait(); } }