Documentation Home Page HYPERSIM Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

ScopeViewApi Commands

General

close():

ScopeViewApiGRPC.close()

Close ScopeView

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

Examples:

  • ScopeView.close()

connectToScopeViewRemote(id=None):

ScopeViewApiGRPC.connectToScopeViewRemote(id=None)

Connect to the first instance of ScopeView

:param id : The unique identifier for the remote ScopeView :type id: int :return: error value :rtype: int :raises AssertionError: raises exception on error

disableScopeViewApiExceptions():

ScopeViewApiGRPC.disableScopeViewApiExceptions()

Disable ScopeViewApi from returning ScopeView exceptions through Python

enableScopeViewApiExceptions():

ScopeViewApiGRPC.enableScopeViewApiExceptions()

Enable ScopeViewApi to return ScopeView exceptions through Python

openScopeView():

ScopeViewApiGRPC.openScopeView()

Open ScopeView

Returns:

process ID

Return type:

int

When using HYPERSIM, or when forceUseHypersimDir is set to True with setEnv(), the ScopeView location is relative to the HYPERSIM_DIR variable. Otherwise, the ScopeView location is relative to the Scopeview API location.

Acquisition

evalAllExpressions():

ScopeViewApiGRPC.evalAllExpressions()

Evaluate all ScopeView expressions from template

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

exportToFile(file_name):

ScopeViewApiGRPC.exportToFile(file_name)

Export ScopeView data source to desired format at provided file location

Parameters:

file_name (str) – path to export file

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

exportToPDF(file_name):

ScopeViewApiGRPC.exportToPDF(file_name)

Export ScopeView graphs to PDF at provided file location

Parameters:

file_name (str) – path to export PDF

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

getCont():

ScopeViewApiGRPC.getCont()

Get ScopeView cont state

Returns:

cont state

Return type:

str

getExpressions():

ScopeViewApiGRPC.getExpressions()

Gets all ScopeView expressions from template

Returns:

a list of ScopeView expressions

Return type:

list[str]

getNumAcq():

ScopeViewApiGRPC.getNumAcq()

Get number of ScopeView acquisitions

Returns:

number of acquisitions

Return type:

str

getNumData():

ScopeViewApiGRPC.getNumData()

Get number of ScopeView data

Returns:

number of data

Return type:

str

getSamplingRate():

ScopeViewApiGRPC.getSamplingRate()

Get ScopeView acquisition sample rate

Returns:

sample rate

Return type:

str

getStartTime():

ScopeViewApiGRPC.getStartTime()

Get ScopeView acquisition start time

Returns:

start time

Return type:

str

getTimeLength():

ScopeViewApiGRPC.getTimeLength()

Get ScopeView acquisition duration

Returns:

time length

Return type:

str

pauseAcquisition():

ScopeViewApiGRPC.pauseAcquisition()

Pause ScopeView acquisition

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setCont(value):

ScopeViewApiGRPC.setCont(value)

Set ScopeView cont option

Parameters:

value (bool) – cont state

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setNumAcq(value):

ScopeViewApiGRPC.setNumAcq(value)

Set number of ScopeView acquisitions

Parameters:

value (int) – number of acquisition

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setSamplingRate(value):

ScopeViewApiGRPC.setSamplingRate(value)

Set ScopeView acquisition sample rate

Parameters:

value (float) – acquisition sample rate (seconds)

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setStartTime(value):

ScopeViewApiGRPC.setStartTime(value)

Set ScopeView acquisition start time

Parameters:

value (float) – time to start acquisition (seconds)

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setSync(value):

ScopeViewApiGRPC.setSync(value)

Set ScopeView sync option

Parameters:

value (bool) – sync state

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setTimeLength(value):

ScopeViewApiGRPC.setTimeLength(value)

Set ScopeView acquisition duration

Parameters:

value (float) – acquisition duration (seconds)

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

setTrig(value):

ScopeViewApiGRPC.setTrig(value)

Set ScopeView trig option

