* @throws InvalidFormatException
*/
public SourceCollection() throws IOException, InvalidFormatException {
super();
cc = new Container("root");
StreamingMSDataSource ds1 = new StreamingMSDataSource("ds1", this, 200,_maxSize, 20000, 10,
20000, true, false, true, false);
cc.addDataSource(ds1);
map.put(DataInfo.getId(ds1), ds1);
add(ds1);
map.put(DataInfo.getId(ds1.getTime()), ds1.getTime());
add(ds1.getTime());
if (ds1.getTime2() != null) {
map.put(DataInfo.getId(ds1.getTime2()), ds1.getTime2());
add(ds1.getTime2());
}
if (ds1.getLabel() != null) {
map.put(DataInfo.getId(ds1.getLabel()), ds1.getLabel());
add(ds1.getLabel());
}
if (ds1.getStatus() != null) {
map.put(DataInfo.getId(ds1.getStatus()), ds1.getStatus());
add(ds1.getStatus());
}
if (ds1.getRaw() != null) {
map.put(DataInfo.getId(ds1.getRaw()), ds1.getRaw());
add(ds1.getRaw());
}
StreamingMSDataSource ds2 = new StreamingMSDataSource("ds2", this, 200,_maxSize, 20000, 10,
20000, true, false, true, false);
cc.addDataSource(ds2);
map.put(DataInfo.getId(ds2), ds2);
add(ds2);
map.put(DataInfo.getId(ds2.getTime()), ds2.getTime());
add(ds2.getTime());
if (ds2.getTime2() != null) {
map.put(DataInfo.getId(ds2.getTime2()), ds2.getTime2());
add(ds2.getTime2());
}
if (ds2.getLabel() != null) {
map.put(DataInfo.getId(ds2.getLabel()), ds2.getLabel());
add(ds2.getLabel());
}
if (ds2.getStatus() != null) {
map.put(DataInfo.getId(ds2.getStatus()), ds2.getStatus());
add(ds2.getStatus());
}
if (ds2.getRaw() != null) {
map.put(DataInfo.getId(ds2.getRaw()), ds2.getRaw());
add(ds2.getRaw());
}
Thread t = new Thread("StreamingMSDataPlugin") {
public void run() {
int cpt = 0;
while (true) {
try {
Thread.sleep(400);
double t = System.currentTimeMillis();
// update ds1
String label = "P";
if ((cpt % 4) == 0) {
label += "1";
}
if ((cpt % 4) == 1) {
label += "2";
}
if ((cpt % 4) == 2) {
label += "3";
}
if ((cpt % 4) == 3) {
label += "4";
}
StreamingMSDataSource ds1 = (StreamingMSDataSource) get("ds1");
ds1.add(t, Math.sin(cpt / 100.), label, 0, (long) (Math.sin(cpt) * 4), 0);
// update ds2
String onOffError = "";
if ((cpt % 4) == 1) {
onOffError = "ON";
} else if ((cpt % 4) == 2) {
onOffError = "OFF";
} else {
onOffError = "ERROR";
}
if ((cpt % 4) == 3) {
label += "4";
}
StreamingMSDataSource ds2 = (StreamingMSDataSource) get("ds2");
ds2.add(t, Math.sin(cpt / 100.), onOffError, 0, (long) (Math.sin(cpt) * 4), 0);
} catch (InterruptedException ie) {
}
cpt++;
}
}