-
-
-
-
{{/each}}
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/index2.jsp b/src/main/webapp/WEB-INF/jsp/index2.jsp
new file mode 100644
index 0000000..9740e38
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/index2.jsp
@@ -0,0 +1,77 @@
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+
+<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+
+
+
WebSockets
+
+
" rel="stylesheet"/>
+
" rel="stylesheet"/>
+ ">
+ ">
+
+
+
+
+
CTDO Raumsteuerung
+
+
Par56:
+
+
+
+
+
Lampel:
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/webapp/resources/js/events.class.js b/src/main/webapp/resources/js/events.class.js
new file mode 100644
index 0000000..6801ccf
--- /dev/null
+++ b/src/main/webapp/resources/js/events.class.js
@@ -0,0 +1,51 @@
+//Copyright (c) 2010 Nicholas C. Zakas. All rights reserved.
+//MIT License
+
+function EventTarget(){
+ this._listeners = {};
+}
+
+EventTarget.prototype = {
+
+ constructor: EventTarget,
+
+ addListener: function(type, listener){
+ if (typeof this._listeners[type] == "undefined"){
+ this._listeners[type] = [];
+ }
+
+ this._listeners[type].push(listener);
+ },
+
+ fire: function(event){
+ if (typeof event == "string"){
+ event = { type: event };
+ }
+ if (!event.target){
+ event.target = this;
+ }
+
+ if (!event.type){ //falsy
+ throw new Error("Event object missing 'type' property.");
+ }
+
+ if (this._listeners[event.type] instanceof Array){
+ var listeners = this._listeners[event.type];
+ for (var i=0, len=listeners.length; i < len; i++){
+ listeners[i].call(this, event);
+ }
+ }
+ },
+
+ removeListener: function(type, listener){
+ if (this._listeners[type] instanceof Array){
+ var listeners = this._listeners[type];
+ for (var i=0, len=listeners.length; i < len; i++){
+ if (listeners[i] === listener){
+ listeners.splice(i, 1);
+ break;
+ }
+ }
+ }
+ }
+};
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/main.js b/src/main/webapp/resources/js/main.js
index 497b13f..31c9ec8 100644
--- a/src/main/webapp/resources/js/main.js
+++ b/src/main/webapp/resources/js/main.js
@@ -5,7 +5,9 @@
* Time: 00:51
* Main Javascript file
*/
-
+var events = new EventTarget();
+var roomDevices = [];
+var roomDeviceViews = [];
Workspace = Backbone.Router.extend({
routes:{
"":"home",
@@ -13,11 +15,27 @@ Workspace = Backbone.Router.extend({
},
home: function() {
+ function roomsLoadedHandler() {
+ rooms.each(function(room) {
+ var id = room.get('roomId');
+ roomDevices[id] = new RoomDevices();
+ roomDevices[id].url = '/resources/json/room' + id + '.json';
+ roomDevices[id].fetch();
+ });
+ events.removeListener("roomsLoaded", roomsLoadedHandler);
+ }
+ events.addListener("roomsLoaded", roomsLoadedHandler);
rooms.fetch();
+
},
show_room: function(id) {
this.home();
- window.roomTabsId = id;
+ function roomsLoadedHandlerTabSelect() {
+ $('#room-tabs').tabs('select', id);
+ events.removeListener("roomsLoaded", roomsLoadedHandlerTabSelect)
+ }
+ events.addListener("roomsLoaded", roomsLoadedHandlerTabSelect);
+
}
});
$(document).ready(function() {
diff --git a/src/main/webapp/resources/js/models.js b/src/main/webapp/resources/js/models.js
index 8ac1861..0ac0d47 100644
--- a/src/main/webapp/resources/js/models.js
+++ b/src/main/webapp/resources/js/models.js
@@ -5,8 +5,8 @@
url: '/resources/json/rooms.json'
});
window.Device = Backbone.Model.extend({});
- window.Devices = Backbone.Collection.extend({
- model: Device,
- url: '/control/devices'
+
+ window.RoomDevices = Backbone.Collection.extend({
+ model: Device
});
})(jQuery);
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/views.js b/src/main/webapp/resources/js/views.js
index d0fac59..0b4d9b7 100644
--- a/src/main/webapp/resources/js/views.js
+++ b/src/main/webapp/resources/js/views.js
@@ -3,12 +3,46 @@ window.RoomsView = Backbone.View.extend({
this.collection.bind('reset', this.render, this);
},
render: function() {
+ $('#room-tabs').tabs('destroy');
this.template = Handlebars.compile($("#room-tabs-template").html());
var rooms = {'rooms': this.collection.toJSON()};
- $('#room-tabs').html(this.template(rooms)).tabs();
- if(typeof(window.roomTabsId) != "undefined") {
- $('#room-tabs').tabs('select', window.roomTabsId);
- }
+ $('#room-tabs').html(this.template(rooms)).tabs({
+ select: function(event, ui) {
+ //set hashtag?
+ }
+ });
+ events.fire("roomsLoaded");
+
+ return this;
+ }
+});
+window.LampelView = Backbone.View.extend({
+ initialize: function() {
+ this.collection.bind('reset', this.render, this);
+ },
+ render: function() {
+ events.fire("lampelLoaded");
+
+ return this;
+ }
+});
+window.BuzzerView = Backbone.View.extend({
+ initialize: function() {
+ this.collection.bind('reset', this.render, this);
+ },
+ render: function() {
+ events.fire("buzzerLoaded");
+
+ return this;
+ }
+});
+window.Par56View = Backbone.View.extend({
+ initialize: function() {
+ this.collection.bind('reset', this.render, this);
+ },
+ render: function() {
+ events.fire("par56Loaded");
+
return this;
}
});
diff --git a/src/main/webapp/resources/json/room0.json b/src/main/webapp/resources/json/room0.json
new file mode 100644
index 0000000..b9911b0
--- /dev/null
+++ b/src/main/webapp/resources/json/room0.json
@@ -0,0 +1,11 @@
+[
+ {
+ "type":"Buzzer",
+ "deviceId":0,
+ "deviceName":"Buzzer",
+ "picture":null,
+ "options": {
+ "state":0
+ }
+ }
+]
\ No newline at end of file
diff --git a/src/main/webapp/resources/json/room1.json b/src/main/webapp/resources/json/room1.json
new file mode 100644
index 0000000..7f52483
--- /dev/null
+++ b/src/main/webapp/resources/json/room1.json
@@ -0,0 +1,85 @@
+[
+ {
+ "startAddress":1,
+ "type":"Par56Spot",
+ "deviceId":0,
+ "deviceName":"Par56 Lampe 1",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+ {
+ "startAddress":6,
+ "type":"Par56Spot",
+ "deviceId":1,
+ "deviceName":"Par56 Lampe 2",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+ {
+ "startAddress":11,
+ "type":"Par56Spot",
+ "deviceId":2,
+ "deviceName":"Par56 Lampe 3",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+ {
+ "startAddress":16,
+ "type":"Par56Spot",
+ "deviceId":3,
+ "deviceName":"Par56 Lampe 5",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+ {
+ "startAddress":21,
+ "type":"Strobe1500",
+ "deviceId":4,
+ "deviceName":"Stroboskop 1",
+ "picture":null,
+ "options": {
+ "mode":0,
+ "speed":0,
+ "intensity":0
+ }
+ },
+ {
+ "startAddress":508,
+ "type":"Par56Spot",
+ "deviceId":5,
+ "deviceName":"Par56 Lampe 5",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+ {
+ "type":"Lampel",
+ "deviceId":6,
+ "deviceName":"Lampel",
+ "picture":null,
+ "options": {
+ "red":0,
+ "green":0,
+ "blue":0
+ }
+ },
+]
\ No newline at end of file
diff --git a/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java b/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java
new file mode 100644
index 0000000..a474047
--- /dev/null
+++ b/src/test/java/de/ctdo/bunti/control/BuntiControllerImplTest.java
@@ -0,0 +1,40 @@
+package de.ctdo.bunti.control;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+//@ContextConfiguration(locations = { "classpath:/META-INF/spring/root-context.xml","classpath:/de/ctdo/bunti/hibernate-test-context.xml" })
+//@RunWith(SpringJUnit4ClassRunner.class)
+//public class BuntiControllerImplTest {
+
+// @Autowired
+// BuntiController dut;
+//
+// @Test
+// public void testUpdateDeviceData() throws Exception {
+//
+// }
+//
+// @Test
+// public void testGetAllRooms() throws Exception {
+//
+// }
+//
+// @Test
+// public void testGetRoomById() throws Exception {
+//
+// }
+//
+// @Test
+// public void testGetAllDevices() throws Exception {
+//
+// }
+//
+// @Test
+// public void testGetDeviceById() throws Exception {
+//
+// }
+//}
diff --git a/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java b/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java
deleted file mode 100644
index 46d34ce..0000000
--- a/src/test/java/de/ctdo/bunti/control/BuntiControllerTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package de.ctdo.bunti.control;
-
-import org.junit.Before;
-
-public class BuntiControllerTest {
-
- BuntiControllerImpl dut;
-
- @Before
- public void setUp() throws Exception {
- dut = new BuntiControllerImpl();
-// dut.setDevicesDAO(daoMock);
- }
-
-// @Test
-// public void testSetDevice() throws Exception {
-// Map
options = new HashMap();
-// options.put("optionA", "valueA");
-// options.put("optionB", 42);
-// assertTrue(dut.updateDeviceData(12, options));
-// }
-
-}
diff --git a/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java b/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java
new file mode 100644
index 0000000..f926a49
--- /dev/null
+++ b/src/test/java/de/ctdo/bunti/dao/BuntiDevicesDAOImplTest.java
@@ -0,0 +1,43 @@
+package de.ctdo.bunti.dao;
+
+import de.ctdo.bunti.model.BuntiDMXDevice;
+import de.ctdo.bunti.model.BuntiDevice;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+@ContextConfiguration(locations = { "classpath:/de/ctdo/bunti/hibernate-test-context.xml" })
+@RunWith(SpringJUnit4ClassRunner.class)
+public class BuntiDevicesDAOImplTest {
+
+ @Autowired
+ BuntiDevicesDAO dut;
+
+ @Test
+ public void testGetAllDMXDevices() throws Exception {
+ List deviceList = dut.getAllDMXDevices();
+ assertEquals(4, deviceList.size());
+ }
+
+ @Test
+ public void testGetAllDevices() throws Exception {
+ List deviceList = dut.getAllDevices();
+ assertEquals(4, deviceList.size());
+ }
+
+ @Test
+ public void testGetDeviceById() throws Exception {
+ BuntiDevice device = dut.getDeviceById(2);
+
+ assertEquals("Lampe2", device.getDeviceName());
+
+ }
+}
diff --git a/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java b/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java
new file mode 100644
index 0000000..881057c
--- /dev/null
+++ b/src/test/java/de/ctdo/bunti/dao/RoomsDAOImplTest.java
@@ -0,0 +1,34 @@
+package de.ctdo.bunti.dao;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+@ContextConfiguration(locations = { "classpath:/de/ctdo/bunti/hibernate-test-context.xml" })
+@RunWith(SpringJUnit4ClassRunner.class)
+public class RoomsDAOImplTest {
+
+ @Autowired
+ RoomsDAO dut;
+
+ @Test
+// @Transactional
+ public void testGetRooms() throws Exception {
+ assertEquals(4, dut.getRooms().size());
+ }
+
+ @Test
+ public void testGetRoomKueche() throws Exception {
+ assertEquals("Kueche", dut.getRoom(1).getName());
+ }
+
+ @Test
+ public void testGetRoomKuecheError() throws Exception {
+ assertNull(dut.getRoom(23));
+ }
+}
diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java
index df71b7f..6bb8375 100644
--- a/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java
+++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelTest.java
@@ -1,5 +1,6 @@
package de.ctdo.bunti.dmx;
+import de.ctdo.bunti.dmx.model.DMXChannel;
import org.junit.Before;
import org.junit.Test;
diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java
index cbc6922..d24c8b8 100644
--- a/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java
+++ b/src/test/java/de/ctdo/bunti/dmx/DMXChannelsTest.java
@@ -1,5 +1,6 @@
package de.ctdo.bunti.dmx;
+import de.ctdo.bunti.dmx.model.DMXChannel;
import org.junit.Before;
import org.junit.Test;
diff --git a/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java b/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java
index 50bc1ef..6d9b321 100644
--- a/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java
+++ b/src/test/java/de/ctdo/bunti/dmx/DMXMixerImplTest.java
@@ -36,7 +36,10 @@ public class DMXMixerImplTest {
@Test
public void testUpdateDevice() throws Exception {
- BuntiDevice device = new Par56Spot(23,42,"deviceName");
+ Par56Spot device = new Par56Spot();
+ device.setId(23);
+ device.setStartAddress(42);
+ device.setDeviceName("deviceName");
Map options = new HashMap();
options.put("red", 44);
assertTrue(dut.updateDevice(device, options));
@@ -44,7 +47,10 @@ public class DMXMixerImplTest {
@Test
public void testUpdateDeviceWrong1() throws Exception {
- BuntiDevice device = new Par56Spot(23,42,"deviceName");
+ Par56Spot device = new Par56Spot();
+ device.setId(23);
+ device.setStartAddress(42);
+ device.setDeviceName("deviceName");
assertFalse(dut.updateDevice(device, null));
}
@@ -57,14 +63,20 @@ public class DMXMixerImplTest {
@Test
public void testUpdateDeviceWrong3() throws Exception {
- BuntiDevice device = new Par56Spot(23,42,"deviceName");
+ Par56Spot device = new Par56Spot();
+ device.setId(23);
+ device.setStartAddress(42);
+ device.setDeviceName("deviceName");
Map options = new HashMap();
assertFalse(dut.updateDevice(device, options));
}
@Test
public void testUpdateDeviceWrong4() throws Exception {
- BuntiDevice device = new Par56Spot(23,42,"deviceName");
+ Par56Spot device = new Par56Spot();
+ device.setId(23);
+ device.setStartAddress(42);
+ device.setDeviceName("deviceName");
Map options = new HashMap();
options.put("rednonexistent", 44);
assertFalse(dut.updateDevice(device, options));
diff --git a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java
index c3583f9..8e69918 100644
--- a/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java
+++ b/src/test/java/de/ctdo/bunti/model/BuntiDMXDeviceTest.java
@@ -1,6 +1,6 @@
package de.ctdo.bunti.model;
-import de.ctdo.bunti.dmx.DMXChannel;
+import de.ctdo.bunti.dmx.model.DMXChannel;
import org.junit.Before;
import org.junit.Test;
@@ -16,7 +16,10 @@ public class BuntiDMXDeviceTest {
@Before
public void setUp() throws Exception {
- dut = new Par56Spot(DEVICEID,STARTADDRESS,"device");
+ dut = new Par56Spot();
+ dut.setId(23);
+ dut.setStartAddress(42);
+ dut.setDeviceName("deviceName");
}
@Test
@@ -139,7 +142,7 @@ public class BuntiDMXDeviceTest {
@Test
public void testGetDeviceId() throws Exception {
- assertEquals(DEVICEID, dut.getDeviceId());
+ assertEquals(DEVICEID, dut.getId());
}
@Test
diff --git a/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java b/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java
index fb1b664..5c304c3 100644
--- a/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java
+++ b/src/test/java/de/ctdo/bunti/model/Par56SpotTest.java
@@ -9,8 +9,10 @@ public class Par56SpotTest {
@Before
public void setUp() throws Exception {
- dut = new Par56Spot(23,42,"device");
-
+ dut = new Par56Spot();
+ dut.setId(23);
+ dut.setStartAddress(42);
+ dut.setDeviceName("device");
}
@Test
diff --git a/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java b/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java
index 91f2264..433556b 100644
--- a/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java
+++ b/src/test/java/de/ctdo/bunti/model/Strobe1500Test.java
@@ -10,8 +10,10 @@ public class Strobe1500Test {
@Before
public void setUp() throws Exception {
- dut = new Strobe1500(23,42,"device");
-
+ dut = new Strobe1500();
+ dut.setId(23);
+ dut.setStartAddress(42);
+ dut.setDeviceName("device");
}
@Test
diff --git a/src/test/resources/de/ctdo/bunti/hibernate-test-context.xml b/src/test/resources/de/ctdo/bunti/hibernate-test-context.xml
new file mode 100644
index 0000000..3def185
--- /dev/null
+++ b/src/test/resources/de/ctdo/bunti/hibernate-test-context.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ org.hibernate.dialect.HSQLDialect
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file