Skip to content

Commit

Permalink
added Value as response (#988)
Browse files Browse the repository at this point in the history
* added Value as response

* added json report from process object

* update

* update

* fix error.
  • Loading branch information
EvenSol authored Apr 23, 2024
1 parent c87dcf9 commit 861a079
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 31 deletions.
10 changes: 10 additions & 0 deletions src/main/java/neqsim/processSimulation/SimulationInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,14 @@ public default void runTransient(double dt, UUID id) {
* @return a boolean
*/
public boolean solved();

/**
* <p>
* getReport_json
* </p>
* Return results of simulation in json format
*
* @return a String
*/
public String getReport_json();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface;
import neqsim.processSimulation.mechanicalDesign.MechanicalDesign;
import neqsim.processSimulation.processEquipment.stream.EnergyStream;
import neqsim.processSimulation.util.report.Report;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -58,7 +59,8 @@ public SystemInterface getThermoSystem() {

/** {@inheritDoc} */
@Override
public void displayResult() {}
public void displayResult() {
}

/**
* Create deep copy.
Expand Down Expand Up @@ -87,7 +89,8 @@ public Object getProperty(String propertyName) {

/** {@inheritDoc} */
@Override
public void setRegulatorOutSignal(double signal) {}
public void setRegulatorOutSignal(double signal) {
}

/** {@inheritDoc} */
@Override
Expand All @@ -101,8 +104,9 @@ public void setController(ControllerDeviceInterface controller) {
* Setter for the field <code>flowValveController</code>.
* </p>
*
* @param controller a {@link neqsim.processSimulation.controllerDevice.ControllerDeviceInterface}
* object
* @param controller a
* {@link neqsim.processSimulation.controllerDevice.ControllerDeviceInterface}
* object
*/
public void setFlowValveController(ControllerDeviceInterface controller) {
this.flowValveController = controller;
Expand All @@ -122,7 +126,8 @@ public MechanicalDesign getMechanicalDesign() {

/** {@inheritDoc} */
@Override
public void initMechanicalDesign() {}
public void initMechanicalDesign() {
}

/** {@inheritDoc} */
@Override
Expand Down Expand Up @@ -153,7 +158,9 @@ public boolean solved() {
* Getter for the field <code>energyStream</code>.
* </p>
*
* @return a {@link neqsim.processSimulation.processEquipment.stream.EnergyStream} object
* @return a
* {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
* object
*/
public EnergyStream getEnergyStream() {
return energyStream;
Expand All @@ -164,8 +171,9 @@ public EnergyStream getEnergyStream() {
* Setter for the field <code>energyStream</code>.
* </p>
*
* @param energyStream a {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
* object
* @param energyStream a
* {@link neqsim.processSimulation.processEquipment.stream.EnergyStream}
* object
*/
public void setEnergyStream(EnergyStream energyStream) {
setEnergyStream(true);
Expand Down Expand Up @@ -232,7 +240,8 @@ public double getExergyChange(String unit, double surroundingTemperature) {

/** {@inheritDoc} */
@Override
public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) {}
public void runConditionAnalysis(ProcessEquipmentInterface refExchanger) {
}

public String conditionAnalysisMessage = "";

Expand Down Expand Up @@ -294,6 +303,15 @@ public String toJson() {
return null;
}

/**
* {@inheritDoc}
*
* @return a String
*/
public String getReport_json() {
return new Report(this).json();
}

/** {@inheritDoc} */
@Override
public void run_step(UUID id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,14 @@ public default SystemInterface getFluid() {
* @return a String
*/
public String toJson();

/**
* <p>
* getReport_json
* </p>
* Return results of simulation in json format
*
* @return a String
*/
public String getReport_json();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import neqsim.processSimulation.SimulationBaseClass;
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.util.Recycle;
import neqsim.processSimulation.util.report.Report;

/**
* A class representing a process module class that can contain unit operations and other modules.
* Module will be runnning until all recycles in this module are solved. If no recycle in the module
* A class representing a process module class that can contain unit operations
* and other modules.
* Module will be runnning until all recycles in this module are solved. If no
* recycle in the module
* then run only once.
*
* @author [seros]
Expand Down Expand Up @@ -53,7 +56,8 @@ public ProcessModule(String name) {
/**
* Add an unit operation to the process module.
*
* @param processSystem the process system that contains the unit operations to be added.
* @param processSystem the process system that contains the unit operations to
* be added.
*/

public void add(ProcessSystem processSystem) {
Expand Down Expand Up @@ -82,7 +86,8 @@ public List<ProcessSystem> getAddedUnitOperations() {
}

/**
* Get the list of operations index. The operations index is used to follow the correct order of
* Get the list of operations index. The operations index is used to follow the
* correct order of
* calculations.
*
* @return the list of operations index
Expand All @@ -103,7 +108,8 @@ public List<ProcessModule> getAddedModules() {
}

/**
* Get the list of module index. The module index is used to follow the correct order of
* Get the list of module index. The module index is used to follow the correct
* order of
* calculations.
*
* @return the list of module index
Expand Down Expand Up @@ -197,11 +203,13 @@ public Thread runAsThread() {
}

/**
* Returns the unit with the given name from the list of added unit operations and list of added
* Returns the unit with the given name from the list of added unit operations
* and list of added
* modules.
*
* @param name the name of the unit to retrieve
* @return the unit with the given name, or {@code null} if no such unit is found
* @return the unit with the given name, or {@code null} if no such unit is
* found
*/
public Object getUnit(String name) {
for (ProcessSystem processSystem : addedUnitOperations) {
Expand All @@ -221,11 +229,13 @@ public Object getUnit(String name) {
}

/**
* Returns the unit with the given name from the list of added unit operations and list of added
* Returns the unit with the given name from the list of added unit operations
* and list of added
* modules.
*
* @param name the name of the unit to retrieve
* @return the unit with the given name, or {@code null} if no such unit is found
* @return the unit with the given name, or {@code null} if no such unit is
* found
*/
public Object getMeasurementDevice(String name) {
for (ProcessSystem processSystem : addedUnitOperations) {
Expand Down Expand Up @@ -261,6 +271,14 @@ public ArrayList<String[]> getReport() {
return null;
}

/**
* {@inheritDoc}
*
* @return a String
*/
public String getReport_json() {
return new Report(this).json();
}

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import neqsim.processSimulation.controllerDevice.ControllerDeviceInterface;
import neqsim.processSimulation.mechanicalDesign.MechanicalDesign;
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.util.report.Report;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -250,6 +251,14 @@ public String toJson() {
return null;
}

/**
* {@inheritDoc}
*
* @return a String
*/
public String getReport_json() {
return new Report(this).json();
}

/** {@inheritDoc} */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processEquipment.util.Recycle;
import neqsim.processSimulation.processEquipment.util.RecycleController;
import neqsim.processSimulation.util.report.Report;
import neqsim.thermo.system.SystemInterface;

/**
Expand Down Expand Up @@ -977,6 +978,15 @@ public boolean equals(Object obj) {
&& Objects.equals(unitOperations, other.unitOperations);
}

/**
* {@inheritDoc}
*
* @return a String
*/
public String getReport_json() {
return new Report(this).json();
}

/*
* @XmlRootElement private class Report extends Object{ public Double name; public
* ArrayList<ReportInterface> unitOperationsReports = new ArrayList<ReportInterface>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package neqsim.processSimulation.util.monitor;

import java.util.ArrayList;
import java.util.HashMap;
import neqsim.processSimulation.processEquipment.stream.StreamInterface;

/**
Expand All @@ -23,27 +23,27 @@ public class StreamResponse {
public Double massflowGas;
public Double massflowOil;
public Double massflowAqueous;
public ArrayList<String[]> data = new ArrayList<String[]>();
public HashMap<String, Value> data = new HashMap<String, Value>();

/**
* <p>
* Constructor for StreamResponse.
* </p>
*
* @param inputStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
* @param inputStream a
* {@link neqsim.processSimulation.processEquipment.stream.StreamInterface}
* object
*/
public StreamResponse(StreamInterface inputStream) {

name = inputStream.getName();

data.add(new String[] {"temperature",
Double
.toString(inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
neqsim.util.unit.Units.getSymbol("temperature")});
data.add(new String[] {"pressure",
Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
neqsim.util.unit.Units.getSymbol("pressure")});
data.put("temperature",
new Value(Double.toString(inputStream.getTemperature(neqsim.util.unit.Units.getSymbol("temperature"))),
neqsim.util.unit.Units.getSymbol("temperature")));
data.put("pressure",
new Value(Double.toString(inputStream.getPressure(neqsim.util.unit.Units.getSymbol("pressure"))),
neqsim.util.unit.Units.getSymbol("pressure")));

fluid = new Fluid(inputStream.getFluid());
temperature = inputStream.getTemperature("C");
Expand Down Expand Up @@ -75,5 +75,6 @@ public StreamResponse(StreamInterface inputStream) {
* print.
* </p>
*/
public void print() {}
public void print() {
}
}
15 changes: 15 additions & 0 deletions src/main/java/neqsim/processSimulation/util/monitor/Value.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package neqsim.processSimulation.util.monitor;

/**
* Unit class nested within Units.
*/
public class Value {
public String value;
public String unit;

public Value(String value, String unit) {
this.value = value;
this.unit = unit;
}

}
18 changes: 17 additions & 1 deletion src/main/java/neqsim/processSimulation/util/report/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass;
import neqsim.processSimulation.processEquipment.ProcessEquipmentInterface;
import neqsim.processSimulation.processSystem.ProcessModule;
import neqsim.processSimulation.processSystem.ProcessModuleBaseClass;
import neqsim.processSimulation.processSystem.ProcessSystem;

/**
Expand All @@ -20,12 +23,25 @@ public class Report {
public static HashMap<String, String> json_reports = new HashMap<>();
Gson gson = new Gson();
ProcessSystem process;
ProcessEquipmentBaseClass processEquipment;

public Report(ProcessSystem process) {
this.process = process;
}

public String json() {
public Report(ProcessEquipmentBaseClass processEquipmentBaseClass) {
processEquipment = processEquipmentBaseClass;
}

public Report(ProcessModule processModule) {
// TODO Auto-generated constructor stub
}

public Report(ProcessModuleBaseClass processModuleBaseClass) {
//TODO Auto-generated constructor stub
}

public String json() {
for (ProcessEquipmentInterface unit : process.getUnitOperations()) {
json_reports.put(unit.getName(), unit.toJson());
}
Expand Down

0 comments on commit 861a079

Please sign in to comment.