Exemple #1
0
        public Task DatapointInd(IReadOnlyCollection <DatapointValue> values)
        {
            foreach (var value in values)
            {
                var dpId = $"{value.DatapointId}";

                DriverContext.Logger.LogDebug($"Datagram on {dpId}");

                TelegramMonitor.NotifyTelegram(TelegramDirection.Input, null, dpId, null, Automatica.Core.Driver.Utility.Utils.ByteArrayToString(value.Data));

                if (_callbackMap.ContainsKey(dpId))
                {
                    foreach (var ac in _callbackMap[dpId])
                    {
                        try
                        {
                            DriverContext.Logger.LogDebug($"Datagram on {dpId} - dispatch to {ac}");
                            ac.Invoke(value.Data);
                        }
                        catch (Exception e)
                        {
                            DriverContext.Logger.LogError($"{e}");
                        }
                    }
                }
                else
                {
                    DriverContext.Logger.LogWarning($"Datagram on GA - no callback registered");
                }
            }
            return(Task.CompletedTask);
        }
Exemple #2
0
        public Task OnDatagram(KnxDatagram datagram)
        {
            KnxHelper.Logger.LogDebug($"Datagram on GA {datagram.DestinationAddress}");

            TelegramMonitor.NotifyTelegram(TelegramDirection.Input, datagram.SourceAddress, datagram.DestinationAddress, datagram.ToString(), Automatica.Core.Driver.Utility.Utils.ByteArrayToString(datagram.Data.AsSpan()));

            if (_callbackMap.ContainsKey(datagram.DestinationAddress))
            {
                foreach (var ac in _callbackMap[datagram.DestinationAddress])
                {
                    try
                    {
                        KnxHelper.Logger.LogDebug($"Datagram on GA {datagram.DestinationAddress} - dispatch to {ac}");
                        ac.Invoke(datagram);
                    }
                    catch (Exception e)
                    {
                        KnxHelper.Logger.LogError($"{e}");
                    }
                }
            }
            else
            {
                KnxHelper.Logger.LogWarning($"Datagram on GA - not callback registered");
            }

            return(Task.CompletedTask);
        }
Exemple #3
0
        private void KnxEventDelegate(object sender, KnxDatgramEventArgs knxDatgramEventArgs)
        {
            KnxHelper.Logger.LogDebug($"Datagram on GA {knxDatgramEventArgs.Datagram.DestinationAddress}");

            TelegramMonitor.NotifyTelegram(TelegramDirection.Input, knxDatgramEventArgs.Datagram.SourceAddress, knxDatgramEventArgs.Datagram.DestinationAddress, knxDatgramEventArgs.Datagram.ToString(), Automatica.Core.Driver.Utility.Utils.ByteArrayToString(knxDatgramEventArgs.Datagram.Data));

            if (_callbackMap.ContainsKey(knxDatgramEventArgs.Datagram.DestinationAddress))
            {
                foreach (var ac in _callbackMap[knxDatgramEventArgs.Datagram.DestinationAddress])
                {
                    try
                    {
                        KnxHelper.Logger.LogDebug($"Datagram on GA {knxDatgramEventArgs.Datagram.DestinationAddress} - dispatch to {ac}");
                        ac.Invoke(knxDatgramEventArgs.Datagram);
                    }
                    catch (Exception e)
                    {
                        KnxHelper.Logger.LogError($"{e}");
                    }
                }
            }
            else
            {
                KnxHelper.Logger.LogWarning($"Datagram on GA - not callback registered");
            }
        }
Exemple #4
0
 private void DriverOnTelegramReceived(object sender, PacketReceivedEventArgs packetReceivedEventArgs)
 {
     if (packetReceivedEventArgs.Telegram is RadioErp1Packet radio)
     {
         TelegramMonitor.NotifyTelegram(Automatica.Core.Base.TelegramMonitor.TelegramDirection.Input, radio.SenderIdString, radio.Packet.DestinationIdString, radio.Packet.ToString(), Utils.ByteArrayToString(radio.Data));
         TelegramReceived(radio);
     }
 }
Exemple #5
0
        private void _driver_PacketSent(object sender, PacketSentEventArgs e)
        {
            var idBase = _driver.IdBase;

            if (e.Telegram is RadioErp1Packet radio)
            {
                TelegramMonitor.NotifyTelegram(Automatica.Core.Base.TelegramMonitor.TelegramDirection.Output, Utils.ByteArrayToString(idBase), "FF FF FF FF", e.Packet.ToString(), Utils.ByteArrayToString(radio.Data));
            }
            else
            {
                TelegramMonitor.NotifyTelegram(Automatica.Core.Base.TelegramMonitor.TelegramDirection.Output, Utils.ByteArrayToString(idBase), "FF FF FF FF", e.Packet.ToString(), "");
            }
        }
Exemple #6
0
 private void _driver_AnswerReceived(object sender, AnswerReceviedEventArgs e)
 {
     TelegramMonitor.NotifyTelegram(Automatica.Core.Base.TelegramMonitor.TelegramDirection.Input, "EnOcean Dongle", "Automatica.Core.Server", e.Packet.ToString(), Utils.ByteArrayToString(e.Packet.Data));
 }