BasicOperations/FBTime.py

BasicOperations/FBTime.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Topic: FBTime
7 #
8 
9 from pyfbsdk import FBSystem, FBTime, FBSleep, FBMessageBox
10 
11 # Get a timestamp before the sleep.
12 lTs1 = FBSystem().SystemTime
13 
14 # Do sleep for a few milliseconds.
15 lSleepTimeMS = 1234
16 FBSleep( lSleepTimeMS )
17 
18 # Get a second timestamp after the sleep.
19 lTs2 = FBSystem().SystemTime
20 lTdiff = lTs2 - lTs1
21 
22 # Now display the actual sleep time.
23 FBMessageBox( "Actual sleep time",
24  "Sleep time requested: %.3f seconds\nActual sleep time : %.3f seconds" %
25  (( lSleepTimeMS / 1000.0 ),
26  (lTdiff.GetMilliSeconds() / 1000.0)),
27  "OK",
28  None,
29  None )
30 
31 # There are some predefined time unit: Infinity, MinusInfinity, Zero, OneSecond, OneMinute, OneHour.
32 lTs1 = FBTime.OneSecond
33 lTs2 = FBTime.OneMinute
34 lTdiff = lTs2 - lTs1
35 
36 FBMessageBox( "Time Math",
37  "one minutues - one second = %.0f seconds" %
38  (lTdiff.GetMilliSeconds() / 1000.0),
39  "OK",
40  None,
41  None )
42 # Cleanup.
43 del( lTs1, lTs2, lTdiff, lSleepTimeMS, FBSystem, FBTime, FBSleep, FBMessageBox )