protected Task Handle(RegisterSerialCommand registration) { if (_messageHandlers.ContainsKey(registration.MessageType)) { throw new ArgumentException($"Message type {registration.MessageType} is already registered in {nameof(SerialPortService)}"); } _messageHandlers.Add(registration.MessageType, registration); return(Task.CompletedTask); }
protected override async Task OnStarted(IContext context) { await base.OnStarted(context).ConfigureAwait(false); _i2cAddress = AsInt(MessageProperties.Address); var registration = new RegisterSerialCommand(Self, I2C_ACTION_HUMANITY, new Format[] { new Format(1, typeof(byte), MessageProperties.PinNumber), new Format(2, typeof(float), MessageProperties.Value) }); await MessageBroker.SendToService(registration).ConfigureAwait(false); }
protected override async Task OnStarted(IContext context) { await base.OnStarted(context); _I2cAddress = AsInt(MessageProperties.Address); _pinNumber = AsInt(MessageProperties.PinNumber); var registration = new RegisterSerialCommand(Self, 2, new Format[] { new Format(1, typeof(uint), "Code"), new Format(2, typeof(byte), "Bits"), new Format(3, typeof(byte), "Protocol") }); await MessageBroker.SendToService(registration); }
protected override async Task OnStarted(IContext context) { await base.OnStarted(context).ConfigureAwait(false); _I2cAddress = AsInt(MessageProperties.Address); var registration = new RegisterSerialCommand(Self, 3, new Format[] { new Format(1, typeof(byte), "System"), new Format(2, typeof(uint), "Code"), new Format(3, typeof(byte), "Bits") } ); await MessageBroker.SendToService(registration).ConfigureAwait(false); }