public override int Update(ACommand Command, Ev3Brick Brick, int Port, int StartIndex) { var Device = Brick.SensorDevice(Port); Device.Value1 = Command.ResData[StartIndex + 2]; Device.Value2 = Command.ResData[StartIndex + 3]; Device.Value3 = Command.ResData[StartIndex + 4]; Device.DeviceType = Ev3SensorDevice.DEVICE_TYPE.SENSOR_DEVICE_COLOR; return(base.Update(Command, Brick, Port, StartIndex) + 3); }
public override int Update(ACommand Command, Ev3Brick Brick, int Port, int StartIndex) { short Distance = (short) ((ushort)Command.ResData[StartIndex + 2] + (((ushort)Command.ResData[StartIndex + 3]) << 8)); byte IsListen = Command.ResData[StartIndex + 4]; var Device = Brick.SensorDevice(Port); Device.Value1 = Distance; Device.Value2 = IsListen; Device.Value3 = 0; Device.DeviceType = Ev3SensorDevice.DEVICE_TYPE.SENSOR_DEVICE_ULTRASONIC; return(base.Update(Command, Brick, Port, StartIndex) + 3); }
public override int Update(ACommand Command, Ev3Brick Brick, int Port, int StartIndex) { short Angle = (short) ((ushort)Command.ResData[StartIndex + 2] + (((ushort)Command.ResData[StartIndex + 3]) << 8)); short Speed = (short) ((ushort)Command.ResData[StartIndex + 4] + (((ushort)Command.ResData[StartIndex + 5]) << 8)); var Device = Brick.SensorDevice(Port); Device.Value1 = Angle; Device.Value2 = Speed; Device.Value3 = 0; Device.DeviceType = Ev3SensorDevice.DEVICE_TYPE.SENSOR_DEVICE_GYRO; return(base.Update(Command, Brick, Port, StartIndex) + 4); }
/// <summary> /// Update sensor device information of Ev3 Brick by GetSensors command. /// </summary> /// <param name="Command">GetSensors command.</param> /// <param name="Brick">Object to set data.</param> public override void Update(ACommand Command, Ev3Brick Brick) { Debug.Assert(Command != null); Debug.Assert(Brick != null); if (Command is Command_0E_00) { int Index = 0; int DataTopIndex = 4; for (Index = 0; Index < 4; Index++) { var Device = Brick.SensorDevice(Index); Device.ConnectedPort = (Ev3Device.INPORT)Index; DEVICE_TYPE DeviceType = DEVICE_TYPE.SENSOR_DEVICE_NO_DEVICE; byte Type = Command.ResData[DataTopIndex + Index]; bool HasValue = DeviceTypeDictionary.ContainsKey(Type); if (HasValue) { DeviceType = DeviceTypeDictionary[Type]; } else { DeviceType = DEVICE_TYPE.SENSOR_DEVICE_UNKNOWN; } Device.DeviceType = DeviceType; switch (DeviceType) { case DEVICE_TYPE.SENSOR_DEVICE_ULTRASONIC: case DEVICE_TYPE.SENSOR_DEVICE_GYRO: case DEVICE_TYPE.SENSOR_DEVICE_TOUCH: case DEVICE_TYPE.SENSOR_DEVICE_COLOR: case DEVICE_TYPE.SENSOR_DEVICE_HT_NXT_ACCEL: case DEVICE_TYPE.SENSOR_DEVICE_NXT_TEMP: Device.IsConnected = true; break; default: Device.IsConnected = false; break; } } } }
public override void Update(ACommand Command, Ev3Brick Brick) { Debug.Assert(Command != null); Debug.Assert(Brick != null); if (Command is Command_40_00) { int Index = 0; int DataTopIndex = 4; int DevNum = Command.ResData[DataTopIndex++]; for (Index = 0; Index < DevNum; Index++) { int DataIndex = DataTopIndex + (Index * 2); byte Port = Command.ResData[DataIndex++]; byte IsTouch = Command.ResData[DataIndex]; var Device = Brick.SensorDevice(Port); Device.ConnectedPort = (Ev3Device.INPORT)Port; Device.IsConnected = true; Device.Value1 = IsTouch; Device.DeviceType = Ev3SensorDevice.DEVICE_TYPE.SENSOR_DEVICE_TOUCH; } } }