Пример #1
0
        public ER SendMessage(ref T_MSG pk_msg)
        {
            if (pk_msg == null)
            {
                return(ER.E_PAR);
            }

            if (pk_msg.msgrfu != null)
            {
                return(ER.E_OBJ);
            }

            m_MsgQueue.AddLast(pk_msg);

            if (m_TskQueue.First != null)
            {
                Task task = m_TskQueue.First.Value;
                m_TskQueue.RemoveFirst();

                if (!task.ReleaseWait())
                {
                    return(ER.E_RLWAI);
                }
            }

            return(ER.E_OK);
        }
Пример #2
0
        public ER ReceiveMessage(out T_MSG ppk_msg, TMO tmout)
        {
            ER ret;

            ppk_msg = null;

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
            {
                return(ER.E_CTX);
            }

            //if (ppk_msg == null)
            //	return ER.E_PAR;

            if ((m_TskQueue.First == null) && (m_MsgQueue.First != null))
            {
                ppk_msg = m_MsgQueue.First.Value;
                m_MsgQueue.RemoveFirst();
            }
            else
            {
                if (task == null)
                {
                    return(ER.E_TMOUT);
                }

                if (tmout == 0)
                {
                    return(ER.E_TMOUT);
                }

                ret = task.Wait(m_TskQueue, TSKWAIT.TTW_MBX, m_MbxID, tmout);

                switch (ret)
                {
                case ER.E_OK:
                    if (m_MsgQueue.First == null)
                    {
                        return(ER.E_RLWAI);
                    }
                    ppk_msg = m_MsgQueue.First.Value;
                    m_MsgQueue.RemoveFirst();
                    break;

                case ER.E_TMOUT:
                    return(ER.E_TMOUT);

                default:
                    return(ER.E_RLWAI);
                }
            }

            //SetDebugInfo(ppk_msg, lpszFileName, nLine);

            return(ER.E_OK);
        }
Пример #3
0
        public ER SendMessage(ref T_MSG pk_msg)
        {
            if (pk_msg == null)
                return ER.E_PAR;

            if (pk_msg.msgrfu != null)
                return ER.E_OBJ;

            m_MsgQueue.AddLast(pk_msg);

            if (m_TskQueue.First != null) {
                Task task = m_TskQueue.First.Value;
                m_TskQueue.RemoveFirst();

                if (!task.ReleaseWait())
                    return ER.E_RLWAI;
            }

            return ER.E_OK;
        }
Пример #4
0
        public ER ReceiveMessage(out T_MSG ppk_msg, TMO tmout)
        {
            ER ret;

            ppk_msg = null;

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
                return ER.E_CTX;

            //if (ppk_msg == null)
            //	return ER.E_PAR;

            if ((m_TskQueue.First == null) && (m_MsgQueue.First != null)) {
                ppk_msg = m_MsgQueue.First.Value;
                m_MsgQueue.RemoveFirst();
            }
            else {
                if (task == null)
                    return ER.E_TMOUT;

                if (tmout == 0)
                    return ER.E_TMOUT;

                ret = task.Wait(m_TskQueue, TSKWAIT.TTW_MBX, m_MbxID, tmout);

                switch (ret) {
                case ER.E_OK:
                    if (m_MsgQueue.First == null)
                        return ER.E_RLWAI;
                    ppk_msg = m_MsgQueue.First.Value;
                    m_MsgQueue.RemoveFirst();
                    break;
                case ER.E_TMOUT:
                    return ER.E_TMOUT;
                default:
                    return ER.E_RLWAI;
                }
            }

            //SetDebugInfo(ppk_msg, lpszFileName, nLine);

            return ER.E_OK;
        }
Пример #5
0
        public ER trcv_msg(out T_MSG ppk_msg, ID mbxid, TMO tmout)
        {
            ER Result = ER.E_NOEXS;
            Mailbox Mailbox;

            ppk_msg = null;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                Mailbox = g_Kernel.Nucleus.GetMailbox(mbxid);
                if (Mailbox == null)
                    Result = ER.E_NOEXS;
                else
                    Result = Mailbox.ReceiveMessage(out ppk_msg, tmout);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }
Пример #6
0
        public ER snd_msg(ID mbxid, T_MSG pk_msg)
        {
            ER Result = ER.E_NOEXS;
            Mailbox Mailbox;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                Mailbox = g_Kernel.Nucleus.GetMailbox(mbxid);
                if (Mailbox == null)
                    Result = ER.E_NOEXS;
                else
                    Result = Mailbox.SendMessage(ref pk_msg);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }