Exemple #1
0
        //
        /// <summary>
        /// Composes a message and place in the queue for processing.
        /// </summary>
        /// <param name="showError"></param>
        /// <param name="msg"></param>
        /// <param name="parms"></param>
        /// <remarks></remarks>
        /// <returns>Operator response code.</returns>
        public Utilities.OperatorResponse SendMessage(bool showError, string msg, string[] parms)
        {
            string msgParms = "";
            string errMsg;

            if (msg == null || msg == "")
            {
                return(Utilities.OperatorResponse.Success);
            }

            if (!Connected)
            {
                errMsg = "Client not connected to Server";
                Utilities.RuntimeError(MessageBoxButtons.OK, 0, errMsg);
                return(Utilities.OperatorResponse.Success);
            }

            // Initialize the return value
            Utilities.OperatorResponse error = Utilities.OperatorResponse.Success;

            // Popup an error if the Client Handler is busy
            while ((clientQ.Count > 0) && showError)
            {
                if (!ClientStopped)
                {
                    errMsg = "***Client Task is busy***";
                    error  = Utilities.RuntimeError(MessageBoxButtons.RetryCancel, 0, errMsg);
                    if (error != Utilities.OperatorResponse.Retry)
                    {
                        return(error);
                    }
                }
            }

            lock (qLocker)
            {
                // Compose the message
                for (int i = 0; i < parms.Length; i++)
                {
                    if (parms[i] != "")
                    {
                        msgParms = msgParms + Delim + parms[i];
                    }
                }
                if (this.Affix)
                {
                    clientQ.Enqueue(this.STX + msg + msgParms + this.ETX);
                }
                else
                {
                    clientQ.Enqueue(msg + msgParms + this.Terminator);
                }
            }
            return(error);
        }
Exemple #2
0
        /// <summary>
        /// Composes a message and place in the queue for processing.
        /// </summary>
        /// <param name="showError"></param>
        /// <param name="msg"></param>
        /// <param name="parms"></param>
        /// <remarks></remarks>
        /// <returns>Operator response code.</returns>
        public Utilities.OperatorResponse Write(bool showError, string msg)
        {
            string errMsg;

            if (msg == null || msg == "")
            {
                return(Utilities.OperatorResponse.Success);
            }

            if (!Connected)
            {
                if (showError)
                {
                    errMsg = this.Name + ": Server not connected to Client";
                    Utilities.RuntimeError(MessageBoxButtons.OK, 0, errMsg);
                    return(Utilities.OperatorResponse.Success);
                }
                else
                {
                    // Ignore the request and exit
                    return(Utilities.OperatorResponse.Success);
                }
            }

            // Initialize the return value
            Utilities.OperatorResponse error = Utilities.OperatorResponse.Success;

            // Popup an error if the Server Handler is busy
            while ((serverQ.Count > 0) && showError)
            {
                if (!ServerStopped)
                {
                    errMsg = "***" + this.Name + ": Server Task is busy***";
                    error  = Utilities.RuntimeError(MessageBoxButtons.RetryCancel, 0, errMsg);
                    if (error != Utilities.OperatorResponse.Retry)
                    {
                        return(error);
                    }
                }
            }

            lock (qLocker)
            {
                serverQ.Enqueue(msg);
            }
            return(error);
        }
Exemple #3
0
        /// <summary>
        /// Send a message to a Server
        /// </summary>
        /// <param name="showError"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public Utilities.OperatorResponse SendMessage(bool showError, string msg)
        {
            string errMsg;

            if (msg == null || msg == "" || !this.Running)
            {
                return(Utilities.OperatorResponse.Success);
            }

            if (!this.Connected && showError)
            {
                errMsg = "Client not connected to Server";
                Utilities.RuntimeError(MessageBoxButtons.OK, 0, errMsg);
                return(Utilities.OperatorResponse.Success);
            }

            // Initialize the return value
            Utilities.OperatorResponse error = Utilities.OperatorResponse.Success;

            // Popup an error if the Client Handler is busy
            while ((clientQ.Count > 0) && showError)
            {
                if (!ClientStopped)
                {
                    errMsg = "***Client Task is busy***";
                    error  = Utilities.RuntimeError(MessageBoxButtons.RetryCancel, 0, errMsg);
                    if (error != Utilities.OperatorResponse.Retry)
                    {
                        return(error);
                    }
                }
            }

            lock (qLocker)
            {
                if (this.Affix)
                {
                    clientQ.Enqueue(this.STX + msg + this.ETX);
                }
                else
                {
                    clientQ.Enqueue(msg + this.Terminator);
                }
            }
            return(error);
        }