Пример #1
0
 public BacnetService(IBacnetTransport transport) : base(transport)
 {
 }
Пример #2
0
 public BacnetClient(IBacnetTransport transport, int timeout = 1000, int retries = 3)
 {
     m_client = transport;
     m_timeout = timeout;
     m_retries = retries;
     DefaultSegmentationHandling = true;
 }
Пример #3
0
 public void Dispose()
 {
     m_client?.Dispose();
     m_client = null;
 }
Пример #4
0
        private void OnRecieve(IBacnetTransport sender, byte[] buffer, int offset, int msg_length, BacnetAddress remote_address)
        {
            try
            {
                //finish receive
                if (m_client == null) return;   //we're disposed

                //parse
                if (msg_length > 0)
                {
                    BacnetNpduControls npdu_function;
                    BacnetAddress destination, source;
                    byte hop_count;
                    BacnetNetworkMessageTypes nmt;
                    ushort vendor_id;
                    int npdu_len = NPDU.Decode(buffer, offset, out npdu_function, out destination, out source, out hop_count, out nmt, out vendor_id);

                    // Modif FC
                    remote_address.RoutedSource = source;

                    if ((npdu_function & BacnetNpduControls.NetworkLayerMessage) == BacnetNpduControls.NetworkLayerMessage)
                    {
                        Trace.TraceInformation("Network Layer message received");
                        return; // Network Layer message discarded
                    }

                    if (npdu_len > 0)
                    {
                        offset += npdu_len;
                        msg_length -= npdu_len;
                        BacnetPduTypes apdu_type;
                        if (msg_length > 0)
                        {
                            apdu_type = APDU.GetDecodedType(buffer, offset);
                            //APDU
                            ProcessApdu(remote_address, apdu_type, buffer, offset, msg_length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error in OnRecieve: " + ex.Message);
            }
        }