Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CML/Driver - Async Macros
#1
Let's say I'm in a poll event* ... I'd like to fire off a macro (or other hunk of CML code) that may take some time or require waiting for a device. I don't want to block my thread/driver. I don't even particularly care for a call back. I'll either assume it worked or check it later.

Can I do this? if so, is there an example out there or a document?










*Outside of a dog, a poll event is man's best friend. Inside of a dog, it's too dark to poll.
Reply
#2
CML is strictly single threaded. So you just have to use state machine like flags to track your state and start the operation, then return and later check for the completion and in the meantime keep up with the fact that the device is incommunicado until it's responded.
Dean Roddey
Explorans limites defectum
Reply
#3
Dean Roddey Wrote:CML is strictly single threaded. So you just have to use state machine like flags to track your state and start the operation, then return and later check for the completion and in the meantime keep up with the fact that the device is incommunicado until it's responded.

So, I could do this:

Driver A - exposes fields (for the user) and talks to the device.
Driver B - Does stuff via backdoor or "command fields"

Driver A in it's poll sets a field in driver B that causes Driver B to execute a (for argument) 30 sec process. Driver B blocks for 30 seconds, but Driver A should return immediately. Thus being responsive.

Of course, if you try to talk to Driver B again, immediately, you'll have trouble, but this would keep the fields in Driver A updating and responsive.

Right?
Reply
#4
In theory you could do that. I'm not sure I would though. I don't think it gains you much relative to just starting it in the first driver and remembering it's started and acting accordingly. It's more complexity to get to the same place.
Dean Roddey
Explorans limites defectum
Reply
#5
Dean Roddey Wrote:In theory you could do that. I'm not sure I would though. I don't think it gains you much relative to just starting it in the first driver and remembering it's started and acting accordingly. It's more complexity to get to the same place.

I guess it would depend on if it's something that I need to wait for a response. If I have to wait I don't want to block the driver. I don't even remember what the application I was thinking of was Smile...
Reply
#6
You don't have to block in order to wait. You jsut remember you are waiting for a response and keep checking for it to arrive until you get it or give up. But, either way, you've effectively blocked the driver in most cases sine you generally cannot then send any outgoing messages to the device until it's responded, so you'd have to reject writes. That's better the just blocking definitely.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CML Macros - Replacing Quotes gReatAutomation 2 264 02-13-2021, 11:59 AM
Last Post: Dean Roddey
  ClickPLC driver now failing after upgrade znelbok 2 505 09-21-2020, 10:48 PM
Last Post: znelbok
  Pentair driver tom 5 1,193 08-02-2020, 11:29 PM
Last Post: kblagron
  Marantz receiver driver (IP) dlmorgan999 6 1,222 05-15-2020, 03:32 PM
Last Post: dlmorgan999
  Variables Driver Client gReatAutomation 4 947 04-25-2020, 12:46 PM
Last Post: gReatAutomation
  Reconfig of Driver Causes Built In Triggers to Fire gReatAutomation 2 734 03-25-2020, 04:09 PM
Last Post: gReatAutomation
  Lutron RadioRA2 Driver and Lutron Visor Control gReatAutomation 29 8,490 03-19-2020, 01:03 PM
Last Post: gReatAutomation
  Timers Driver / Field Time Image / Seconds gReatAutomation 1 693 03-16-2020, 05:48 PM
Last Post: Dean Roddey
  Problem with Accesssing Variables Driver Client Interface kblagron 5 1,317 03-05-2020, 02:24 PM
Last Post: kblagron
  ISYv2 Driver - FanLinc simplextech 4 1,422 02-04-2020, 06:55 PM
Last Post: simplextech

Forum Jump:


Users browsing this thread: 1 Guest(s)