Package ASAM :: Package HILAPI :: Package Concurrent :: Package MAPort :: Module MAPort :: Class MAPort

Class MAPort

                       object --+        
                                |        
Interfaces.Common.Port.Port.IPort --+    
                                    |    
     Interfaces.MAPort.MAPort.IMAPort --+
                                        |
                                       MAPort

Return an ASAM AE HIL Model Access Port to a running SimWB test.

Instance Methods
Capture
CreateCapture(self, task)
Returns a new capture task identified by name 'task'.
SignalGenerator
CreateSignalGenerator(self)
Returns a signal generator for a variable on this port.
 
CreateWatcher(self, watcher)
Create a generic watcher on this port.
 
DeleteCapture(self, task)
Delete the capture task identified by name 'task', or raise an exception.
 
GetCapture(self, task)
Return the capture task identified by name 'task', or raise an exception.
DataType
GetDataType(self, variableName)
Returns the ASAM enumerated data type (eINT, eFLOAT, etc) for 'variableName'.
bool
IsReadable(self, variableName)
Always True.
bool
IsWritable(self, variableName)
Always True.
BaseValue
Read(self, variableName)
Return the value of 'variableName'.
 
SetLoggingVariables(self, names, fresh=True)
Set the SimWB logger variable list to the variables in "names" (either a single name or a list of names).
 
StartSimulation(self)
Run the configured test on the target.
 
StopSimulation(self)
Stop the test.
 
Write(self, variableName, value)
Set the value of 'variableName' to 'value'.
 
__init__(self, configurationDict={})
Module import and object creation: from ASAM.HILAPI.Concurrent.MAPort import MAPort m = MAPort(configDict)
 
__repr__(self)
repr(x)
 
getCaptureOK(self)
When True, captures are possible on this MAPort.
 
getDAQClock(self)
Returns the data logging time interval in seconds.
 
getLock(self)
Get the lock to be shared accross multiple model access ports for serializing capture data extraction.
unicode[]
getTaskNames(self)
Returns a list of capture tasks.
 
getVariableAttributes(self)
Companion to getVariableNames.
unicode[]
getVariableNames(self)
Returns a list of all variable names for the running test (RTDB items, signals and parameters).
 
getVariableUnits(self)
Companion to getVariableNames.
 
setLock(self, lock)
Set the lock to be shared accross multiple model access ports for serializing capture data extraction.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties
  CaptureOK
  DAQClock
  Lock
  TaskNames
  VariableAttributes
  VariableNames
  VariableUnits

Inherited from object: __class__

Method Details

CreateCapture(self, task)

 

Returns a new capture task identified by name 'task'.
The resultant task name (see NOTE beolow) is available as attribute TaskName of
the returned capture object.

NOTES: 
    * Non-alphanumeric characters in 'task' are replaced with underscores.
    * Task names must be unique.

Returns: Capture
Overrides: Interfaces.MAPort.MAPort.IMAPort.CreateCapture

CreateSignalGenerator(self)

 

Returns a signal generator for a variable on this port.

Returns: SignalGenerator
Overrides: Interfaces.MAPort.MAPort.IMAPort.CreateSignalGenerator

CreateWatcher(self, watcher)

 

Create a generic watcher on this port. This is implemented as a capture task
without capture variables and without returning any data. It has only a single
watch condition (the passed "watcher") that is either a ConditionWatcher or
DurationWatcher. It will be used as the start trigger, with the stop trigger
being a DurationWatcher(0).

This can be very useful in terms of logic branching based on model behavior
(i.e. knowing that something has happened without capturing data).

The return is technically an active capture object, but the only things of
interest are state and whether or not the conditon was met or not. For example:
    map = MAPort(configDict)
    ...
    # watcher = a ConditionWatcher() or DurationWatcher()
    ...
    wat = map.CreateWatcher(watcher)
    ...
    while wat.State != EWatcherState.eFINISHED:
        time.sleep(0.1)
    ...
    if wat.StartByTimeout:
        print('watcher timed out!')

The EWatcherState enum is identical to the ECaptureState enum, but renamed
for clarity of use.

GetDataType(self, variableName)

 

Returns the ASAM enumerated data type (eINT, eFLOAT, etc) for 'variableName'.

Returns: DataType
Overrides: Interfaces.MAPort.MAPort.IMAPort.GetDataType

IsReadable(self, variableName)

 

Always True.

Returns: bool
Overrides: Interfaces.MAPort.MAPort.IMAPort.IsReadable

IsWritable(self, variableName)

 

Always True.

Returns: bool
Overrides: Interfaces.MAPort.MAPort.IMAPort.IsWritable

Read(self, variableName)

 

Return the value of 'variableName'.

WARNING: SimWB maintains both a current (cvt) and alternate (alt) value of a
         variable. This method will ALWAYS return the cvt value (which is the
         value seen by the model).

Returns: BaseValue
Overrides: Interfaces.MAPort.MAPort.IMAPort.Read

SetLoggingVariables(self, names, fresh=True)

 

Set the SimWB logger variable list to the variables in "names" (either a single name or a list of names). These should be names returned via the VariableNames property.

When "fresh" is True, any existing logging variables are removed prior to adding those in "names". When False, this call effectively appends the named variables to the logger list.

StartSimulation(self)

 

Run the configured test on the target.

This method waits until the target indicates the test is running.

NOTES:
    * This is part of the ASAM XIL-MA 2.1.0 extensions.

StopSimulation(self)

 

Stop the test.

This method waits until the target indicates the test is stopped.
Stopping a stopped test is okay.

NOTES:
    * This is part of the ASAM XIL-MA 2.1.0 extensions.

Write(self, variableName, value)

 

Set the value of 'variableName' to 'value'.

Overrides: Interfaces.MAPort.MAPort.IMAPort.Write

__init__(self, configurationDict={})
(Constructor)

 

Module import and object creation:
    from ASAM.HILAPI.Concurrent.MAPort import MAPort
    m = MAPort(configDict)

Where configDict = {'host':'<SimWB server>',
                    'username':'<SimWB username>',
                    'password':'<SimWB password>',
                    'project':'<SimWB project name>',
                    'test':'<SimWB running test>',
                    'session':'<SimWB running session name>',
                   }
    Optional keys in the cofigDict are:
        'cpu'    the CPU the ASAM task is to run on
        'debug'  a 0 or 1, where a 1 produces debug output

NOTES:
    * Variable name arguments should be one of those returned by getVariableNames().
    * All SimWB variable are both readable and writable.
    * This class has a print method.
    * Capture data extraction in SimWB must be serialized between multiple MAPorts.
      This is done by the calling script creating a thread lock object and setting
      the Lock property to that object for ALL created MAPorts:
            import thread
            lock = thread.allocate_lock()
            map1 = MAPort(configDict)
            map1.Lock = lock
            map2 = MAPort(configDict2)
            map2.Lock = lock

Overrides: object.__init__

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

getCaptureOK(self)

 

When True, captures are possible on this MAPort. False responses are most likely because the session does not have logging enabled.

getDAQClock(self)

 

Returns the data logging time interval in seconds.

NOTES:
    * This is part of the ASAM XIL-MA 2.1.0 extensions.

getTaskNames(self)

 

Returns a list of capture tasks.

Returns: unicode[]
Overrides: Interfaces.MAPort.MAPort.IMAPort.getTaskNames

getVariableAttributes(self)

 

Companion to getVariableNames. See getVariableNames for details.

getVariableNames(self)

 

Returns a list of all variable names for the running test (RTDB items, signals
and parameters).

In addition, create two additional dictionaries with information about the
variables. The keys are the variable names returned by this method. These are:
Attributes
    a string like "r", "rw", "rwc", where "r" is readable, "w" is writable, and "c"
    is capturable. If a variable is "w" is is also "r". Variables that are "r" but
    not "w" can be considered "measurements". Variables that are "w" can be
    considered "parameters".
    (available via getVariableAttributes() or VariableAttribues property)
Units
    a string with a units name (e.g. "km", "sec", "gallons/minute", etc.). Undefined
    units will be an empty string.
    (available via getVariableUnits() or VariableUnits property)

Returns: unicode[]
Overrides: Interfaces.MAPort.MAPort.IMAPort.getVariableNames

getVariableUnits(self)

 

Companion to getVariableNames. See getVariableNames for details.


Property Details

CaptureOK

Get Method:
getCaptureOK(self) - When True, captures are possible on this MAPort.

DAQClock

Get Method:
getDAQClock(self) - Returns the data logging time interval in seconds.

Lock

Get Method:
getLock(self) - Get the lock to be shared accross multiple model access ports for serializing capture data extraction.
Set Method:
setLock(self, lock) - Set the lock to be shared accross multiple model access ports for serializing capture data extraction.

TaskNames

Get Method:
getTaskNames(self) - Returns a list of capture tasks.

VariableAttributes

Get Method:
getVariableAttributes(self) - Companion to getVariableNames.

VariableNames

Get Method:
getVariableNames(self) - Returns a list of all variable names for the running test (RTDB items, signals and parameters).

VariableUnits

Get Method:
getVariableUnits(self) - Companion to getVariableNames.