public BacnetService(IBacnetTransport transport) : base(transport) { }
public BacnetClient(IBacnetTransport transport, int timeout = 1000, int retries = 3) { m_client = transport; m_timeout = timeout; m_retries = retries; DefaultSegmentationHandling = true; }
public void Dispose() { m_client?.Dispose(); m_client = null; }
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); } }