Trees | Indices | Help |
|
---|
|
SIMulation Workbench PYToolkit Data Logger Client API This module provides an interface into the SIMulation Workbench (SimWB) data logging facility. With it, you can query logged results and extract logged data. All procedure documentation is avialable via the standard python techniques, i.e. pydoc and help(). Sample usage: import simwbPath import simwbDLClient as dl import sys import time # Connect to the logging host (this may or may not be the realtime host) r = dl.dlConnect('wyatt') if r != 0: sys.exit(dl.strerror(r)) # Select a project r = dl.dlSetProject('<default>') if r != 0: sys.exit(dl.strerror(r)) # Select a test/session r = dl.dlSetSession('ASAMTest/Main') if r != 0: sys.exit(dl.strerror(r)) # Get the test info # NOTE: Times reported by dlQueryTest are seconds/microseconds r,info = dl.dlQueryTest() if r != 0: sys.exit(dl.strerror(r)) print 'lastFrame',info[0] print 'frameLength',info[1],'us' print 'startT %s' % time.asctime(time.localtime(float(info[2])+float(info[3])/1000000.)) print 'stopT %s' % time.asctime(time.localtime(float(info[4])+float(info[5])/1000000.)) # Get the recorded variable info r,d = dl.dlGetMetaTable() if r < 0: sys.exit(dl.strerror(r)) print 'recorded %d vars' % r k = d.keys() for i in k: print '%r: %r' % (i,d[i]) # This is the callback function used by dlGetRecords. It is called for each sample. # My routine will bias the time so that it always starts from zero. I'll just # print them out. t0 = None def cb(recNum, tSec, tNSec, cvtVal, altVal, rawVal, dlF, rtF): global t0 # NOTE: times reported by dlGetRecords are seconds/nanoseconds t = float(tSec)+float(tNSec)/1000000000. if not t0: t0 = t print >>sys.stderr, '%.6f %f %f %f' % (t-t0, cvtVal[0], cvtVal[1], cvtVal[2]) # Get 50 samples of variable 'everything' (a 3x1 array) starting with sample 4518. # NOTE: To get all available data use dl.dlGetRecords('everything', 0, dl.dlAllSamples, cb) r = dl.dlGetRecords('everything', 4518, 50, cb) if r != 0: sys.exit(dl.strerror(r)) There is a companion module, simwbConstants, that is used to define internal SimWB constant values. This module is automatically imported by simwbDLClient, and is unlikely to be explicitely useful to the user. There is one global boolean variable in the module: dlIsConnected True if connect, False if not. Other global variables should not be modified, and are intended as constants to be used with dlGetRecords(). Their values may change in future releases. Copyright (c) Concurrent Real-Time
Classes | |
DLTime Data Logger client data record time class. |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Function Details |
Connect to the data logger file server running on the host system given by 'hostName', the name or IP address of the data log server. This may or may not be the same as the SimWB realtime host. Returns an integer success status. When already connected this funtion simply returns 0. The return code has the following meaning: 0 : success. != 0 : error (see simwbDLClient.strerror(code)). |
Disconnect from the log server. This routine always succeeds. |
When project or session are unspecified, whatever had been previously set via dlSetProject() and dlSetSession() are used. Returns a tuple of (reply,metaData) for the session as set by the dlSetSession() call. The metaData is a dictionary of variable names, with values being a dictionary keyed as: 'index' int 'pointType' int 'numElements' int 'dimensions' 3-tuple of int The reply code has the following meaning: >= 0 : success (equal to number of variables). < 0 : error (see simwbDLClient.strerror(code)). |
When project or session are unspecified, whatever had been previously set via dlSetProject() and dlSetSession() are used. If either of these routines have not been called, then the corresponding keyword argument must be specified, or the routine will return an error. Fetch nSamples of the log data for 'what', starting with startFrame. When 'what' is a string it is assumed to be the variable name. Otherwise it should be an int representing the index of the variable (which you can get from the meta info). If nSamples is dlAllSamples then get all available data after the start frame. The callback is a user-supplied subroutine that will be invoked with the data corresponding to each data record requested. It should be declared as: callback(recNum, tSec, tUSec, cvtVal, altVal, rawVal, dlF, rtF, **ckwargs) with arguments: recNum int record number [startFrame, startFrame+nSampels-1] tSec int \_ sample time (C timespec: seconds and nanoseconds tNSec int / since the EPOCH, 1/1/1970 00:00:00 UTC) cvtVal list RTDB CVT value(s) (double) altVal list RTDB alternate value(s) (double) rawVal list RTDB raw value(s) (double) dlF int data logger flag (char(dlF) = '*', 'p' or ' ') rtF int realtime flags ckwargs dict optional keyword arguments to be passed to callback The 'options' available at this time are: dlCvtOnly This modifies the callback declaration as follows: callback(tSec, tNSec, cvtVal, **ckwargs) with arguments defined as above. NOTE: If you request more records then have been recorded past the start record you will only get the available data - no error is reported. It is up to the user to keep track of how many samples have been passed to the callback. cvtVal, altVal and rawVal are ALWAYS passed to the callback as a list, even if they are scalar values. It is more efficient to have previously set a project and session. This method needs information from those calls and will fetch it if it can, thus increasing the time overhead for the first call to this routine. Subsequent calls will then be faster if the project and session do not change. For backwards compatibility when nSamples <= 0 then all available data is returned. This behavior may change in the future. Returns an int with the following meaning: 0 : success (equal to number of variables). != 0 : error (see simwbDLClient.strerror(code)). |
When project or session are unspecified, whatever had been previously set via dlSetProject() and dlSetSession() are used. Returns a tuple of (reply,info) for the session as set by the dlSetSession() call. The info is a 6-tuple: [0] lastFrame int [1] frameLength int microseconds [2] startTimeSec int [3] startTimeUSec int [4] stopTimeSec int [5] stopTimeUSec int The reply code has the following meaning: 0 : success. < 0 : error (see simwbDLClient.strerror(code)). |
Select the project from whose tests data my be extracted. * NOTE subprojects are delimited with a '/' character. E.g. to slect the pre-installed Hardware-Tests AO16 project use the name 'Hardware-Tests/AO16'. Return: The reply code from the log server. The return code has the following meaning: 0 : success. < 0 : error (see simwbDLClient.strerror(code)). |
Select the Test/Session from which data my be extracted. Return: The reply code from the log server. The return code has the following meaning: 0 : success. < 0 : error (see simwbDLClient.strerror(code)). |
Trees | Indices | Help |
|
---|
(c) Concurrent Real-Time | http://www.concurrent-rt.com |