Commit f4f8b041 authored by patrick.lambert's avatar patrick.lambert
Browse files

with an observer triggered by movement processes

parent 2bce4f91
<hashtable> <hashtable>
<entry> <entry>
<java-class>fr.cemagref.simaqualife.kernel.AquaticWorld</java-class> <!--
<java-class>fr.cemagref.simaqualife.kernel.AquaticWorld</java-class>-->
<java-class>environment.RIOBasinNetworkWithContinent</java-class>
<fr.cemagref.observation.kernel.ObservablesHandler> <fr.cemagref.observation.kernel.ObservablesHandler>
<observers> <observers>
<environment.RIOBasinNetworkObserverWithContinent> <environment.RIOBasinNetworkObserverWithContinent>
......
...@@ -5,7 +5,6 @@ import java.util.List; ...@@ -5,7 +5,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import environment.OffshoreBasin.OffshoreBasinFunction; import environment.OffshoreBasin.OffshoreBasinFunction;
import fr.cemagref.observation.kernel.ObservablesHandler;
import fr.cemagref.simaqualife.kernel.AquaNismsGroup; import fr.cemagref.simaqualife.kernel.AquaNismsGroup;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters; import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot; import fr.cemagref.simaqualife.pilot.Pilot;
...@@ -32,22 +31,12 @@ public abstract class RIOBasinNetwork extends BasinNetwork { ...@@ -32,22 +31,12 @@ public abstract class RIOBasinNetwork extends BasinNetwork {
protected transient Time time; protected transient Time time;
protected static transient ObservablesHandler cobservable;
public ObservablesHandler getCobservable() {
return cobservable;
}
@Override @Override
@InitTransientParameters @InitTransientParameters
public void initTransientParameters(Pilot pilot) { public void initTransientParameters(Pilot pilot) {
time = new Time(); time = new Time();
if (cobservable == null) {
cobservable = pilot.addObservable(this.getClass());
}
} }
......
...@@ -24,6 +24,7 @@ import com.thoughtworks.xstream.XStream; ...@@ -24,6 +24,7 @@ import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.OffshoreBasin.OffshoreBasinFunction; import environment.OffshoreBasin.OffshoreBasinFunction;
import fr.cemagref.observation.kernel.ObservablesHandler;
import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters; import fr.cemagref.simaqualife.kernel.util.TransientParameters.InitTransientParameters;
import fr.cemagref.simaqualife.pilot.Pilot; import fr.cemagref.simaqualife.pilot.Pilot;
import miscellaneous.QueueMemoryMap; import miscellaneous.QueueMemoryMap;
...@@ -55,6 +56,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork { ...@@ -55,6 +56,13 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
private transient Map<String, Path2D.Double> mapContinent; private transient Map<String, Path2D.Double> mapContinent;
protected transient ObservablesHandler cobservable;
public ObservablesHandler getCobservable() {
return cobservable;
}
class Record implements Comparable<Record> { class Record implements Comparable<Record> {
private int order; private int order;
...@@ -215,6 +223,10 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork { ...@@ -215,6 +223,10 @@ public class RIOBasinNetworkWithContinent extends RIOBasinNetwork {
super.initTransientParameters(pilot); super.initTransientParameters(pilot);
if (cobservable == null) {
cobservable = pilot.addObservable(this.getClass());
}
FileReader reader; FileReader reader;
Scanner scanner; Scanner scanner;
......
...@@ -13,6 +13,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver; ...@@ -13,6 +13,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.InshoreBasin; import environment.InshoreBasin;
import environment.RIOBasinNetwork; import environment.RIOBasinNetwork;
import environment.RIOBasinNetworkWithContinent;
import environment.RiverBasin; import environment.RiverBasin;
import environment.Time; import environment.Time;
import environment.Time.Season; import environment.Time.Season;
...@@ -247,14 +248,16 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di ...@@ -247,14 +248,16 @@ public class DisperseAndMigrateToRiverWithMultiNomDistriAndDeathBasin extends Di
} }
} }
} }
System.out.println(this.getClass().getSimpleName());
System.out.println(" total abundance in river basins: " + group.getFishEffective()); System.out.println(" total abundance in river basins: " + group.getFishEffective());
System.out.println("female spawners: " + group.getFemaleSpawnerEffective() + " \tmale spawners: " System.out.println(" female spawners: " + group.getFemaleSpawnerEffective() + " \tmale spawners: "
+ group.getMaleSpawnerEffective()); + group.getMaleSpawnerEffective());
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// update the observers // update the observers
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
group.getEnvironment().getCobservable().fireChanges(group.getEnvironment(), pilot.getCurrentTime()); ((RIOBasinNetworkWithContinent) group.getEnvironment()).getCobservable().fireChanges((group.getEnvironment()),
pilot.getCurrentTime());
} }
} }
} }
...@@ -10,6 +10,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver; ...@@ -10,6 +10,7 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
import environment.Basin; import environment.Basin;
import environment.OffshoreBasin; import environment.OffshoreBasin;
import environment.RIOBasinNetworkWithContinent;
import environment.RiverBasin; import environment.RiverBasin;
import environment.Time.Season; import environment.Time.Season;
import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess; import fr.cemagref.simaqualife.kernel.processes.AquaNismsGroupProcess;
...@@ -65,7 +66,9 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -65,7 +66,9 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// update the observers // update the observers
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
group.getEnvironment().getCobservable().fireChanges(group.getEnvironment(), pilot.getCurrentTime()); ((RIOBasinNetworkWithContinent) group.getEnvironment()).getCobservable().fireChanges((group.getEnvironment()),
pilot.getCurrentTime());
} else if (group.getEnvironment().getTime().getSeason(group.getPilot()) == migrationSeasonToReachSummeringOffshore) { } else if (group.getEnvironment().getTime().getSeason(group.getPilot()) == migrationSeasonToReachSummeringOffshore) {
for (OffshoreBasin winteringOffshoreBasin : group.getEnvironment().getWinteringOffshoreBasins()) { for (OffshoreBasin winteringOffshoreBasin : group.getEnvironment().getWinteringOffshoreBasins()) {
...@@ -93,7 +96,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis ...@@ -93,7 +96,8 @@ public class MigrateBetweenOffshores extends AquaNismsGroupProcess<DiadromousFis
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
// update the observers // update the observers
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
group.getEnvironment().getCobservable().fireChanges(group.getEnvironment(), pilot.getCurrentTime()); ((RIOBasinNetworkWithContinent) group.getEnvironment()).getCobservable().fireChanges((group.getEnvironment()),
pilot.getCurrentTime());
} }
} }
} }
\ No newline at end of file
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