|
@@ -802,10 +802,10 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
*/
|
|
*/
|
|
|
|
|
|
long hour = 60 * 60 * 1000;
|
|
long hour = 60 * 60 * 1000;
|
|
- long endTime = 24*hour;
|
|
|
|
- long noAnomEnd = 26*hour;
|
|
|
|
- long lightEnd = 27*hour;
|
|
|
|
- long tempEnd = 28*hour;
|
|
|
|
|
|
+ long endTime = 72*hour;
|
|
|
|
+ long noAnomEnd = endTime + 2 * hour;
|
|
|
|
+ long lightEnd = noAnomEnd + 1 * hour;
|
|
|
|
+ long tempEnd = lightEnd + 1 * hour;
|
|
long stepLength=hour;
|
|
long stepLength=hour;
|
|
long currentSimTime=0;
|
|
long currentSimTime=0;
|
|
|
|
|
|
@@ -980,20 +980,24 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
/**
|
|
/**
|
|
* Light Events (random switch every 30min+-15min
|
|
* Light Events (random switch every 30min+-15min
|
|
*/
|
|
*/
|
|
- NormalDistribution lightDist = new NormalDistribution(hour/2, hour/4);
|
|
|
|
|
|
+ NormalDistribution lightDist = new NormalDistribution(hour/10, hour/20);
|
|
long eventTime = 0;
|
|
long eventTime = 0;
|
|
|
|
+ boolean on = true;
|
|
while(eventTime < noAnomEnd) {
|
|
while(eventTime < noAnomEnd) {
|
|
/**
|
|
/**
|
|
* At least 1 second between events
|
|
* At least 1 second between events
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+ final boolean newVal = on;
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void simulateEvent(long time) {
|
|
public void simulateEvent(long time) {
|
|
- smartLight.setBSval(!smartLight.isTrueStatus());
|
|
|
|
- smartLight.setTrueStatus(!smartLight.isTrueStatus());
|
|
|
|
|
|
+ smartLight.setTrueStatus(newVal);
|
|
|
|
+ smartLight.setBSval(newVal);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ on = !on;
|
|
eventTime+=Math.max(1000, Math.round(lightDist.sample()));
|
|
eventTime+=Math.max(1000, Math.round(lightDist.sample()));
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1002,15 +1006,21 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
*/
|
|
*/
|
|
NormalDistribution tempDist = new NormalDistribution(2*hour, hour/2);
|
|
NormalDistribution tempDist = new NormalDistribution(2*hour, hour/2);
|
|
eventTime = 0;
|
|
eventTime = 0;
|
|
|
|
+ boolean low = true;
|
|
while(eventTime < lightEnd) {
|
|
while(eventTime < lightEnd) {
|
|
/**
|
|
/**
|
|
* At least 1 second between events
|
|
* At least 1 second between events
|
|
*/
|
|
*/
|
|
|
|
+ final float newTemp;
|
|
|
|
+ if(low)
|
|
|
|
+ newTemp = heaterDevice.getFSmax();
|
|
|
|
+ else
|
|
|
|
+ newTemp = heaterDevice.getFSmin();
|
|
|
|
+ low = !low;
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void simulateEvent(long time) {
|
|
public void simulateEvent(long time) {
|
|
- float newTemp = (float)(heaterDevice.getFSmin() + Math.random() * (heaterDevice.getFSmax()-heaterDevice.getFSmin()));
|
|
|
|
heaterDevice.setFSval(newTemp);
|
|
heaterDevice.setFSval(newTemp);
|
|
heaterDevice.setTrueTemperature(newTemp);
|
|
heaterDevice.setTrueTemperature(newTemp);
|
|
}
|
|
}
|
|
@@ -1050,10 +1060,9 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
snifferKNNwithLabels.setCurrentScenario("NoAnomalies");
|
|
snifferKNNwithLabels.setCurrentScenario("NoAnomalies");
|
|
snifferKNNnoLabels.setCurrentScenario("NoAnomalies");
|
|
snifferKNNnoLabels.setCurrentScenario("NoAnomalies");
|
|
System.out.println("Test w/0 anomalies:");//TODO
|
|
System.out.println("Test w/0 anomalies:");//TODO
|
|
- while(currentSimTime<noAnomEnd) {
|
|
|
|
- sim.getSimulationManager().simulateTimeIntervall(currentSimTime, stepLength);
|
|
|
|
- currentSimTime+=stepLength;
|
|
|
|
- }
|
|
|
|
|
|
+ sim.getSimulationManager().simulateTimeIntervall(currentSimTime, noAnomEnd-currentSimTime);
|
|
|
|
+ currentSimTime=noAnomEnd;
|
|
|
|
+
|
|
|
|
|
|
new_time = System.currentTimeMillis();
|
|
new_time = System.currentTimeMillis();
|
|
elapsed_time = new_time-currentTime;
|
|
elapsed_time = new_time-currentTime;
|
|
@@ -1067,12 +1076,31 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
snifferKNNwithLabels.setCurrentScenario("LightAnomalies");
|
|
snifferKNNwithLabels.setCurrentScenario("LightAnomalies");
|
|
snifferKNNnoLabels.setCurrentScenario("LightAnomalies");
|
|
snifferKNNnoLabels.setCurrentScenario("LightAnomalies");
|
|
System.out.println("Light Anomaly:");
|
|
System.out.println("Light Anomaly:");
|
|
|
|
+ eventTime = noAnomEnd;
|
|
|
|
+ on = true;
|
|
|
|
+ while(eventTime < lightEnd) {
|
|
|
|
+ /**
|
|
|
|
+ * At least 1 second between events
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ final boolean newVal = on;
|
|
|
|
+ SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void simulateEvent(long time) {
|
|
|
|
+ smartLight.setTrueStatus(newVal);
|
|
|
|
+ smartLight.setBSval(!newVal);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ on = !on;
|
|
|
|
+ eventTime+=Math.max(1000, Math.round(lightDist.sample()));
|
|
|
|
+
|
|
|
|
+ }
|
|
smartLight.setTrueStatus(!smartLight.getBSval());
|
|
smartLight.setTrueStatus(!smartLight.getBSval());
|
|
smartLight.setLabel((short)-1);
|
|
smartLight.setLabel((short)-1);
|
|
- while(currentSimTime<lightEnd) {
|
|
|
|
- sim.getSimulationManager().simulateTimeIntervall(currentSimTime, stepLength);
|
|
|
|
- currentSimTime+=stepLength;
|
|
|
|
- }
|
|
|
|
|
|
+ sim.getSimulationManager().simulateTimeIntervall(currentSimTime, lightEnd-currentSimTime);
|
|
|
|
+ currentSimTime=lightEnd;
|
|
|
|
+
|
|
smartLight.setLabel((short)0);
|
|
smartLight.setLabel((short)0);
|
|
smartLight.setBSval(smartLight.isTrueStatus());
|
|
smartLight.setBSval(smartLight.isTrueStatus());
|
|
|
|
|
|
@@ -1084,20 +1112,23 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
/**
|
|
/**
|
|
* Schedule new light events
|
|
* Schedule new light events
|
|
*/
|
|
*/
|
|
- eventTime = 27 * hour;
|
|
|
|
- while(eventTime < 29 * hour) {
|
|
|
|
|
|
+ eventTime = lightEnd;
|
|
|
|
+ on = true;
|
|
|
|
+ while(eventTime < tempEnd) {
|
|
/**
|
|
/**
|
|
* At least 1 second between events
|
|
* At least 1 second between events
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+ final boolean newVal = on;
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
SimulationManager.scheduleEvent(new AbstractEvent(eventTime) {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void simulateEvent(long time) {
|
|
public void simulateEvent(long time) {
|
|
- smartLight.setBSval(!smartLight.isTrueStatus());
|
|
|
|
- smartLight.setTrueStatus(!smartLight.isTrueStatus());
|
|
|
|
|
|
+ smartLight.setTrueStatus(newVal);
|
|
|
|
+ smartLight.setBSval(newVal);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+ on = !on;
|
|
eventTime+=Math.max(1000, Math.round(lightDist.sample()));
|
|
eventTime+=Math.max(1000, Math.round(lightDist.sample()));
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1111,10 +1142,10 @@ public class MenuBarNetworkExamples extends JMenu{
|
|
heaterDevice.setFSval(21f);
|
|
heaterDevice.setFSval(21f);
|
|
heaterDevice.setTrueTemperature(34f);
|
|
heaterDevice.setTrueTemperature(34f);
|
|
heaterDevice.setLabel((short)-1);//-1 Value anomaly
|
|
heaterDevice.setLabel((short)-1);//-1 Value anomaly
|
|
- while(currentSimTime<tempEnd) {
|
|
|
|
- sim.getSimulationManager().simulateTimeIntervall(currentSimTime, stepLength);
|
|
|
|
- currentSimTime+=stepLength;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ sim.getSimulationManager().simulateTimeIntervall(currentSimTime, tempEnd-currentSimTime);
|
|
|
|
+ currentSimTime=tempEnd;
|
|
|
|
+
|
|
heaterDevice.setFSval(21f);
|
|
heaterDevice.setFSval(21f);
|
|
heaterDevice.setTrueTemperature(21f);
|
|
heaterDevice.setTrueTemperature(21f);
|
|
heaterDevice.setLabel((short)0);
|
|
heaterDevice.setLabel((short)0);
|