Device Filtering from Actions.xml

Posted on
Fri Mar 09, 2018 1:37 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Device Filtering from Actions.xml

I think I understand the updates to device filtering in the current API, and I think this case isn't covered but wanted to make sure. Within Actions.xml, I filter on "self" which returns all the device types defined within the plugin. However, I have one device type for which a particular action is not appropriate. There isn't a way to filter out device types, so if I want to keep that device type from being returned, I need to AND together all the devices except that one type. To exclude deviceType3:

Code: Select all
  <Action id="action_id" deviceFilter="self.deviceType1, self.deviceType2, self.deviceType4" uiPath="DeviceActions">
    <Name>Action Name</Name>
    <CallbackMethod>actionCallbackMethod</CallbackMethod>
  </Action>


That works, I'm just double-checking to make sure that's the most efficient way.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Mar 09, 2018 2:59 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Device Filtering from Actions.xml

Retracted.
Last edited by Colorado4Wheeler on Fri Mar 09, 2018 5:39 pm, edited 1 time in total.

Posted on
Fri Mar 09, 2018 4:46 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Device Filtering from Actions.xml

DaveL17 wrote:
That works, I'm just double-checking to make sure that's the most efficient way.


Sure, that's fine, and would be slightly more efficient than a custom list since the server builds it rather than a separate round-trip to the plugin (which may call back into the server, etc).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Mar 10, 2018 6:20 am
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device Filtering from Actions.xml

Hmmm. I don't know what I was looking at yesterday, but it seems I might've spoken too soon. When I list more than one device type id, I only get results for the last one in the list. It seems they may be OR'ing instead of AND'ing.

Code: Select all
  <Action id="refreshAChartAction" deviceFilter="self.barChartingDevice" uiPath="DeviceActions">
    <Name>Redraw Chart</Name>
    <CallbackMethod>refreshAChartAction</CallbackMethod>
  </Action>

Screen Shot 2018-03-10 at 5.55.10 AM.png
One device type id.
Screen Shot 2018-03-10 at 5.55.10 AM.png (35.36 KiB) Viewed 2155 times

Code: Select all
  <Action id="refreshAChartAction" deviceFilter="self.barChartingDevice, self.lineChartingDevice" uiPath="DeviceActions">
    <Name>Redraw Chart</Name>
    <CallbackMethod>refreshAChartAction</CallbackMethod>
  </Action>

Screen Shot 2018-03-10 at 5.56.51 AM.png
Two device type ids.
Screen Shot 2018-03-10 at 5.56.51 AM.png (35.42 KiB) Viewed 2155 times


Seems I might have to provide a config UI for the action to deliver the custom list.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Mar 10, 2018 10:48 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Device Filtering from Actions.xml

Unfortunately, you are correct. While you can have more than one filter listed, it only accepts/uses one base/class filter. The additional filter arguments (which allow more than 1) apply to sub-types and properties. I think this might work:

Code: Select all
<Action id="refreshAChartAction" deviceFilter="self, props.IsBar, props.IsLine" uiPath="DeviceActions"]

where you would have to set pluginProps for each of those appropriately either in the code, or via a hidden boolean in the Devices.XML:

Code: Select all
newProps = someBarDev.pluginProps
newProps["IsBar"] = True
someBarDev.replacePluginPropsOnServer(newProps)

newProps = someLineDev.pluginProps
newProps["IsLine"] = True
someLineDev.replacePluginPropsOnServer(newProps)

Image

Posted on
Sat Mar 10, 2018 12:51 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device Filtering from Actions.xml

Super Matt, thanks. What you're saying makes sense, is easy to implement and works perfectly.

I may make it a habit to add a similar prop element to the custom devices of all my plugins; I think it's worth it for this purpose alone.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Mar 10, 2018 9:05 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device Filtering from Actions.xml

Just as a follow-up, this is working great and is super fast. This is for the Matplotlib plugin and I chose to go with a binary test:

Actions.xml
Code: Select all
<Action id="refreshAChartAction" deviceFilter="self, props.IsChart uiPath="DeviceActions">

plugin.py
Code: Select all
newProps = someBarDev.pluginProps
newProps["IsChart"] = True
someBarDev.replacePluginPropsOnServer(newProps)

Thanks Matt!
Last edited by DaveL17 on Tue Mar 20, 2018 5:39 am, edited 1 time in total.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Mar 19, 2018 7:37 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Device Filtering from Actions.xml

Is there similar syntax for the Events.xml file? I need to create a trigger than only needs the device to be identified. I tried this, but didn't get a popup with devices with that property.

Code: Select all
   <Event id="buttonPress"  deviceFilter="self, props.IsButton">
      <Name>Button Press</Name>
    </Event>

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Mar 20, 2018 6:29 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Device Filtering from Actions.xml

Bump. Anyone?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Mar 20, 2018 6:45 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device Filtering from Actions.xml

I think (but don't know for sure) that you'll have to set it up through a config ui. I've tried a couple different attempts -- with and without the specific filter and with and without a callback and no luck.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 20, 2018 6:58 pm
DaveL17 offline
User avatar
Posts: 6743
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Device Filtering from Actions.xml

Not sure it's still true, but I did find this which indicates that deviceFilter is not implemented for events.

http://forums.indigodomo.com/viewtopic.php?f=108&t=10714&hilit=events+popup#p69570

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 20, 2018 6:59 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Device Filtering from Actions.xml

Oh well, writing some short functions....

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Mar 21, 2018 8:49 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Device Filtering from Actions.xml

Sorry for the slow response. Dave is correct – not currently implemented but is on the API request list.

Image

Posted on
Wed Mar 21, 2018 8:52 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Device Filtering from Actions.xml

matt (support) wrote:
Sorry for the slow response. Dave is correct – not currently implemented but is on the API request list.


That's cool. I missed that old thread about it. Already done with that part of the code.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests