Package ASAM :: Package HILAPI :: Package Concurrent :: Package Common :: Package Utils :: Module Utils

Module Utils

Functions
 
getTestConfig(config)
Given a host target dictionary 'config' with the following keys: host username password project test session (see simwbClient.getTarget())
 
getTestVariable(name, config)
Given a complete test configuration in 'config' (see getTestConfig), determine if 'name' is an RTDB item, model parameter or model signal.
 
parseFISCConfig(lines)
Convert FISC config file lines into usable data structures.
 
strTestConfig(config, nShow=50, indent=' ')
Given a complete test configuration (see getTestConfig), return a string representation suitable for printing.
 
tag2dict(fname)
Given a tag file 'fname': tag1 var name 1 tag2 var name 2 ...
 
xml2varList(xmlFile, openErrFatal=True, ignoreFiles=[])
Scan the given XML file for variable names.
Variables
  PYTHON2 is True when running Python 2.x
  PYTHON3 is True when running Python 3.x
  PYTHON_VERSION is an integer 3-tuple of the running Python version
  __package__ = 'ASAM.HILAPI.Concurrent.Common.Utils'
Function Details

getTestConfig(config)

 

Given a host target dictionary 'config' with the following keys:
    host
    username
    password
    project
    test
    session
(see simwbClient.getTarget())

Validate that the 'test' has the given 'session', that the initial conditions
are '.default', that logging is enabled. It is recommended that direct I/O is
off, but not required.

Return a complete test configuration by adding the following keys to
the 'config' dictionary:
    priv
    group
    rtdb
      [ rtdb1, rtdb2, ... ]
    items
      { name1:{ pointtype:P1, cvttype:T1, ..., DataType:E1 },
        name2:{ pointtype:P2, cvttype:T2, ..., DataType:E2 },
        ...
      }
    modelslist
      [ model1, model2, ... ]
    models
      { model1:
            { PARM:{ p1:{ cvttype:T1, dimensions:D1, DataType:E1 },
                     p2:{ cvttype:T2, dimensions:D2, DataType:E2 },
                     ...
                   }
              MDLSIGNAL:{ s1:{ cvttype:T1, dimensions:D1, DataType:E1 },
                          s2:{ cvttype:T2, dimensions:D2, DataType:E2 },
                          ...
                        }
            },
        model2:
            { PARM:{ p1:{ cvttype:T1, dimensions:D1, DataType:E1 },
                     p2:{ cvttype:T2, dimensions:D2, DataType:E2 },
                     ...
                   }
              MDLSIGNAL:{ s1:{ cvttype:T1, dimensions:D1, DataType:E1 },
                          s2:{ cvttype:T2, dimensions:D2, DataType:E2 },
                          ...
                        }
            },
        ...
      }
NOTE: 'DataType' is the ASAM data type.

getTestVariable(name, config)

 

Given a complete test configuration in 'config' (see getTestConfig),
determine if 'name' is an RTDB item, model parameter or model signal.
If so, return a list of tuples, where each tuple contains:
    ( SimWBName,
        { metaflags:X, loggingperiod:0, pointtype:P, numelements:N, cvttype:C, DataType:d }
    )

NOTE:
  The metaflags will be modified to turn on the METAFL_ARCHIVE bit.
  These tuple contents are suitable for use in the platform interest list.
  This is a list since there may be more than one instance of a name.

parseFISCConfig(lines)

 

Convert FISC config file lines into usable data structures.

Everything is case insensitive (and internally stored in lower case) EXCEPT
signal names in the "Define Signal" lines. Their case is retained.

(sigs,faults) = parseFISCConfig(lines)

Define Fault  400    1.5.A             SA_GND_FAULT
Define Fault  681    1.17.C            SA_PWR_FAULT
Define Fault  823    1.17.D            SA_C2C_FAULT
Addto  Fault  823    1.2.E             SA_OPEN_FAULT
Define Signal 1.5.A  pgt_HS
Define Signal 1.17.C mvs0_HS
Define Signal 1.17.D mvs0_LS

         |  |
         |  |
        \|  |/
         \  /
          \/
(
    {'1.5.a':'pgt_HS',
     '1.17.c':'mvs0_HS',
     '1.17.d':'mvs0_LS'
    },
    {400:{'line':['1.5.a'], 'fault':['sa_gnd_fault']},
     681:{'line':['1.17.c'], 'fault':['sa_pwr_fault'}],
     823:{'line':['1.17.d', '1.2.e'], 'fault':['sa_c2c_fault', 'sa_open_fault'}]
    }
)

tag2dict(fname)

 

Given a tag file 'fname':
    tag1    var name 1
    tag2    var name 2
    ...
Return a dictionary of tag names versus variable names.

xml2varList(xmlFile, openErrFatal=True, ignoreFiles=[])

 

Scan the given XML file for variable names. A variable name will be
tagged as one of (case ignored):
    <varnames?>(.*)</varnames?>
    <variablenames?>(.*)</variablenames?>
    <path>(.*)</path>
    <capturevariable>(.*)</capturevariable>
    <capturevariable name="([^"]*)".*/>
    <calnames?>(.*)</calnames?>
Returns the variable names found in a list.

Also scan for additional XML files to scan for variables. A file name
will be tagged as one of (case ignored):
    <.*filename>(.*xml)</.*filename>
    <.*file>(.*xml)</.*file>
    <.*filename>(.*gtx)</.*filename>
    <.*file>(.*gtx)</.*file>
    <.*filename>(.*pjt)</.*filename>
    <.*file>(.*pjt)</.*file>

There is no file depth limit.
Scanned files are remembered for efficiency and to avoid infinite loops.
File open errors can be fatal or not.