mechaware——理解事件确认

来源:互联网 发布:c#集合和数组的区别 编辑:程序博客网 时间:2024/06/06 13:02

Event Notification 事件确认机理

The best way to understand how event notification works, is to use a mail delivery analogy. Think of yourself as your program. If you use a thread to wait for events (mpiNotifyEventWait), you are waiting for the mail carrier (Event Manager). If you are polling for events (mpiNotifyEventWait), you check the mail periodically.

使用信封传递的例子来理解事件确认(event notification)。把自己当做一个程序,如果使用一个线程等待事件(比如mpiNotifyEventWait线程),你正在等邮递员(event manager)。如果轮询事件(mpiNotifyEventWait),那么你是在定期的查看邮件。这是两种处理事件的方式。

When the firmware sends an event, it is like a friend (MPI Object) sending you (Thread) a letter (ex: Event -- Motion Done). The letter (Event) travels to the post office (Controller Event Pool) where your mail carrier (Event Manager) retrieves it and then delivers it to your mailbox (Notify Object).

当固件(firmware)发送一个事件时,就好像一个朋友(MPI Object)发送给你(线程)一封信(事件之Motion Done)。这封信(事件)先到邮局(控制器事件池),在这里邮递员(event manager)检索它并把它传送到你的邮箱(notify 对象)。

Here are the three common cases:

下面是常见的几个例子:

 
  1. Thread Waiting for Events 线程中等待事件
    As soon as the mail carrier (Event Manager) shows up, the thread in your program checks the mailbox (Notify Object). 邮递员(event manager)一出现,你的程序中的线程就立即查看邮箱(notify 对象)。

  2. Thread Polling for Events 线程中轮询事件
    The thread in the program periodically checks the mailbox (Notify Object) to see if there is a letter (Event).线程定期的查看邮箱(notify 对象)来看是否有信(event)。                                                        
  3. Thread using mpiNotifyEventWait  线程中使用mpiNotifyEventWait 
    If the thread in the program does not check the mailbox (Notify object), it will start to fill up with letters. The mail carrier (Event Manager) keeps stuffing more letters into the mailbox and figures that you will eventually check it. If the thread calls an mpiNotifyEventWait(...), it checks the mailbox. But, it can only check one letter at a time。如果程序中的线程不检查邮箱(notify对象),邮箱会填满邮件。邮递员(event manager)持续往邮箱加信,他以为你最终会查看邮箱的。如果线程调用了 mpiNotifyEventWait(...),它会检查邮箱。但是一次只看一封信。
  4. Thread using mpiNotifyEventFlush 线程中使用mpiNotifyEventFlush
    If the thread in the program does not check the mailbox (Notify object), it will start to fill up with letters. The mail carrier (Event Manager) keeps stuffing more letters into the mailbox and figures that you will eventually empty it. If the thread calls mpiNotifyEventFlush(...), mail carrier empties the mailbox and throws all the letters in the trash.如果程序中的线程没有检查邮箱(notify对象),邮箱会逐渐的变满。邮递员(event manager)持续的网邮箱里加邮件,他认为你最终会清空它。如果线程调用mpiNotifyEventFlush(...),邮递员会清空邮箱,并把所有的信扔进垃圾箱。