Parameters:

value (bool) – trig state

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

startAcquisition():

ScopeViewApiGRPC.startAcquisition()

Start ScopeView acquisition

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

stopAcquisition():

ScopeViewApiGRPC.stopAcquisition()

Stop ScopeView acquisition

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

Comtrade

calculateComtradeSignalDelay(files, signal_pairs=None):

ScopeViewApiGRPC.calculateComtradeSignalDelay(files, signal_pairs=None)

calculateComtradeSignalDelay method returns a map of the comtrade file names with a delay calculated in seconds. The delay is calculated by having a default file (the first value in the files array), compared to the other files. To calculate a delay, a match needs to be made between a signal from the default file, and a signal from the rest of the list. The method tries to make a match by checking which signal names have words in common, but if no similarities are made, an error will be given.

Manual signal matching can be made, by passing a list of tuple (pairs) of strings that represents signal names. This list will contain a signal name from the default file and one from the other signal, the order of those pairs needs to be the same as the order of the filenames passed.

Parameters:
  • files (list[tuple(str, str)]) – A list of file names or paths of the COMTRADE files used to calculate delays. The first element of this array is chosen as the default comtrade and will be compared to the others. This means that all other comtrades are delayed compared to the default.

  • signal_pairs – A list of tuples (pairs) representing signal names. The left part of this pair (index 0) is always a signal name from the default comtrade file (first file in the files parameter).

Returns:

A map containing the delay value for each filename. The first element will always be 0 as it is the default comtrade file.

Return type:

Dict[str, float]

Raises:

OSError – If any of the input files cannot be found in the current directory.

import ScopeViewApiGRPC as scopeview

scopeview.connectToScopeViewRemote()

files = [
    "L35460NT120L16UPC_A/20221114_173712506.cfg",
    "L35460NT120L16UPC_B/20221114_173712489.cfg",
]

# Automatic signal name matching
result = scopeview.calculateComtradeSignalDelay(files)

signal_pairs = [
    ("E_AN_L1421", "5 E_AN_L1421")
]

# Manual signal name matching
# The signal_pairs needs to have the default comtrade signal always on the left (value 0 of each tuples)
# The default comtrade file is always the first file in the files array (20221114_173712506.cfg in this example)
# An error will be returned if a non-existent signal name is used
result2 = scopeview.calculateComtradeSignalDelay(files, signal_pairs)
scopeview.calc
files = [
    "L35460NT120L16UPC_A/20221114_173712506.cfg",
    "L35460NT120L16UPC_B/20221114_173712489.cfg",
]

combineComtrade(inputs, output_file, parameters=None, selected_signals: Dict[str, List[str]] = None):

ScopeViewApiGRPC.combineComtrade(inputs, output_file, parameters=None, selected_signals: Dict[str, List[str]] = None)

combineComtrade method combines multiple COMTRADE files into a single output file.

Parameters:
  • inputs (list) – A list of file names or paths of the COMTRADE files to be combined

  • output_file (str) – The name or path of the output file

  • parameters (Dict[str, any]) – Optional parameters to combine comtrade files. See getCombineComtradeParameters to create the dict

  • selected_signals – A map representing the signal names for each comtrade files that will be added to the output

of the combined files. Other signals will be discarded :type selected_signals: Dict[str, List[str]] :raises OSError: If any of the input files cannot be found in the current directory.

scopeview.connectToScopeViewRemote()

files = [
    "L35460NT120L16UPC_A/20221114_173712506.cfg",
    "L35460NT120L16UPC_B/20221114_173712489.cfg",
]

parameters = scopeview.getCombineComtradeParameters(files)

# Modify the given parameters
parameters["interpolationMethod"] = "Spline"
parameters["unitConfig"][1] = "V"
parameters["sampleRate"] = 4000

# Combine the comtrade files with a custom parameters dictionary
scopeview.combineComtrade(
    files,
    "combined.cfg",
    parameters,
    None
)

