示例#1
0
 private static void OnDatagramReceived(object sender, KnxDatgramEventArgs e)
 {
     if (e.Datagram.DestinationAddress == "7/7/7")
     {
         var data = DptTranslator.Instance.FromDataPoint("10.001", e.Datagram.Data);
     }
 }
示例#2
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");
            }
        }