MenuBarNetworkExamples.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.view.menuBar;
  2. import java.util.HashMap;
  3. import java.util.Iterator;
  4. import java.util.LinkedList;
  5. import java.util.Map.Entry;
  6. import javax.swing.JMenu;
  7. import javax.swing.JMenuItem;
  8. import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
  9. import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
  10. import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController;
  11. import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SimulationController;
  12. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
  13. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
  14. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
  15. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
  16. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
  17. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketCollector;
  18. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
  19. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
  20. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
  21. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
  22. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolCollectorDevice;
  23. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.BoolSensorDevice;
  24. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatCollectorDevice;
  25. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.devices.FloatSensorDevice;
  26. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.distributionHandler.NormalDistributionHandler;
  27. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
  28. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.CountingMetric;
  29. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.Manipulation_RandomMove;
  30. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
  31. import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
  32. public class MenuBarNetworkExamples extends JMenu{
  33. /**
  34. *
  35. */
  36. private static final long serialVersionUID = 1L;
  37. /**
  38. * Controller controller
  39. */
  40. private Controller controller;
  41. /**
  42. * Controller for editing the network
  43. */
  44. private NetworkController networkController;
  45. /**
  46. * Controller for configuration of the program
  47. */
  48. private SettingsController settingsController;
  49. /**
  50. * SimulationController for running the simulation
  51. */
  52. private SimulationController simulationController;
  53. /**
  54. * Creates the JMenu for network examples in the MenuBar
  55. * @param controller controller to create examples
  56. */
  57. public MenuBarNetworkExamples(Controller controller) {
  58. super("Create example Network");
  59. this.controller = controller;
  60. this.networkController = controller.getNetworkController();
  61. this.settingsController = controller.getSettingsController();
  62. this.simulationController = controller.getSimulationController();
  63. /**
  64. * MQTT example
  65. */
  66. JMenuItem mnMQTT = new JMenuItem("MQTT Example");
  67. mnMQTT.addActionListener(a->initializeMQTTTest());
  68. this.add(mnMQTT);
  69. /**
  70. * Small Network Test
  71. */
  72. JMenuItem mnTest = new JMenuItem("Network Example");
  73. mnTest.addActionListener(a->initializeTest());
  74. this.add(mnTest);
  75. /**
  76. * Performance Comparison Example
  77. */
  78. JMenuItem mnPerformance = new JMenuItem("Performane Evaluation Preset");
  79. mnPerformance.addActionListener(a->initializePerformanceTest());
  80. this.add(mnPerformance);
  81. /**
  82. * User Study Preset
  83. */
  84. JMenuItem mnUserStudy = new JMenuItem("User Study Preset");
  85. mnUserStudy.addActionListener(a->initializeUserStudy());
  86. this.add(mnUserStudy);
  87. /**
  88. * Packet Collection example
  89. */
  90. JMenuItem mnPacketCollectionExmample = new JMenuItem("Packet Collection Example");
  91. mnPacketCollectionExmample.addActionListener(a->testPackageCollection());
  92. this.add(mnPacketCollectionExmample);
  93. /**
  94. * Paper example
  95. */
  96. JMenuItem mnPaperExample = new JMenuItem("Paper Example");
  97. mnPaperExample.addActionListener(a->createPaperExample());
  98. this.add(mnPaperExample);
  99. }
  100. private void initializePerformanceTest(){
  101. SmartDevice tic = new SmartDevice("Tic");
  102. tic.setX(100);
  103. tic.setY(100);
  104. SmartDevice toc = new SmartDevice("Toc");
  105. toc.setX(100);
  106. toc.setY(250);
  107. networkController.addSmartDevice(tic);
  108. networkController.addSmartDevice(toc);
  109. Link l = new PrecisionLink("Channel");
  110. networkController.addLink(l);
  111. networkController.addLinkToDevice(l, tic);
  112. networkController.addLinkToDevice(l, toc);
  113. Port ticP = new Port(tic, (short)2, 200, (short)0, 0, (short)0);
  114. Port tocP = new Port(toc, (short)3, 200, (short)0, -100, (short)0);
  115. tic.addPort(ticP);
  116. toc.addPort(tocP);
  117. Connection con = new ConnectionPrecision(l, new SimpleProtocol());
  118. networkController.addConnection(con);
  119. networkController.addConnectionToLink(con, l);
  120. networkController.addDeviceToConnectionAndProtocol(ticP, con, 0);
  121. networkController.addDeviceToConnectionAndProtocol(tocP, con, 1);
  122. simulationController.setStepDuration(100000000);
  123. simulationController.setEndTime(1000000000);
  124. controller.notifyObservers();
  125. }
  126. /**
  127. * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
  128. */
  129. private void initializeUserStudy(){
  130. /**
  131. * Preset one SmartDevice
  132. */
  133. SmartDevice A = new SmartDevice("Homestation");
  134. A.setX(200);
  135. A.setY(200);
  136. networkController.addSmartDevice(A);
  137. /**
  138. * Packagecollector, which is registered at the Device
  139. */
  140. PacketCollector collector = new PacketCollector(new CountingMetric());
  141. simulationController.getPacketCaptureController().addPacketCollector(collector);
  142. simulationController.getPacketCaptureController().addDeviceToCollector(collector, A);
  143. simulationController.setPrintPackets(true);
  144. controller.notifyObservers();
  145. }
  146. /**
  147. * Test package collectors
  148. */
  149. private void testPackageCollection() {
  150. simulationController.addAlgorithm(new Manipulation_RandomMove(), controller);
  151. PacketCollector collector = new PacketCollector();
  152. simulationController.getSimulationManager().getPacketCollectionManager().addPacketCollector(collector);
  153. System.out.println("Collector 0-500 - nothing collected:");
  154. simulationController.getSimulationManager().simulateTimeIntervall(0, 500);
  155. HashMap<Link, LinkedList<Packet>> map = collector.getPackets();
  156. for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
  157. System.out.println("Link: "+e.getKey().getName());
  158. for(Packet p : e.getValue())
  159. System.out.println(p.getTextualRepresentation());
  160. }
  161. System.out.println("");
  162. System.out.println("");
  163. Iterator<SmartDevice> it = networkController.getSmartDevices().iterator();
  164. it.next();
  165. SmartDevice d = it.next();
  166. collector.addDevice(d);
  167. SmartDevice f = it.next();
  168. collector.addDevice(f);
  169. System.out.println("Collector 500-1000 - "+d.getName()+" & "+f.getName()+" collected:");
  170. simulationController.getSimulationManager().simulateTimeIntervall(500, 500);
  171. map = collector.getPackets();
  172. for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
  173. System.out.println("Link: "+e.getKey().getName());
  174. for(Packet p : e.getValue())
  175. System.out.println(p.getTextualRepresentation());
  176. }
  177. System.out.println("");
  178. System.out.println("");
  179. Link l = networkController.getLinks().iterator().next();
  180. collector.addLink(l);
  181. System.out.println("Collector 2000-3000 - "+l+" collected:");
  182. simulationController.getSimulationManager().simulateTimeIntervall(1000, 500);
  183. map = collector.getPackets();
  184. for(Entry<Link, LinkedList<Packet>> e:map.entrySet()){
  185. System.out.println("Link: "+e.getKey().getName());
  186. for(Packet p : e.getValue())
  187. System.out.println(p.getTextualRepresentation());
  188. }
  189. simulationController.resetSimulation();
  190. controller.notifyObservers();
  191. }
  192. /**
  193. * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
  194. */
  195. private void initializeTest(){
  196. SmartDevice A = null, B = null, C = null;
  197. for(int i = 0; i<5; i++){
  198. A = new SmartDevice("SmartTV"+i);
  199. A.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  200. A.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  201. B = new SmartDevice("SmartDoor"+i);
  202. B.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  203. B.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  204. C = new SmartDevice("SmartLight"+i);
  205. C.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  206. C.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  207. networkController.addSmartDevice(A);
  208. networkController.addSmartDevice(B);
  209. networkController.addSmartDevice(C);
  210. }
  211. Link link = new SimpleLink("SimpleWifi");
  212. link.addDevice(A);
  213. link.addDevice(B);
  214. link.addDevice(C);
  215. A.addLink(link);
  216. B.addLink(link);
  217. C.addLink(link);
  218. Port a = new Port(A, (short) 1, 68);
  219. a.setLastTrigger(0);
  220. a.setStatus(Port.SENDING);
  221. A.addPort(a);
  222. Port b = new Port(B, (short) 2, 102);
  223. b.setStatus(Port.SENDING);
  224. B.addPort(b);
  225. Connection s = new ConnectionPerformance(link, new SimpleProtocol(a, b));
  226. s.setPacketLossProbability(0.01);//1% Packet loss probability
  227. a.setConnection(s);
  228. b.setConnection(s);
  229. s.addSmartDevice(a);
  230. s.addSmartDevice(b);
  231. link.addConnection(s);
  232. networkController.addLink(link);
  233. networkController.addConnection(s);
  234. controller.notifyObservers();
  235. }
  236. /**
  237. * Initializes a basic test Network, which contains a few SmartDevices, one Link and one Connection
  238. */
  239. private void initializeMQTTTest(){
  240. SimpleLink link = new SimpleLink("WIFI");
  241. link.setFixedDelay(5);
  242. SmartDevice broker = new SmartDevice("MQTT-Broker");
  243. broker.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  244. broker.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  245. networkController.addSmartDevice(broker);
  246. Port brokerPort = new Port(broker, (short) 0, 987);
  247. brokerPort.setLastTrigger(0);
  248. brokerPort.setStatus(Port.OPEN);
  249. broker.addPort(brokerPort);
  250. link.addDevice(broker);
  251. broker.addLink(link);
  252. Protocol protocol = new MQTT_protocol(brokerPort);
  253. Connection con = new ConnectionPrecision(link, protocol);
  254. con.setPacketLossProbability(0.01);//1% Packet loss probability
  255. con.addSmartDevice(brokerPort);
  256. brokerPort.setConnection(con);
  257. con.setStatus(Connection.ACTIVE);
  258. networkController.addLink(link);
  259. link.addConnection(con);
  260. networkController.addConnection(con);
  261. SmartDevice A = null, A1 = null, A2 = null, B = null, C = null;
  262. Port aP,a1P,a2P,bP,cP;
  263. for(int i = 0; i<3; i++){
  264. FloatSensorDevice aS = new FloatSensorDevice("SmartThermostat"+i+"(Pub)");
  265. aS.setFSinfoName("room"+i+"/temperature");
  266. A=aS;
  267. A.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  268. A.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  269. link.addDevice(A);
  270. A.addLink(link);
  271. aP = new Port(A,((short) (3*i+1)),100+(int)(Math.random()*900));
  272. aP.setLastTrigger(0);
  273. aP.setJitter((short) (Math.random()*50));
  274. aP.setStatus(Port.SENDING);
  275. aP.setConnection(con);
  276. protocol.addDeviceOfRole(aP, 2);
  277. con.addSmartDevice(aP);
  278. A.addPort(aP);
  279. networkController.addSmartDevice(A);
  280. FloatCollectorDevice aS1 = new FloatCollectorDevice("SmartAirCondition"+i+"(Sub)");
  281. aS1.setFCinfoName("room"+i+"/temperature");
  282. A1=aS1;
  283. A1.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  284. A1.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  285. link.addDevice(A1);
  286. A1.addLink(link);
  287. a1P = new Port(A1,((short) (3*i+1)),100+(int)(Math.random()*900));
  288. a1P.setLastTrigger(0);
  289. a1P.setJitter((short) (Math.random()*50));
  290. a1P.setStatus(Port.SENDING);
  291. a1P.setConnection(con);
  292. protocol.addDeviceOfRole(a1P, 3);
  293. con.addSmartDevice(a1P);
  294. A1.addPort(a1P);
  295. networkController.addSmartDevice(A1);
  296. FloatCollectorDevice aS2 = new FloatCollectorDevice("SmartHeater"+i+"(Sub)");
  297. aS2.setFCinfoName("room"+i+"/temperature");
  298. A2=aS2;
  299. A2.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  300. A2.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  301. link.addDevice(A2);
  302. A2.addLink(link);
  303. a2P = new Port(A2,((short) (3*i+1)),100+(int)(Math.random()*900));
  304. a2P.setLastTrigger(0);
  305. a2P.setJitter((short) (Math.random()*50));
  306. a2P.setStatus(Port.SENDING);
  307. a2P.setConnection(con);
  308. protocol.addDeviceOfRole(a2P, 3);
  309. con.addSmartDevice(a2P);
  310. A2.addPort(a2P);
  311. networkController.addSmartDevice(A2);
  312. B = new BoolSensorDevice("SmartDoor"+i+"(Pub)");
  313. ((BoolSensorDevice)B).setBSinfoName("room"+i+"/DoorOpen");
  314. B.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  315. B.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  316. link.addDevice(B);
  317. B.addLink(link);
  318. bP = new Port(B,((short) (3*i+2)),10+(int)(Math.random()*190));
  319. bP.setLastTrigger(0);
  320. bP.setJitter((short) (Math.random()*50));
  321. bP.setStatus(Port.SENDING);
  322. bP.setConnection(con);
  323. protocol.addDeviceOfRole(bP, 2);
  324. con.addSmartDevice(bP);
  325. B.addPort(bP);
  326. networkController.addSmartDevice(B);
  327. C = new BoolCollectorDevice("SmartDoorStatusLight"+i+"(Sub)");
  328. ((BoolCollectorDevice)C).setBCinfoName("room"+i+"/DoorOpen");
  329. C.setX((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  330. C.setY((int)(Math.random()*settingsController.getWidth()-2*settingsController.getDeviceVisualizationRadius())+settingsController.getDeviceVisualizationRadius());
  331. link.addDevice(C);
  332. C.addLink(link);
  333. cP = new Port(C,((short) (3*i+1)), 50+(int)(Math.random()*450));
  334. cP.setLastTrigger(0);
  335. cP.setJitter((short) (Math.random()*50));
  336. cP.setStatus(Port.SENDING);
  337. cP.setConnection(con);
  338. protocol.addDeviceOfRole(cP, 3);
  339. con.addSmartDevice(cP);
  340. C.addPort(cP);
  341. networkController.addSmartDevice(C);
  342. controller.notifyObservers();
  343. }
  344. }
  345. public void createPaperExample(){
  346. /*
  347. * Main networking devices
  348. */
  349. SmartDevice router = networkController.createSmartDevice("Wifi-Router", 500, 100, 50);
  350. SmartDevice zigBeeRouter = networkController.createSmartDevice("ZigBee-Router", 500, 300, 50);
  351. SmartDevice broker = networkController.createSmartDevice("Broker", 500, 500, 50);
  352. /*
  353. * Links/Networks
  354. */
  355. Link wifi = new PrecisionLink("Wifi");
  356. networkController.addLink(wifi);
  357. Link zigbee = new PrecisionLink("ZigBee");
  358. networkController.addLink(zigbee);
  359. /*
  360. * Connect Devices to Links
  361. */
  362. networkController.addLinkToDevice(wifi, router);
  363. networkController.addLinkToDevice(wifi, zigBeeRouter);
  364. networkController.addLinkToDevice(zigbee, zigBeeRouter);
  365. networkController.addLinkToDevice(zigbee, broker);
  366. /*
  367. * Internet Access Connection
  368. */
  369. Connection inetAcces = new ConnectionPrecision();
  370. inetAcces.setName("Cloud Access");
  371. networkController.addConnectionToLink(inetAcces, wifi);
  372. inetAcces.setProtocol(new SimpleProtocol());
  373. Port pRouter = new Port(router, (short)80, 500L);
  374. pRouter.setTriggerHandler(new NormalDistributionHandler(500, 100));
  375. networkController.addDeviceToConnectionAndProtocol(pRouter, inetAcces, 0);
  376. Port pZigBee = new Port(zigBeeRouter, (short)80, 1000L);
  377. pZigBee.setTriggerHandler(new NormalDistributionHandler(1000, 300));
  378. networkController.addDeviceToConnectionAndProtocol(pRouter, inetAcces, 0);
  379. networkController.addDeviceToConnectionAndProtocol(pZigBee, inetAcces, 1);
  380. networkController.addConnection(inetAcces);
  381. /*
  382. * ZigbeeRouter -> Broker ?
  383. */
  384. Connection homeAutomationInternetAccess = new ConnectionPrecision();
  385. homeAutomationInternetAccess.setName("Home Automation Webinterface");
  386. networkController.addConnectionToLink(homeAutomationInternetAccess, zigbee);
  387. homeAutomationInternetAccess.setProtocol(new SimpleProtocol());
  388. Port pBrokerWebInterface = new Port(broker, (short)80);
  389. pBrokerWebInterface.setTriggerHandler(new NormalDistributionHandler(2000, 500));
  390. pBrokerWebInterface.setStatus(Port.SENDING);
  391. pBrokerWebInterface.setResponseTime((short)2);
  392. pBrokerWebInterface.setLastTrigger(-284L);
  393. networkController.addDeviceToConnectionAndProtocol(pBrokerWebInterface, homeAutomationInternetAccess, 0);
  394. networkController.addConnection(homeAutomationInternetAccess);
  395. Port pRouterWebInterface = new Port(zigBeeRouter, (short)80);
  396. pRouterWebInterface.setTriggerHandler(new NormalDistributionHandler(5000, 3000));
  397. pRouterWebInterface.setStatus(Port.SENDING);
  398. pRouterWebInterface.setResponseTime((short)2);
  399. pRouterWebInterface.setLastTrigger(-142L);
  400. networkController.addDeviceToConnectionAndProtocol(pRouterWebInterface, homeAutomationInternetAccess, 1);
  401. networkController.addConnection(homeAutomationInternetAccess);
  402. /*
  403. * Create MQTT Connection
  404. */
  405. Connection mqtt = new ConnectionPrecision();
  406. mqtt.setName("Automation (MQTT)");
  407. networkController.addConnectionToLink(mqtt, zigbee);
  408. mqtt.setProtocol(new MQTT_protocol());
  409. Port pBroker = new Port(broker, (short)1883);
  410. pBroker.setStatus(Port.OPEN);
  411. pBroker.setResponseTime((short)2);
  412. networkController.addDeviceToConnectionAndProtocol(pBroker, mqtt, 0);
  413. networkController.addConnection(mqtt);
  414. /*
  415. * Add some MQTT Devices
  416. */
  417. /**
  418. * Kitchen Thermostat
  419. */
  420. FloatSensorDevice floatSensor = new FloatSensorDevice("Kitchen Thermostat");
  421. floatSensor.setFSinfoName("home/kitchen/temperature");
  422. networkController.addLinkToDevice(zigbee, floatSensor);
  423. networkController.moveSmartDevice(floatSensor, 300, 500, 50);
  424. floatSensor.setFSmin(15.0f);
  425. floatSensor.setFSmax(32.0f);
  426. networkController.addSmartDevice(floatSensor);
  427. Port pFloatSensor = new Port(floatSensor, (short)1883, 15000);
  428. pFloatSensor.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  429. pFloatSensor.setStatus(Port.SENDING);
  430. pFloatSensor.setLastTrigger(-357L);
  431. networkController.addDeviceToConnectionAndProtocol(pFloatSensor, mqtt,1);
  432. /*
  433. * Add Fridge
  434. */
  435. FloatSensorDevice kitchenFridge = new FloatSensorDevice("Smart Fridge");
  436. kitchenFridge.setFSinfoName("home/kitchen/fridgeTemp");
  437. networkController.addLinkToDevice(zigbee, kitchenFridge);
  438. networkController.moveSmartDevice(kitchenFridge, 100, 600, 50);
  439. kitchenFridge.setFSmin(-4.0f);
  440. kitchenFridge.setFSmax(12.0f);
  441. networkController.addSmartDevice(kitchenFridge);
  442. Port pKitchenFridge = new Port(kitchenFridge, (short)1883, 15000);
  443. pKitchenFridge.setStatus(Port.SENDING);
  444. pKitchenFridge.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  445. pKitchenFridge.setLastTrigger(-1231L);
  446. networkController.addDeviceToConnectionAndProtocol(pKitchenFridge, mqtt,1);
  447. /*
  448. * Add some kitchen lights
  449. */
  450. BoolSensorDevice kitchenLight = new BoolSensorDevice("Kitchen Light");
  451. kitchenLight.setBSinfoName("home/kitchen/light");
  452. networkController.addLinkToDevice(zigbee, kitchenLight);
  453. networkController.moveSmartDevice(kitchenLight, 250, 400, 50);
  454. networkController.addSmartDevice(kitchenLight);
  455. Port pKitchenLight = new Port(kitchenLight, (short)1883, 15000);
  456. pKitchenLight.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  457. pKitchenLight.setStatus(Port.SENDING);
  458. pKitchenLight.setLastTrigger(-1207L);
  459. networkController.addDeviceToConnectionAndProtocol(pKitchenLight, mqtt,1);
  460. //TODO Further devices & Connections
  461. /*
  462. * Bedroom
  463. */
  464. BoolSensorDevice sleepingRoomLight = new BoolSensorDevice("Bedroom Light");
  465. sleepingRoomLight.setBSinfoName("home/bedroom/light");
  466. networkController.addLinkToDevice(zigbee, sleepingRoomLight);
  467. networkController.moveSmartDevice(sleepingRoomLight, 750, 400, 50);
  468. networkController.addSmartDevice(sleepingRoomLight);
  469. Port pBedroomLight = new Port(sleepingRoomLight, (short)1883, 15000);
  470. pBedroomLight.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  471. pBedroomLight.setStatus(Port.SENDING);
  472. pBedroomLight.setLastTrigger(-1337L);
  473. networkController.addDeviceToConnectionAndProtocol(pBedroomLight, mqtt,1);
  474. /*
  475. * Bedroom Thermostat
  476. */
  477. FloatSensorDevice bedroomThermostat = new FloatSensorDevice("Bedroom Thermostat");
  478. bedroomThermostat.setFSinfoName("home/bedroom/temperature");
  479. networkController.addLinkToDevice(zigbee, bedroomThermostat);
  480. networkController.moveSmartDevice(bedroomThermostat, 700, 500, 50);
  481. bedroomThermostat.setFSmin(15.0f);
  482. bedroomThermostat.setFSmax(32.0f);
  483. networkController.addSmartDevice(bedroomThermostat);
  484. Port pBedroomThermostat = new Port(bedroomThermostat, (short)1883, 15000);
  485. pBedroomThermostat.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  486. pBedroomThermostat.setStatus(Port.SENDING);
  487. pBedroomThermostat.setLastTrigger(-820L);
  488. networkController.addDeviceToConnectionAndProtocol(pBedroomThermostat, mqtt,1);
  489. /*
  490. * Bedroom Info Screen
  491. */
  492. FloatCollectorDevice bedroomInfoScreen = new FloatCollectorDevice("Information Panel");
  493. bedroomInfoScreen.setFCinfoName("home/kitchen/fridgeTemp");
  494. networkController.addLinkToDevice(zigbee, bedroomInfoScreen);
  495. networkController.moveSmartDevice(bedroomInfoScreen, 900, 600, 50);
  496. networkController.addSmartDevice(bedroomInfoScreen);
  497. Port pBedroomInfo = new Port(bedroomInfoScreen, (short)1883, 15000);
  498. pBedroomInfo.setStatus(Port.SENDING);
  499. pBedroomInfo.setTriggerHandler(new NormalDistributionHandler(15000, 500));
  500. pBedroomInfo.setLastTrigger(-666L);
  501. networkController.addDeviceToConnectionAndProtocol(pBedroomInfo, mqtt,1);
  502. /*
  503. * Update visualization
  504. */
  505. controller.notifyObservers();
  506. }
  507. }