Пример #1
0
        public override void Init(ConnUri uri, bool persistent, string ID, int inactivityMS, int _sendGap = 0)
        {
            if ((uri == null || !uri.IsValid) && !tcpClientProvided)
            {
                return;
            }

            messageCircularBuffer = new CircularByteBuffer4Comms(65536);

            MINIMUM_SEND_GAP = _sendGap;
            RECEIVE_TIMEOUT  = inactivityMS;
            frameWrapper?.SetID(ID);

            CommsUri = uri ?? CommsUri;
            SetIPChunks(CommsUri.IP);

            if (!tcpClientProvided)
            {
                tcpEq        = new CommEquipmentObject <TcpClient>(ID, uri, null, persistent);
                tcpEq.ID     = ID;
                receiverTask = new Task(Connect2EquipmentCallback, TaskCreationOptions.LongRunning);
            }
            else
            {
                tcpEq.ID     = ID;
                receiverTask = new Task(ReceiveCallback, TaskCreationOptions.LongRunning);
            }

            senderTask = new Task(DoSendStart, TaskCreationOptions.LongRunning);
        }
Пример #2
0
        public override void Init(ConnUri uri, bool persistent, string ID, int inactivityMS, int _sendGap = 0)
        {
            if ((uri == null || !uri.IsValid) && !tcpClientProvided)
            {
                return;
            }

            this.ID          = ID;
            messageQueu      = useCircular ? (ICommsQueue) new CircularByteBuffer4Comms(65536) : (ICommsQueue) new BlockingByteQueue();
            MINIMUM_SEND_GAP = _sendGap;
            RECEIVE_TIMEOUT  = inactivityMS;
            frameWrapper?.SetID(ID);
            State = STATE.STOP;

            CommsUri = uri ?? CommsUri;
            SetIPChunks(CommsUri.IP);

            if (!tcpClientProvided)
            {
                tcpEq    = new CommEquipmentObject <TcpClient>(ID, uri, null, persistent);
                tcpEq.ID = ID;
            }
            else
            {
                tcpEq.ID = ID;
            }
        }