Interface GatewayProgressManager
-
- All Superinterfaces:
ProgressManager
public interface GatewayProgressManager extends ProgressManager
The GatewayProgressManager is used to execute tasks on the gateway that might take a while. The tasks are initiated by a client (usually a designer), and updates on the task's state are fed back to the client progress system through the gateway's push mechanism.The running tasks publish updates by retrieving the current progress listener for their thread through the function on this interface. This method is used due to the way that methods are invoked by the client on the gateway.
The easiest way to use this system is to write a GatewayFunc annotated function, and use the "asyncInvoke" flag of that annotation. That will cause the function to be passed through this system automatically.
-
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.ignition.common.gui.progress.ProgressManager
PUSH_PROTOCOL_UPDATE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancelTask(java.lang.String taskId)
Sets the canceled flag of the specified task.TaskProgressListener
getProgressListenerForThread()
Returns the TaskProgressListener registered for the calling thread.java.util.List<TaskProgressState>
getState()
Returns the current state of all running tasks.java.lang.String
runAsyncTask(GatewayProgressRunnable task)
Similar torunAsyncTask(String, GatewayProgressRunnable)
, but registers a task that doesn't exist under a user session.java.lang.String
runAsyncTask(java.lang.String sessionid, GatewayProgressRunnable task)
Registers a task to run asynchronously.void
setProgressListenerForThread(TaskProgressListener listener)
-
-
-
Method Detail
-
runAsyncTask
java.lang.String runAsyncTask(java.lang.String sessionid, GatewayProgressRunnable task)
Registers a task to run asynchronously. The provided task will be run in a different thread, who will have a threadlocal TaskProgressListener that can be updated. The registration returns a task uid that can be used to monitor the state.- Parameters:
sessionid
- the client session that is interested in the progress of this task.task
- the runnable to execute.- Returns:
- the task uid
-
runAsyncTask
java.lang.String runAsyncTask(GatewayProgressRunnable task)
Similar torunAsyncTask(String, GatewayProgressRunnable)
, but registers a task that doesn't exist under a user session.
-
cancelTask
void cancelTask(java.lang.String taskId)
Sets the canceled flag of the specified task. The task will only be canceled if the executor watches the flag and exits.Right now unknown task ids are just ignored, but in the future we might want to throw an error. We may also want to provide some sort of feedback.
-
getProgressListenerForThread
TaskProgressListener getProgressListenerForThread()
Returns the TaskProgressListener registered for the calling thread. If no listener is registered, a "dummy" listener will be returned that will discard updates.- Returns:
- a TaskProgressListener, guaranteed to not be null.
-
setProgressListenerForThread
void setProgressListenerForThread(TaskProgressListener listener)
-
getState
java.util.List<TaskProgressState> getState()
Returns the current state of all running tasks.
-
-