Jump to content

drjdpowell

Members
  • Posts

    1,986
  • Joined

  • Last visited

  • Days Won

    183

Posts posted by drjdpowell

  1. I did discuss the different options with Allen Smith at NI Week and the conclusion was for command pattern across a network, the abstraction (or interface) design was the cleanest or at least easiest to understand.

    Uh, my demo is command pattern over TCP.  I needed to create two new classes and four simple VIs, and if you are willing to use standard Variant/Object messages for data then you only need one class and two VIs.  One of those VIs (configuring the command with any meta info) is optional, so that leaves a single Command.lvclass:Do.vi as the only required.  

     

    Surely this is simpler than any abstraction design, no?

  2. On 8/13/2014 at 7:47 PM, John Lokanis said:

     I concluded that the way I am decoupling my network messages is the only practical solution for a command-pattern based message system.  

     

    Didn't like my "envelope" demo, eh?  Personally I would drop the command pattern for the data message (using standard Variant or Object messages instead) and just use command pattern for actual commands.   Then there is one class per message transfer, with server decoupled from client.

  3. I never thought of that, but I use User Events not Queues.  So while the reference will still be destroyed, I wouldn't have any idea it was destroyed unless I again polled the reference to see that it was still valid.

     

    EDIT:  Maybe I could get away with just the watchdog actor polling the reference, and the other actors being told by the watchdog to shutdown if the reference goes invalid.

    Yes, I encountered the same problem with User Events.   I now use a watchdog Queue separate from communication.  No one ever posts data to this Queue; the watchdog just waits on it to be destroyed.  When it does, it posts a shutdown message on the communication Queue/UserEvent (which is always created/owned by the receiving subactor). The watchdog does have to do polling, not on this watchdog Queue, but rather on the communication reference itself, as the watchdog must also abort itself if the subactor shuts down.

     

    An advantage of a watchdog Queue separate from communication is that the subactor can continue to receive messages from subsubactors that it has created, should it need to as part of its shutdown procedure. 

  4. Correct. I have a watchdog.vi in the top-level VI, with watchpuppy.vi in each actor. The watchdog sends out an event every so often (about 1sec), if the watchpuppy doesn't receive an event in say 1.5 secs, it aborts the vi. I can post an example if you'd like. They are easily removed or disabled later if you decide you do not want them in the final version. Although I usually keep them.

    If your actors are dynamically called, you can use a Queue or other reference created in the top-level.  When the top-level goes idle it destroys the reference and this can be used to trigger an error in the watchdog.  I stopped bothering to write shutdown code for most subactors a while ago and happily hit the top-level abort button if needed.

  5. The problem arises when you wish to send these messages across a network between two separate applications.  In most cases, these applications are not duplicates of each other, but rather serve completely separate purposes.  An example would be a client and a server.  The client needs to message requests to the server and the server needs to push data to the client.  For a process to send a message, it needs to package the inputs in the private data of the message class and then transmit it via the network transport (which can be implemented in multiple different ways and is not material to this discussion).  In order to construct the message, the sender will need a copy of the message class included in their application.  This will mean they will need to also load the class of the message recipient since it is statically linked to the message class within the method that executes the message.  And since that will trigger many other class dependencies to load, the end results is the majority of the classes in the recipient application will need to be included in the sending application.  This is not an optimal solution.

    So, we need to find a way to decouple messages from their recipients but still be able to execute them.

     

    Note: I was on vacation when this conversation was going on, and I haven’t read it in great detail.

     

    I only use Command-Pattern messages in limited cases, favouring a variation on string-variant messages mostly.  But the framework I use can do Command Pattern, and can decouple the command from the “serverâ€.   So I made a test example.  In it, the Client sends a request (non-command-pattern for simplicity) for a data message (DataAA.lvclass).   As part of its reply “addressâ€, it specifies an “envelope message†(CommandAA.lvclass) that it wishes to receive the data message inside of.  The TCP Framework keeps the reply address in flattened form while on the server side, so the server never needs to load class CommandAA.  The “Do.vi†method of CommandAA.lvclass invokes the “Read.vi†static method of DataAA.lvclass.

     

    post-18176-0-69546800-1407254804_thumb.p

     

    The methods one needs to write are Write and Read for the Data message, and Do for the Command (with an optional method to add metadata to the Command if desired).  [aside: AQ proposed a slightly different form, where the Command class is a child of the Data Message Class; he would need an additional method to support building the Command from the Data message.]  

    Command Pattern Uncoupling.zip

    drjdpowell_lib_messenging-1.2.1.29.vip

    drjdpowell_lib_cyclic_table_probes-1.1.0.8.vip

  6. Hi,

     

    If I'm not mistaken, Vision Common Resources provides the ability to run those VIs in a deployed environment, while the IMAQdx drivers provides the ability to develop code using those VIs.

     

     

    Have you installed IMAQdx drivers?

    Hmm, your right, I seem to have a misunderstanding of what this package is for; it does state that it is to allow deployment of the list of VIs without the Vision Runtime license.  Yet I felt sure that I needed this in a past project to access a key VI in development mode without Vision.  Must have just needed it for an EXE.

     

    Thanks for the help.

  7. Hmmm, interesting. So do your low level processes trigger events which your UI is registered for? I'm trying to think how the one loop arrangement differs in anything other than an aesthetic sense? Also, if you need to save data, how does that work? Is the File IO actor event structure based as well?

    Just to be clear, I’m talking about using a Message User Event created by the receiving module, instead of a Message Queue, and passed to other modules so they can send messages.  This is different that the archetypal User Event, which is created in the sending process and passed to other modules so they may choose to register.  The later is usually a separate User Event for each strictly-type message, while the former uses a weakly-typed message like the Lapdog message objects you are using.

     

    Using a Message User Event is interchangeable with using a Message Queue, and avoids the extra work of sending messages from a separate event-structure loop.  I don’t really understand why your “File IO” actor is displaying “Microscope Images”, but if it needs to do UI work like that, then why not use an event structure?

  8. Takes a bit of thinking about as any long running processes (i.e. stuff happening in another diagram) can really scupper things, so now you need to do things like spawn off workers etc.

    Didn’t you already have that problem?  If your “Do Action A” event sends a “UI—>CTRL:Do Action A” message to your second loop, nothing will actually happen till it finishes with “Somebody->CTRL:Do Long Running Action B”.

  9. I routinely use User Events to receive messages in anything that is a UI component, and often in things that aren’t a UI component (so I can give them a ‘debug’ UI if needed).  To me, the topmost loop you have is redundant; it does nothing other than stream the Event Queue into the Message Queue, with no ability to do any actual work (since it doesn’t have access to any state information) and it requires you to write lots of extra build-and-parse message code.  Pointless.

  10. There is no direct way to write a cluster.  Partly this is because there is no direct one-to-one correspondence between LabVIEW and SQLIte types; in particular, a LabVIEW string can be either text of binary (SQLIte Text and Blob types).  Note that it is relatively easy to wire a long set of “Get Column” into a corresponding cluster bundle (or an unbundle into the corresponding “Bind”).  That is part of the reason for making “Get Column” and “Bind” property nodes.

  11. Whatever timing method you choose, you will get the maximum flexibility by making it a separate loop from your actual periodic task.  Have the separate timing loop signal the main loop handling the task via some messaging method such as a User Event.  That way the main loop is not constrained by the timing technique; the OP’s process could be reading data every 15 sec AND saving to disk every 5 min AND updating some UI element every 500 ms (by using three external timing loops). And as a message-handler, the main loop can accept (and immediately act on) other messages than just “stop”.  Meanwhile, the dedicated timing loop can be made a reusable component (as it only does timing).

  12. Why would he be handling mouse-move events in his data collecting loop?  Handle that somewhere else.

     

    Any finite timeout is unreliable if there can be repeated events; your 100ms timeout would fail during a mouse move.  The only reliable timeouts are 0, −1, and a timeout recalculated after each event based on the previous time the timeout case executed.

     

    Added later: actually, 0 isn’t that reliable either.

  13. I don't mind this idea, the one thing I wasn't sure of is the fact that now the main VI which owns the subpanel has access to all the other VIs references. To me, it feels like these references should be private and other VIs shouldn't have access to them. 

    Also, isn’t this unnecessarily complicated.  You already are keeping track of the communication references to these subcomponents; now your going to have to keep track of the VI refs of their VIs (plus whatever mechanism you use to get the VI refs to the top-level subpanel owner).  An “Insert into the attached subpanel” message is trivially simple.

  14. Why does each VI have a copy of the subpanel reference?  I would just have the top-level owner of the subpanel just send send the subpanel ref to the chosen subView, after calling “Remove VIEW”.  The receiving subView would call “Insert VI” as part of handling the message, but wouldn’t bother saving the reference.

  15.  I've so far thought that the only way to avoid getting blocked by the root loop was to populate the asynchronous call pool (and hope that the pool is large enough to meet the demand during a blocking event...).  Populating the call pool is only required for a speed gain then, or?

    Getting the ref with “Open VI Ref” is blocking, but increasing the size of the pool when needed does not, so there isn’t a need to prepopulate the clone pool.  

     

    On my benchmarks adding an extra clone is about 1000us, while reuse of a clone in the pool is about 100us (LabVIEW 2011).  

×
×
  • Create New...

Important Information

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