hynet.visual.capability package

Submodules

hynet.visual.capability.settings module

Settings view to edit parameters in the capability region visualizer.

class hynet.visual.capability.settings.DescriptiveEntry(master=None, name='Label', alignment='horizontal', value=0.0)[source]

Bases: tkinter.ttk.Frame

Container that bundles a label with an input field.

VALIDATION_REGEX = re.compile('^[+-]?([0-9]*[.])?[0-9]+$')
error_state(old_value=None)[source]

Set the foreground to red and return the callback to undo this change.

Parameters:old_value (float) – If this value is set, then the value of the input component is set to this value when this callback is called.
Returns:Callback to undo this change (set the foreground back to black).
Return type:function
get_value()[source]

Return the current value of the field.

Returns:
Return type:float
reset_to_normal_state(old_value=None)[source]

Reset the element to the normal state (black font on white background).

Parameters:old_value (float) – If this value is set, then the value of the input component is set to this value when this callback is called.
set_callback(callback)[source]

Set a callback that listens for value changes.

Parameters:callback (function) – The function that should be called when a value has changed.
set_value(value)[source]

Set the value for the field.

Parameters:value (float or str) –
class hynet.visual.capability.settings.PowerFactorView(master=None)[source]

Bases: tkinter.ttk.Frame

View for setting the power factor limit.

set_callback(callback_function)[source]

Set the callback for updating the power factor limit.

Parameters:callback_function (function) – Function that takes the power factor as an argument and updates the capability region.
class hynet.visual.capability.settings.SettingsView(master=None, cap_region=[0.0,0.0]x[0.0,0.0])[source]

Bases: tkinter.ttk.Frame

Settings view to edit parameters in the capability region visualizer.

deactivate_all_halfspaces()[source]

Deactivate all checkboxes and, therewith, remove all half-spaces.

setup_halfspace_callbacks(update_view_callback)[source]

Set the callback that updates the view with changes of the half-spaces.

Parameters:update_view_callback (function) – This function is called when the checkbox is (de)activated and should update/reload the view of the capability region.
update_from_capability_region()[source]

Update the views with the (possibly) changed capability region.

class hynet.visual.capability.settings.ValueView(master=None, name='Unnamed ValueView', right_value_name='Slope:', left_value_name='Offset:', initial_value_tuple=(0, 0), checkbox_state=None)[source]

Bases: tkinter.ttk.Frame

Container view for two descriptive entries.

Furthermore, the value view handles the update of the associated half-space (if provided) as well as the error and update callbacks.

callback = None
update_from_capability_region(halfspace)[source]

Updates this view based on the provided half-space specification.

Parameters:halfspace (HalfSpace) – The half-space associated with this value view.

hynet.visual.capability.utilities module

This module contains various classes to provide interchangable data types between the view classes

class hynet.visual.capability.utilities.AutoValue[source]

Bases: enum.Enum

This class provides a base class for enum that have a predefined, readable string representation.

class hynet.visual.capability.utilities.Axis[source]

Bases: hynet.visual.capability.utilities.AutoValue

This enum represents the two axes.

ACTIVE_POWER = 1
REACTIVE_POWER = 2
class hynet.visual.capability.utilities.Bound[source]

Bases: hynet.visual.capability.utilities.AutoValue

This enum represents the two bounds of the reactive and active limits of a capability region.

MAX = 2
MIN = 1
class hynet.visual.capability.utilities.LinearFunction(halfspace, limits)[source]

Bases: object

Helper class to simplify the handling of the PWLs

f(p)[source]
This function computes the PWL function for the input value p.
Parameters:p (float) – The active power value for this linear function
Returns:$ ext{self.slope}*p + ext{self.t}$
Return type:The result of the linear curve equation for the input value
f_1(q)[source]

This function computes the inverse PWL function for the input value q.

Parameters:q (float) – The reactive power value for this linear function.
Returns:$ (q - ext{self.t}) / ext{self.slope}$
Return type:The result of the linear curve equation for the input value
intersect_with(other)[source]

This function computes the intersection of this LinearFunction with the LinearFunction other.

Parameters:other (LinearFunction) – The other LinearFunction we want to compute the intersection with.
Returns:
  • Either None or a Point that represents the intersection of the two
  • instances of LinearFunction
class hynet.visual.capability.utilities.Orientation[source]

Bases: hynet.visual.capability.utilities.AutoValue

This enum represents the four possibilities for halfspaces. These should only appear in pairs of two: {RIGHT, LEFT} x {TOP, BOTTOM}.

BOTTOM = 4
LEFT = 2
RIGHT = 1
TOP = 3
class hynet.visual.capability.utilities.Point[source]

Bases: hynet.visual.capability.utilities.Point

Representation of a point in the P/Q-plane

hynet.visual.capability.visualizer module

Visualization of a capability region.

class hynet.visual.capability.visualizer.Window(master=None, capability_region=[0.0,0.0]x[0.0,0.0], edit=True)[source]

Bases: tkinter.ttk.Frame

This class creates a window that visualizes a capability region.

CAPABILITY_REGION_COLOR = '#BBBBBB'
HALFSPACES_COLOR = '#777777'
POLYGON_EDGE_COLOR = '#777777'
POLYGON_FILL_COLOR = '#BAEBAC'
SCALING_FACTOR = 1
static compute_polygon_vertices(cap_region)[source]

Compute the vertices of the capability region polygon.

This function computes the intersections of the four lines that delimit the capability region. The algorithm starts with the left-top half space and continues clock-wise with the other half-spaces.

The algorithm assumes that p_max != p_min and q_max != q_min. Furthermore, the assumptions on the slopes and offsets must be satisfied as well. If the preconditions are met, the function returns a list of all vertices that specify the polygon, in a clock-wise ordering.

Parameters:cap_region (CapRegion) – The capability region that shall be drawn.
Returns:List of polygon vertices.
Return type:list[tuple(p,q)]
display_operating_point(point)[source]

Display an operating point in the P/Q-plane of the capability region.

Parameters:point (tuple(p,q)) – This tuple represents the operating point as a (p,q)-tuple of floats.
static show(capability_region, edit=True, operating_point=None)[source]

Create and show a capability region visualizer window.

Parameters:
  • capability_region (CapRegion) –
  • edit (bool, optional) – If True (default), editing of the specified capability region is enabled.
  • operating_point (tuple(p,q), optional) – If provided, this operating point is shown by a marker in the P/Q-plane.

Module contents