|
@@ -4,6 +4,7 @@ import classes.*;
|
|
|
|
|
|
import com.google.gson.JsonParseException;
|
|
import com.google.gson.JsonParseException;
|
|
|
|
|
|
|
|
+import holeg.HolegGateway;
|
|
import holeg.HolegPowerFlowContext;
|
|
import holeg.HolegPowerFlowContext;
|
|
import javafx.geometry.Pos;
|
|
import javafx.geometry.Pos;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
@@ -42,6 +43,7 @@ import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
|
+import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -570,7 +572,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
g.fillRect(sx, y, x - sx, sy - y);
|
|
g.fillRect(sx, y, x - sx, sy - y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public void paintComponent(Graphics g) {
|
|
|
|
|
|
+ public void paintComponent(Graphics g) {
|
|
super.paintComponent(g);
|
|
super.paintComponent(g);
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
|
g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
|
@@ -584,43 +586,43 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
//<--
|
|
//<--
|
|
//SelectedCable
|
|
//SelectedCable
|
|
HashSet<Edge> selectedEdges = new HashSet<Edge>();
|
|
HashSet<Edge> selectedEdges = new HashSet<Edge>();
|
|
- for(AbstractCanvasObject aCps: model.getSelectedCpsObjects()) {
|
|
|
|
- for(Edge edge: aCps.getConnections()) {
|
|
|
|
|
|
+ for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
|
|
|
|
+ for (Edge edge : aCps.getConnections()) {
|
|
selectedEdges.add(edge);
|
|
selectedEdges.add(edge);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(model.getSelectedEdge() != null) selectedEdges.add(model.getSelectedEdge());
|
|
|
|
|
|
+ if (model.getSelectedEdge() != null) selectedEdges.add(model.getSelectedEdge());
|
|
//timstep:
|
|
//timstep:
|
|
- g.setFont(new Font("TimesNewRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
|
|
|
|
+ g.setFont(new Font("TimesNewRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10)));
|
|
g2d.setColor(Color.BLACK);
|
|
g2d.setColor(Color.BLACK);
|
|
-
|
|
|
|
- VisualRepresentationalState visualState = controller.getSimManager().getActualVisualRepresentationalState();
|
|
|
|
|
|
+
|
|
|
|
+ VisualRepresentationalState visualState = controller.getSimManager().getActualVisualRepresentationalState();
|
|
//VisualState Representation:
|
|
//VisualState Representation:
|
|
- for(ExitCable cable : visualState.getExitCableList()) {
|
|
|
|
|
|
+ for (ExitCable cable : visualState.getExitCableList()) {
|
|
paintExitCable(controller, g2d, cable, showConnectionInformation);
|
|
paintExitCable(controller, g2d, cable, showConnectionInformation);
|
|
}
|
|
}
|
|
- for(DecoratedCable cable : visualState.getCableList()) {
|
|
|
|
|
|
+ for (DecoratedCable cable : visualState.getCableList()) {
|
|
paintCable(controller, g2d, cable, selectedEdges.contains(cable.getModel()), showConnectionInformation);
|
|
paintCable(controller, g2d, cable, selectedEdges.contains(cable.getModel()), showConnectionInformation);
|
|
}
|
|
}
|
|
- for(DecoratedGroupNode dGroupNode : visualState.getGroupNodeList()) {
|
|
|
|
|
|
+ for (DecoratedGroupNode dGroupNode : visualState.getGroupNodeList()) {
|
|
paintGroupNode(g2d, dGroupNode);
|
|
paintGroupNode(g2d, dGroupNode);
|
|
}
|
|
}
|
|
- for(Consumer con: visualState.getConsumerList()) {
|
|
|
|
- paintConsumer(g2d, con);
|
|
|
|
|
|
+ for (Consumer con : visualState.getConsumerList()) {
|
|
|
|
+ paintConsumer(g2d, con);
|
|
}
|
|
}
|
|
- for(Supplier sup: visualState.getSupplierList()) {
|
|
|
|
- paintSupplier(g2d, sup);
|
|
|
|
|
|
+ for (Supplier sup : visualState.getSupplierList()) {
|
|
|
|
+ paintSupplier(g2d, sup);
|
|
}
|
|
}
|
|
- for(Passiv pas: visualState.getPassivList()) {
|
|
|
|
|
|
+ for (Passiv pas : visualState.getPassivList()) {
|
|
paintCanvasObject(g2d, pas);
|
|
paintCanvasObject(g2d, pas);
|
|
}
|
|
}
|
|
- for(DecoratedSwitch dSwitch : visualState.getSwitchList()) {
|
|
|
|
|
|
+ for (DecoratedSwitch dSwitch : visualState.getSwitchList()) {
|
|
paintSwitch(g2d, dSwitch);
|
|
paintSwitch(g2d, dSwitch);
|
|
}
|
|
}
|
|
- for(Node node : visualState.getNodeList()) {
|
|
|
|
- drawCanvasObject(g2d, "/Images/node.png" , node.getPosition());
|
|
|
|
|
|
+ for (Node node : visualState.getNodeList()) {
|
|
|
|
+ drawCanvasObject(g2d, "/Images/node.png", node.getPosition());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//-->oldCode
|
|
//-->oldCode
|
|
if (doMark) {
|
|
if (doMark) {
|
|
g2d.setColor(Color.BLACK);
|
|
g2d.setColor(Color.BLACK);
|
|
@@ -632,30 +634,29 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
g2d.setColor(Color.BLUE);
|
|
g2d.setColor(Color.BLUE);
|
|
g2d.setStroke(new BasicStroke(1));
|
|
g2d.setStroke(new BasicStroke(1));
|
|
Color transparentGrey = new Color(128, 174, 247, 40);
|
|
Color transparentGrey = new Color(128, 174, 247, 40);
|
|
- for(AbstractCanvasObject aCps: model.getSelectedCpsObjects()) {
|
|
|
|
- if(aCps instanceof Node) {
|
|
|
|
|
|
+ for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
|
|
|
|
+ if (aCps instanceof Node) {
|
|
Position pos = aCps.getPosition();
|
|
Position pos = aCps.getPosition();
|
|
g2d.setColor(transparentGrey);
|
|
g2d.setColor(transparentGrey);
|
|
- g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
|
|
|
+ g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setStroke(new BasicStroke(2));
|
|
g2d.setStroke(new BasicStroke(2));
|
|
- g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
|
+ } else {
|
|
Position pos = aCps.getPosition();
|
|
Position pos = aCps.getPosition();
|
|
g2d.setColor(transparentGrey);
|
|
g2d.setColor(transparentGrey);
|
|
- g2d.fillRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
|
|
|
+ g2d.fillRect(pos.x - (int) (controller.getScaleDiv2() * 1.5f), pos.y - (int) (controller.getScaleDiv2() * 1.5f), (int) (controller.getScale() * 1.5f), (int) (controller.getScale() * 1.5f));
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setColor(Color.LIGHT_GRAY);
|
|
g2d.setStroke(new BasicStroke(2));
|
|
g2d.setStroke(new BasicStroke(2));
|
|
- g2d.drawRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
|
|
|
+ g2d.drawRect(pos.x - (int) (controller.getScaleDiv2() * 1.5f), pos.y - (int) (controller.getScaleDiv2() * 1.5f), (int) (controller.getScale() * 1.5f), (int) (controller.getScale() * 1.5f));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
//maybeReplace:
|
|
//maybeReplace:
|
|
- if(mayBeReplaced != null){
|
|
|
|
|
|
+ if (mayBeReplaced != null) {
|
|
g2d.setColor(Color.RED);
|
|
g2d.setColor(Color.RED);
|
|
Position pos = mayBeReplaced.getPosition();
|
|
Position pos = mayBeReplaced.getPosition();
|
|
- g2d.drawImage(ImageImport.loadImage("/Images/replace.png") ,
|
|
|
|
|
|
+ g2d.drawImage(ImageImport.loadImage("/Images/replace.png"),
|
|
pos.x + controller.getScaleDiv2(),
|
|
pos.x + controller.getScaleDiv2(),
|
|
pos.y - controller.getScale(),
|
|
pos.y - controller.getScale(),
|
|
controller.getScaleDiv2(), controller.getScaleDiv2(), null);
|
|
controller.getScaleDiv2(), controller.getScaleDiv2(), null);
|
|
@@ -663,13 +664,21 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
|
|
//<-- OldCode
|
|
//<-- OldCode
|
|
|
|
|
|
// Draw solver job
|
|
// Draw solver job
|
|
- HolegPowerFlowContext context = SingletonControl.getInstance().getControl().getSimManager().getHolegPowerFlowContext();
|
|
|
|
- if (context != null) {
|
|
|
|
|
|
+ Set<HolegPowerFlowContext> contextSet = HolegGateway.getALlContext();
|
|
|
|
+ if (contextSet.size() > 0) {
|
|
|
|
+ float maxTime = 0;
|
|
|
|
+ int runningCount = 0;
|
|
|
|
+ for (HolegPowerFlowContext context : contextSet) {
|
|
|
|
+ maxTime = Math.max(maxTime, context.solverTimeMilliseconds);
|
|
|
|
+ if (context.isSolving())
|
|
|
|
+ runningCount++;
|
|
|
|
+ }
|
|
|
|
+
|
|
g2d.setColor(Color.BLACK);
|
|
g2d.setColor(Color.BLACK);
|
|
- if (context.isSolving())
|
|
|
|
- g2d.drawString("Solver running...", 4, 14);
|
|
|
|
|
|
+ if (runningCount > 0)
|
|
|
|
+ g2d.drawString(String.format("%d of %d solver running...", runningCount, contextSet.size()), 4, 14);
|
|
else
|
|
else
|
|
- g2d.drawString(String.format("Solver finished in %.2f ms", context.solverTimeMilliseconds), 4, 14);
|
|
|
|
|
|
+ g2d.drawString(String.format("Solver finished in max %.2f ms", maxTime), 4, 14);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|