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

Cosimulation feature 1 #233

Open
wants to merge 23 commits into
base: development
Choose a base branch
from

Conversation

PandoraQS
Copy link
Contributor

  • Coe.json is shown in a cosimulation page
  • CoE server runs/stops when "CoE Start"/"CoE Stop" is pressed

TODO:

  • Run the cosimulation
  • Include a better scrollbar/customize it

Copy link
Collaborator

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PandoraQS Thanks for the PR. Please check the comments.

src/components/Cosimulation/Cosimulation.tsx Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
src/main.ts Outdated
return;
}

const coeJarPath = path.join(app.getAppPath(), 'resources', 'coe', 'coe.jar');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the application is completely dependent on Maestro, it is probably better to include maestro jar file in resources during the packaging of the application. Remember to use the latest release.
Please add the an npm command that can execute a small javascript file that can download the latest maestro release and place it in resources. This software can be used for npm start and npm test.
In addition, please have the jar integrated into the release being built in npm run dist step.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can push this task to next PR if you prefer.

src/main.ts Outdated Show resolved Hide resolved
src/resources/cosimulation/2018may7/coe.json Outdated Show resolved Hide resolved
src/utils/renderJson.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The application needs to be responsive. For example, please see this code

@PandoraQS
Copy link
Contributor Author

As discussed, this is the screenshot for the cosimulation process (failing).

image

@PandoraQS
Copy link
Contributor Author

Simulation seems to be working now: comparing them, the result outputs.csv is the same as the one of the simulation made with the previous version of the software. Plotting outputs.csv:
image

@prasadtalasila
Copy link
Collaborator

@PandoraQS

Let us follow the INTO-CPS Project (this is a new project created by a user; similar to the project structure of tutorials) as proposed in this discussion.

For this PR, we can work with the following project structure:

FMUs
  FMU1
  FMU2

cosimulation
   default/
      multi-model.json
      experiment.json

results/
  experiment_<timestamp>.csv

into-cps.yml

Please do update the README to reflect the working project structure expected from the user.

@PandoraQS
Copy link
Contributor Author

PandoraQS commented Dec 6, 2024

config.json (one folder above the codebase):

{
  "coeJarPath": "/home/simone/Scrivania/into-cps-forked_react/coe/coe.jar",
  "simulationConfigPath": "/home/simone/Scrivania/into-cps-forked_react/INTO-CPS Project/default",
  "fmusPath": "/home/simone/Scrivania/into-cps-forked_react/INTO-CPS Project/FMUS",
  "multiModels": "/home/simone/Scrivania/into-cps-forked_react/INTO-CPS Project/default/",
  "outputPath": "/home/simone/Scrivania/into-cps-forked_react/INTO-CPS Project/results"
}

To change the config.coe path in .env:

CONFIG_COE_PATH="/home/simone/Scrivania/into-cps-forked_react/config.json"

Copy link
Collaborator

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PandoraQS thanks for the updates. Please check the comments.

src/App.tsx Outdated Show resolved Hide resolved
src/components/Bottom.tsx Outdated Show resolved Hide resolved
src/components/Cosimulation/Cosimulation.tsx Outdated Show resolved Hide resolved
src/components/Cosimulation/Cosimulation.tsx Outdated Show resolved Hide resolved
src/components/Cosimulation/Cosimulation.tsx Show resolved Hide resolved
src/main.ts Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
src/cosimulation/simulationContext.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this convention. The src/cosimulation is better than src/maestro. The src/cosimulation/maestro.ts could still be there for interacting with Maestro at low-level.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this file as well.

@PandoraQS
Copy link
Contributor Author

PR Activities Review:

  • Refactored MaestroManager:

    • Brought status messages together into a single file constants/statuses.ts.
    • Improved error handling for Java misconfiguration and startup issues with startMaestro, making messages more about Maestro's runtime behaviour rather than Java.
    • Ensured that startMaestro waits for the server to be ready before proceeding with cosimulation.
    • Improve handling of maestro JAR extraction
    • Fix port conflicts.
  • Dynamic Cosimulation menu (Electron) enable/disable according to Maestro state

Added the useCosimulation hook:

  • Unifying simulation status and error state in useCosimulation.ts.
  • Listened for IPC messages that return simulation update, simulation error, simulation reset.

Cosimulation component refactored:

  • Logics useCosimulation.ts separated from the UI CoSimulation.tsx.
  • Dynamic showing of simulation results and error (Snackbar).

Improving the communication via IPC.

  • Centralized electronAPI and cosimulationAPI in preload.ts for secure and consistent usage, while separating them for a better logical management.

    • Improved type safety with updates to global.d.ts.
  • Added Maven JAR download:

    • Add postinstall script which dynamically downloads Maestro JAR from Maven repository.
  • Fixed case sensitivity:

    • Standardised imports and filenames CoSimulation and useCosimulation.
  • Various improvements:

    • Better TypeScript configuration with more strict checks.
    • Simulation errors are now displayed with visual feedback using Snackbar.

TO BE DONE:

  • maestro.ts needs to be reviewed for a better management of the different functions.

@PandoraQS
Copy link
Contributor Author

I have included the diagrams for the Maestro Model and the interaction between Maestro and the UI via IPC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants