Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/28/2011 in all areas

  1. Following on the "Self-addressed Stamped Envelopes" topic, I'd like to present a design of an Active Object using my messaging library. This template has the ability to both "reply" to messages and to allow "observers" to register for event updates. I haven't used this template yet (just wrote the observer-registration part yesterday) and I would appreciate any feedback before I use it in a real-world project (which I'll be doing after a weeks vacation). The example object, "PP Template" does the following: Responds to "Current Time?" with a text string of the current time. Sets the format string for the time by the command "SetTimeFormat" Starts generating "TimeUpdate" messages periodically on the period given in the command "AutoGenerateTime" Allows external processes to register as observers of the following events: "SetTimeFormat" received "Current Time" issued "TimeUpdate" issued "Macro: Exit" received (this is the shutdown command for the active object) All error messages Here is how a higher-level VI might create ("launch") and communicate with "PP Template": In this example we launch "PP Template", register a Message Logger (another active object) as observer of all published events, send a nonsense message "Blah Blah" just to demonstrate error handling, set the time format, and query "Current Time?" first synchronously(*), then asynchronously with the message reply going to the "Asynchronous Receiver" loop. Then we register "Asynchronous Receiver" as an observer of TimeUpdate events (and set the autogenerate time of these events). On pushing the "stop" button, "PP Template" is sent a "Macro: Exit" command to shut down. Here's what the Message Logger receives when we run this VI: And here is the VI dynamically launched VI at the heart of the active object. It's basically a message handler with eight cases; three of the cases handle the three commands, then there is a timeout case, an error handling case, a shutdown case, an "ignore null messages" case (not shown), and a default case to catch unhandled commands (and spelling errors). The way receiver timeout and errors feed into the message case structure is stolen from Daklu's Lapdog messaging library. Some details of communication with the active object: 1) The object is launched by dynamically calling the PP Template.vi, setting it's "Startup Message" control via a VI Server call, and then doing some handshaking messages between "Launch.vi" and the "Startup" and "Acknowledge Startup" VI's. This creates the incoming command messenger for the process (in this case it is a queue based messenger, but there is an alternate "Startup" VI for a User-Event-based messenger). Calling a "Send" or "Query" method on the active object calls the same method on the command messenger. There are two startup modes: when started as an "autoshutdown slave", the messenger is created inside the Launch.vi, which means that if the main VI goes idle, the queue reference will become invalid, which triggers a "MSRReceiverError" that shuts down the launched VI ("Message Logger" in the above example shuts down in this way). The other way creates the Messenger inside the "Startup" VI, making the active object independant of the Launching process. 2) Observer registration is handled by an "ObsReg" by-ref object, with two methods: "Registration", which filters out and acts on registration commands, maintaining a list of all observers for each event message (and sets for all events and all error events), and "Notify Observers", which accepts messages and sends them to all observers registered for them. Thus, it is extremely easy to publish new event types; just package a message for the event and pass it to "Notify Observers". 3) Reply-based communication involves a "return address" (a messenger or other active object reference) to be attached to the message, and the active object using a "Reply" VI to respond (in synchronous communication, the "Query" VI creates a single-use response queue to receive the reply). For error handling, the Reply VI will package any error in it's error terminal as an error message and send this to the return address (this is in addition to an observers being notified of the error). -- James (*) Please note the potential problems of synchronous communication brought up by mje.
    1 point
  2. Move Australia closer.
    1 point
  3. Although different...just tossing this out there http://screencast.com/t/PseOPTRZ LEGACY - STD Keyboard.zip Good luck ~,~ The Captain
    1 point
  4. I've never tried it in a built EXE, so you'll need to test it. Let me know what you figure out.
    1 point
  5. A quick update (a year later...) The LabVIEW Tools Network (where OpenG is listed on ni.com) now has ratings. If you've used OpenG and like (or don't like!) it, you can rate it there... http://sine.ni.com/nips/cds/view/p/lang/en/nid/209027 See you at NIWeek
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.