Commit 88c320d4 authored by THEBAULT Antoine's avatar THEBAULT Antoine
Browse files

set a clock in the net tab on the ui

parent f8b24e3b
Pipeline #346585 passed with stages
in 8 minutes and 50 seconds
......@@ -42,7 +42,7 @@ transition:6:td3to4:[1.8,2.2]
transition:7:ta4:[0.5,1]
transition:8:td4to5:[1.8,2.2]
transition:9:ta5:[5,5]
transition:9:ta5:[0.5,1]
transition:10:td5to6:[1.8,2.2]
transition:11:ta6:[0.5,1]
......
......@@ -4,10 +4,14 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import fr.inria.mochy.core.mochysim.Delay;
import fr.inria.mochy.core.mochysim.Marking;
import fr.inria.mochy.core.mochysim.Place;
import fr.inria.mochy.core.mochysim.Transition;
import fr.inria.mochy.core.timetable.Tag;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleFloatProperty;
/**
* it extends the Net class
......@@ -17,10 +21,12 @@ public abstract class PhysicalModel {
public float timeElapsed = 0;// duration elapsed so far during a simulation
public int stepsNb = 0;
public int nbDiscreteSteps = 0;// number of discrete steps that occurred during simulation
public boolean discreteStep = false;
public boolean discreteStep = false;//set to true if the last step is a discrete step
public boolean startLogs = false;// set to true once the first line of the logs of the out.txt file have be written
//public HashMap<Integer, ? extends TransitionAbstract> transitions;
float clock = 0;//the date set to 0 at start or at reset and increase at each time move
FloatProperty clockProperty = new SimpleFloatProperty();
ArrayList<Delay> delays = new ArrayList<>();//allow delays to transitions for a specific duration
public abstract String loadFile();
public abstract HashMap<Integer, ? extends TransitionAbstract> getTransitions();
......@@ -31,13 +37,14 @@ public abstract class PhysicalModel {
public abstract boolean isBlocked(int tnum);
public void progressTime(Float delta) {
clock += delta;
setClock(getClock() + delta);
manageDelays();
}
public abstract void discreteMove();
public abstract void multipleSteps(int steps);
public void reset (boolean init) {
startLogs = false;
clock = 0;
setClock(0);
}
public abstract boolean discreteMove(String pathLogs, long elapsedTime, boolean enableLogs);
public abstract void drop();
......@@ -78,4 +85,36 @@ public abstract class PhysicalModel {
public boolean isDiscreteStep() {
return discreteStep;
}
public void setDelays(ArrayList<Delay> delays) {
this.delays = delays;
}
/**add the delays to specific transition(s) at a specific time as indicated in the scenario menu*/
public void manageDelays() {
for (Delay delay : delays) {
if (delay.isValid() && clock > delay.getEndDate()) {
TransitionAbstract transition = this.findTransition(delay.getTransitionNb());
transition.setLowerBound(transition.getLowerBound() - delay.getDelay());
transition.setUpperBound(transition.getUpperBound() - delay.getDelay());
delay.setValid(false);
}
else if (!delay.isValid() && clock >= delay.getStartDate() && clock <= delay.getEndDate()) {
TransitionAbstract transition = this.findTransition(delay.getTransitionNb());
transition.setLowerBound(transition.getLowerBound() + delay.getDelay());
transition.setUpperBound(transition.getUpperBound() + delay.getDelay());
delay.setValid(true);
}
}
}
public float getClock() {
return clock;
}
public void setClock(float clock) {
this.clock = clock;
this.clockProperty.setValue(this.clock);
}
public FloatProperty getClockProperty() {
return clockProperty;
}
}
......@@ -128,9 +128,9 @@ public class EquNetNeuralMov extends EquNetNeural {
rearrangeTokens();
updateGarageTransition();
}
for (Token token : tokens) {
/*for (Token token : tokens) {
System.out.println("token at place "+token.p.getName());
}
}*/
}
@Override
......
......@@ -64,8 +64,8 @@ public class EquNetOneByOne extends EquNetNeuralMov {
return output;
}
/**browse the bunching tokens and block or unblock them*/
public void manageHashMaps() {
// browse the bunching tokens and block or unblock them
for (Iterator<Token> it = bunchingTokens.iterator(); it.hasNext();) {
Token token = it.next();
if (!token.blocked) {
......
......@@ -51,7 +51,9 @@ import fr.inria.mochy.statsAndTasks.AbstractStats;
import fr.inria.mochy.statsAndTasks.GenerateNnetMultiTokensNbTask;
import fr.inria.mochy.statsAndTasks.OptimizeNnetMultiTokensNbTask;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
......@@ -208,6 +210,11 @@ public class StartController implements Initializable {
/** if set to true, display the chart after the call of launchsteps method */
static boolean displayChart = true;
/**the date of the net network in the net tab*/
static StringProperty dateNetString = new SimpleStringProperty();
@FXML
TextField dateNet;
/** display the current date of the timetable */
static StringProperty dateTTString = new SimpleStringProperty();
@FXML
......@@ -575,6 +582,10 @@ public class StartController implements Initializable {
System.out.println("Loaded a " + classModel);
PhysicalModel net = simu.getN();
displayNet(simu.displayFeedback());
FloatProperty o = simu.getN().getClockProperty();
o.addListener((observable, oldValue, newValue) -> {
dateNet.setText(Float.toString(newValue.floatValue()));
});
}
}
......@@ -2223,14 +2234,18 @@ public class StartController implements Initializable {
public static void setDelays(ArrayList<Delay> delays, boolean reset) {
StartController.delays = delays;
if (rpnc != null) {
if (rpnc != null) {//if there is a timetable joint to a net
rpnc.setDelays(delays);
rpnc.manageDelays();
if (reset)
rpnc.reset();
}else {
/*clock*/
/*clock set,
* add field ui on the net tab, linked to the clock
* update it at each timemove??
* physicalModel.setDelays*/
simu.getN().setDelays(delays);
simu.getN().manageDelays();
}
}
......
......@@ -128,6 +128,8 @@
<Label fx:id="stepsEqualizationInfo" layoutX="741.0" layoutY="20.0" prefHeight="86.0" prefWidth="721.0" />
<TextField fx:id="targetEqualization" layoutX="679.0" layoutY="47.0" prefHeight="31.0" prefWidth="48.0" />
<Button fx:id="insertTokenButton" layoutX="524.0" layoutY="82.0" mnemonicParsing="false" onAction="#insertToken" text="Insert Token" />
<TextField fx:id="dateNet" editable="false" layoutX="1371.0" layoutY="115.0" prefHeight="31.0" prefWidth="81.0" />
<Label layoutX="1315.0" layoutY="120.0" text="Date : " />
</children>
</AnchorPane>
</content>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment