Module simwbConnect

Module simwbConnect

SIMulation Workbench PYToolkit Connection Module.

This module is provided as a companion to the simwbClient module. When importing simwbClient into a program only one connection to a single system is allowed. This module gives you the ability to have multiple connections to different systems (or the same system) at the same time.

It is assumed that you are familiar with simwbClient and it's capabilities (see 'pydoc simwbClient' for more details, or the HTML documentation shipped with the PYToolkit (which is also available online in the Configuration GUI) for more details).

All simwbClient functions are available via the module.

Copyright (c) Concurrent Real-Time

Functions
 
simwbConnect(moduleName, target=None, envvar=None, host=None, login=None, errormsg=False)
Returns a simwbClient module that can be (or is) connected to a SimWB server.
Variables
  __package__ = None
Function Details

simwbConnect(moduleName, target=None, envvar=None, host=None, login=None, errormsg=False)

 

Returns a simwbClient module that can be (or is) connected to a SimWB
server. The actions and return value(s) depend on the arguments passed.

The 'moduleName' can be any string. It is simply assigned to
the module when created. You will see this name when you examine
the module.__name__.

If no other arguments are passed, then the module is unconnected
and it is up to the user to connect and login.

    import simwbPath
    from simwbConnect import simwbConnect
    module = simwbConnect('wyatt server')
    module.connect('wyatt')
    module.login('admin/nimda')

In this form just the module is returned.

First checked is 'target', a SimWB target XML file name.  In this
case the returned module will already be connected, logged in, and
have selected the project using the information found in the target file.

    import simwbPath
    from simwbConnect import simwbConnect
    (module,infodict) = simwbConnect('wyatt server', target='target.xml')

Returns a tuple of (module,infodict) where the dictionary is the
connection information (and is the same as that retuned by the
readXMLTarget() function).
On error the module is None and infodict is an integer error code.

Next checked is if 'envvar' is the name of a SimWB target environment
variable. In this case the returned module will be connected if the
host is defined, logged in if login info is defined, and the project
selected if project is defined.

    import simwbPath
    from simwbConnect import simwbConnect
    (module,infodict) = simwbConnect('wyatt server', envvar='SIMWB_TARGET')

Returns a tuple of (module,infodict) where the dictionary is the
connection information (and is the same as that retuned by the
getTarget() function).
On error the module is None and infodict is an integer error code.

When 'host' is specified but 'login' is not, the module will be
connected to that host.

    import simwbPath
    from simwbConnect import simwbConnect
    (module,ret) = simwbConnect('wyatt server', host='wyatt')
    module.login('admin/nimda')

Returns a tuple of (module,ret) where ret is an integer return
code from the connect() function.
On error the module is None and ret is an integer error code.

When both 'host' and 'login' are specified, the module will be
connected to that host and the sting in 'login' used to log in.

    import simwbPath
    from simwbConnect import simwbConnect
    (module,ret,priv,group) = simwbConnect('wyatt server', host='wyatt', login='admin/nimda')

Returns a tuple of (module,ret,priv,group) where ret is an integer
return code from the connect() and/or login() functions. The priv
and group will be the same as those returned by the login() function.
On error the module, priv and group are None and ret is an integer
error code.

NOTE:
    By default errors return an error code.  When errormsg is set
    to True, an error message is returned in place of the error
    code.