omnetpp.scave.analysis

This module allows reading, writing, creating and editing OMNeT++ Analysis (.anf) files, querying their contents, and running the charts scripts they contain. The main user of this module is opp_charttool.

Attributes

logger

Classes

DialogPage

Represents a dialog page in a Chart. Dialog pages have an ID, a label

Chart

Represents a chart in an Analysis. Charts have an ID, a name, a chart script

Folder

Represents a folder in an Analysis. Folders may contain charts and further folders.

Workspace

This is an abstraction of an IDE workspace, and makes it possible to map

Analysis

Represents an OMNeT++ Analysis, i.e. the contents of an anf file. Methods

Functions

load_anf_file(anf_file_name)

Reads the given anf file and returns its content as an Analysis object.

Module Contents

logger[source]
class DialogPage(id: str = None, label: str = '', content: str = '')[source]

Represents a dialog page in a Chart. Dialog pages have an ID, a label (which the IDE displays on the page’s tab in the Chart Properties dialog), and XSWT content (which describes the UI controls on the page).

id = None[source]
label = ''[source]
content = ''[source]
class Chart(id: str = None, name: str = '', type: str = 'MATPLOTLIB', template: str = None, icon: str = None, script: str = '', dialog_pages=list(), properties=dict(), created_with: str = None)[source]

Represents a chart in an Analysis. Charts have an ID, a name, a chart script (a Python script that mainly uses Pandas and the omnetpp.scave.* modules), dialog pages (which make up the contents of the Chart Properties dialog in the IDE), and properties (which are what the Chart Properties dialog in the IDE edits).

id = ''[source]
name = ''[source]
type = 'MATPLOTLIB'[source]
template = None[source]
icon = None[source]
script = ''[source]
dialog_pages[source]
properties[source]
created_with = None[source]
__repr__()[source]
class Folder(id: str = None, name: str = '', items=list())[source]

Represents a folder in an Analysis. Folders may contain charts and further folders.

id = ''[source]
name = ''[source]
items = [][source]
__iter__()[source]
__len__()[source]
__repr__()[source]
class Workspace(workspace_dir=None, project_locations=None)[source]

This is an abstraction of an IDE workspace, and makes it possible to map workspace paths to filesystem paths. This is necessary because the inputs in the Analysis are workspace paths. The class tolerates if workspace metadata (the .metadata subdirectory) is missing; then it looks for projects in directories adjacent to other known projects.

project_locations[source]
static find_workspace(dir=None)[source]

Utility function: Find the IDE workspace directory searching from the given directory (or the current dir if not given) upwards. The workspace directory of the Eclipse-based IDE can be recognized by having a .metadata subdir. If the workspace is not found, None is returned.

static find_enclosing_project_location(file=None)[source]

Utility function: Find the project directory searching from the given directory (or the current dir if not given) upwards. Project directories of the Eclipse-based IDE can be recognized by having a .project file in them.

get_project_name(project_dir)[source]

Returns the “real” name of the project from the .project (project description) file in the given project directory.

find_enclosing_project(file=None)[source]

Find the project name searching from the given directory (or the current dir if not given) upwards. Project directories of the Eclipse-based IDE can be recognized by having a .project file in them.

get_project_location(project_name)[source]

Returns the location of the given workspace project in the filesystem path.

get_referenced_projects(project_name)[source]

Returns a list of projects that are referenced by the given project.

get_all_referenced_projects(project_name, include_self=False)[source]

Returns a list of projects that are referenced by the given project, even transitively.

to_filesystem_path(wspath)[source]

Translate workspace paths to filesystem path.

__repr__()[source]
class Analysis(inputs=list(), items=list())[source]

Represents an OMNeT++ Analysis, i.e. the contents of an anf file. Methods allow reading/writing anf files, and running the charts in them for interactive display, image/data export or other side effects.

inputs = [][source]
root_folder[source]
static from_anf_file(anf_file_name)[source]

Reads the given anf file and returns its content as an Analysis object.

collect_charts(folder=None)[source]

Collects and returns a list of all charts in the specified folder, or in this Analysis if no folder is given.

get_item_path(item)[source]

Returns the path of the item (Chart or Folder) within the Analysis as list of path segments (Folder items). The returned list includes both the root folder of the Analysis and the item itself. If the item is not part of the Analysis, None is returned.

get_item_path_as_string(item, separator=' / ')[source]

Returns the path of the item (Chart or Folder) within the Analysis as a string. Segments are joined with the given separator. The returned string includes the item name itself, but not the root folder (i.e. for items in the root folder, the path string equals to the item name). If the item is not part of the Analysis, None is returned.

run_chart(chart, wd, workspace, extra_props=dict(), show=False, suppress_print=False)[source]

Runs a chart script with the given working directory, workspace, and extra properties in addition to the chart’s properties. If show=True, it calls plt.show() if it was not already called by the script.

export_image(chart, wd, workspace, format='svg', target_folder=None, filename=None, width=None, height=None, dpi=300, enforce=True, extra_props=dict(), suppress_print=False)[source]

Runs a chart script for image export. This method just calls run_chart() with extra properties that instruct the chart script to perform image export. (It is assumed that the chart script invokes utils.export_image_if_needed() or implements equivalent functionality).

export_data(chart, wd, workspace, format='csv', target_folder=None, filename=None, enforce=True, extra_props=dict(), suppress_print=False)[source]

Runs a chart script for data export. This method just calls run_chart() with extra properties that instruct the chart script to perform data export. (It is assumed that the chart script invokes utils.export_data_if_needed() or implements equivalent functionality).

to_anf_file(filename)[source]

Saves the analysis to the given .anf file.

load_anf_file(anf_file_name)[source]

Reads the given anf file and returns its content as an Analysis object. This is synonym for Analysis.from_anf_file().