merge complete
This commit is contained in:
commit
f1bae83556
45
pom.xml
45
pom.xml
|
@ -47,6 +47,13 @@
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${org.springframework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
@ -73,15 +80,9 @@
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.validation</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>validation-api</artifactId>
|
<artifactId>spring-orm</artifactId>
|
||||||
<version>1.0.0.GA</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hibernate</groupId>
|
|
||||||
<artifactId>hibernate-validator</artifactId>
|
|
||||||
<version>4.1.0.Final</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -90,12 +91,32 @@
|
||||||
<version>3.6.7.Final</version>
|
<version>3.6.7.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-commons-annotations</artifactId>
|
||||||
|
<version>3.2.0.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate.javax.persistence</groupId>
|
||||||
|
<artifactId>hibernate-jpa-2.0-api</artifactId>
|
||||||
|
<version>1.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hsqldb</groupId>
|
<groupId>org.hsqldb</groupId>
|
||||||
<artifactId>hsqldb</artifactId>
|
<artifactId>hsqldb</artifactId>
|
||||||
<version>1.8.0.10</version>
|
<version>1.8.0.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<version>1.3.160</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
|
@ -147,11 +168,7 @@
|
||||||
<artifactId>jetty-server</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
<version>${jettyVersion}</version>
|
<version>${jettyVersion}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework</groupId>
|
|
||||||
<artifactId>spring-orm</artifactId>
|
|
||||||
<version>3.0.6.RELEASE</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class ByteUtils {
|
||||||
private final byte[] data;
|
private final byte[] data;
|
||||||
|
|
||||||
public ByteUtils(byte[] data) {
|
public ByteUtils(byte[] data) {
|
||||||
this.data = data;
|
this.data = data.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int byteToUint(byte b) {
|
public static int byteToUint(byte b) {
|
||||||
|
@ -40,7 +40,7 @@ public class ByteUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final byte[] getBytes() {
|
public final byte[] getBytes() {
|
||||||
return data;
|
return data.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getInt16(int offset) {
|
public final int getInt16(int offset) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public abstract class ArtNetPacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setData(byte[] data) {
|
public final void setData(byte[] data) {
|
||||||
this.data = new ByteUtils(data);
|
this.data = new ByteUtils(data.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final PacketType getType() {
|
public final PacketType getType() {
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
package de.ctdo.bunti.artnet.packets;
|
package de.ctdo.bunti.artnet.packets;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public enum PacketType {
|
public enum PacketType {
|
||||||
|
|
||||||
ART_POLL(0x2000, null),
|
ART_POLL(0x2000, null),
|
||||||
|
@ -47,6 +50,8 @@ public enum PacketType {
|
||||||
|
|
||||||
private final int opCode;
|
private final int opCode;
|
||||||
private final Class<? extends ArtNetPacket> packetClass;
|
private final Class<? extends ArtNetPacket> packetClass;
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(PacketType.class);
|
||||||
|
|
||||||
|
|
||||||
private PacketType(int code, Class<? extends ArtNetPacket> clazz) {
|
private PacketType(int code, Class<? extends ArtNetPacket> clazz) {
|
||||||
opCode = code;
|
opCode = code;
|
||||||
|
@ -59,9 +64,9 @@ public enum PacketType {
|
||||||
try {
|
try {
|
||||||
p = packetClass.newInstance();
|
p = packetClass.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Could not instanciate ArtNetPacket: ",e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Could not instanciate ArtNetPacket: ",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.ctdo.bunti.control;
|
package de.ctdo.bunti.control;
|
||||||
|
|
||||||
import de.ctdo.bunti.model.BuntiDevice;
|
import de.ctdo.bunti.model.BuntiDevice;
|
||||||
|
import de.ctdo.bunti.model.Room;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -12,4 +13,7 @@ public interface BuntiController {
|
||||||
|
|
||||||
boolean updateDeviceData(int deviceId, Map<String, Object> options);
|
boolean updateDeviceData(int deviceId, Map<String, Object> options);
|
||||||
|
|
||||||
|
Collection<Room> getAllRooms();
|
||||||
|
Room getRoomById(int roomId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import de.ctdo.bunti.dao.BuntiDevicesDAO;
|
||||||
import de.ctdo.bunti.model.*;
|
import de.ctdo.bunti.model.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class BuntiControllerImpl implements BuntiController, ApplicationEventPublisherAware {
|
public class BuntiControllerImpl implements BuntiController, ApplicationEventPublisherAware {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerImpl.class);
|
||||||
private ApplicationEventPublisher applicationEventPublisher = null;
|
private ApplicationEventPublisher applicationEventPublisher = null;
|
||||||
private BuntiDevicesDAO devicesDAO;
|
private BuntiDevicesDAO devicesDAO;
|
||||||
|
@ -54,6 +54,16 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Room> getAllRooms() {
|
||||||
|
return roomsDAO.getRooms();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Room getRoomById(int roomId) {
|
||||||
|
return roomsDAO.getRoom(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<BuntiDevice> getAllDevices() {
|
public Collection<BuntiDevice> getAllDevices() {
|
||||||
return devicesDAO.getAllDevices();
|
return devicesDAO.getAllDevices();
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
package de.ctdo.bunti.dao;
|
package de.ctdo.bunti.dao;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ctdo.bunti.model.*;
|
import de.ctdo.bunti.model.*;
|
||||||
|
|
||||||
public interface BuntiDevicesDAO {
|
public interface BuntiDevicesDAO {
|
||||||
|
|
||||||
Collection<BuntiDevice> getAllDevices();
|
List<BuntiDevice> getAllDevices();
|
||||||
Collection<BuntiDMXDevice> getAllDMXDevices();
|
List<BuntiDMXDevice> getAllDMXDevices();
|
||||||
BuntiDevice getDeviceById(int deviceId);
|
BuntiDevice getDeviceById(int deviceId);
|
||||||
|
|
||||||
|
void addDevice(BuntiDevice device);
|
||||||
|
void removeDevice(int deviceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,36 @@
|
||||||
package de.ctdo.bunti.dao;
|
package de.ctdo.bunti.dao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import de.ctdo.bunti.model.*;
|
import de.ctdo.bunti.model.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
@Repository
|
|
||||||
public final class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiDevicesDAOImpl.class);
|
|
||||||
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
|
|
||||||
|
|
||||||
public BuntiDevicesDAOImpl() {
|
|
||||||
addDummyDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void addDummyDevices() {
|
public final class BuntiDevicesDAOImpl extends HibernateDaoSupport implements BuntiDevicesDAO {
|
||||||
int deviceID = 0;
|
|
||||||
|
|
||||||
devices.add(new Par56Spot(deviceID++, 1, "Par56 Lampe 1"));
|
|
||||||
devices.add(new Par56Spot(deviceID++, 6, "Par56 Lampe 2"));
|
|
||||||
devices.add(new Par56Spot(deviceID++, 11, "Par56 Lampe 3"));
|
|
||||||
devices.add(new Par56Spot(deviceID++, 16, "Par56 Lampe 4"));
|
|
||||||
devices.add(new Strobe1500(deviceID++, 21, "Stroboskop 1"));
|
|
||||||
devices.add(new Par56Spot(deviceID, 508, "Par56 Lampe 5"));
|
|
||||||
LOGGER.debug("added dummy devices in DAO");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<BuntiDMXDevice> getAllDMXDevices() {
|
public List<BuntiDMXDevice> getAllDMXDevices() {
|
||||||
List<BuntiDMXDevice> list = new ArrayList<BuntiDMXDevice>();
|
return getHibernateTemplate().loadAll(BuntiDMXDevice.class);
|
||||||
for (BuntiDevice device : devices) {
|
|
||||||
if( device instanceof BuntiDMXDevice ) {
|
|
||||||
list.add((BuntiDMXDevice) device);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<BuntiDevice> getAllDevices() {
|
public List<BuntiDevice> getAllDevices() {
|
||||||
return Collections.unmodifiableCollection(devices);
|
return getHibernateTemplate().loadAll(BuntiDevice.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuntiDevice getDeviceById(int deviceId) {
|
public BuntiDevice getDeviceById(int deviceId) {
|
||||||
for (BuntiDevice dev : devices) {
|
return getHibernateTemplate().get(BuntiDevice.class,deviceId);
|
||||||
if(dev.getDeviceId() == deviceId) {
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDevice(BuntiDevice device) {
|
||||||
|
getHibernateTemplate().save(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDevice(int deviceId) {
|
||||||
|
getHibernateTemplate().delete(getDeviceById(deviceId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,9 @@ import de.ctdo.bunti.model.Room;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: lucas
|
|
||||||
* @date: 15.03.12 21:55
|
|
||||||
*/
|
|
||||||
public interface RoomsDAO {
|
public interface RoomsDAO {
|
||||||
|
|
||||||
List<Room> getRooms();
|
List<Room> getRooms();
|
||||||
Room getRoom(int id);
|
Room getRoom(int id);
|
||||||
Room addRoom(Room room);
|
Room addRoom(Room room);
|
||||||
void removeRoom(int id);
|
void removeRoom(int id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,10 @@ package de.ctdo.bunti.dao;
|
||||||
|
|
||||||
import de.ctdo.bunti.model.Room;
|
import de.ctdo.bunti.model.Room;
|
||||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public final class RoomsDAOImpl extends HibernateDaoSupport implements RoomsDAO {
|
public final class RoomsDAOImpl extends HibernateDaoSupport implements RoomsDAO {
|
||||||
|
|
||||||
public RoomsDAOImpl() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Room> getRooms() {
|
public List<Room> getRooms() {
|
||||||
return getHibernateTemplate().loadAll(Room.class);
|
return getHibernateTemplate().loadAll(Room.class);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package de.ctdo.bunti.dmx;
|
package de.ctdo.bunti.dmx;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package de.ctdo.bunti.dmx;
|
package de.ctdo.bunti.dmx.model;
|
||||||
|
|
||||||
public class DMXChannel {
|
public class DMXChannel {
|
||||||
private int offset;
|
private int offset;
|
|
@ -1,28 +1,30 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
import de.ctdo.bunti.dmx.DMX;
|
import de.ctdo.bunti.dmx.DMX;
|
||||||
import de.ctdo.bunti.dmx.DMXChannel;
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
import de.ctdo.bunti.dmx.DMXChannels;
|
import de.ctdo.bunti.dmx.DMXChannels;
|
||||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||||
|
import org.hibernate.annotations.Entity;
|
||||||
|
|
||||||
|
import javax.persistence.Transient;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
@Entity
|
||||||
public abstract class BuntiDMXDevice extends BuntiDevice {
|
public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
private int startAddress;
|
private int startAddress;
|
||||||
private final DMXChannels dmxChannels = new DMXChannels();
|
private final DMXChannels dmxChannels = new DMXChannels();
|
||||||
|
|
||||||
public BuntiDMXDevice(int deviceId, int startAddress, String name) {
|
public BuntiDMXDevice() {
|
||||||
super(deviceId, name);
|
|
||||||
setStartAddress(startAddress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the DMX start address for this device
|
* Gets the DMX start address for this device
|
||||||
* @return The address value from 1 to max 512
|
* @return The address value from 1 to max 512
|
||||||
*/
|
*/
|
||||||
public final int getStartAddress() {
|
public int getStartAddress() {
|
||||||
return startAddress;
|
return startAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +33,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
* @param startAddress The address value from 1 to max 512
|
* @param startAddress The address value from 1 to max 512
|
||||||
* @return True on success, false if start address is wrong
|
* @return True on success, false if start address is wrong
|
||||||
*/
|
*/
|
||||||
public final boolean setStartAddress(int startAddress) {
|
public boolean setStartAddress(int startAddress) {
|
||||||
if(startAddress < DMX.DMX_CHANNEL_INDEX_MIN ||
|
if(startAddress < DMX.DMX_CHANNEL_INDEX_MIN ||
|
||||||
startAddress - 1 + dmxChannels.getCount() > DMX.DMX_CHANNEL_INDEX_MAX) {
|
startAddress - 1 + dmxChannels.getCount() > DMX.DMX_CHANNEL_INDEX_MAX) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -62,6 +64,8 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
* @param name The channel name to get the value from.
|
* @param name The channel name to get the value from.
|
||||||
* @return The desired channel value.
|
* @return The desired channel value.
|
||||||
*/
|
*/
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
protected final int getChannelValueByName(String name) {
|
protected final int getChannelValueByName(String name) {
|
||||||
DMXChannel dx = dmxChannels.getChannelByName(name);
|
DMXChannel dx = dmxChannels.getChannelByName(name);
|
||||||
if (dx != null) {
|
if (dx != null) {
|
||||||
|
@ -75,6 +79,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
* @return The channel data with startaddress+offset of every channel
|
* @return The channel data with startaddress+offset of every channel
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public Map<Integer, Integer> getChannelData() {
|
public Map<Integer, Integer> getChannelData() {
|
||||||
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
|
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
|
||||||
|
|
||||||
|
@ -106,6 +111,18 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
@Override
|
||||||
|
public final Map<String, Object> getOptions() {
|
||||||
|
Map<String, Object> options = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
for(DMXChannel channel: dmxChannels.getAllChannels()) {
|
||||||
|
options.put(channel.getName(), channel.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a channel to this DMX Device
|
* Add a channel to this DMX Device
|
||||||
* used internally by subclasses to define their structure
|
* used internally by subclasses to define their structure
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,43 +8,53 @@ import java.util.Map;
|
||||||
* Maybe this is a lamp, or a switchable power source, or a strobe, ...
|
* Maybe this is a lamp, or a switchable power source, or a strobe, ...
|
||||||
* @author lucas
|
* @author lucas
|
||||||
*/
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "devices")
|
||||||
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
||||||
public abstract class BuntiDevice {
|
public abstract class BuntiDevice {
|
||||||
private int deviceId;
|
private int id;
|
||||||
private String deviceName;
|
private String deviceName;
|
||||||
private String picture;
|
private String picture;
|
||||||
|
|
||||||
public BuntiDevice(int deviceId, String deviceName) {
|
public BuntiDevice() {
|
||||||
this.deviceId = deviceId;
|
|
||||||
this.deviceName = deviceName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of this device
|
* Get the type of this device
|
||||||
* @return a string with the class name (=the Type)
|
* @return a string with the class name (=the Type)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@Transient
|
||||||
public final String getType() {
|
public final String getType() {
|
||||||
String FQClassName = this.getClass().getName();
|
String fqClassName = this.getClass().getName();
|
||||||
int firstChar = FQClassName.lastIndexOf ('.') + 1;
|
int firstChar = fqClassName.lastIndexOf ('.') + 1;
|
||||||
if ( firstChar > 0 ) {
|
if ( firstChar > 0 ) {
|
||||||
FQClassName = FQClassName.substring ( firstChar );
|
fqClassName = fqClassName.substring ( firstChar );
|
||||||
}
|
}
|
||||||
return FQClassName;
|
return fqClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the device Id
|
* Gets the device Id
|
||||||
* @return the device Id
|
* @return the device Id
|
||||||
*/
|
*/
|
||||||
public final int getDeviceId() {
|
@Id
|
||||||
return deviceId;
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "BUNTIDEVICE_ID", updatable=false, nullable=false)
|
||||||
|
public final int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the device name
|
* Gets the device name
|
||||||
* @return The name of the device
|
* @return The name of the device
|
||||||
*/
|
*/
|
||||||
public final String getDeviceName() {
|
public String getDeviceName() {
|
||||||
return deviceName;
|
return deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +62,7 @@ public abstract class BuntiDevice {
|
||||||
* Sets the device Name
|
* Sets the device Name
|
||||||
* @param deviceName a String with the device name
|
* @param deviceName a String with the device name
|
||||||
*/
|
*/
|
||||||
public final void setDeviceName(String deviceName) {
|
public void setDeviceName(String deviceName) {
|
||||||
this.deviceName = deviceName;
|
this.deviceName = deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +70,7 @@ public abstract class BuntiDevice {
|
||||||
* Get the relative URL to the picture of this device
|
* Get the relative URL to the picture of this device
|
||||||
* @return the relative URL to the picture
|
* @return the relative URL to the picture
|
||||||
*/
|
*/
|
||||||
public final String getPicture() {
|
public String getPicture() {
|
||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +78,7 @@ public abstract class BuntiDevice {
|
||||||
* Get the relative URL to the picture of this device
|
* Get the relative URL to the picture of this device
|
||||||
* @param picture The relative URL to the picture
|
* @param picture The relative URL to the picture
|
||||||
*/
|
*/
|
||||||
public final void setPicture(String picture) {
|
public void setPicture(String picture) {
|
||||||
this.picture = picture;
|
this.picture = picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,4 +101,8 @@ public abstract class BuntiDevice {
|
||||||
public abstract boolean setValuesFromOptions(Map<String, Object> options);
|
public abstract boolean setValuesFromOptions(Map<String, Object> options);
|
||||||
|
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public abstract Map<String, Object> getOptions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Transient;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Entity
|
||||||
public abstract class BuntiSwitchingDevice extends BuntiDevice {
|
public abstract class BuntiSwitchingDevice extends BuntiDevice {
|
||||||
private static final String OPTION_STATE = "state";
|
private static final String OPTION_STATE = "state";
|
||||||
|
|
||||||
private boolean state = false;
|
private boolean state = false;
|
||||||
|
|
||||||
public BuntiSwitchingDevice(int deviceId, String deviceName) {
|
public BuntiSwitchingDevice() {
|
||||||
super(deviceId, deviceName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean setValuesFromOptions(Map<String, Object> options) {
|
public final boolean setValuesFromOptions(Map<String, Object> options) {
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public abstract class BuntiSwitchingDevice extends BuntiDevice {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
public boolean isState() {
|
public boolean isState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
import de.ctdo.bunti.dmx.DMX;
|
import de.ctdo.bunti.dmx.DMX;
|
||||||
import de.ctdo.bunti.dmx.DMXChannel;
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
|
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
@Entity
|
||||||
public class Par56Spot extends BuntiDMXDevice {
|
public class Par56Spot extends BuntiDMXDevice {
|
||||||
|
|
||||||
private static final String CHANNEL_MODE = "mode";
|
private static final String CHANNEL_MODE = "mode";
|
||||||
|
@ -11,8 +16,12 @@ public class Par56Spot extends BuntiDMXDevice {
|
||||||
private static final String CHANNEL_BLUE = "blue";
|
private static final String CHANNEL_BLUE = "blue";
|
||||||
private static final String CHANNEL_SPEED = "speed";
|
private static final String CHANNEL_SPEED = "speed";
|
||||||
|
|
||||||
public Par56Spot(int deviceId, int startAddress, String deviceName) {
|
public Par56Spot() {
|
||||||
super(deviceId, startAddress, deviceName);
|
super();
|
||||||
|
addChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addChannels() {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
addChannel(new DMXChannel(offset++, CHANNEL_MODE));
|
addChannel(new DMXChannel(offset++, CHANNEL_MODE));
|
||||||
addChannel(new DMXChannel(offset++, CHANNEL_RED));
|
addChannel(new DMXChannel(offset++, CHANNEL_RED));
|
||||||
|
@ -33,14 +42,20 @@ public class Par56Spot extends BuntiDMXDevice {
|
||||||
setChannelValueByName(CHANNEL_BLUE, value);
|
setChannelValueByName(CHANNEL_BLUE, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getRed() {
|
public final int getRed() {
|
||||||
return getChannelValueByName(CHANNEL_RED);
|
return getChannelValueByName(CHANNEL_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getGreen() {
|
public final int getGreen() {
|
||||||
return getChannelValueByName(CHANNEL_GREEN);
|
return getChannelValueByName(CHANNEL_GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getBlue() {
|
public final int getBlue() {
|
||||||
return getChannelValueByName(CHANNEL_BLUE);
|
return getChannelValueByName(CHANNEL_BLUE);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +82,7 @@ public class Par56Spot extends BuntiDMXDevice {
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Par56Spot ");
|
sb.append("Par56Spot ");
|
||||||
sb.append(getDeviceId());
|
sb.append(getId());
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
sb.append(getDeviceName());
|
sb.append(getDeviceName());
|
||||||
sb.append(" [");
|
sb.append(" [");
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.persistence.*;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table( name = "rooms" )
|
||||||
public final class Room {
|
public final class Room {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String floor;
|
||||||
|
private int xCord;
|
||||||
|
private int yCord;
|
||||||
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
|
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "ROOM_ID", updatable=false, nullable=false)
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +26,7 @@ public final class Room {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Column( name = "roomName")
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -27,26 +35,62 @@ public final class Room {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getxCord() {
|
||||||
|
return xCord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setxCord(int xCord) {
|
||||||
|
this.xCord = xCord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getyCord() {
|
||||||
|
return yCord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setyCord(int yCord) {
|
||||||
|
this.yCord = yCord;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getFloor() {
|
||||||
|
return floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFloor(String floor) {
|
||||||
|
this.floor = floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = BuntiDevice.class)
|
||||||
|
@JoinTable(name = "ROOM_BUNTIDEVICE",
|
||||||
|
joinColumns = { @JoinColumn(name = "ROOM_ID") },
|
||||||
|
inverseJoinColumns = { @JoinColumn(name = "BUNTIDEVICE_ID") })
|
||||||
|
public List<BuntiDevice> getDevices() {
|
||||||
|
return Collections.unmodifiableList(this.devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevices(List<BuntiDevice> devices) {
|
||||||
|
this.devices = devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transient
|
||||||
public boolean addDevice(BuntiDevice device) {
|
public boolean addDevice(BuntiDevice device) {
|
||||||
return devices.add(device);
|
return getDevices().add(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
public boolean removeDevice(BuntiDevice device) {
|
public boolean removeDevice(BuntiDevice device) {
|
||||||
return devices.remove(device);
|
return getDevices().remove(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
public BuntiDevice getDevice(int id) {
|
public BuntiDevice getDevice(int id) {
|
||||||
for (BuntiDevice device: devices) {
|
for (BuntiDevice device: getDevices()) {
|
||||||
if( device.getDeviceId() == id) {
|
if( device.getId() == id) {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<BuntiDevice> getDeviceList() {
|
|
||||||
return Collections.unmodifiableList(devices);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
package de.ctdo.bunti.model;
|
package de.ctdo.bunti.model;
|
||||||
|
|
||||||
import de.ctdo.bunti.dmx.DMX;
|
import de.ctdo.bunti.dmx.DMX;
|
||||||
import de.ctdo.bunti.dmx.DMXChannel;
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
|
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
@Entity
|
||||||
public class Strobe1500 extends BuntiDMXDevice {
|
public class Strobe1500 extends BuntiDMXDevice {
|
||||||
|
|
||||||
private static final String CHANNEL_SPEED = "speed";
|
private static final String CHANNEL_SPEED = "speed";
|
||||||
private static final String CHANNEL_INTENSITY = "intensity";
|
private static final String CHANNEL_INTENSITY = "intensity";
|
||||||
private static final String CHANNEL_MODE = "mode";
|
private static final String CHANNEL_MODE = "mode";
|
||||||
|
|
||||||
public Strobe1500(int deviceId, int startAddress, String deviceName) {
|
public Strobe1500() {
|
||||||
super(deviceId, startAddress, deviceName);
|
super();
|
||||||
|
addChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addChannels() {
|
||||||
addChannel(new DMXChannel(0, CHANNEL_SPEED));
|
addChannel(new DMXChannel(0, CHANNEL_SPEED));
|
||||||
addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
|
addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
|
||||||
addChannel(new DMXChannel(2, CHANNEL_MODE));
|
addChannel(new DMXChannel(2, CHANNEL_MODE));
|
||||||
|
@ -29,14 +37,20 @@ public class Strobe1500 extends BuntiDMXDevice {
|
||||||
return setChannelValueByName(CHANNEL_MODE, value);
|
return setChannelValueByName(CHANNEL_MODE, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getSpeed() {
|
public final int getSpeed() {
|
||||||
return getChannelValueByName(CHANNEL_SPEED);
|
return getChannelValueByName(CHANNEL_SPEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getIntensity() {
|
public final int getIntensity() {
|
||||||
return getChannelValueByName(CHANNEL_INTENSITY);
|
return getChannelValueByName(CHANNEL_INTENSITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@Transient
|
||||||
public final int getMode() {
|
public final int getMode() {
|
||||||
return getChannelValueByName(CHANNEL_MODE);
|
return getChannelValueByName(CHANNEL_MODE);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +73,7 @@ public class Strobe1500 extends BuntiDMXDevice {
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Strobe1500 ");
|
sb.append("Strobe1500 ");
|
||||||
sb.append(getDeviceId());
|
sb.append(getId());
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
sb.append(getDeviceName());
|
sb.append(getDeviceName());
|
||||||
sb.append(" [");
|
sb.append(" [");
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package de.ctdo.bunti.web;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.control.BuntiController;
|
||||||
|
import de.ctdo.bunti.webmodel.DeviceUpdate;
|
||||||
|
import de.ctdo.bunti.webmodel.DeviceUpdates;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/control")
|
||||||
|
public class DeviceControlController {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceControlController.class);
|
||||||
|
private BuntiController controller;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public final void setController(BuntiController controller) {
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/devices", method = RequestMethod.POST)
|
||||||
|
public void setDevices(@RequestBody DeviceUpdates updates) {
|
||||||
|
LOGGER.info("handle PUT /devices" + " request update=" + updates.toString() );
|
||||||
|
|
||||||
|
for (DeviceUpdate update: updates.getUpdates()) {
|
||||||
|
LOGGER.info("Update deviceId=" + update.getDeviceId());
|
||||||
|
controller.updateDeviceData(update.getDeviceId(), update.getOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package de.ctdo.bunti.web;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.dao.BuntiDevicesDAO;
|
||||||
|
import de.ctdo.bunti.model.BuntiDevice;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/devices")
|
||||||
|
public class DevicesController {
|
||||||
|
private BuntiDevicesDAO devicesDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
|
||||||
|
this.devicesDAO = devicesDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody Collection<BuntiDevice> getAll() {
|
||||||
|
return devicesDAO.getAllDevices();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody BuntiDevice getDeviceById(@PathVariable("id") int id) {
|
||||||
|
return devicesDAO.getDeviceById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "", method = RequestMethod.POST)
|
||||||
|
public @ResponseBody BuntiDevice setDevices(@RequestBody BuntiDevice device) {
|
||||||
|
devicesDAO.addDevice(device);
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,62 +0,0 @@
|
||||||
package de.ctdo.bunti.web;
|
|
||||||
|
|
||||||
import de.ctdo.bunti.control.BuntiController;
|
|
||||||
import de.ctdo.bunti.model.BuntiDevice;
|
|
||||||
import de.ctdo.bunti.webmodel.DeviceUpdate;
|
|
||||||
import de.ctdo.bunti.webmodel.DeviceUpdates;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.Validator;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping(value = "/control")
|
|
||||||
public class RestController {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RestController.class);
|
|
||||||
private BuntiController controller;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public final void setController(BuntiController controller) {
|
|
||||||
this.controller = controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/devices", method = RequestMethod.GET)
|
|
||||||
public @ResponseBody Collection<BuntiDevice> getAll() {
|
|
||||||
LOGGER.info("handle GET /devices request");
|
|
||||||
return controller.getAllDevices();
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/devices/{id}", method = RequestMethod.GET)
|
|
||||||
public @ResponseBody BuntiDevice getDeviceById(@PathVariable("id") int id) {
|
|
||||||
LOGGER.info("handle GET /devices/" + id + " request");
|
|
||||||
return controller.getDeviceById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/devices/{id}", method = RequestMethod.POST)
|
|
||||||
public @ResponseBody BuntiDevice setDeviceById(@PathVariable("id") int id, @RequestBody DeviceUpdate update) {
|
|
||||||
LOGGER.info("handle PUT /devices/" + id + " request update=" + update.toString() );
|
|
||||||
|
|
||||||
|
|
||||||
controller.updateDeviceData(id, update.getOptions());
|
|
||||||
return controller.getDeviceById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/devices", method = RequestMethod.POST)
|
|
||||||
public String setDevices(@RequestBody DeviceUpdates updates) {
|
|
||||||
LOGGER.info("handle PUT /devices" + " request update=" + updates.toString() );
|
|
||||||
|
|
||||||
for (DeviceUpdate update: updates.getUpdates()) {
|
|
||||||
LOGGER.info("Update deviceId=" + update.getDeviceId());
|
|
||||||
|
|
||||||
controller.updateDeviceData(update.getDeviceId(), update.getOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
return "bla";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package de.ctdo.bunti.web;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.dao.RoomsDAO;
|
||||||
|
import de.ctdo.bunti.model.BuntiDevice;
|
||||||
|
import de.ctdo.bunti.model.Room;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/rooms")
|
||||||
|
public class RoomsController {
|
||||||
|
private RoomsDAO roomsDAO;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setRoomsDAO(RoomsDAO roomsDAO) {
|
||||||
|
this.roomsDAO = roomsDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody Collection<Room> getAll() {
|
||||||
|
return roomsDAO.getRooms();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody Room getRoomById(@PathVariable("id") int id) {
|
||||||
|
return roomsDAO.getRoom(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{id}/devices", method = RequestMethod.GET)
|
||||||
|
public @ResponseBody
|
||||||
|
List<BuntiDevice> getDevicesFromRoom(@PathVariable("id") int id) {
|
||||||
|
Room room = roomsDAO.getRoom(id);
|
||||||
|
|
||||||
|
if(room != null) {
|
||||||
|
return room.getDevices();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
package de.ctdo.bunti.webmodel;
|
package de.ctdo.bunti.webmodel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Klasse gibts nur, weil ich es nicht hinbekomme mit Jackson
|
||||||
|
* ein ArrayList<DeviceUpdate> als Parameter im Controller zu verarbeiten.
|
||||||
|
*/
|
||||||
public class DeviceUpdates {
|
public class DeviceUpdates {
|
||||||
|
|
||||||
private long timeStamp = 0;
|
private long timeStamp = 0;
|
||||||
|
|
||||||
private List<DeviceUpdate> updates = new ArrayList<DeviceUpdate>();
|
private List<DeviceUpdate> updates = new ArrayList<DeviceUpdate>();
|
||||||
|
|
||||||
|
|
||||||
public List<DeviceUpdate> getUpdates() {
|
public List<DeviceUpdate> getUpdates() {
|
||||||
return updates;
|
return updates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,43 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"
|
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"
|
||||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc">
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc">
|
||||||
|
|
||||||
<jdbc:embedded-database id="dataSource" type="HSQL">
|
<jdbc:embedded-database id="dataSource" type="H2">
|
||||||
<jdbc:script location="classpath:init.sql" />
|
<jdbc:script location="classpath:init_schema.sql" />
|
||||||
|
<jdbc:script location="classpath:init_data.sql" />
|
||||||
</jdbc:embedded-database>
|
</jdbc:embedded-database>
|
||||||
|
|
||||||
<bean id="hibernateSessionFactory"
|
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
||||||
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
|
<property name="packagesToScan" value="de.ctdo.bunti.model"/>
|
||||||
<property name="mappingResources">
|
|
||||||
<list>
|
|
||||||
<value>/bunti.hbm.xml</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="hibernateProperties">
|
<property name="hibernateProperties">
|
||||||
<props>
|
<props>
|
||||||
<prop key="hibernate.dialect">
|
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
|
||||||
org.hibernate.dialect.HSQLDialect
|
|
||||||
</prop>
|
|
||||||
<prop key="hibernate.show_sql">true</prop>
|
<prop key="hibernate.show_sql">true</prop>
|
||||||
<!-- <prop key="hibernate.hbm2ddl.auto">create</prop> -->
|
<!--<prop key="hibernate.hbm2ddl.auto">create</prop>-->
|
||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
<property name="dataSource" ref="dataSource" />
|
<property name="dataSource" ref="dataSource" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="transactionManager"
|
<bean id="roomsDAO" class="de.ctdo.bunti.dao.RoomsDAOImpl">
|
||||||
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
|
||||||
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="roomsDAO" class="de.ctdo.bunti.dao.RoomsDAOImpl">
|
<bean id="devicesDAO" class="de.ctdo.bunti.dao.BuntiDevicesDAOImpl">
|
||||||
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
|
||||||
|
|
||||||
|
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||||
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
|
<tx:annotation-driven />
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE hibernate-mapping PUBLIC
|
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
|
||||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
|
||||||
<hibernate-mapping auto-import="true">
|
|
||||||
|
|
||||||
<class name="de.ctdo.bunti.model.Room" table="rooms" >
|
|
||||||
<id name="id" unsaved-value="0">
|
|
||||||
<generator class="native"/>
|
|
||||||
</id>
|
|
||||||
<property name="name"/>
|
|
||||||
</class>
|
|
||||||
|
|
||||||
</hibernate-mapping>
|
|
|
@ -1,2 +1,2 @@
|
||||||
db.driverClassName=org.hsqldb.jdbcDriver
|
#db.driverClassName=org.hsqldb.jdbcDriver
|
||||||
db.url=jdbc:hsqldb:mem:buntiserver
|
#db.url=jdbc:hsqldb:mem:buntiserver
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
DROP TABLE DUAL_HIBERNATE_SEQUENCE IF EXISTS
|
|
||||||
DROP TABLE ROOMS IF EXISTS
|
|
||||||
DROP TABLE SEQUENCE IF EXISTS
|
|
||||||
|
|
||||||
|
|
||||||
CREATE MEMORY TABLE SEQUENCE(SEQ_NAME VARCHAR(50) NOT NULL PRIMARY KEY,SEQ_COUNT NUMERIC(38))
|
|
||||||
CREATE MEMORY TABLE ROOMS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,NAME VARCHAR(255))
|
|
||||||
CREATE MEMORY TABLE DUAL_HIBERNATE_SEQUENCE(ZERO INTEGER)
|
|
||||||
INSERT INTO SEQUENCE VALUES('SEQ_GEN',0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
|
||||||
|
insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Etage', 'Kueche', '0', '0');
|
||||||
|
insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Etage', 'Wohnzimmer', '0', '1');
|
||||||
|
insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Etage', 'Werkstatt', '1', '0');
|
||||||
|
insert into rooms (ROOM_ID, floor, roomName, xCord, yCord) values (null, '2. Etage', 'Flur', '1', '1');
|
||||||
|
|
||||||
|
|
||||||
|
insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress)
|
||||||
|
values ('Par56Spot',null,'Lampe1',null, 1);
|
||||||
|
insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress)
|
||||||
|
values ('Par56Spot',null,'Lampe2',null, 6);
|
||||||
|
insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress)
|
||||||
|
values ('Par56Spot',null,'Lampe3',null, 11);
|
||||||
|
insert into devices (DTYPE, BUNTIDEVICE_ID, deviceName, picture, startAddress)
|
||||||
|
values ('Par56Spot',null,'Lampe4',null, 16);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
drop table ROOM_BUNTIDEVICE if exists;
|
||||||
|
drop table devices if exists;
|
||||||
|
drop table rooms if exists;
|
||||||
|
|
||||||
|
create table ROOM_BUNTIDEVICE (ROOM_ID integer not null, BUNTIDEVICE_ID int not null,
|
||||||
|
primary key (ROOM_ID, BUNTIDEVICE_ID), unique (BUNTIDEVICE_ID));
|
||||||
|
|
||||||
|
create table devices (DTYPE varchar(31) not null,
|
||||||
|
BUNTIDEVICE_ID integer generated by default as identity (start with 1),
|
||||||
|
deviceName varchar(255),
|
||||||
|
picture varchar(255),
|
||||||
|
startAddress integer,
|
||||||
|
primary key (BUNTIDEVICE_ID));
|
||||||
|
|
||||||
|
create table rooms (ROOM_ID integer generated by default as identity (start with 1),
|
||||||
|
floor varchar(255),
|
||||||
|
roomName varchar(255),
|
||||||
|
xCord integer not null,
|
||||||
|
yCord integer not null,
|
||||||
|
primary key (ROOM_ID));
|
||||||
|
|
||||||
|
alter table ROOM_BUNTIDEVICE add constraint FK96EF8F028BB4B62 foreign key (ROOM_ID) references rooms;
|
||||||
|
alter table ROOM_BUNTIDEVICE add constraint FK96EF8F021E9F392 foreign key (BUNTIDEVICE_ID) references devices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
#log4j.rootLogger=debug, stdout
|
|
||||||
|
|
||||||
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
|
||||||
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
|
||||||
|
|
||||||
# Print the date in ISO 8601 format
|
|
||||||
##log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
|
||||||
#log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c: %m%n
|
|
||||||
|
|
||||||
#log4j.appender.R=org.apache.log4j.RollingFileAppender
|
|
||||||
#log4j.appender.R.File=application.log
|
|
||||||
#log4j.appender.R.MaxFileSize=100KB
|
|
||||||
#log4j.appender.R.MaxBackupIndex=1
|
|
||||||
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
|
||||||
#log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
|
|
|
@ -15,18 +15,18 @@
|
||||||
<level value="info" />
|
<level value="info" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<logger name="org.springframework.orm">
|
|
||||||
<level value="debug" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
|
|
||||||
<logger name="de.ctdo">
|
<logger name="de.ctdo">
|
||||||
<level value="debug" />
|
<level value="debug" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.hibernate">
|
||||||
|
<level value="info" />
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<priority value="debug" />
|
<priority value="info" />
|
||||||
<appender-ref ref="console" />
|
<appender-ref ref="console" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<link type="text/css" href="<c:url value="/resources/css/smoothness/jquery-ui-1.8.18.custom.css"/>" rel="stylesheet" />
|
<link type="text/css" href="<c:url value="/resources/css/smoothness/jquery-ui-1.8.18.custom.css"/>" rel="stylesheet" />
|
||||||
<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.7.1.min.js" />"></script>
|
<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.7.1.min.js" />"></script>
|
||||||
<script type="text/javascript" src="<c:url value="/resources/js/jquery-ui-1.8.18.custom.min.js" />"></script>
|
<script type="text/javascript" src="<c:url value="/resources/js/jquery-ui-1.8.18.custom.min.js" />"></script>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/js/events.class.js" />"></script>
|
||||||
<script type="text/javascript" src="<c:url value="/resources/js/jquery.cookie.js" />"></script>
|
<script type="text/javascript" src="<c:url value="/resources/js/jquery.cookie.js" />"></script>
|
||||||
<script type="text/javascript" src="<c:url value="/resources/js/underscore.js" />"></script>
|
<script type="text/javascript" src="<c:url value="/resources/js/underscore.js" />"></script>
|
||||||
<script type="text/javascript" src="<c:url value="/resources/js/backbone-min.js" />"></script>
|
<script type="text/javascript" src="<c:url value="/resources/js/backbone-min.js" />"></script>
|
||||||
|
@ -26,45 +27,8 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>CTDO Raumsteuerung</h1>
|
<h1>CTDO Raumsteuerung</h1>
|
||||||
|
<div id="container">
|
||||||
<div id="room-tabs">
|
<div id="room-tabs">
|
||||||
<ul>
|
|
||||||
<li><a href="#tabs-1">Global</a></li>
|
|
||||||
<li><a href="#tabs-2">Raum 1</a></li>
|
|
||||||
</ul>
|
|
||||||
<div id="tabs-1">
|
|
||||||
</div>
|
|
||||||
<div id="tabs-2">
|
|
||||||
<div id="v-tabs" class="inner-tabs-container">
|
|
||||||
<ul>
|
|
||||||
<li><a href="#v-tabs-1">Licht</a></li>
|
|
||||||
<li><a href="#v-tabs-2">Musik</a></li>
|
|
||||||
<li><a href="#v-tabs-3">Lampel</a></li>
|
|
||||||
</ul>
|
|
||||||
<div id="v-tabs-1">
|
|
||||||
<div id="colorpicker-raum1"></div>
|
|
||||||
<select multiple="multiple" id="par56select">
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div id="v-tabs-2">
|
|
||||||
<label for="slider1">Lautstärke Raum 1:</label><div id="slider1" class="slider"></div>
|
|
||||||
</div>
|
|
||||||
<div id="v-tabs-3">
|
|
||||||
<div class="lampel">
|
|
||||||
<span class="circle red" title="click to toggle"></span>
|
|
||||||
<span class="circle yellow" title="click to toggle"></span>
|
|
||||||
<span class="circle green" title="click to toggle"></span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="switch">
|
|
||||||
Raumlicht:<br />
|
|
||||||
<input type="radio" name="raum-1-licht">An <input type="radio" name="raum-1-licht" checked="checked">Aus
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -80,6 +44,20 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/x-handlebars-template" id="room-vertical-tabs-template">
|
||||||
|
<div id="room{{roomId}}-vertical-tabs" class="ui-tabs-vertical">
|
||||||
|
<ul>
|
||||||
|
{{#each types}}
|
||||||
|
<li><a href="#room{{roomId}}-vertical-tabs-{{id}}">{{typeName}}</a></li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
{{#each types}}
|
||||||
|
<div id="room{{roomId}}-vertical-tabs-{{id}}">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
<script type="text/x-handlebars-template" id="par56-options-template">
|
<script type="text/x-handlebars-template" id="par56-options-template">
|
||||||
{{#each devices}}
|
{{#each devices}}
|
||||||
<option name="{{deviceId}}">{{deviceName}}</option>
|
<option name="{{deviceId}}">{{deviceName}}</option>
|
||||||
|
@ -91,6 +69,15 @@
|
||||||
<button>Buzzern</button>
|
<button>Buzzern</button>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/x-handlebars-template" id="lampel-template">
|
||||||
|
|
||||||
|
<div class="lampel">
|
||||||
|
<span class="circle red" title="click to toggle"></span>
|
||||||
|
<span class="circle yellow" title="click to toggle"></span>
|
||||||
|
<span class="circle green" title="click to toggle"></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
<script type="text/x-handlebars-template">
|
<script type="text/x-handlebars-template">
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
|
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>WebSockets</title>
|
||||||
|
|
||||||
|
<link type="text/css" href="<c:url value="/resources/css/screen.css"/>" rel="stylesheet"/>
|
||||||
|
<link type="text/css" href="<c:url value="/resources/css/styles.css"/>" rel="stylesheet"/>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.7.1.min.js" />"></script>
|
||||||
|
<script type="text/javascript" src="<c:url value="/resources/js/main.js" />"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function sendData(data) {
|
||||||
|
var time = Math.round(new Date().getTime() / 1000);
|
||||||
|
data = {"timeStamp":time, "updates":data};
|
||||||
|
$.ajax({
|
||||||
|
type:'POST',
|
||||||
|
url:"/control/devices",
|
||||||
|
contentType:"application/json",
|
||||||
|
dataType:"json",
|
||||||
|
data:JSON.stringify(data)
|
||||||
|
});
|
||||||
|
console.log(data);
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
}
|
||||||
|
$('#par56 .pink').click(function () {
|
||||||
|
data = [
|
||||||
|
{"deviceId":0, "options":{"red":255, "green":0, "blue":40}},
|
||||||
|
{"deviceId":1, "options":{"red":255, "green":0, "blue":40}},
|
||||||
|
{"deviceId":2, "options":{"red":255, "green":0, "blue":40}},
|
||||||
|
{"deviceId":3, "options":{"red":255, "green":0, "blue":40}}
|
||||||
|
];
|
||||||
|
sendData(data);
|
||||||
|
});
|
||||||
|
$('#par56 .gruen').click(function () {
|
||||||
|
data = [
|
||||||
|
{"deviceId":0, "options":{"red":0, "green":255, "blue":0}},
|
||||||
|
{"deviceId":1, "options":{"red":0, "green":255, "blue":0}},
|
||||||
|
{"deviceId":2, "options":{"red":0, "green":255, "blue":0}},
|
||||||
|
{"deviceId":3, "options":{"red":0, "green":255, "blue":0}}
|
||||||
|
];
|
||||||
|
sendData(data);
|
||||||
|
});
|
||||||
|
$('#par56 .rot').click(function () {
|
||||||
|
data = [
|
||||||
|
{"deviceId":0, "options":{"red":255, "green":0, "blue":0}},
|
||||||
|
{"deviceId":1, "options":{"red":255, "green":0, "blue":0}},
|
||||||
|
{"deviceId":2, "options":{"red":255, "green":0, "blue":0}},
|
||||||
|
{"deviceId":3, "options":{"red":255, "green":0, "blue":0}}
|
||||||
|
];
|
||||||
|
sendData(data);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>CTDO Raumsteuerung</h1>
|
||||||
|
|
||||||
|
<p id="par56">Par56: <br>
|
||||||
|
<button class="pink">Pink</button>
|
||||||
|
<button class="gruen">Grün</button>
|
||||||
|
<button class="rot">Rot</button>
|
||||||
|
</p>
|
||||||
|
<p id="lampel">Lampel:<br>
|
||||||
|
<button class="rota">Rot (an)</button>
|
||||||
|
<button class="gelba">Gelb (an)</button>
|
||||||
|
<button class="gruena">Grün (an)</button>
|
||||||
|
<button class="roto">Rot (aus)</button>
|
||||||
|
<button class="gelbo">Gelb (aus)</button>
|
||||||
|
<button class="grueno">Grün (aus)</button>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -5,7 +5,9 @@
|
||||||
* Time: 00:51
|
* Time: 00:51
|
||||||
* Main Javascript file
|
* Main Javascript file
|
||||||
*/
|
*/
|
||||||
|
var events = new EventTarget();
|
||||||
|
var roomDevices = [];
|
||||||
|
var roomDeviceViews = [];
|
||||||
Workspace = Backbone.Router.extend({
|
Workspace = Backbone.Router.extend({
|
||||||
routes:{
|
routes:{
|
||||||
"":"home",
|
"":"home",
|
||||||
|
@ -13,11 +15,27 @@ Workspace = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
home: function() {
|
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();
|
rooms.fetch();
|
||||||
|
|
||||||
},
|
},
|
||||||
show_room: function(id) {
|
show_room: function(id) {
|
||||||
this.home();
|
this.home();
|
||||||
window.roomTabsId = id;
|
function roomsLoadedHandlerTabSelect() {
|
||||||
|
$('#room-tabs').tabs('select', id);
|
||||||
|
events.removeListener("roomsLoaded", roomsLoadedHandlerTabSelect)
|
||||||
|
}
|
||||||
|
events.addListener("roomsLoaded", roomsLoadedHandlerTabSelect);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
url: '/resources/json/rooms.json'
|
url: '/resources/json/rooms.json'
|
||||||
});
|
});
|
||||||
window.Device = Backbone.Model.extend({});
|
window.Device = Backbone.Model.extend({});
|
||||||
window.Devices = Backbone.Collection.extend({
|
|
||||||
model: Device,
|
window.RoomDevices = Backbone.Collection.extend({
|
||||||
url: '/control/devices'
|
model: Device
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
|
@ -3,12 +3,46 @@ window.RoomsView = Backbone.View.extend({
|
||||||
this.collection.bind('reset', this.render, this);
|
this.collection.bind('reset', this.render, this);
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
$('#room-tabs').tabs('destroy');
|
||||||
this.template = Handlebars.compile($("#room-tabs-template").html());
|
this.template = Handlebars.compile($("#room-tabs-template").html());
|
||||||
var rooms = {'rooms': this.collection.toJSON()};
|
var rooms = {'rooms': this.collection.toJSON()};
|
||||||
$('#room-tabs').html(this.template(rooms)).tabs();
|
$('#room-tabs').html(this.template(rooms)).tabs({
|
||||||
if(typeof(window.roomTabsId) != "undefined") {
|
select: function(event, ui) {
|
||||||
$('#room-tabs').tabs('select', window.roomTabsId);
|
//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;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type":"Buzzer",
|
||||||
|
"deviceId":0,
|
||||||
|
"deviceName":"Buzzer",
|
||||||
|
"picture":null,
|
||||||
|
"options": {
|
||||||
|
"state":0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
|
@ -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 {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -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<String,Object> options = new HashMap<String, Object>();
|
|
||||||
// options.put("optionA", "valueA");
|
|
||||||
// options.put("optionB", 42);
|
|
||||||
// assertTrue(dut.updateDeviceData(12, options));
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -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<BuntiDMXDevice> deviceList = dut.getAllDMXDevices();
|
||||||
|
assertEquals(4, deviceList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllDevices() throws Exception {
|
||||||
|
List<BuntiDevice> deviceList = dut.getAllDevices();
|
||||||
|
assertEquals(4, deviceList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetDeviceById() throws Exception {
|
||||||
|
BuntiDevice device = dut.getDeviceById(2);
|
||||||
|
|
||||||
|
assertEquals("Lampe2", device.getDeviceName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ctdo.bunti.dmx;
|
package de.ctdo.bunti.dmx;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.ctdo.bunti.dmx;
|
package de.ctdo.bunti.dmx;
|
||||||
|
|
||||||
|
import de.ctdo.bunti.dmx.model.DMXChannel;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,10 @@ public class DMXMixerImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDevice() throws Exception {
|
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<String,Object> options = new HashMap<String, Object>();
|
Map<String,Object> options = new HashMap<String, Object>();
|
||||||
options.put("red", 44);
|
options.put("red", 44);
|
||||||
assertTrue(dut.updateDevice(device, options));
|
assertTrue(dut.updateDevice(device, options));
|
||||||
|
@ -44,7 +47,10 @@ public class DMXMixerImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDeviceWrong1() throws Exception {
|
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));
|
assertFalse(dut.updateDevice(device, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,14 +63,20 @@ public class DMXMixerImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDeviceWrong3() throws Exception {
|
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<String,Object> options = new HashMap<String, Object>();
|
Map<String,Object> options = new HashMap<String, Object>();
|
||||||
assertFalse(dut.updateDevice(device, options));
|
assertFalse(dut.updateDevice(device, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDeviceWrong4() throws Exception {
|
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<String,Object> options = new HashMap<String, Object>();
|
Map<String,Object> options = new HashMap<String, Object>();
|
||||||
options.put("rednonexistent", 44);
|
options.put("rednonexistent", 44);
|
||||||
assertFalse(dut.updateDevice(device, options));
|
assertFalse(dut.updateDevice(device, options));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ctdo.bunti.model;
|
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.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ public class BuntiDMXDeviceTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
dut = new Par56Spot(DEVICEID,STARTADDRESS,"device");
|
dut = new Par56Spot();
|
||||||
|
dut.setId(23);
|
||||||
|
dut.setStartAddress(42);
|
||||||
|
dut.setDeviceName("deviceName");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -139,7 +142,7 @@ public class BuntiDMXDeviceTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDeviceId() throws Exception {
|
public void testGetDeviceId() throws Exception {
|
||||||
assertEquals(DEVICEID, dut.getDeviceId());
|
assertEquals(DEVICEID, dut.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -9,8 +9,10 @@ public class Par56SpotTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
dut = new Par56Spot(23,42,"device");
|
dut = new Par56Spot();
|
||||||
|
dut.setId(23);
|
||||||
|
dut.setStartAddress(42);
|
||||||
|
dut.setDeviceName("device");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -10,8 +10,10 @@ public class Strobe1500Test {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
dut = new Strobe1500(23,42,"device");
|
dut = new Strobe1500();
|
||||||
|
dut.setId(23);
|
||||||
|
dut.setStartAddress(42);
|
||||||
|
dut.setDeviceName("device");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||||
|
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
|
||||||
|
|
||||||
|
<jdbc:embedded-database id="dataSource" type="H2">
|
||||||
|
<jdbc:script location="classpath:init_schema.sql" />
|
||||||
|
<jdbc:script location="classpath:init_data.sql" />
|
||||||
|
</jdbc:embedded-database>
|
||||||
|
|
||||||
|
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
||||||
|
<property name="packagesToScan" value="de.ctdo.bunti.model"/>
|
||||||
|
<property name="hibernateProperties">
|
||||||
|
<props>
|
||||||
|
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
|
||||||
|
<prop key="hibernate.show_sql">true</prop>
|
||||||
|
<!--<prop key="hibernate.hbm2ddl.auto">create</prop>-->
|
||||||
|
</props>
|
||||||
|
</property>
|
||||||
|
<property name="dataSource" ref="dataSource" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="roomsDAO" class="de.ctdo.bunti.dao.RoomsDAOImpl">
|
||||||
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="devicesDAO" class="de.ctdo.bunti.dao.BuntiDevicesDAOImpl">
|
||||||
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||||
|
<property name="sessionFactory" ref="hibernateSessionFactory" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<tx:annotation-driven />
|
||||||
|
|
||||||
|
</beans>
|
Loading…
Reference in New Issue