Previous Next        Current Page: NeXtMidas Training / Primitives / Lab 8 / Instructions
back
Start Here   
Background   
Common Midas Concepts   
Getting Started - Part 1   
Getting Started - Part 2   
Working with Files   
Option Trees   
Macros - Part 1 (Basics)   
Macros - Part 2 (Graphics)   
NetBeans - Part 1 (Setup)   
NetBeans - Part 2 (GUIs)   
NetBeans - Part 3 (Profiler)   
Eclipse - Part 1 (Setup)   
Eclipse - Part 2 (GUIs)   
Primitives   
   + Overview   
   + Open, Process, Close   
   + Building   
   + The NeXtMidas API   
   + Lab 1   
   + Special Variables   
   + Lab 2   
   + Lab 3*   
   + Files in a Primitive   
   + Lab 4   
   + Lab 5*   
   + Test Macros   
   + Lab 6   
   + Real Time Controls   
   + Lab 7   
   + Working with Messages   
   - Lab 8   
      - Instructions   
      - Solution   
   + Primitive Restarts   
   + Introduction to DSP   
   + Lab 9   
WebStart   
Maps & Imagery   
X-Midas Interoperability   
RMIF & Remoting   
Installing NeXtMidas   
Support & Maintenance   
File Handlers   


  • Lab 8:
    • For this lab you are given a primitive that is supposed to fan messages out to 0 or more listeners. Your job will be to fill in the processMessage(..) method so that is does this.
    • Files (be sure to save these with the correct names):
    • Use UPDATE to add the primitive to the command dictionary. It takes in 0+ parameters.
    • Whenever a message is received the primitive should send a copy of the message on to each of the message handlers listed on the command line.
      • Example:
        pipe on
          ...
          plot/id=plot1 ...
          plot/id=plot2 ...
          plot/id=plot3 ...
          plot/id=plot4 ...
        
          primlab8 plot1 plot2 plot3 plot4
        pipe off
        Whenever primlab8 receives a message, it should send a copy of that message to plot1, plot2, plot3, and plot4; then it should process the message by calling super.processMessage(..).
      • In the open() method the msgHandlers array is initialized with the message handlers to use. (This is done for you.)
      • Hint: You need to use one of the MQ.put(..) methods in order to send a copy of the message's name, info, and data to a given message handler (target destination). Checkout the docs for nxm.sys.lib.MessageQueue to find out which one.
    • Use the test macro to test it out.
    • Hint: This lab requires you to fill in the processMessage(..) method. You do not need to add code anywhere else in the file, all is done for you.
Don't Make This Mistake:
Do not give the message passed into processMessage(..) to MQ.put(..) doing so can cause one of the following problems: (1) infinite loop if msg.to is still set to the current primitive, (2) sharing of the Message object between multiple primitives simultaneously (remember, the different primitives process the message in their own threads, if the same Message object is sent to multiple commands, invalid messages may get processed due to the changing of msg.to between calls).

back