示例#1
0
        public async Task <byte> GetFanMode(CoolitSensorAddress fanAddress)
        {
            await DoSetCurrentFan(fanAddress);

            await cmd.Run((byte)CoolitModernCommandCode.FAN_MODE_GET);

            if (cmd.IsFaulted)
            {
                return(0);
            }

            byte mode = ByteParser.ParseResponse(cmd.Result);

            return((byte)(mode & 0x8E)); // high bit is set if fan detected, bits 3..1 contain fan mode. Low bit is set when the fan is 4-pin, ignore it.
        }
示例#2
0
        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);
        }