Examples:

  • combineComtrade([“file1.cfg”, “file2.cfg”], “output.CFG”)

convertComtradeRevisionYear(filepath, version, new_filepath=None):

ScopeViewApiGRPC.convertComtradeRevisionYear(filepath, version, new_filepath=None)

convertComtradeRevisionYearRequest takes the filepath of a comtrade file and it’s desired revision year. The method then converts the file and overwrites it at the same filepath given. If no newFilepath is given, the method will override the given filepath to its converted format.

Parameters:
  • filepath (str) – The filepath of the comtrade file.

  • version (int) – The desired COMTRADE version (1991, 1997, 2013, etc.).

  • newFilepath (str) – The desired location to write the converted comtrade file. This filepath needs to be absolute and is optional.

Raises:

OSError – If the input file cannot be found in the current directory.

Examples:
>>> convertComtradeVersion("file1.cfg", 2013)

findSynchronizableComtradeSignalPairs(files):

ScopeViewApiGRPC.findSynchronizableComtradeSignalPairs(files)

findSynchronizableComtradeSignalPairs method parses the list of COMTRADE files and returns a list of pair of signals. The first file in the files array passed to the method is chosen as the default file for synchronization. Each pair that is returned has the list of default signals on the left and the list of synchronizable signals on the right. The user then has to choose only 1 signal per pair to make a synchronization.

Parameters:

files (list[str]) – A list of file names or paths of the COMTRADE files to be parsed into pairs. The first file in the array is the default file. Minimum length of 2.

Returns:

The list of pairs containing the multiple signal names to choose from.

Return type:

list[tuple[list[str], list[str]]]

Raises:

OSError – If any of the input files cannot be found in the current directory.

Examples:
>>> synchronizationPairs = scopeview.findSynchronizableComtradeSignalPairs(["file1.cfg", "file2.cfg"])

getCombineComtradeParameters(files=None) :

ScopeViewApiGRPC.getCombineComtradeParameters(files=None)

getCombineComtradeParameters returns a dictionnary of properties used to combine comtrade files. There is an optional list of comtrade files parameter that can be passed and the method will try to return a parameter dictionnary that is configured with those COMTRADE files.

Parameters:

files (list) – A list of file names or paths of the COMTRADE files to be combined

Returns:

A dictionnary containing the parameters used to combine comtrade files

Return type:

Dict[str, any]

Raises:

OSError – If any of the files cannot be found in the current directory.

Examples:
>>> getCombineComtradeParameters(["file1.cfg", "file2.cfg"])

getComtradeSignals(files) :

ScopeViewApiGRPC.getComtradeSignals(files)

getComtradeSignals returns a map of list of strings that represents the signals inside the given comtrade files. Each comtrade file has a list of signals. This is because comtrade files can have the same signals name, so a map is used to differenciate the signal names from those files. This can then be used to combine comtrade files and only write the requested signals to the combined file.

Parameters:

files (list) – A list of file names or paths of the COMTRADE files to be combined

Returns:

A map of list of strings containing the signals for each comtrade file

Return type:

Dict[str, list[str]]

Raises:

OSError – If any of the files cannot be found in the current directory.

Examples:
>>> getComtradeSignals(["file1.cfg", "file2.cfg"])

Data Source

loadDataSource(uri):

ScopeViewApiGRPC.loadDataSource(uri)

Load data source from provided source

Parameters:

uri (str) – data source location

Returns:

datasource name

Return type:

string

Raises:

AssertionError – raises exception on error

loadFileDataSource(file_name):

ScopeViewApiGRPC.loadFileDataSource(file_name)

Load ScopeView data source

Parameters:

file_name (str) – path to data source location

Returns:

datasource name

Return type:

string

Raises:

AssertionError – raises exception on error

reloadAllDataSources():

ScopeViewApiGRPC.reloadAllDataSources()

Reload all ScopeView data sources

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

removeAllDataSources():

ScopeViewApiGRPC.removeAllDataSources()

Remove all ScopeView data sources

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

