Ejemplo n.º 1
0
 public BacnetMstpProtocolTransport(IBacnetSerialTransport transport, short source_address = -1, byte max_master = 127, byte max_info_frames = 1)
 {
     m_max_info_frames = max_info_frames;
     m_TS           = source_address;
     m_max_master   = max_master;
     m_local_buffer = new byte[MaxBufferLength];
     m_port         = transport;
 }
Ejemplo n.º 2
0
 public BacnetMstpProtocolTransport(IBacnetSerialTransport transport, short sourceAddress = -1,
                                    byte maxMaster = 127, byte maxInfoFrames = 1)
 {
     MaxInfoFrames = maxInfoFrames;
     SourceAddress = sourceAddress;
     MaxMaster     = maxMaster;
     _localBuffer  = new byte[MaxBufferLength];
     _port         = transport;
 }
Ejemplo n.º 3
0
 public BacnetPtpProtocolTransport(IBacnetSerialTransport transport, bool isServer)
 {
     _port           = transport;
     _isServer       = isServer;
     Type            = BacnetAddressTypes.PTP;
     HeaderLength    = PTP.PTP_HEADER_LENGTH;
     MaxBufferLength = 502;
     MaxAdpuLength   = PTP.PTP_MAX_APDU;
 }
Ejemplo n.º 4
0
 public void Dispose()
 {
     if (m_port != null)
     {
         try
         {
             m_port.Close();
         }
         catch
         {
         }
         m_port = null;
     }
 }
Ejemplo n.º 5
0
        public BacnetMstpProtocolTransport(IBacnetSerialTransport transport, short sourceAddress = -1,
                                           byte maxMaster = 127, byte maxInfoFrames = 1)
        {
            SourceAddress   = sourceAddress;
            MaxMaster       = maxMaster;
            Type            = BacnetAddressTypes.MSTP;
            HeaderLength    = MSTP.MSTP_HEADER_LENGTH;
            MaxBufferLength = 502;
            MaxAdpuLength   = MSTP.MSTP_MAX_APDU;
            MaxInfoFrames   = maxInfoFrames;

            _localBuffer = new byte[MaxBufferLength];
            _port        = transport;
        }
Ejemplo n.º 6
0
        // Just Sniffer mode, no Bacnet activity generated here
        // Modif FC
        private void mstp_thread_sniffer()
        {
            while (true)
            {
                try
                {
                    BacnetMstpFrameTypes frameType;
                    byte destinationAddress;
                    int  msgLength;
                    byte sourceAddress;
                    var  status = GetNextMessage(T_NO_TOKEN, out frameType, out destinationAddress, out sourceAddress,
                                                 out msgLength);

                    switch (status)
                    {
                    case GetMessageStatus.ConnectionClose:
                        _port = null;
                        return;

                    case GetMessageStatus.Good:
                        // frame event client ?
                        if (RawMessageRecieved != null)
                        {
                            var length = msgLength + MSTP.MSTP_HEADER_LENGTH + (msgLength > 0 ? 2 : 0);

                            // Array copy
                            // after that it could be put asynchronously another time in the Main message loop
                            // without any problem
                            var packet = new byte[length];
                            Array.Copy(_localBuffer, 0, packet, 0, length);

                            // No need to use the thread pool, if the pipe is too slow
                            // frames task list will grow infinitly
                            RawMessageRecieved(packet, 0, length);
                        }
                        RemoveCurrentMessage(msgLength);
                        break;
                    }
                }
                catch
                {
                    _port = null;
                }
            }
        }
Ejemplo n.º 7
0
        // Just Sniffer mode, no Bacnet activity generated here
        // Modif FC
        private void mstp_thread_sniffer()
        {
            for (;;)
            {
                BacnetMstpFrameTypes frame_type;
                byte destination_address;
                byte source_address;
                int  msg_length;

                try
                {
                    GetMessageStatus status = GetNextMessage(T_NO_TOKEN, out frame_type, out destination_address, out source_address, out msg_length);

                    if (status == GetMessageStatus.ConnectionClose)
                    {
                        m_port = null;
                        return;
                    }
                    if (status == GetMessageStatus.Good)
                    {
                        // frame event client ?
                        if (RawMessageRecieved != null)
                        {
                            int length = msg_length + MSTP.MSTP_HEADER_LENGTH + (msg_length > 0 ? 2 : 0);

                            // Array copy
                            // after that it could be put asynchronously another time in the Main message loop
                            // without any problem
                            byte[] packet = new byte[length];
                            Array.Copy(m_local_buffer, 0, packet, 0, length);

                            // No need to use the thread pool, if the pipe is too slow
                            // frames task list will grow infinitly
                            RawMessageRecieved(packet, 0, length);
                        }

                        RemoveCurrentMessage(msg_length);
                    }
                }
                catch
                {
                    m_port = null;
                }
            }
        }
Ejemplo n.º 8
0
 public void Dispose()
 {
     if (m_port != null)
     {
         try
         {
             m_port.Close();
         }
         catch
         {
         }
         m_port = null;
     }
 }
Ejemplo n.º 9
0
        private short m_TS; //"This Station," the MAC address of this node. TS is generally read from a hardware DIP switch, or from nonvolatile memory. Valid values for TS are 0 to 254. The value 255 is used to denote broadcast when used as a destination address but is not allowed as a value for TS.

        #endregion Fields

        #region Constructors

        public BacnetMstpProtocolTransport(IBacnetSerialTransport transport, short source_address = -1, byte max_master = 127, byte max_info_frames = 1)
        {
            m_max_info_frames = max_info_frames;
            m_TS = source_address;
            m_max_master = max_master;
            m_local_buffer = new byte[MaxBufferLength];
            m_port = transport;
        }
Ejemplo n.º 10
0
 public BacnetPtpProtocolTransport(IBacnetSerialTransport transport, bool is_server)
 {
     m_port = transport;
     m_is_server = is_server;
 }
Ejemplo n.º 11
0
        // Just Sniffer mode, no Bacnet activity generated here
        // Modif FC
        private void mstp_thread_sniffer()
        {
            for (; ; )
            {
                BacnetMstpFrameTypes frame_type;
                byte destination_address;
                byte source_address;
                int msg_length;

                try
                {
                    GetMessageStatus status = GetNextMessage(T_NO_TOKEN, out  frame_type, out  destination_address, out  source_address, out  msg_length);

                    if (status == GetMessageStatus.ConnectionClose)
                    {
                        m_port = null;
                        return;
                    }
                    else if (status == GetMessageStatus.Good)
                    {
                        // frame event client ?
                        if (RawMessageRecieved != null)
                        {

                            int length = msg_length + MSTP.MSTP_HEADER_LENGTH + (msg_length > 0 ? 2 : 0);

                            // Array copy
                            // after that it could be put asynchronously another time in the Main message loop
                            // without any problem
                            byte[] packet = new byte[length];
                            Array.Copy(m_local_buffer, 0, packet, 0, length);

                            // No need to use the thread pool, if the pipe is too slow
                            // frames task list will grow infinitly
                            RawMessageRecieved(packet, 0, length);
                        }

                        RemoveCurrentMessage(msg_length);
                    }
                }
                catch
                {
                    m_port = null;
                }
            }
        }
 public BacnetPtpProtocolTransport(IBacnetSerialTransport transport, bool isServer)
 {
     _port     = transport;
     _isServer = isServer;
 }
 public void Dispose()
 {
     _port?.Close();
     _port = null;
 }
Ejemplo n.º 14
0
 public override void Dispose()
 {
     _port?.Close();
     _port = null;
 }