TUDelft-CITG / OpenCLSim

Rule driven scheduling of cyclic activities for in-depth comparison of alternative operating strategies.
https://openclsim.readthedocs.io
MIT License
14 stars 17 forks source link

Redesign loggable #98

Closed Pietervanhalem closed 3 years ago

Pietervanhalem commented 3 years ago

In this PR we refactored the loggable of the simulation engine. For the Van Oord application, we ran into two fundamental issues in the logging module. The main purpose of refactoring the logging module is to make the logs more machine-readable.

The first issue was that the state of the simulation objects was nog logged. There was a Value column in the log that was misused for logging various state parameters (Duration, level, amount, ect.) Therefore we added ObjectState column to the log. This is a column of dicts containing the state properties of the simulation object. To get the state of the simulation objects we added a function to the mix-ins. These are the get_state() functions that are chained with the super() method of python classes.

The second issue in the logging module was the string concatinations. In the old logging module we had the Message column with contianed multiple pieces of information. It contained the activity name and the wether it was a subprocess or not. We split these piece of information into the ActivityID, and ActivityLabel columns. We removed the Message column to prevent further sting concationations and because id does not have any unique information. If there is realy something that can only be a message string you can add a message property to the ActivityLabels column.

A second topic that we tackled was the refactoring of the WhileActivity and the RepeatActivity. Since they were basically identical except for the trigger we combined the classes to prevent code duplication. We also changed the sub_process property into the sub_processes property. This means that the WhileActivity and the RepeatActivity can now have multiple sub_processes instead of just one.

This PR was created together with @hoonhout