replaceDataSource(oldDataSourceLabel, newDataSourceLocation):

ScopeViewApiGRPC.replaceDataSource(oldDataSourceLabel, newDataSourceLocation)

Replace ScopeView data source with provided source

Parameters:
  • oldDataSourceLabel (str) – ScopeView data source label

  • newDataSourceLocation (str) – data source location

Returns:

datasource name

Return type:

string

Raises:

AssertionError – raises exception on error

setDataSourceParameter(dataSourceLabel, parameter, value):

ScopeViewApiGRPC.setDataSourceParameter(dataSourceLabel, parameter, value)

Set an acquisition parameter for a custom data source which uses additional parameters

Parameters:
  • dataSourceLabel (str) – The data source label. It should contain the brackets

  • parameter (str) – The string parameter ID. The parameters are defined in the description of the relevant data sources.

  • value (str) – value

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

Examples:

  • HyWorksApi.ScopeView.setDataSourceParameter(‘[REC1]’, ‘timeLength’, ‘0.4’)

  • HyWorksApi.ScopeView.setDataSourceParameter(‘[OPA1]’, ‘triggerFunction’, ‘Level’)

Template

addExpression(expression):

ScopeViewApiGRPC.addExpression(expression)

Add ScopeView expression :param expression: :return:

addTemplateFunction(function, signals, page, visible):

ScopeViewApiGRPC.addTemplateFunction(function, signals, page, visible)

Add function to the current template :param function: function string :type function: str :param signals: list of signals :type signals: list[str] :param page: page number :type page: int :param visible: visibility :type visible: bool :return: error value :rtype: int

addTemplateSignals(signals, page, visible):

ScopeViewApiGRPC.addTemplateSignals(signals, page, visible)

Add expressions to the current template :param signals: :type signals: list[str] :param page: :type page: int :param visible: :type visible: bool :return:

executeTemplate(file_name):

ScopeViewApiGRPC.executeTemplate(file_name)

Execute ScopeView template

Parameters:

file_name (str) – path to template location

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

getSignal(signal_name, data_source_label):

ScopeViewApiGRPC.getSignal(signal_name, data_source_label)

Get a ScopeView signal name

Parameters:
  • signal_name (str) – signal name

  • data_source_label (str) – data source label

Returns:

signal

Return type:

Signal{signal_name, data_source_label}

Raises:

AssertionError – raises exception on error

getTemplateDataSources():

ScopeViewApiGRPC.getTemplateDataSources()

Get all ScopeView data sources of the current template

Returns:

a list of data sources

Return type:

list[str]

importTemplate(file_name, appendNewPage):

ScopeViewApiGRPC.importTemplate(file_name, appendNewPage)

Import template to ScopeView

Parameters:
  • file_name (str) – path to template location

  • appendNewPage (bool) – append template to new page

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

loadTemplate(file_name):

ScopeViewApiGRPC.loadTemplate(file_name)

Load template to ScopeView

Parameters:

file_name (str) – path to template location

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

newTemplate():

ScopeViewApiGRPC.newTemplate()

Create new ScopeView template

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

removeAllPages():

ScopeViewApiGRPC.removeAllPages()

Removes all pages from ScopeView template

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

removeTemplateFunction(function, page, visible):

ScopeViewApiGRPC.removeTemplateFunction(function, page, visible)

Remove function from the current template :param function: :type function: str :param page: :type page: int :param visible: :type visible: bool :return: error value :rtype: int

removeTemplateSignals(signals, page, visible):

ScopeViewApiGRPC.removeTemplateSignals(signals, page, visible)

Remove signals from the current template

Parameters:
  • signals (list[str]) – list of signals

  • page (int) – page number

  • visible (bool) – visibility

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

saveTemplate(file_name):

ScopeViewApiGRPC.saveTemplate(file_name)

Save ScopeView template

Parameters:

file_name (str) – path to template location

Returns:

error value

Return type:

int

Raises:

AssertionError – raises exception on error

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter