Skip navigation

Community

1 2 Previous Next 2399 Views 15 Replies Latest reply: Apr 2, 2012 4:53 PM by AristosQueue RSS
Todd_Lesher Calculating status...
Currently Being Moderated

Mar 13, 2012 8:09 PM

Conversion from (QMH + LV2 Globals) to AF

(Cross-posted in LAVA: http://lavag.org/topic/15554-conversion-from-qmh-lv2-globals-to-af/)

 

I have a device with a serial interface. The device is always listening for commands. Some commands cause an immediate response, some commands cause a continuous response, and some responses show up without having given a command.

 

There are several types of responses (streaming and immediate). In my current code, I use several LV2 globals to hold the most recent 5 minutes of each type of data. In a particular test, I can retrieve the most recent value, all values, the next new value, etc.

 

WIth AF, I can't figure out a good way to replace the LV2s. In the attached zip file, the main code is in "main.vi" and "SerialDevice.lvlib  Actors  Sim.lvclass  Actor Core.vi".

 

Any advice or analysis is appreciated. Note that some inheritance is there since the protocol can (and does) change often, and I need to maintain backwards compatibility.

Attachments:
  • Currently Being Moderated
    1. Mar 15, 2012 1:02 PM (in response to Todd_Lesher)
    Re: Conversion from (QMH + LV2 Globals) to AF

    For a circular buffer like this, you can convert the functional global into an actor.  The actor's private data would be the data stored by your functional global (anything in a shift register), and it would have one public method for each operation the global supports (write data, read last, etc).  You will provide a message for each of these methods, of course.

     

    To use this buffer, launch the actor and pass its queue to whoever needs to access it.

  • Currently Being Moderated
    2. Mar 15, 2012 1:20 PM (in response to niACS)
    Re: Conversion from (QMH + LV2 Globals) to AF

    If all you do is convert your LV2 global into an actor, you'll likely have to create ReplyMessages so that you can activley ask the global for its value. Actors are meant to be active, and they work best when they do the telling about their value changing, so you'll probably find a cleaner system (and one less likely to accidentally introduce a deadlock) if anyone who cares about the value in the global is told about it proactively by your new actor, instead of them having to ask for it.

  • Currently Being Moderated
    3. Mar 15, 2012 1:30 PM (in response to AristosQueue)
    Re: Conversion from (QMH + LV2 Globals) to AF

    It is true for a circular buffer that several of the messages will generate replies.  But, as you have pointed out in the past, those messages don't have to be Reply Messages.  A requestor can send a query and then assume the response will show up on its receive queue.  That should be OK for the kinds of arbitrary retrieval scenarios where circular buffers are used.

     

    You'll want to implement zero coupling, of course, but that's not a big deal.

  • Currently Being Moderated
    5. Mar 15, 2012 4:28 PM (in response to Todd_Lesher)
    Re: Conversion from (QMH + LV2 Globals) to AF

    Your existing approach -- top-level send messages for each "write this" command, and reply messages for each "read this" command -- is sound. The problem with this approach is if you are using reply messages in other parts of your code, you can end up with a hang as everyone is waiting for a reply from someone else. But as long as reply messages are only used on one side of the communication channel, they are safe from deadlocks.

     

    When you are calling into actors from code that is not organized entirely around actors, this is a sound approach, but it does not scale as an application becomes more complex. Inevitably, you start introducing more and more parts that want to "do their own thing", and that's when you start converting other parts of your program to actors. At that point, you'll find that you're far better off using your send VIs for the "write this" messages, but not having messsages for "read this" and instead having a queue where the LV2-global sends you messages that says, "By the way, this got written", and having one of those queues for every independent module. Essentially, the LV2-style-global stops being a central repository of data and turns into a message post office.

  • Currently Being Moderated
    8. Mar 16, 2012 11:33 AM (in response to Todd_Lesher)
    Re: Conversion from (QMH + LV2 Globals) to AF

    Please keep in mind... I am not encouraging you to complicate your application if it is not needed. There's a balance to be struck here between apps that need to go to the next level of complexity and the business need to actually get apps written.

     

    My job is merely to highlight options and to suggest improvements. You have to evaluate whether those are appropriate for your app. I have a bias against LV2-globals because I know where their failure points are and can design without them from the outset at this point, but if they get the job done well enough, use them. ("Well enough" is a term for you to define, with as short or long term a scope as you see fit.)

  • jdebuhr Calculating status...
    Currently Being Moderated
    11. Mar 20, 2012 1:04 PM (in response to Todd_Lesher)
    Re: Conversion from (QMH + LV2 Globals) to AF

    I just wanted to comment that this discussion is also helping me as I work through to understand the Actor framework and how I might implement it.

1 2 Previous Next

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points