Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blackbox flag #446

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ansys/motorcad/core/motorcad_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(
keep_instance_open=False,
url="",
timeout=2,
use_blackbox_licence=False,
):
self.connection = _MotorCADConnection(
port,
Expand All @@ -52,6 +53,7 @@ def __init__(
keep_instance_open,
url=url,
timeout=timeout,
use_blackbox_licence=use_blackbox_licence,
)

_RpcMethodsCore.__init__(self, mc_connection=self.connection)
Expand All @@ -78,6 +80,9 @@ class MotorCAD(_MotorCADCore):
Whether to keep the Motor-CAD instance open after the instance becomes free.
url: string, default = ""
Full url for Motor-CAD connection. Assumes we are connecting to existing instance.
use_blackbox_licence: Boolean, default: False
Ask Motor-CAD to consume blackbox licence.

Returns
-------
MotorCAD object.
Expand All @@ -92,6 +97,7 @@ def __init__(
reuse_parallel_instances=False,
keep_instance_open=False,
url="",
use_blackbox_licence=False,
):
"""Initiate MotorCAD object."""
_MotorCADCore.__init__(
Expand All @@ -103,6 +109,7 @@ def __init__(
reuse_parallel_instances=reuse_parallel_instances,
keep_instance_open=keep_instance_open,
url=url,
use_blackbox_licence=use_blackbox_licence,
)


Expand Down
6 changes: 6 additions & 0 deletions src/ansys/motorcad/core/rpc_client_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def __init__(
url="",
timeout=2,
compatibility_mode=False,
use_blackbox_licence=False,
):
"""Create a MotorCAD object for communication.

Expand All @@ -204,6 +205,8 @@ def __init__(
Whether to try to run an old script written for ActiveX.
url: string, default = ""
Full url for Motor-CAD connection. Assumes we are connecting to existing instance.
use_blackbox_licence: Boolean, default: False
Ask Motor-CAD to consume blackbox licence.

Returns
-------
Expand Down Expand Up @@ -231,6 +234,9 @@ def __init__(
self._url = url
self._timeout = timeout

if use_blackbox_licence:
environ["MOTORDES_BLACKBOX"] = "1"

if DEFAULT_INSTANCE != -1:
# Getting called from MotorCAD internal scripting so port is known
port = DEFAULT_INSTANCE
Expand Down
7 changes: 7 additions & 0 deletions tests/test_rpc_client_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,10 @@ def test__resolve_localhost():
raise e
finally:
mc2.quit()


def test_blackbox_licencing():
mc2 = MotorCAD(use_blackbox_licence=True)
# Not sure it's possible to assert that only a blackbox licence was consumed
# Just check it works for now
mc2.get_licence()
Loading