Check what programs are running.

  • I am looking for a way to check if a program is running in the background via a system variable. I know the common practice is to use Flags to check this, but there is room for error in this method as others have discussed. This can be fixed using a WAIT 0.01 sec, but I'm looking for a more reliable way to do this.

    In the below example, the main program calls COORD and waits for F[23] to turn on meaning the program has finished, but what I see happening is that the flag turns on before COORD is actually finished. In the main program on line 4, I get the error "Program is already running".

    The program COORD has 4 steps, the three lines of code and the program END command. The flag gets turned on on step 3 before the program has ended.

    -- MAIN PROGRAM --
    1: RUN COORD ;
    2: WAIT (F[23]) ;
    3: PR[2]=PR[1] ;
    4: RUN COORD ;
    5: DO WORK

    1: F[23:Prg Run]=(OFF) ;
    3: F[23:Prg Run]=(ON) ;

    Does anyone know of a way to check what programs are currently running without using flags?

  • karel has some built in routines for parsing the currently assigned tasks. i have looked though the variables and have found nothing that will do exactly what you say without more information. you can try the $MOR_GROUP[1].$CUR_PROG. that will have the name of the last program that generated motion for that motion group. that might be sufficient for your task. beware though as it is invalidated as soon as the robot is jogged.

Advertising from our partners