This is the standard BACNet udp transport
Inheritance: IBacnetTransport, IDisposable
コード例 #1
0
        private void Forward_NPDU(byte[] buffer, int msg_length, bool ToGlobalBroadcast, Net.IPEndPoint EPsender)
        {
            // Forms the forwarded NPDU from the original one, and send it to all
            // orignal     - 4 bytes BVLC -  NPDU  - APDU
            // change to   -  10 bytes BVLC  -  NPDU  - APDU

            // copy, 6 bytes shifted
            byte[] b = new byte[msg_length + 6];    // normaly only 'small' frames are present here, so no need to check if it's to big for Udp
            Array.Copy(buffer, 0, b, 6, msg_length);

            // 10 bytes for the BVLC Header, with the embedded 6 bytes IP:Port of the original sender
            First4BytesHeaderEncode(b, BacnetBvlcFunctions.BVLC_FORWARDED_NPDU, msg_length + 6);
            BacnetAddress BacSender;

            BacnetIpUdpProtocolTransport.Convert(EPsender, out BacSender); // to embbed in the forward BVLC header
            for (int i = 0; i < BacSender.adr.Length; i++)
            {
                b[4 + i] = BacSender.adr[i];
            }

            // To BBMD
            SendToBBMDs(b, msg_length + 6);
            // To FD, except the sender
            SendToFDs(b, msg_length + 6, EPsender);
            // Broadcast if required
            if (ToGlobalBroadcast == true)
            {
                MyBBMDTransport.Send(b, msg_length + 6, new Net.IPEndPoint(Net.IPAddress.Parse(BroadcastAdd), MyBBMDTransport.SharedPort));
            }
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is BacnetIpUdpProtocolTransport))
            {
                return(false);
            }
            BacnetIpUdpProtocolTransport a = (BacnetIpUdpProtocolTransport)obj;

            return(a.m_port == m_port);
        }
コード例 #3
0
 public BVLC(BacnetIpUdpProtocolTransport Transport)
 {
     MyBBMDTransport = Transport;
     BroadcastAdd    = MyBBMDTransport.GetBroadcastAddress().ToString().Split(':')[0];
 }