Python Script Sleep and Refreshing EZ-IO Binary States

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Sat Apr 13, 2013 3:26 pm
automaton offline
Posts: 88
Joined: May 23, 2008

Python Script Sleep and Refreshing EZ-IO Binary States

I haven't been able to find the answers to the following by searching the docs and forums.

I have an embedded Python script that refreshes an EZ-io module status, then reads the updated status, then acts based on the status like this:

Code: Select all
# Refresh the EZ-IO status
indigo.iodevice.statusRequest(EZ-IO-Device)
#
# Need to have a delay here to wait for the status request to complete
indigo.script.sleep(2)
#
# Get Status of EZ-IO Binary Input here and take appropriate action


My two questions:
1. Am I using indigo.script.sleep(2) properly here? Does this just cause this script to sleep, or does it sleep indigo or all scripts?
2. Is there a command which will only refresh the binary input status (vs. both binary and analog status) of the EZ-IO module (you can do this directly in Indigo, but I couldn't figure out if this was possible using a script command. Refreshing just the binary status is quicker.

If anyone can help, it would be much appreciated.

Posted on
Sun Apr 14, 2013 9:24 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Python Script Sleep and Refreshing EZ-IO Binary States

The sleep call will block the script for 2 seconds. If it is an embedded script then you don't want to block for very long, since only one embedded script can execute at a time. If the IndigoServer detects a script is taking too long to run, then it will kill it so other embedded scripts have a chance to run. But 2 seconds should be fine.

There is no python script command to only request the binary states, but you can do it by creating an Action Group that only requests the binary states then execute the Action Group from the script (instead of calling .statusRequest()).

Image

Posted on
Sun Apr 14, 2013 10:18 am
automaton offline
Posts: 88
Joined: May 23, 2008

Re: Python Script Sleep and Refreshing EZ-IO Binary States

Thanks Matt. I suppose the best practice is to make most scripts external to avoid conflicts and running out of execution time. By the way, is there a preferred or recommended location to create a folder to store external scripts?

Posted on
Sun Apr 14, 2013 10:42 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Python Script Sleep and Refreshing EZ-IO Binary States

It depends. There is overhead in starting up the process that executes the script. For every external python script file a new process has to be started (and then it has to perform a handshake with the IndigoServer to get started). For embedded scripts they share this process context. So the first one take a second or so to start, but then after that other embedded scripts can startup very quickly (but serially, so one blocking or sleeping will hold up the sequence).

So in general I recommend embedded scripts if they will finish executing in a couple of seconds. And I recommend external script if they need to take longer than that, or if they might have to block/wait on external services/applications.

You can put the scripts anywhere, but I would recommend:

/Library/Application Support/Perceptive Automation/Indigo 6/Scripts/

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests