Show the progress of an APX

You can use the apxprogress command in your program APX to provide information about the progress of your APX. This is useful for program APXs that run for a long period of time when you want to give the user status on the progress of your APX.

You can use a web APX as a front-end to the program APX and display the progress in the web APX.

apxprogress command

Use the apxprogress command to define the number of steps in the execution of a program APX and to record when each step has completed. This lets users of the APX know how far the APX has progressed and how much is remaining.

Syntax of apxprogress

apxprogress {option}...

Options to the apxprogress command

Option

Description

-i <total number of steps>

Specifies the total number of steps the APX takes to run. Use this option once at the beginning of the APX to specify the total number of steps the APX will take.

You can use this option multiple times in an APX to increase the number steps. Each use increments the total number of steps by the specified value.

-c <current step>

Specifies the current step number. Call apxprogress with this option after each step in the APX code has completed.

-m <message>

Specifies a text message describing the status of the APX.

-a <data>

Specifies additional information the APX can make available about itself.

-d

Indicates debug mode. Displays the output of the command to stdout for debugging purposes.

-h

Displays help information about the apxprogress command.

Example shell script that uses apxprogress

The following shell script is part of a program APX that uses the apxprogress command. The APX defines a total of 100 steps and announces its current progress 100 times. Each time it also provides a message that includes the step number.

#!/bin/sh
######################################################################
# A simple shell script for a program APX that displays progress
# about itself.
# Author: <name>
######################################################################
echo "This is a simple APX that uses apxprogress."
totalsteps=100
apxprogress -i $totalsteps -c 1
for i in `seq $totalsteps`; do
apxprogress -c $i -m "APX is running, working on step $i" -d
sleep 10
done

Viewing APX progress

You can use the SA API method JobService.getProgress()to access the progress information about a running APX that calls the apxprogress command. For an example showing this method, see Viewing the APX progress in the Twister interface, which is part of the Tutorial: Create a program APX.