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

Figure out why OPUS answers in Chinese #124

Open
dostuffthatmatters opened this issue Sep 9, 2022 · 0 comments
Open

Figure out why OPUS answers in Chinese #124

dostuffthatmatters opened this issue Sep 9, 2022 · 0 comments
Assignees
Labels
scope:opus status:implemented has been implemented in some dev branch
Milestone

Comments

@dostuffthatmatters
Copy link
Member

dostuffthatmatters commented Sep 9, 2022

In previous versions, when starting a macro or loading an experiment, OPUS returned the string "OK" as well as the Macro ID. Now it does not do that any more, but returns some Chinese Unicode symbols:

def load_experiment(self) -> None:
    """Loads a new experiment in OPUS over DDE connection."""
    assert sys.platform == "win32"

    self.__connect_to_dde_opus()
    experiment_path = self._CONFIG["opus"]["experiment_path"]

    if not self.__test_dde_connection():
        return
    answer = self.conversation.Request("LOAD_EXPERIMENT " + experiment_path)
    logger.info(f"Loaded new OPUS experiment: {experiment_path}")
    self.current_experiment = experiment_path

    # TODO: why does the following logic not work anymore
    """
    if "OK" in answer:
        logger.info("Loaded new OPUS experiment: {}.".format(full_path))
        self.current_experiment = full_path
    else:
        logger.info("Could not load OPUS experiment as expected.")
    """

def start_macro(self) -> None:
    """Starts a new macro in OPUS over DDE connection."""
    assert sys.platform == "win32"

    # perform connect
    self.__connect_to_dde_opus()
    if not self.__test_dde_connection():
        return

    # load macro
    macro_path = self._CONFIG["opus"]["macro_path"]
    answer = self.conversation.Request(f"RUN_MACRO {macro_path}")
    logger.info(f"Started OPUS macro: {macro_path}")

    # TODO: why does the following logic not work anymore
    """
    active_macro_id = str(answer[4:-1])
    StateInterface.update({"active_opus_macro_id": active_macro_id}, persistent=True)

    if "OK" in answer:
        logger.info(f"Started OPUS macro: {macro_basename} with id: {active_macro_id}.")
    else:
        logger.info(f"Could not start OPUS macro with id: {active_macro_id} as expected.")
    """

def stop_macro(self) -> None:
    """Stops the currently running macro in OPUS over DDE connection."""
    assert sys.platform == "win32"

    # perform connect
    self.__connect_to_dde_opus()
    if not self.__test_dde_connection():
        return

    # stop macro
    macro_path = os.path.basename(self._CONFIG["opus"]["macro_path"])
    answer = self.conversation.Request("KILL_MACRO " + macro_path)
    logger.info(f"Stopped OPUS macro: {macro_path}")

    # TODO: why does the following logic not work anymore
    """
    if "OK" in answer:
        logger.info(f"Stopped OPUS macro: {macro_basename} with id: {active_macro_id}.")
        StateInterface.update({"active_opus_macro_id": None}, persistent=True)
    else:
        logger.info(f"Could not stop OPUS macro with id: {active_macro_id} as expected.")
    """

def close_opus(self) -> None:
    """Closes OPUS via DDE call."""
    assert sys.platform == "win32"

    self.__connect_to_dde_opus()

    if not self.__test_dde_connection():
        return
    answer = self.conversation.Request("CLOSE_OPUS")
    logger.info("Stopped OPUS.exe")

    # TODO: why does the following logic not work anymore
    """
    if "OK" in answer:
        logger.info("Stopped OPUS.exe")
    else:
        logger.info("No response for OPUS.exe close request.")
    """

From documentation:

In the current version, we did not figure out how to process the answers from the OPUS DDE server. When using the same conversation to start and stop a macro, we do not need a Macro ID (which should be inside the answer). But when using a different conversation (e.g. from the CLI's stop-core command), we need a Macro ID that we don't have. Hence, we currently terminate the two OPUS processes "opus.exe" and "OpusCore.exe" manually instead of sending "Stop Macro" and "Stop OPUS" commands and waiting for a graceful shutdown.

@dostuffthatmatters dostuffthatmatters added backlog not included in a planned update yet Update: Performance Improvements and removed backlog not included in a planned update yet labels Sep 9, 2022
@dostuffthatmatters dostuffthatmatters changed the title Figure out why OPUS answers is chinese Figure out why OPUS answers in Chinese Sep 10, 2022
@dostuffthatmatters dostuffthatmatters added this to the 4.0.TBD - Performance Improvements milestone Nov 13, 2022
@dostuffthatmatters dostuffthatmatters added backlog not included in a planned update yet and removed status:planned is assigned to a specific milestone labels Feb 7, 2023
@dostuffthatmatters dostuffthatmatters removed this from the 4.X.X - Performance Improvements milestone Jan 9, 2024
@dostuffthatmatters dostuffthatmatters added status:implemented has been implemented in some dev branch status:planned is assigned to a specific milestone and removed backlog not included in a planned update yet status:planned is assigned to a specific milestone labels Oct 9, 2024
@dostuffthatmatters dostuffthatmatters added this to the 4.2.0 milestone Oct 9, 2024
@dostuffthatmatters dostuffthatmatters self-assigned this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:opus status:implemented has been implemented in some dev branch
Projects
None yet
Development

No branches or pull requests

1 participant