Embedded Python Real-Time FrameWork : API
Build 20250616.1
|
Commonly used routines. More...
Classes | |
class | Binding |
A collection of event handler functions and methods to Bind() and Unbind() the handlers to a particular event. More... | |
class | DSTCalendar |
DST Calendar as list of [ UnixTime, gmt_offset ] tuples. More... | |
class | GLelapsed |
Calculates the time elapsed in millis. More... | |
Functions | |
def | AddDict |
Add dict d2 to d1. More... | |
def | CallStack |
Debugging : Dump Call Stack to list using traceback. More... | |
def | CallStack2 |
Debugging : Dump Call Stack to list using inspect. More... | |
def | CpuTime |
Return amount of CPU time used by process. More... | |
def | CurrentThreadID |
Return current thread ID. More... | |
def | DateTime |
Return string-ified time as YYYY-MM-DD HH:MM:SS. More... | |
def | DateTimeMs |
Return string-ified time as YYYY-MM-DD HH:MM:SS.mmm. More... | |
def | DateTimeUs |
Return string-ified time as YYYY-MM-DD HH:MM:SS.uuuuuu. More... | |
def | FmtIntToSize |
Formats integer quantities to user-defined lengths, appending K, G, T. More... | |
def | FmtQty |
Formats quantities into readable comma-separated thousands, hundreds, etc. More... | |
def | GetIdx |
Return a process-wide unique index. More... | |
def | HexDump |
Return hexDump of binary message. More... | |
def | InRange |
Return True if b is in the closed interval between a and c inclusive. More... | |
def | IsNone |
Return True if 'v' is None. More... | |
def | IsPY3 |
Return True if Python 3.x. More... | |
def | LOG |
Log a message Log a message in log file and optionally Console. More... | |
def | MicroTime |
Returns time.clock() if WIN32 and _bWin32Clock is True; time.time() if not. More... | |
def | ProgressBar |
def | PyClock |
PyVer-agnostic time.clock() More... | |
def | ReadFile |
Open and read file as ASCII. More... | |
def | RollLogFile |
Roll the log file. More... | |
def | SetDriftPerHr |
Set drift / hour to MicroTime() clock to compenstate for drifting time.clock() More... | |
def | SetLog |
Initialize Global Log File. More... | |
def | Str2HMS |
Break HH:MM:SS string into [ h, m, s ]. More... | |
def | Str2Time |
Convert string-ified YYYY-MM-DD HH:MM:SS.mmm to Unix Time. More... | |
def | Str2Time_OBSOLETE |
def | SubDict |
Subtract dict d2 from d1. More... | |
def | Time |
Return string-ified time as HH:MM:SS. More... | |
def | Time2Mark |
Return millis to user-supplied HH:MM:SS. More... | |
def | TimeMs |
Return string-ified time as HH:MM:SS.mmm. More... | |
def | TimeUs |
Return string-ified time as HH:MM:SS.uuuuuu. More... | |
def | tStart |
Returns ntp-anchroed time used for basis of MicroTime() clock. More... | |
def | uDrift |
Returns current calculated drift in MicroTime() clock. More... | |
def | uDriftPerSec |
Returns current calculated drift / sec from MicroTime() clock. More... | |
def | WithinRange |
Ensure b is in the closed interval between a and c inclusive. More... | |
def | Xdefaults |
Parse .Xdefaults type config file. More... | |
Commonly used routines.
def pyRT.gatea.sys.GLcommon.AddDict | ( | d1, | |
d2, | |||
bInclZero = True |
|||
) |
Add dict d2 to d1.
d1 | - Operand dict 1 |
d2 | - Operand dict 2 |
bInclZero | - Allow zero values; Default is True |
def pyRT.gatea.sys.GLcommon.CallStack | ( | ) |
Debugging : Dump Call Stack to list using traceback.
def pyRT.gatea.sys.GLcommon.CallStack2 | ( | ) |
Debugging : Dump Call Stack to list using inspect.
def pyRT.gatea.sys.GLcommon.CpuTime | ( | ) |
Return amount of CPU time used by process.
def pyRT.gatea.sys.GLcommon.CurrentThreadID | ( | ) |
Return current thread ID.
def pyRT.gatea.sys.GLcommon.DateTime | ( | t = None , |
|
bGMT = False , |
|||
bToday = False |
|||
) |
Return string-ified time as YYYY-MM-DD HH:MM:SS.
bToday | t | Description |
---|---|---|
True | Today | TODAY HH:MM:SS |
True | Not Today | YYYY-MM-DD HH:MM:SS |
False | Any | YYYY-MM-DD HH:MM:SS |
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
bToday | - 'TODAY' if True and t is today; YYYY-MM-DD if False (default) |
def pyRT.gatea.sys.GLcommon.DateTimeMs | ( | t = None , |
|
bGMT = False |
|||
) |
Return string-ified time as YYYY-MM-DD HH:MM:SS.mmm.
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
def pyRT.gatea.sys.GLcommon.DateTimeUs | ( | t = None , |
|
bGMT = False |
|||
) |
Return string-ified time as YYYY-MM-DD HH:MM:SS.uuuuuu.
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
def pyRT.gatea.sys.GLcommon.FmtIntToSize | ( | iVal, | |
sz | |||
) |
Formats integer quantities to user-defined lengths, appending K, G, T.
iVal | - Value to format |
sz | - Max formatted string len |
def pyRT.gatea.sys.GLcommon.FmtQty | ( | fmt, | |
dQty | |||
) |
Formats quantities into readable comma-separated thousands, hundreds, etc.
fmt | - printf-like format w/ requested Sigf=Fig |
dQty | - Quantity |
def pyRT.gatea.sys.GLcommon.GetIdx | ( | ) |
Return a process-wide unique index.
def pyRT.gatea.sys.GLcommon.HexDump | ( | binMsg | ) |
Return hexDump of binary message.
binMsg | : Binary (or string) message |
def pyRT.gatea.sys.GLcommon.InRange | ( | a, | |
b, | |||
c | |||
) |
Return True if b is in the closed interval between a and c inclusive.
a | - Lower Bound |
b | - Value to check |
c | - Upper Bound |
def pyRT.gatea.sys.GLcommon.IsNone | ( | v | ) |
Return True if 'v' is None.
v | - Variable to Check |
def pyRT.gatea.sys.GLcommon.IsPY3 | ( | ) |
Return True if Python 3.x.
def pyRT.gatea.sys.GLcommon.LOG | ( | msg, | |
bCons = True |
|||
) |
Log a message Log a message in log file and optionally Console.
msg | - Message to log |
bCons | - True to log to console if set; Default is True |
def pyRT.gatea.sys.GLcommon.MicroTime | ( | ) |
Returns time.clock() if WIN32 and _bWin32Clock is True; time.time() if not.
def pyRT.gatea.sys.GLcommon.ProgressBar | ( | i, | |
tck = 1000 |
|||
) |
def pyRT.gatea.sys.GLcommon.PyClock | ( | ) |
PyVer-agnostic time.clock()
def pyRT.gatea.sys.GLcommon.ReadFile | ( | pFile | ) |
Open and read file as ASCII.
pFile | : Filename |
def pyRT.gatea.sys.GLcommon.RollLogFile | ( | pLog, | |
numRoll | |||
) |
Roll the log file.
pLog | - Log file name |
numRoll | - Number to roll |
def pyRT.gatea.sys.GLcommon.SetDriftPerHr | ( | dDriftPerHr | ) |
Set drift / hour to MicroTime() clock to compenstate for drifting time.clock()
dDriftPerHr | - Expected drift per hour |
def pyRT.gatea.sys.GLcommon.SetLog | ( | fp, | |
cons = None |
|||
) |
Initialize Global Log File.
fp | - File from open() |
cons | - (Optional) wx Console |
def pyRT.gatea.sys.GLcommon.Str2HMS | ( | str | ) |
Break HH:MM:SS string into [ h, m, s ].
str | - HH:MM:SS |
def pyRT.gatea.sys.GLcommon.Str2Time | ( | str, | |
bGMT = False |
|||
) |
Convert string-ified YYYY-MM-DD HH:MM:SS.mmm to Unix Time.
This method handles the following conditions:
str | - YYYY-MM-DD HH:MM:SS.mmm or YYYYMMDD-HH:MM:SS.uuu |
bGMT | - True for GMT; False for localtime |
def pyRT.gatea.sys.GLcommon.Str2Time_OBSOLETE | ( | str, | |
bGMT = False |
|||
) |
def pyRT.gatea.sys.GLcommon.SubDict | ( | d1, | |
d2, | |||
bInclZero = True |
|||
) |
Subtract dict d2 from d1.
d1 | - Operand dict 1 |
d2 | - Operand dict 2 |
bInclZero | - Allow zero values; Default is True |
def pyRT.gatea.sys.GLcommon.Time | ( | t = 0.0 , |
|
bGMT = False |
|||
) |
Return string-ified time as HH:MM:SS.
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
def pyRT.gatea.sys.GLcommon.Time2Mark | ( | hr, | |
min, | |||
sec, | |||
bGMT = False |
|||
) |
Return millis to user-supplied HH:MM:SS.
This method handles rollover past Midnight, but requires user-supplied mark to be within 24 hours from current time
hr | - Hour mark |
min | - Minute mark |
sec | - Second mark |
bGMT | - True for GMT; False for localtime |
def pyRT.gatea.sys.GLcommon.TimeMs | ( | t = 0.0 , |
|
bGMT = False |
|||
) |
Return string-ified time as HH:MM:SS.mmm.
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
def pyRT.gatea.sys.GLcommon.TimeUs | ( | t = 0.0 , |
|
bGMT = False |
|||
) |
Return string-ified time as HH:MM:SS.uuuuuu.
t | - Unix Time; Use now if None (default) |
bGMT | - True for GMT; False (default) for localtime |
def pyRT.gatea.sys.GLcommon.tStart | ( | ) |
Returns ntp-anchroed time used for basis of MicroTime() clock.
tStart() also allows you to determine how long your application has been running. The following holds true:
def pyRT.gatea.sys.GLcommon.uDrift | ( | ) |
Returns current calculated drift in MicroTime() clock.
Drift is based on configurable SetDriftPerHr()
def pyRT.gatea.sys.GLcommon.uDriftPerSec | ( | ) |
Returns current calculated drift / sec from MicroTime() clock.
def pyRT.gatea.sys.GLcommon.WithinRange | ( | a, | |
b, | |||
c | |||
) |
Ensure b is in the closed interval between a and c inclusive.
a | - Lower Bound |
b | - Value to check |
c | - Upper Bound |
def pyRT.gatea.sys.GLcommon.Xdefaults | ( | pDflt | ) |
Parse .Xdefaults type config file.