internal bool SetValue(byte[] data) { BatteryValue newValue = null; switch (Mode) { case BatteryMode.All: { newValue = UIReadMethods.BatteryValue(data, 0); break; } case BatteryMode.Level: { newValue = new BatteryValue(Mode) { Level = UIReadMethods.BatteryValueLevel(data, 0) }; break; } } bool hasChanged = (Value != newValue); if (hasChanged) { Value = newValue; if (MonitorEvents) { ValueChanged?.Invoke(newValue); } } return(hasChanged); }
/// <summary> /// Gets all battery information /// </summary> /// <returns></returns> public async Task <BatteryValue> GetValue() { BatteryValue value = await UIReadMethods.GetBatteryValue(Brick.Socket); Value = value; return(value); }
internal static async Task <BrickInfo> GetBrickInfo() { BrickInfo info = new BrickInfo { Firmware = new FirmwareInfo { Version = await UIReadMethods.GetFirmwareVersion(Brick.Socket), Build = await UIReadMethods.GetFirmwareBuild(Brick.Socket) }, OS = new OSInfo { Version = await UIReadMethods.GetOSVersion(Brick.Socket), Build = await UIReadMethods.GetOSBuild(Brick.Socket) }, Hardware = new HardwareInfo { Version = await UIReadMethods.GetHardwareVersion(Brick.Socket) }, Version = await UIReadMethods.GetVersion(Brick.Socket), }; return(info); }
internal ushort BatchCommand(PayLoadBuilder payLoadBuilder, int index) { if (!MonitorEvents || WarningReceived == null) { return(0); // no need to poll data } return(UIReadMethods.GetWarning_BatchCommand(payLoadBuilder, index)); }
internal ushort BatchCommand(PayLoadBuilder payLoadBuilder, int index) { ushort byteLength = 0; if (!MonitorEvents || ValueChanged == null) { return(byteLength); // no need to poll data } switch (Mode) { case BatteryMode.All: return(UIReadMethods.GetBatteryValue_BatchCommand(payLoadBuilder, index)); case BatteryMode.Level: { DataType type = UIReadMethods.GetBatteryLevel_BatchCommand(payLoadBuilder, index); return(type.ByteLength()); } } return(byteLength); }
/// <summary> /// Gets the brick IP address if assigned else string.Empty /// </summary> /// <returns></returns> public async Task <string> GetIPAddress() { return(await UIReadMethods.GetIPAddress(Brick.Socket)); }
/// <summary> /// Gets any warnings /// </summary> /// <returns></returns> public async Task <IEnumerable <Warning> > GetWarnings() { return(await UIReadMethods.GetWarnings(Brick.Socket)); }