private async Task ReadFwVersion() { fwVersion = "<Empty>"; CommandStateMachine cmd; var parser = new BCDFWVersionParser(); byte commandCode; IReportFactory factory; switch (deviceInfo.ProtocolType) { case ProtocolType.Modern: default: commandCode = (byte)CoolitModernCommandCode.FW_VERSION; factory = modernReportFactory; break; } cmd = new CommandStateMachine(deviceEntity, factory, new CoolitBridgeResponseValidator()); await RunCmdSynchronized(cmd, commandCode); fwVersion = (GetCommandStateMachineResult(cmd, parser) ?? string.Empty).ToString(); }
private IResponseParser GetParser(CoolitModernCommandCode commandCode) { IResponseParser result = null; if (commandCode == CoolitModernCommandCode.FAN_CURRENT_RPM || commandCode == CoolitModernCommandCode.TEMPERATURE_CURRENT_TEMPERATURE) { result = new WordParser(); } if (commandCode == CoolitModernCommandCode.NUMBER_OF_FANS || commandCode == CoolitModernCommandCode.NUMBER_OF_TEMPERATURES || commandCode == CoolitModernCommandCode.NUMBER_OF_LEDS) { result = new ByteParser(); } if (commandCode == CoolitModernCommandCode.FAN_MODE_GET) { result = new ByteParser(); } if (commandCode == CoolitModernCommandCode.FW_VERSION) { result = new BCDFWVersionParser(); } // TODO: [tm] add more parsers here if (result == null) { result = new NullParser(); } return(result); }