public void DigitalOutputMultiple() { CayenneEncoder cayenneEncoder = new CayenneEncoder(); byte dod = 37; byte channeldo = 3; cayenneEncoder.AddDigitalOutput(channeldo, dod); byte dod2 = 12; byte channeldo2 = 35; cayenneEncoder.AddDigitalOutput(channeldo2, dod2); var buff = cayenneEncoder.GetBuffer(); CayenneDecoder cayenneDecoder = new CayenneDecoder(buff); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Value, dod); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Channel, channeldo); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[1].Value, dod2); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[1].Channel, channeldo2); }
public void DigitalOutput() { var cayenneEncoder = new CayenneEncoder(); byte dod = 37; byte channeldo = 3; _ = cayenneEncoder.AddDigitalOutput(channeldo, dod); var buff = cayenneEncoder.GetBuffer(); var cayenneDecoder = new CayenneDecoder(buff); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Value, dod); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Channel, channeldo); }
public void TestAllSensors() { CayenneEncoder cayenneEncoder = new CayenneEncoder(); double temp = 33.7; byte channelt = 1; cayenneEncoder.AddTemperature(channelt, temp); byte di = 37; byte channeldi = 2; cayenneEncoder.AddDigitalInput(channeldi, di); byte dod = 37; byte channeldo = 3; cayenneEncoder.AddDigitalOutput(channeldo, dod); double ao = -37; byte channelao = 4; cayenneEncoder.AddAnalogOutput(channelao, ao); double ai = 37; byte channelai = 5; cayenneEncoder.AddAnalogInput(channelai, ai); ushort lum = 37124; byte channellum = 6; cayenneEncoder.AddLuminosity(channellum, lum); byte ps = 104; byte channelps = 6; cayenneEncoder.AddPresence(channelps, ps); double hum = 99.5; byte channelhum = 6; cayenneEncoder.AddRelativeHumidity(channelhum, hum); double baro = 1014.5; byte channelbaro = 7; cayenneEncoder.AddBarometricPressure(channelbaro, baro); double ax = -4.545; double ay = 4.673; double az = 1.455; byte channela = 8; cayenneEncoder.AddAccelerometer(channela, ax, ay, az); double gx = 4.54; double gy = -4.63; double gz = 1.55; byte channelg = 6; cayenneEncoder.AddGyrometer(channelg, gx, gy, gz); double lat = -4.54; double lon = 4.63; double alt = 1.55; byte channelgps = 6; cayenneEncoder.AddGPS(channelgps, lat, lon, alt); var buff = cayenneEncoder.GetBuffer(); CayenneDecoder cayenneDecoder = new CayenneDecoder(buff); Assert.Equal(cayenneDecoder.CayenneDevice.TemperatureSensor[0].Value, temp); Assert.Equal(cayenneDecoder.CayenneDevice.TemperatureSensor[0].Channel, channelt); Assert.Equal(cayenneDecoder.CayenneDevice.DigitalInput[0].Value, di); Assert.Equal(cayenneDecoder.CayenneDevice.DigitalInput[0].Channel, channeldi); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Value, dod); Assert.Equal(cayenneDecoder.CayenneDevice.DigitaOutput[0].Channel, channeldo); Assert.Equal(cayenneDecoder.CayenneDevice.AnalogOutput[0].Value, ao); Assert.Equal(cayenneDecoder.CayenneDevice.AnalogOutput[0].Channel, channelao); Assert.Equal(cayenneDecoder.CayenneDevice.AnalogOutput[0].Value, ao); Assert.Equal(cayenneDecoder.CayenneDevice.AnalogOutput[0].Channel, channelao); Assert.Equal(cayenneDecoder.CayenneDevice.IlluminanceSensor[0].Value, lum); Assert.Equal(cayenneDecoder.CayenneDevice.IlluminanceSensor[0].Channel, channellum); Assert.Equal(cayenneDecoder.CayenneDevice.PresenceSensor[0].Value, ps); Assert.Equal(cayenneDecoder.CayenneDevice.PresenceSensor[0].Channel, channelps); Assert.Equal(cayenneDecoder.CayenneDevice.HumiditySensor[0].Value, hum); Assert.Equal(cayenneDecoder.CayenneDevice.HumiditySensor[0].Channel, channelhum); Assert.Equal(cayenneDecoder.CayenneDevice.Barometer[0].Value, baro); Assert.Equal(cayenneDecoder.CayenneDevice.Barometer[0].Channel, channelbaro); Assert.Equal(cayenneDecoder.CayenneDevice.Accelerator[0].X, ax); Assert.Equal(cayenneDecoder.CayenneDevice.Accelerator[0].Y, ay); Assert.Equal(cayenneDecoder.CayenneDevice.Accelerator[0].Z, az); Assert.Equal(cayenneDecoder.CayenneDevice.Accelerator[0].Channel, channela); Assert.Equal(cayenneDecoder.CayenneDevice.Gyrometer[0].X, gx); Assert.Equal(cayenneDecoder.CayenneDevice.Gyrometer[0].Y, gy); Assert.Equal(cayenneDecoder.CayenneDevice.Gyrometer[0].Z, gz); Assert.Equal(cayenneDecoder.CayenneDevice.Gyrometer[0].Channel, channelg); Assert.Equal(cayenneDecoder.CayenneDevice.GPSLocation[0].Latitude, lat); Assert.Equal(cayenneDecoder.CayenneDevice.GPSLocation[0].Longitude, lon); Assert.Equal(cayenneDecoder.CayenneDevice.GPSLocation[0].Altitude, alt); Assert.Equal(cayenneDecoder.CayenneDevice.GPSLocation[0].Channel, channelgps); }