public void PulseLogoVariable(Mqtt.Subscription subscription, int address, MqttChannelConfig.Types type, int duration) { if (type != MqttChannelConfig.Types.Byte) { throw new ArgumentOutOfRangeException(nameof(type), type, null); } subscription.MessageReceived += async(sender, args) => await mapping.PulseByte(logo.ByteAt(address), args.ApplicationMessage.Payload, duration); }
public void WriteLogoVariable(Mqtt.Subscription subscription, int address, MqttChannelConfig.Types type) { subscription.MessageReceived += type switch { MqttChannelConfig.Types.Integer => (sender, args) => mapping.ReceivedInteger(logo.IntegerAt(address), args.ApplicationMessage.Payload), MqttChannelConfig.Types.Byte => (sender, args) => mapping.ReceivedByte(logo.ByteAt(address), args.ApplicationMessage.Payload), MqttChannelConfig.Types.Float => (sender, args) => mapping.ReceivedFloat(logo.FloatAt(address), args.ApplicationMessage.Payload), _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) }; }