59 lines
1.4 KiB
Java
59 lines
1.4 KiB
Java
package de.ctdo.bunti.dao;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import de.ctdo.bunti.model.*;
|
|
|
|
@Component
|
|
public class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private List<BuntiDevice> devices = new ArrayList<BuntiDevice>();
|
|
|
|
public BuntiDevicesDAOImpl() {
|
|
addDummyDevices();
|
|
}
|
|
|
|
|
|
private void addDummyDevices() {
|
|
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
|
|
public Collection<BuntiDMXDevice> getAllDMXDevices() {
|
|
List<BuntiDMXDevice> liste = new ArrayList<BuntiDMXDevice>();
|
|
for (BuntiDevice device : devices) {
|
|
if( device instanceof BuntiDMXDevice ) {
|
|
liste.add((BuntiDMXDevice) device);
|
|
}
|
|
}
|
|
return liste;
|
|
}
|
|
|
|
@Override
|
|
public BuntiDevice getDeviceById(int deviceId) {
|
|
for (BuntiDevice dev : devices) {
|
|
if(dev.getDeviceId() == deviceId) {
|
|
return dev;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|