hexagon logo

output program runtime

I've searched for this as I know this has been discussed once or twice. Can you output the runtime of a program? Or track it somehow just bu executing a program?

We are running CMMs (machinists, QA techs) virtually around the clock and boss want to know if we can track this for a week or so to justify getting a person to just run parts for the machinists.
  • Duane, how do you need this information? Do you need it in a variable or tracefiled or something? It sounds like the footer will not do what you need.
  • I have been recoding runtimes, in a seperate text file, for years. The code I use to do it is below. It was written for readability but could be modified to be more easily imported into another program.

    $$ NO,'$
    $$ NO,' start cntr segment one
    ASSIGN/DTE = SYSTEMDATE("M'/'d'/'y'")
    ASSIGN/TM2 = SYSTEMTIME("HH':'mm':'ss")
    FPTR =FILE/OPEN,C:\USAGE\FPTR.TXT,APPEND
    FILE/WRITELINE,FPTR," "
    FILE/WRITE_BLOCK,FPTR,DTE
    FILE/WRITELINE,FPTR," YOUR PART NUMBER "
    FILE/CLOSE,FPTR,KEEP
    ASSIGN/S2 = RIGHT(TM2,2)
    ASSIGN/M2 = MID(TM2,3,2)
    ASSIGN/H2 = LEFT(TM2,2)
    ASSIGN/H2S_B = (H2)*3600
    ASSIGN/M2S_B = (M2)*60
    ASSIGN/TO_SC_2 = (H2S_B)+(M2S_B)+(S2)
    $$ NO,' end cntr segment one
    $$ NO,'
    $$ NO,'
    $$ NO,'
    $$ NO,' start cntr segment two
    ASSIGN/TM1 = SYSTEMTIME("HH':'mm':'ss")
    ASSIGN/S1 = RIGHT(TM1,2)
    ASSIGN/M1 = MID(TM1,3,2)
    ASSIGN/H1 = LEFT(TM1,2)
    ASSIGN/H2S_A = (H1)*3600
    ASSIGN/M2S_A = (M1)*60
    ASSIGN/TO_SC_1 = (H2S_A)+(M2S_A)+(S1)
    ASSIGN/EL_SEC = (TO_SC_1)-(TO_SC_2)
    ASSIGN/EL_MIN = (EL_SEC)/60
    FPTR =FILE/OPEN,C:\USAGE\FPTR.TXT,APPEND
    FILE/WRITE_BLOCK,FPTR,"START TIME "
    FILE/WRITE_BLOCK,FPTR,TM2
    FILE/WRITE_BLOCK,FPTR," MINUTES MEASURING "
    FILE/WRITE_BLOCK,FPTR,EL_MIN
    FILE/WRITELINE,FPTR," "
    $$ NO,' end cntr segment two
    $$ NO,'
    $$ NO,'
  • Tracefield's only apply to stats, yes? Nothing gets dumped into stats.

    If I can have this as a variable, I will open an external file, append it with the time/variable with a read line statement or whatever.

    We do have a guy here who is our "DOS expert" looking at creating a batch file to see if he can open the elogo.dat file, read just the "#ELAPSTIM" and write/append that data to another file.

    We are trying to justify either another CMM or a body on each shift to run parts. Mills it while operator run their parts and there is always a waiting line for parts to be run.
  • See what Mark Bosacker's code can do for you. I was just about to start trimming the strings myself (what he is doing) as I just found I can not simply do the math on the SYSTEMTIME.
  • I have been recoding runtimes, in a seperate text file, for years. The code I use to do it is below. It was written for readability but could be modified to be more easily imported into another program.

    $$ NO,'$
    $$ NO,' start cntr segment one
    ASSIGN/DTE = SYSTEMDATE("M'/'d'/'y'")
    ASSIGN/TM2 = SYSTEMTIME("HH':'mm':'ss")
    FPTR =FILE/OPEN,C:\USAGE\FPTR.TXT,APPEND
    FILE/WRITELINE,FPTR," "
    FILE/WRITE_BLOCK,FPTR,DTE
    FILE/WRITELINE,FPTR," YOUR PART NUMBER "
    FILE/CLOSE,FPTR,KEEP
    ASSIGN/S2 = RIGHT(TM2,2)
    ASSIGN/M2 = MID(TM2,3,2)
    ASSIGN/H2 = LEFT(TM2,2)
    ASSIGN/H2S_B = (H2)*3600
    ASSIGN/M2S_B = (M2)*60
    ASSIGN/TO_SC_2 = (H2S_B)+(M2S_B)+(S2)
    $$ NO,' end cntr segment one
    $$ NO,'
    $$ NO,'
    $$ NO,'
    $$ NO,' start cntr segment two
    ASSIGN/TM1 = SYSTEMTIME("HH':'mm':'ss")
    ASSIGN/S1 = RIGHT(TM1,2)
    ASSIGN/M1 = MID(TM1,3,2)
    ASSIGN/H1 = LEFT(TM1,2)
    ASSIGN/H2S_A = (H1)*3600
    ASSIGN/M2S_A = (M1)*60
    ASSIGN/TO_SC_1 = (H2S_A)+(M2S_A)+(S1)
    ASSIGN/EL_SEC = (TO_SC_1)-(TO_SC_2)
    ASSIGN/EL_MIN = (EL_SEC)/60
    FPTR =FILE/OPEN,C:\USAGE\FPTR.TXT,APPEND
    FILE/WRITE_BLOCK,FPTR,"START TIME "
    FILE/WRITE_BLOCK,FPTR,TM2
    FILE/WRITE_BLOCK,FPTR," MINUTES MEASURING "
    FILE/WRITE_BLOCK,FPTR,EL_MIN
    FILE/WRITELINE,FPTR," "
    $$ NO,' end cntr segment two
    $$ NO,'
    $$ NO,'


    I tried using the SYSTEMTIME at the beginning and end of the program with variables and it would not give any results. Kept showing nothing but "" when I would mouse over the ASSIGN/V3 = V1-V2 in the program. Didn't think it was working because of the this.

    Just an after thought. I was trying to use the SYSTEMTIME routine running the program offline. Could this be why it wouldn't work?
  • It is because they are strings you have to trim them down to do the math, kind of a pain but that is what has to be done I think.

  • We do have a guy here who is our "DOS expert" looking at creating a batch file to see if he can open the elogo.dat file, read just the "#ELAPSTIM" and write/append that data to another file.


    The elogo.dat file is only a template and will not have the actual elapsed time in it.
  • The elogo.dat file is only a template and will not have the actual elapsed time in it.


    Thanks J.


    I will set up Mark's code tomorrow morning and give it a shot.
  • Put this at the beginning of your program (this will only give whole seconds):

    [COLOR="White"].[/COLOR]
                ASSIGN/STARTTIME = INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss"))
    [COLOR="White"].[/COLOR]
    


    Put this at the end of your program:

    [COLOR="White"].[/COLOR]
                ASSIGN/TOTALTIME = INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss")) - STARTTIME
    [COLOR="White"].[/COLOR]
    


    The variable TOTALTIME is the number of seconds it took your program to execute.

    For decimal minutes:

    [COLOR="White"].[/COLOR]
                ASSIGN/TOTALTIME = (INT(SYSTEMTIME("HH") * 3600) + INT(SYSTEMTIME("mm") * 60) + INT(SYSTEMTIME("ss")) - STARTTIME) / 60
    [COLOR="White"].[/COLOR]
    
  • Does the previous post look like this for everyone else? I can't see the code I posted. What the heck is up with that?