From a20dda011d0770aa85738b93aa6adc2ec7368b2a Mon Sep 17 00:00:00 2001 From: Even Solbraa <41290109+EvenSol@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:11:10 +0000 Subject: [PATCH] update --- .../process/processmodel/ProcessModel.java | 65 +++++-------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/src/main/java/neqsim/process/processmodel/ProcessModel.java b/src/main/java/neqsim/process/processmodel/ProcessModel.java index 6669d569a..48d1b5f53 100644 --- a/src/main/java/neqsim/process/processmodel/ProcessModel.java +++ b/src/main/java/neqsim/process/processmodel/ProcessModel.java @@ -8,52 +8,17 @@ import org.apache.logging.log4j.Logger; /** - *

- * ProcessModel class. Manages a collection of processes that can be run in steps or continuously. + * A process model that can run multiple processes in parallel. * - * Extended to also allow grouping of processes and the ability to run only the processes within a - * given group instead of always running all. - *

- */ -/** - * The ProcessModel class represents a model that manages and runs multiple process systems. It - * supports both step mode and continuous mode execution, and allows grouping of processes. - * - *

- * This class implements the Runnable interface, enabling it to be executed in a separate thread. - * - *

- * Features: - *

- * - *

- * Usage example: - * - *

- * {@code
- * ProcessModel model = new ProcessModel();
- * model.add("process1", new ProcessSystem());
- * model.createGroup("group1");
- * model.addProcessToGroup("group1", "process1");
- * model.runAsThread();
- * }
- * 
- * - *

- * Thread safety: This class is not thread-safe and should be synchronized externally if used in a - * multi-threaded environment. - * - *

- * Logging: This class uses a logger to log debug information and errors. + * This class is a simple model that can run multiple processes in parallel. It + * can run in two modes: + * - Step mode: each process is run once in a loop, in the order they were + * added. - Continuous mode: + * each process is run in a loop until all processes are finished or a maximum + * number of iterations + * is reached. * - * @see ProcessSystem + * You can also create groups of processes and run them separately. */ public class ProcessModel implements Runnable { /** Logger object for class. */ @@ -65,7 +30,8 @@ public class ProcessModel implements Runnable { /** * Map of group name -> list of process names in that group. * - * We store process *names* here, pointing to the actual ProcessSystem in `processes`. + * We store process *names* here, pointing to the actual ProcessSystem in + * `processes`. * Alternatively, you can store the ProcessSystem references directly. */ private Map> groups = new LinkedHashMap<>(); @@ -221,8 +187,10 @@ public boolean isGroupFinished(String groupName) { /** * The core run method. * - * - If runStep == true, each process is run in "step" mode exactly once. - Otherwise (continuous - * mode), it loops up to maxIterations or until all processes are finished (isFinished() == true). + * - If runStep == true, each process is run in "step" mode exactly once. - + * Otherwise (continuous + * mode), it loops up to maxIterations or until all processes are finished + * (isFinished() == true). */ @Override public void run() { @@ -318,7 +286,8 @@ public Map getThreads() { } /** - * Calculates the total power consumption of all processes in the specified unit. + * Calculates the total power consumption of all processes in the specified + * unit. * * @param unit the unit of power to be used (e.g., "kW", "MW"). * @return the total power consumption of all processes in the specified unit.