Ejemplo n.º 1
0
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static new void Release(IMessage rInstance)
        {
            if (rInstance == null) { return; }

            // We should never release an instance unless we're
            // sure we're done with it. So clearing here is fine
            rInstance.Clear();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // and removed by default.
            rInstance.IsSent = true;
            rInstance.IsHandled = true;

            // Make it available to others.
            if (rInstance is MyCustomMessage)
            {
                sPool.Release((MyCustomMessage)rInstance);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(IMessage rInstance)
        {
            if (rInstance == null)
            {
                return;
            }

            // We should never release an instance unless we're
            // sure we're done with it. So clearing here is fine
            rInstance.Clear();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // and removed by default.
            rInstance.IsSent    = true;
            rInstance.IsHandled = true;

            // Make it available to others.
            if (rInstance is Message)
            {
                sPool.Release((Message)rInstance);
            }
        }
Ejemplo n.º 3
0
 private void ClearMessage(IMessage message)
 {
     message.Clear();
 }
Ejemplo n.º 4
0
        //send to instrument by visacom
        private string send_to_instrument(string fullcmd,string address,string cmd, IMessage ioDmm,int delay = 0)
        {
            WriteTraceText(fullcmd);
            //IVisaSession basesession = null;
            //IMessage talksession = null;

            string strRd = "";
            string instrumentAddress = address;
            //lock
            //this.WriteTraceText("\n");
            lock (_lock_Instrument)
            {

                    ioDmm.Clear();
                    ioDmm.WriteString(cmd);

                    if (delay != 0 && delay > 500)
                        Thread.Sleep(delay);
                    else
                        Thread.Sleep(500);
                    if (cmd.Contains("?"))
                    {
                        for (int i = 0; i < 5; i++)
                        {

                            try
                            {

                                strRd = ioDmm.ReadString(4069);
                                break;
                            }
                            catch (Exception exp)
                            {
                                ioDmm.Clear();
                                if (i != 9)
                                {
                                    Thread.Sleep(200);
                                    continue;

                                }
                                else
                                {
                                    WriteErrorText("write/read to instrumen by visacom error: " + exp.Message);
                                    throw new Exception(exp.Message);
                                }

                            }

                        }

                    }

            }
            strRd = strRd.TrimEnd('\n');
            return strRd;
        }