private void SendLabel(ModbusPkt pkt)
        {
            SendRetrieveXML send = new SendRetrieveXML(MB);

            send.Log += Modbus_Log;
            try {
                send.SendXML(pkt.Label);
            } finally {
                AsyncComplete ac = new AsyncComplete(MB, pkt);
                parent.BeginInvoke(new EventHandler(delegate { Complete(this, ac); }));
                send.Log -= Modbus_Log;
                send      = null;
            }
        }
        private void Send(ModbusPkt pkt)
        {
            SendRetrieveXML send = new SendRetrieveXML(MB);

            send.Log += Modbus_Log;
            try {
                send.SendXML(pkt.Data);
            } finally {
                string        logXML = send.LogXML;
                AsyncComplete ac     = new AsyncComplete(MB, pkt)
                {
                    Resp2 = logXML
                };
                parent.Invoke(new EventHandler(delegate { Complete(this, ac); }));
                send.Log -= Modbus_Log;
                send      = null;
            }
        }
        private void RetrieveMsg(ModbusPkt pkt)
        {
            string          msgXML      = string.Empty;
            SendRetrieveXML retrieveMsg = new SendRetrieveXML(MB);

            retrieveMsg.Log += Modbus_Log;
            try {
                msgXML = retrieveMsg.Retrieve();
            } finally {
                AsyncComplete ac = new AsyncComplete(MB, pkt)
                {
                    Resp1 = msgXML
                };
                parent.BeginInvoke(new EventHandler(delegate { Complete(this, ac); }));
                retrieveMsg.Log -= Modbus_Log;
                retrieveMsg      = null;
            }
        }
        private void WriteSelectedItems(ModbusPkt pkt)
        {
            bool            success = false;
            SendRetrieveXML send    = new SendRetrieveXML(MB);

            send.Log += Modbus_Log;
            try {
                success = send.WriteSelectedItems(pkt.Item, pkt.Data);
            } finally {
                AsyncComplete ac = new AsyncComplete(MB, pkt)
                {
                    Success = success
                };
                parent.BeginInvoke(new EventHandler(delegate { Complete(this, ac); }));
                send.Log -= Modbus_Log;
                send      = null;
            }
        }
        private void DoSubstitutions(ModbusPkt pkt)
        {
            bool            success = false;
            Substitution    sub     = null;
            SendRetrieveXML sr      = new SendRetrieveXML(MB);

            if (pkt.substitution == null)
            {
                sub = sr.RetrieveAllSubstitutions(1);
            }
            else
            {
                sr.SendSubstitution(pkt.substitution);
            }
            sr = null;
            AsyncComplete ac = new AsyncComplete(MB, pkt)
            {
                Success = success, substitution = sub
            };

            parent.Invoke(new EventHandler(delegate { Complete(this, ac); }));
        }