hexagon logo

Runtime script with inexplicable results...

I have a function in my scripts to calculate the runtime in seconds for a program, using the Timer value from windows, which returns the current time as seconds from midnight.

The blue code is my script run at the beginning of a part program. The red code is what is run at the end. (I've cut and pasted these sections from the scripts...they are too long.) In the event that a program runs through midnight, I have a section in the red code to correctly calculate runtime. I've tested this code in the excel editor while resetting my computer clock to 11:59 PM and running it through midnight, and it works. Unfortunately, this code does not work when running PC-DMIS through midnight. I get program times of more than 86400.

Any ideas why this is not calculating correctly only when run through PC-DMIS?

[COLOR="Blue"]Sub Main()

Dim BeforeTime As String
BeforeTime = Timer
BeforeTime = CLng(BeforeTime)

End Sub[/COLOR]

[COLOR="Red"]
Sub Main()

Dim Aftertime As String
Aftertime = Timer
Aftertime = CLng(Aftertime)
Dim RunTime As String

If Aftertime < BeforeTime Then
RunTime = (86400 - BeforeTime) + Aftertime
Else
RunTime = Aftertime - BeforeTime
End If

End Sub[/COLOR]
Parents
  • Ok... I do the same thing on some of my customer's parametric programs. It is mostly for me for debugging purposes and also to tell what programs they ran, how often, etc... A customer can also tell if they cancel a program, run a tip cal, if they let a CMM sit waiting for operator entry, didnt measure parts when they said they did, didnt measure the correct number during a shift.

    I do not bring any of it back into the measurement software though, it is all written to a CSV file and then if I need to analyze the run time or whatever, I open in excel and do the time deltas in excel.

    Each activity is a separate time stamp in the CSV file. Each program start, each stop, etc.... I have entries to show what each time stamp means. Program path and file name to make sure they ran the correct program. Each entry begins with the date and time, that is followed by the reason, then the other misc information.
Reply
  • Ok... I do the same thing on some of my customer's parametric programs. It is mostly for me for debugging purposes and also to tell what programs they ran, how often, etc... A customer can also tell if they cancel a program, run a tip cal, if they let a CMM sit waiting for operator entry, didnt measure parts when they said they did, didnt measure the correct number during a shift.

    I do not bring any of it back into the measurement software though, it is all written to a CSV file and then if I need to analyze the run time or whatever, I open in excel and do the time deltas in excel.

    Each activity is a separate time stamp in the CSV file. Each program start, each stop, etc.... I have entries to show what each time stamp means. Program path and file name to make sure they ran the correct program. Each entry begins with the date and time, that is followed by the reason, then the other misc information.
Children
No Data