Do some cleanup

This commit is contained in:
Juergen Jung 2012-03-04 10:50:50 +01:00
parent e786db9406
commit 27741a5330
24 changed files with 287 additions and 251 deletions

View File

@ -18,16 +18,16 @@ public class DeviceChangedEvent extends ApplicationEvent {
this.options = options; this.options = options;
} }
public BuntiDevice getDevice() { public final BuntiDevice getDevice() {
return device; return device;
} }
public Map<String, Object> getOptions() { public final Map<String, Object> getOptions() {
return options; return options;
} }
@Override @Override
public String toString() { public final String toString() {
return "DeviceChangedEvent " + getDevice().getDeviceName(); return "DeviceChangedEvent " + getDevice().getDeviceName();
} }

View File

@ -17,7 +17,7 @@ import de.ctdo.bunti.artnet.packets.ArtNetPacket;
public class ArtNetSocketImpl implements ArtNetSocket { public class ArtNetSocketImpl implements ArtNetSocket {
private final Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
public static final int DEFAULT_PORT = 0x1936; public static final int DEFAULT_PORT = 0x1936;
protected DatagramSocket socket; private DatagramSocket socket;
public ArtNetSocketImpl() { public ArtNetSocketImpl() {
try { try {
@ -33,12 +33,12 @@ public class ArtNetSocketImpl implements ArtNetSocket {
} }
@Override @Override
public boolean unicastPacket(ArtNetPacket pack, String address) { public final boolean unicastPacket(ArtNetPacket pack, String address) {
InetAddress targetAdress; InetAddress targetAdress;
try { try {
targetAdress = InetAddress.getByName(address); targetAdress = InetAddress.getByName(address);
DatagramPacket packet = new DatagramPacket(pack.getData(), pack.getLength(), targetAdress, DEFAULT_PORT); DatagramPacket packet = new DatagramPacket(pack.getRawData(), pack.getLength(), targetAdress, DEFAULT_PORT);
socket.send(packet); socket.send(packet);
//socket.send(packet, targetAdress); //socket.send(packet, targetAdress);

View File

@ -20,8 +20,8 @@
package de.ctdo.bunti.artnet; package de.ctdo.bunti.artnet;
public class ByteUtils { public class ByteUtils {
protected final byte[] data; private final byte[] data;
public final int length; private final int length;
public ByteUtils(byte[] data) { public ByteUtils(byte[] data) {
this.data = data; this.data = data;
@ -44,7 +44,7 @@ public class ByteUtils {
return stuff; return stuff;
} }
public boolean compareBytes(byte[] other, int offset, int length) { public final boolean compareBytes(byte[] other, int offset, int length) {
boolean isEqual = (offset + length) < data.length; boolean isEqual = (offset + length) < data.length;
for (int i = 0; i < length && isEqual; i++) { for (int i = 0; i < length && isEqual; i++) {
isEqual = data[offset++] == other[i]; isEqual = data[offset++] == other[i];
@ -60,7 +60,7 @@ public class ByteUtils {
return buffer; return buffer;
} }
public byte[] getBytes() { public final byte[] getBytes() {
return data; return data;
} }

View File

@ -15,13 +15,13 @@ public class SimpleArtNetSenderImpl implements SimpleArtNetSender {
private int sequence = 0; private int sequence = 0;
@Autowired @Autowired
public void setSocket(ArtNetSocket socket) { public final void setSocket(ArtNetSocket socket) {
this.socket = socket; this.socket = socket;
} }
@Override @Override
public void sendDMXData(Map<Integer,Integer> dmxdata, String adr) { public final void sendDMXData(Map<Integer,Integer> dmxdata, String adr) {
ArtDmxPacket packet = new ArtDmxPacket(); ArtDmxPacket packet = new ArtDmxPacket();

View File

@ -31,92 +31,92 @@ public class ArtDmxPacket extends ArtNetPacket {
setData(new byte[530]); setData(new byte[530]);
setHeader(); setHeader();
setProtocol(); setProtocol();
data.setInt8(0x02, 13); getData().setInt8(0x02, 13);
} }
/** /**
* @return the actual packet size used. If an odd number DMX channels is * @return the actual packet size used. If an odd number DMX channels is
* used, the packet size is made even automatically. * used, the packet size is made even automatically.
* *
* @see artnet4j.packets.ArtNetPacket#getLength() * @see ArtNetPacket#getLength()
*/ */
@Override @Override
public int getLength() { public final int getLength() {
return 18 + (1 == numChannels % 2 ? numChannels + 1 : numChannels); return 18 + (1 == numChannels % 2 ? numChannels + 1 : numChannels);
} }
/** /**
* @return the number of DMX channels * @return the number of DMX channels
*/ */
public int getNumChannels() { public final int getNumChannels() {
return numChannels; return numChannels;
} }
/** /**
* @return the sequenceID * @return the sequenceID
*/ */
public int getSequenceID() { public final int getSequenceID() {
return sequenceID; return sequenceID;
} }
/** /**
* @return the subnetID * @return the subnetID
*/ */
public int getSubnetID() { public final int getSubnetID() {
return subnetID; return subnetID;
} }
/** /**
* @return the universeID * @return the universeID
*/ */
public int getUniverseID() { public final int getUniverseID() {
return universeID; return universeID;
} }
@Override @Override
public boolean parse(byte[] raw) { public final boolean parse(byte[] raw) {
return false; return false;
} }
public void setDMX(byte[] dmxData, int numChannels) { public final void setDMX(byte[] dmxData, int numChannels) {
this.numChannels = numChannels; this.numChannels = numChannels;
data.setByteChunk(dmxData, 18, numChannels); getData().setByteChunk(dmxData, 18, numChannels);
data.setInt16((1 == numChannels % 2 ? numChannels + 1 : numChannels), getData().setInt16((1 == numChannels % 2 ? numChannels + 1 : numChannels),
16); 16);
} }
/** /**
* @param numChannels * @param numChannels
* the number of DMX channels to set * the number of DMX channels to set
*/ */
public void setNumChannels(int numChannels) { public final void setNumChannels(int numChannels) {
this.numChannels = numChannels > 512 ? 512 : numChannels; this.numChannels = numChannels > 512 ? 512 : numChannels;
} }
public void setSequenceID(int id) { public final void setSequenceID(int id) {
sequenceID = id % 0xff; sequenceID = id % 0xff;
data.setInt8(id, 12); getData().setInt8(id, 12);
} }
/** /**
* @param subnetID * @param subnetID
* the subnetID to set * the subnetID to set
*/ */
public void setSubnetID(int subnetID) { public final void setSubnetID(int subnetID) {
this.subnetID = subnetID & 0x0f; this.subnetID = subnetID & 0x0f;
} }
public void setUniverse(int subnetID, int universeID) { public final void setUniverse(int subnetID, int universeID) {
this.subnetID = subnetID & 0x0f; this.subnetID = subnetID & 0x0f;
this.universeID = universeID & 0x0f; this.universeID = universeID & 0x0f;
data.setInt16LE(subnetID << 4 | universeID, 14); getData().setInt16LE(subnetID << 4 | universeID, 14);
} }
/** /**
* @param universeID * @param universeID
* the universeID to set * the universeID to set
*/ */
public void setUniverseID(int universeID) { public final void setUniverseID(int universeID) {
this.universeID = universeID & 0x0f; this.universeID = universeID & 0x0f;
} }
} }

View File

@ -3,25 +3,30 @@ package de.ctdo.bunti.artnet.packets;
import de.ctdo.bunti.artnet.ByteUtils; import de.ctdo.bunti.artnet.ByteUtils;
public abstract class ArtNetPacket { public abstract class ArtNetPacket {
public static final byte[] HEADER = "Art-Net\0".getBytes(); static final byte[] HEADER = "Art-Net\0".getBytes();
public static final int PROTOCOL_VERSION = 14; public static final int PROTOCOL_VERSION = 14;
protected ByteUtils data; private ByteUtils data;
protected final PacketType type; private final PacketType type;
public final ByteUtils getData() {
return data;
}
public ArtNetPacket(PacketType type) { public ArtNetPacket(PacketType type) {
this.type = type; this.type = type;
} }
public byte[] getData() { public final byte[] getRawData() {
return data.getBytes(); return data.getBytes();
} }
public int getLength() { public int getLength() {
return data.length; return getData().getLength();
} }
public PacketType getType() { public final PacketType getType() {
return type; return type;
} }
@ -40,11 +45,11 @@ public abstract class ArtNetPacket {
* @param data * @param data
* the data to set * the data to set
*/ */
public void setData(byte[] data) { public final void setData(byte[] data) {
this.data = new ByteUtils(data); this.data = new ByteUtils(data);
} }
public void setData(byte[] raw, int maxLength) { public final void setRawData(byte[] raw, int maxLength) {
if (raw.length > maxLength) { if (raw.length > maxLength) {
byte[] raw2 = new byte[maxLength]; byte[] raw2 = new byte[maxLength];
System.arraycopy(raw, 0, raw2, 0, maxLength); System.arraycopy(raw, 0, raw2, 0, maxLength);
@ -53,17 +58,17 @@ public abstract class ArtNetPacket {
setData(raw); setData(raw);
} }
protected void setHeader() { protected final void setHeader() {
data.setByteChunk(HEADER, 0, 8); data.setByteChunk(HEADER, 0, 8);
data.setInt16LE(type.getOpCode(), 8); data.setInt16LE(type.getOpCode(), 8);
} }
protected void setProtocol() { protected final void setProtocol() {
data.setInt16(PROTOCOL_VERSION, 10); data.setInt16(PROTOCOL_VERSION, 10);
} }
@Override @Override
public String toString() { public final String toString() {
return data.toHex(getLength()); return data.toHex(getLength());
} }

View File

@ -21,11 +21,11 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
private BuntiDevicesDAO devicesDAO; private BuntiDevicesDAO devicesDAO;
@Autowired @Autowired
public void setDevicesDAO(BuntiDevicesDAO devicesDAO) { public final void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
this.devicesDAO = devicesDAO; this.devicesDAO = devicesDAO;
} }
public void performJSONString(String json) { public final void performJSONString(String json) {
JSONObject jsonobj = JSONObject.fromObject(json); JSONObject jsonobj = JSONObject.fromObject(json);
@ -42,7 +42,7 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
} }
@Override @Override
public boolean setDevice(int deviceId, Map<String, Object> options) { public final boolean setDevice(int deviceId, Map<String, Object> options) {
BuntiDevice device = devicesDAO.getDeviceById(deviceId); BuntiDevice device = devicesDAO.getDeviceById(deviceId);
@ -61,7 +61,7 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
} }
@Override @Override
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) { public final void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
this.applicationEventPublisher = publisher; this.applicationEventPublisher = publisher;
} }

View File

@ -35,7 +35,7 @@ public class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
@Override @Override
public Collection<BuntiDMXDevice> getAllDMXDevices() { public final Collection<BuntiDMXDevice> getAllDMXDevices() {
List<BuntiDMXDevice> liste = new ArrayList<BuntiDMXDevice>(); List<BuntiDMXDevice> liste = new ArrayList<BuntiDMXDevice>();
for (BuntiDevice device : devices) { for (BuntiDevice device : devices) {
if( device instanceof BuntiDMXDevice ) { if( device instanceof BuntiDMXDevice ) {
@ -46,7 +46,7 @@ public class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
} }
@Override @Override
public BuntiDevice getDeviceById(int deviceId) { public final BuntiDevice getDeviceById(int deviceId) {
for (BuntiDevice dev : devices) { for (BuntiDevice dev : devices) {
if(dev.getDeviceId() == deviceId) { if(dev.getDeviceId() == deviceId) {
return dev; return dev;

View File

@ -11,7 +11,7 @@ import de.ctdo.bunti.model.BuntiSwitchingDevice;
public class DeviceMixerImpl implements DeviceMixer, ApplicationListener<DeviceChangedEvent> { public class DeviceMixerImpl implements DeviceMixer, ApplicationListener<DeviceChangedEvent> {
@Override @Override
public void onApplicationEvent(DeviceChangedEvent arg0) { public final void onApplicationEvent(DeviceChangedEvent arg0) {
if( arg0.getDevice() instanceof BuntiSwitchingDevice) { if( arg0.getDevice() instanceof BuntiSwitchingDevice) {

View File

@ -1,42 +1,47 @@
package de.ctdo.bunti.dmx; package de.ctdo.bunti.dmx;
public class DMX { public final class DMX {
public static final int DMX_CHANNELS_MAX = (byte) 511; public static final int DMX_CHANNELS_MAX = (byte) 511;
public static final int DMX_CHANNELS_MIN = 0; public static final int DMX_CHANNELS_MIN = 0;
public static final int DMX_CHANNEL_VALUE_MAX = (byte) 255; public static final int DMX_CHANNEL_VALUE_MAX = (byte) 255;
public static final int DMX_CHANNEL_VALUE_MIN = 0; public static final int DMX_CHANNEL_VALUE_MIN = 0;
/** /**
* Offset by which startaddress differs from DMX512 Data Array location * Offset by which startaddress differs from DMX512 Data Array location
*/ */
public static final int DMX_STARTADDRESS_OFFSET = -1; public static final int DMX_STARTADDRESS_OFFSET = -1;
private DMX(){ private DMX() {
} }
/** /**
* Checks the DMX Value boundaries * Checks the DMX Value boundaries
* @param value *
* @return A valid DMX512 channel value * @param value
*/ * @return A valid DMX512 channel value
public static int sanitizeDMXValue(int value) { */
if(value < DMX_CHANNEL_VALUE_MIN) value = DMX_CHANNEL_VALUE_MIN; public static int sanitizeDMXValue(int value) {
if(value > DMX_CHANNEL_VALUE_MAX) value = DMX_CHANNEL_VALUE_MAX; if (value < DMX_CHANNEL_VALUE_MIN) {
return value; return DMX_CHANNEL_VALUE_MIN;
} }
if (value > DMX_CHANNEL_VALUE_MAX) {
/** return DMX_CHANNEL_VALUE_MAX;
* Checks the DMX Channel boundaries }
* @param channel The channel to check return value;
* @return True if channel is valid. Otherwise false. }
*/
public static boolean checkChannelBoundaries(int channel) { /**
return (channel >= DMX_CHANNELS_MIN && channel <= DMX_CHANNELS_MAX); * Checks the DMX Channel boundaries
} *
* @param channel The channel to check
* @return True if channel is valid. Otherwise false.
*/
public static boolean checkChannelBoundaries(int channel) {
return (channel >= DMX_CHANNELS_MIN && channel <= DMX_CHANNELS_MAX);
}
} }

View File

@ -12,41 +12,41 @@ public class DMXChannel {
this.value = 0; this.value = 0;
} }
public int getValue() { public final int getValue() {
return value; return value;
} }
public void setValue(int value) { public final void setValue(int value) {
this.value = value; this.value = value;
lastChangedTimestamp = System.currentTimeMillis(); lastChangedTimestamp = System.currentTimeMillis();
} }
public long getLastChangedTimestamp() { public final long getLastChangedTimestamp() {
return lastChangedTimestamp; return lastChangedTimestamp;
} }
public int getOffset() { public final int getOffset() {
return offset; return offset;
} }
public void setOffset(int offset) { public final void setOffset(int offset) {
this.offset = offset; this.offset = offset;
} }
public String getName() { public final String getName() {
return name; return name;
} }
public void setName(String name) { public final void setName(String name) {
this.name = name; this.name = name;
} }
public void hasbeenSendOut() { public final void hasbeenSendOut() {
this.lastChangedTimestamp = System.currentTimeMillis(); this.lastChangedTimestamp = System.currentTimeMillis();
} }
@Override @Override
public String toString() { public final String toString() {
return "DMXChannel " + getName() + "," + getOffset() + "," + getValue(); return "DMXChannel " + getName() + "," + getOffset() + "," + getValue();
} }

View File

@ -12,14 +12,14 @@ import java.util.Map;
*/ */
public class DMXChannels { public class DMXChannels {
protected Map<Integer,DMXChannel> channelByNumber = new HashMap<Integer, DMXChannel>(); private Map<Integer,DMXChannel> channelByNumber = new HashMap<Integer, DMXChannel>();
protected Map<String,DMXChannel> channelByName = new HashMap<String, DMXChannel>(); private Map<String,DMXChannel> channelByName = new HashMap<String, DMXChannel>();
/** /**
* Returns the number of channels * Returns the number of channels
* @return number of channels * @return number of channels
*/ */
public int getCount() { public final int getCount() {
return this.channelByNumber.size(); return this.channelByNumber.size();
} }
@ -28,7 +28,7 @@ public class DMXChannels {
* @param name channel name * @param name channel name
* @return channel or null if not found * @return channel or null if not found
*/ */
public DMXChannel getChannelByName(String name) { public final DMXChannel getChannelByName(String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
@ -40,7 +40,7 @@ public class DMXChannels {
* @param number number * @param number number
* @return channel or null if not found * @return channel or null if not found
*/ */
public DMXChannel getChannelByNumber(int number) { public final DMXChannel getChannelByNumber(int number) {
return this.channelByNumber.get(number); return this.channelByNumber.get(number);
} }
@ -49,7 +49,7 @@ public class DMXChannels {
* @param channel channel to add * @param channel channel to add
* @return true on success, false on error * @return true on success, false on error
*/ */
public boolean addChannel(DMXChannel channel) { public final boolean addChannel(DMXChannel channel) {
// object cannot be null // object cannot be null
if (channel == null) { if (channel == null) {
return false; return false;
@ -76,7 +76,7 @@ public class DMXChannels {
* @param offset offset * @param offset offset
* @return removed channel or null if it does not exist * @return removed channel or null if it does not exist
*/ */
public DMXChannel removeChannel(int offset) { public final DMXChannel removeChannel(int offset) {
DMXChannel tmpChannel = this.channelByNumber.remove(offset); DMXChannel tmpChannel = this.channelByNumber.remove(offset);
if (tmpChannel != null) { if (tmpChannel != null) {
this.channelByName.remove(tmpChannel.getName()); this.channelByName.remove(tmpChannel.getName());
@ -89,7 +89,7 @@ public class DMXChannels {
* @param name channel name * @param name channel name
* @return removed channel or null if it does not exist * @return removed channel or null if it does not exist
*/ */
public DMXChannel removeChannel(String name) { public final DMXChannel removeChannel(String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
@ -105,7 +105,7 @@ public class DMXChannels {
* Returns an (unmodifiable) collection of all channels * Returns an (unmodifiable) collection of all channels
* @return unmodifiable collection of all channels * @return unmodifiable collection of all channels
*/ */
public Collection<DMXChannel> getAllChannels() { public final Collection<DMXChannel> getAllChannels() {
return Collections.unmodifiableCollection(this.channelByNumber.values()); return Collections.unmodifiableCollection(this.channelByNumber.values());
} }

View File

@ -1,88 +1,90 @@
package de.ctdo.bunti.dmx; package de.ctdo.bunti.dmx;
import de.ctdo.bunti.DeviceChangedEvent;
import de.ctdo.bunti.artnet.SimpleArtNetSender;
import de.ctdo.bunti.model.BuntiDMXDevice;
import de.ctdo.bunti.model.BuntiDevice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import de.ctdo.bunti.DeviceChangedEvent;
import de.ctdo.bunti.artnet.SimpleArtNetSender;
import de.ctdo.bunti.model.*;
@Component @Component
public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChangedEvent> { public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChangedEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(DMXMixerImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(DMXMixerImpl.class);
private static final String ARTNET_DEVICE_ADDRESS = "192.168.0.90"; private static final String ARTNET_DEVICE_ADDRESS = "192.168.0.90";
private final Map<Integer,Integer> dmxMap = Collections.synchronizedMap(new HashMap<Integer,Integer>()); private final Map<Integer, Integer> dmxMap = Collections.synchronizedMap(new HashMap<Integer, Integer>());
private SimpleArtNetSender artNetSender; private SimpleArtNetSender artNetSender;
private boolean hasDataChanged = true; private boolean hasDataChanged = true;
@Autowired @Autowired
public void setArtNetSender(SimpleArtNetSender artNetSender) { public final void setArtNetSender(SimpleArtNetSender artNetSender) {
this.artNetSender = artNetSender; this.artNetSender = artNetSender;
} }
public void initDMXData() { public final void initDMXData() {
for (int i = 0; i <= DMX.DMX_CHANNELS_MAX; i++) { for (int i = 0; i <= DMX.DMX_CHANNELS_MAX; i++) {
dmxMap.put(i, 0); dmxMap.put(i, 0);
} }
} }
@Scheduled(fixedDelay=100) //TODO aendern auf 10ms @Scheduled(fixedDelay = 100) //TODO aendern auf 10ms
public void sendOutDMXBuffer() { public final void sendOutDMXBuffer() {
if( dmxMap.size() == 0) initDMXData(); if (dmxMap.size() == 0) {
initDMXData();
}
if (hasDataChanged) {
artNetSender.sendDMXData(dmxMap, ARTNET_DEVICE_ADDRESS);
hasDataChanged = false;
}
if( hasDataChanged ) {
artNetSender.sendDMXData(dmxMap, ARTNET_DEVICE_ADDRESS);
hasDataChanged = false;
}
// logger.debug(sb.toString()); // logger.debug(sb.toString());
} }
public void updateDevice(BuntiDevice device, Map<String, Object> options) { public final void updateDevice(BuntiDevice device, Map<String, Object> options) {
BuntiDMXDevice dmxDev = (BuntiDMXDevice)device; BuntiDMXDevice dmxDev = (BuntiDMXDevice) device;
if( dmxDev.setValuesFromOptions(options) ) { if (dmxDev.setValuesFromOptions(options)) {
dmxMap.putAll(dmxDev.getChannelData()); dmxMap.putAll(dmxDev.getChannelData());
LOGGER.info("setValuesFromOptions on " + device); LOGGER.info("setValuesFromOptions on " + device);
} else { }
LOGGER.info("setValuesFromOptions on " + device + " failed"); else {
} LOGGER.info("setValuesFromOptions on " + device + " failed");
}
}
}
@Override
public void setDMX512Channel(int channel, int value) { @Override
if(!DMX.checkChannelBoundaries(channel)) return; public final void setDMX512Channel(int channel, int value) {
value = DMX.sanitizeDMXValue(value); if (!DMX.checkChannelBoundaries(channel)) {
return;
dmxMap.put(channel, value); }
hasDataChanged = true;
} dmxMap.put(channel, DMX.sanitizeDMXValue(value));
hasDataChanged = true;
@Override }
public void onApplicationEvent(DeviceChangedEvent arg0) {
if( arg0.getDevice() instanceof BuntiDMXDevice) { @Override
updateDevice(arg0.getDevice(), arg0.getOptions()); public final void onApplicationEvent(DeviceChangedEvent arg0) {
if (arg0.getDevice() instanceof BuntiDMXDevice) {
hasDataChanged = true; updateDevice(arg0.getDevice(), arg0.getOptions());
// TODO: hier kann man z.B. auch noch direkt einmal die DMX Daten zu verschicken veranlassen
} hasDataChanged = true;
} // TODO: hier kann man z.B. auch noch direkt einmal die DMX Daten zu verschicken veranlassen
}
}
} }

View File

@ -7,29 +7,29 @@ import java.util.Map.Entry;
import de.ctdo.bunti.dmx.*; import de.ctdo.bunti.dmx.*;
public abstract class BuntiDMXDevice extends BuntiDevice { public abstract class BuntiDMXDevice extends BuntiDevice {
protected int startAddress; private int startAddress;
private long lastSendOut; private long lastSendOut;
protected DMXChannels dmxChannels = new DMXChannels(); private DMXChannels dmxChannels = new DMXChannels();
public BuntiDMXDevice(int deviceId, int startAddress, String name) { public BuntiDMXDevice(int deviceId, int startAddress, String name) {
this.startAddress = startAddress; super(deviceId,name);
this.deviceName = name; this.startAddress = startAddress;
this.deviceId = deviceId;
} }
public long getLastSendOut() { public final long getLastSendOut() {
return lastSendOut; return lastSendOut;
} }
public void setSendOutNow() { public final void setSendOutNow() {
this.lastSendOut = System.currentTimeMillis(); this.lastSendOut = System.currentTimeMillis();
} }
public int getStartAddress() { public final int getStartAddress() {
return startAddress; return startAddress;
} }
public void setStartAddress(int startAddress) { public final void setStartAddress(int startAddress) {
this.startAddress = startAddress; this.startAddress = startAddress;
} }
@ -38,7 +38,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
* @param name The channel name to change the value. * @param name The channel name to change the value.
* @param value The channel value to set. * @param value The channel value to set.
*/ */
protected void setChannelValueByName(String name, int value) { protected final void setChannelValueByName(String name, int value) {
DMXChannel dx = dmxChannels.getChannelByName(name); DMXChannel dx = dmxChannels.getChannelByName(name);
if(dx != null) { if(dx != null) {
dx.setValue(DMX.sanitizeDMXValue(value)); dx.setValue(DMX.sanitizeDMXValue(value));
@ -51,7 +51,7 @@ 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.
*/ */
protected 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) {
return dx.getValue(); return dx.getValue();
@ -122,7 +122,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
} }
@Override @Override
public boolean setValuesFromOptions(Map<String, Object> options) { public final boolean setValuesFromOptions(Map<String, Object> options) {
for (Entry<String, Object> opt : options.entrySet()) { for (Entry<String, Object> opt : options.entrySet()) {
@ -141,9 +141,13 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
} }
return true; return true;
} }
public final boolean addChannel(DMXChannel channel){
return dmxChannels.addChannel(channel);
}
@Override @Override
public String toString() { public String toString() {
return "BuntiDMXDevice " + deviceId + ", " + deviceName; return "BuntiDMXDevice " + getDeviceId() + ", " + getDeviceName();
} }
} }

View File

@ -3,27 +3,37 @@ package de.ctdo.bunti.model;
import java.util.Map; import java.util.Map;
public abstract class BuntiDevice { public abstract class BuntiDevice {
protected int deviceId; private int deviceId;
protected String deviceName; private String deviceName;
private long lastChanged; private long lastChanged;
public int getDeviceId() { public BuntiDevice(int deviceId, String deviceName, long lastChanged) {
this.deviceId = deviceId;
this.deviceName = deviceName;
this.lastChanged = lastChanged;
}
public BuntiDevice(int deviceId, String deviceName) {
this(deviceId,deviceName,0);
}
public final int getDeviceId() {
return deviceId; return deviceId;
} }
public long getLastChanged() { public final long getLastChanged() {
return lastChanged; return lastChanged;
} }
protected void lastChangedNow() { protected final void lastChangedNow() {
this.lastChanged = System.currentTimeMillis(); this.lastChanged = System.currentTimeMillis();
} }
public String getDeviceName() { public final String getDeviceName() {
return deviceName; return deviceName;
} }
public void setDeviceName(String deviceName) { public final void setDeviceName(String deviceName) {
this.deviceName = deviceName; this.deviceName = deviceName;
} }

View File

@ -4,7 +4,16 @@ import java.util.Map;
public class BuntiSwitchingDevice extends BuntiDevice { public class BuntiSwitchingDevice extends BuntiDevice {
@Override
public BuntiSwitchingDevice(int deviceId, String deviceName, long lastChanged) {
super(deviceId, deviceName, lastChanged);
}
public BuntiSwitchingDevice(int deviceId, String deviceName) {
super(deviceId, deviceName);
}
@Override
public void switchOff() { public void switchOff() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -17,7 +26,7 @@ public class BuntiSwitchingDevice extends BuntiDevice {
} }
@Override @Override
public boolean setValuesFromOptions(Map<String, Object> options) { public final boolean setValuesFromOptions(Map<String, Object> options) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }

View File

@ -4,44 +4,45 @@ import de.ctdo.bunti.dmx.DMX;
import de.ctdo.bunti.dmx.DMXChannel; import de.ctdo.bunti.dmx.DMXChannel;
public class Par56Spot extends BuntiDMXDevice { public class Par56Spot extends BuntiDMXDevice {
private final static String CHANNEL_MODE = "mode"; private static final String CHANNEL_MODE = "mode";
private final static String CHANNEL_RED = "red"; private static final String CHANNEL_RED = "red";
private final static String CHANNEL_GREEN = "green"; private static final String CHANNEL_GREEN = "green";
private final static String CHANNEL_BLUE = "blue"; private static final String CHANNEL_BLUE = "blue";
private final static String CHANNEL_SPEED = "speed"; private static final String CHANNEL_SPEED = "speed";
public Par56Spot(int deviceId, int startAddress, String deviceName) { public Par56Spot(int deviceId, int startAddress, String deviceName) {
super(deviceId, startAddress, deviceName); super(deviceId, startAddress, deviceName);
dmxChannels.addChannel(new DMXChannel(0, CHANNEL_MODE));
dmxChannels.addChannel(new DMXChannel(1, "red")); addChannel(new DMXChannel(0, CHANNEL_MODE));
dmxChannels.addChannel(new DMXChannel(2, CHANNEL_GREEN)); addChannel(new DMXChannel(1, "red"));
dmxChannels.addChannel(new DMXChannel(3, CHANNEL_BLUE)); addChannel(new DMXChannel(2, CHANNEL_GREEN));
dmxChannels.addChannel(new DMXChannel(4, CHANNEL_SPEED)); addChannel(new DMXChannel(3, CHANNEL_BLUE));
addChannel(new DMXChannel(4, CHANNEL_SPEED));
} }
public void setColorRed(int value) { public final void setColorRed(int value) {
setChannelValueByName(CHANNEL_RED, value); setChannelValueByName(CHANNEL_RED, value);
} }
public void setColorGreen(int value) { public final void setColorGreen(int value) {
setChannelValueByName(CHANNEL_GREEN, value); setChannelValueByName(CHANNEL_GREEN, value);
} }
public void setColorBlue(int value) { public final void setColorBlue(int value) {
setChannelValueByName(CHANNEL_BLUE, value); setChannelValueByName(CHANNEL_BLUE, value);
} }
public int getColorRed() { public final int getColorRed() {
return getChannelValueByName(CHANNEL_RED); return getChannelValueByName(CHANNEL_RED);
} }
public int getColorGreen() { public final int getColorGreen() {
return getChannelValueByName(CHANNEL_GREEN); return getChannelValueByName(CHANNEL_GREEN);
} }
public int getColorBlue() { public final int getColorBlue() {
return getChannelValueByName(CHANNEL_BLUE); return getChannelValueByName(CHANNEL_BLUE);
} }
@Override @Override
public void switchOff() { public final void switchOff() {
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
setColorRed(DMX.DMX_CHANNEL_VALUE_MIN); setColorRed(DMX.DMX_CHANNEL_VALUE_MIN);
setColorGreen(DMX.DMX_CHANNEL_VALUE_MIN); setColorGreen(DMX.DMX_CHANNEL_VALUE_MIN);
@ -50,7 +51,7 @@ public class Par56Spot extends BuntiDMXDevice {
} }
@Override @Override
public void switchOn() { public final void switchOn() {
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
setColorRed(DMX.DMX_CHANNEL_VALUE_MAX); setColorRed(DMX.DMX_CHANNEL_VALUE_MAX);
setColorGreen(DMX.DMX_CHANNEL_VALUE_MAX); setColorGreen(DMX.DMX_CHANNEL_VALUE_MAX);
@ -59,8 +60,8 @@ public class Par56Spot extends BuntiDMXDevice {
} }
@Override @Override
public String toString() { public final String toString() {
return "Par56Spot " + deviceId + ", " + deviceName + " " + return "Par56Spot " + getDeviceId() + ", " + getDeviceName() + " " +
"[" + getColorRed() + "," + getColorGreen() + "," + getColorBlue() + "]"; "[" + getColorRed() + "," + getColorGreen() + "," + getColorBlue() + "]";
} }

View File

@ -5,54 +5,54 @@ import de.ctdo.bunti.dmx.DMXChannel;
public class Strobe1500 extends BuntiDMXDevice { public class Strobe1500 extends BuntiDMXDevice {
private final static String CHANNEL_SPEED = "speed"; private static final String CHANNEL_SPEED = "speed";
private final static String CHANNEL_INTENSITY = "intensity"; private static final String CHANNEL_INTENSITY = "intensity";
private final static String CHANNEL_MODE = "mode"; private static final String CHANNEL_MODE = "mode";
public Strobe1500(int deviceId, int startAddress, String deviceName) { public Strobe1500(int deviceId, int startAddress, String deviceName) {
super(deviceId, startAddress, deviceName); super(deviceId, startAddress, deviceName);
this.dmxChannels.addChannel(new DMXChannel(0, CHANNEL_SPEED)); addChannel(new DMXChannel(0, CHANNEL_SPEED));
this.dmxChannels.addChannel(new DMXChannel(1, CHANNEL_INTENSITY)); addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
this.dmxChannels.addChannel(new DMXChannel(2, CHANNEL_MODE)); addChannel(new DMXChannel(2, CHANNEL_MODE));
} }
public void setSpeed(int value) { public final void setSpeed(int value) {
setChannelValueByName(CHANNEL_SPEED, value); setChannelValueByName(CHANNEL_SPEED, value);
} }
public void setIntensity(int value) { public final void setIntensity(int value) {
setChannelValueByName(CHANNEL_INTENSITY, value); setChannelValueByName(CHANNEL_INTENSITY, value);
} }
public void setMode(int value) { public final void setMode(int value) {
setChannelValueByName(CHANNEL_MODE, value); setChannelValueByName(CHANNEL_MODE, value);
} }
public int getSpeed() { public final int getSpeed() {
return getChannelValueByName(CHANNEL_SPEED); return getChannelValueByName(CHANNEL_SPEED);
} }
public int getIntensity() { public final int getIntensity() {
return getChannelValueByName(CHANNEL_INTENSITY); return getChannelValueByName(CHANNEL_INTENSITY);
} }
public int getMode() { public final int getMode() {
return getChannelValueByName(CHANNEL_MODE); return getChannelValueByName(CHANNEL_MODE);
} }
@Override @Override
public void switchOff() { public final void switchOff() {
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MIN);
setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MIN);
} }
@Override @Override
public void switchOn() { public final void switchOn() {
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN); setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MAX); setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MAX);
setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MAX); setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MAX);
} }
@Override @Override
public String toString() { public final String toString() {
return "Strobe1500 " + deviceId + ", " + deviceName + return "Strobe1500 " + getDeviceId() + ", " + getDeviceName() +
"[" + getSpeed() + "," + getIntensity() + "," + getMode() + "]"; "[" + getSpeed() + "," + getIntensity() + "," + getMode() + "]";
} }

View File

@ -16,15 +16,15 @@ import de.ctdo.bunti.control.BuntiController;
@Controller @Controller
public class TestController { public class TestController {
private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class); private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
BuntiController buntiController; private BuntiController buntiController;
@Autowired @Autowired
public void setBuntiController(BuntiController buntiController) { public final void setBuntiController(BuntiController buntiController) {
this.buntiController = buntiController; this.buntiController = buntiController;
} }
@RequestMapping("/foobar") @RequestMapping("/foobar")
public ModelAndView blafasel() { public final ModelAndView blafasel() {
Map<String,Object> options = new HashMap<String,Object>(); Map<String,Object> options = new HashMap<String,Object>();
options.put("red", 124); options.put("red", 124);
@ -59,7 +59,7 @@ public class TestController {
} }
@RequestMapping("/foobar2") @RequestMapping("/foobar2")
public ModelAndView blafasel2() { public final ModelAndView blafasel2() {
Map<String,Object> options = new HashMap<String,Object>(); Map<String,Object> options = new HashMap<String,Object>();

View File

@ -12,23 +12,23 @@ import com.sun.grizzly.websockets.WebSocketListener;
@Component @Component
public class BuntiControllerApplication extends WebSocketApplication { public class BuntiControllerApplication extends WebSocketApplication {
Logger logger = LoggerFactory.getLogger(BuntiControllerApplication.class); private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerApplication.class);
@Override @Override
public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) { public final WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) {
BuntiControllerWebSocket socket = new BuntiControllerWebSocket(protocolHandler, listeners); BuntiControllerWebSocket socket = new BuntiControllerWebSocket(protocolHandler, listeners);
// BuntiControllerImpl.getInstance().addListener(socket); // BuntiControllerImpl.getInstance().addListener(socket);
return socket; return socket;
} }
@Override @Override
public boolean isApplicationRequest(Request request) { public final boolean isApplicationRequest(Request request) {
final String uri = request.requestURI().toString(); final String uri = request.requestURI().toString();
return uri.endsWith("/bunti"); return uri.endsWith("/bunti");
} }
@Override @Override
public void onClose(WebSocket socket, com.sun.grizzly.websockets.DataFrame frame) { public final void onClose(WebSocket socket, com.sun.grizzly.websockets.DataFrame frame) {
BuntiControllerWebSocket ws = (BuntiControllerWebSocket) socket; BuntiControllerWebSocket ws = (BuntiControllerWebSocket) socket;
// BuntiControllerImpl.getInstance().removeListener(ws); // BuntiControllerImpl.getInstance().removeListener(ws);
} }

View File

@ -9,32 +9,32 @@ import org.springframework.stereotype.Component;
@Component @Component
public class BuntiControllerServlet { // extends HttpServlet { public class BuntiControllerServlet { // extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
Logger logger = LoggerFactory.getLogger(BuntiControllerServlet.class); private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerServlet.class);
private BuntiControllerApplication app; private BuntiControllerApplication app;
@Autowired @Autowired
public void setApp(BuntiControllerApplication app) { public final void setApp(BuntiControllerApplication app) {
this.app = app; this.app = app;
} }
public void BuntiControllerApplication() { public void buntiControllerApplication() {
// WebSocketEngine.getEngine().register(app); // WebSocketEngine.getEngine().register(app);
// logger.debug("registered BuntiControllerApplication"); // LOGGER.debug("registered buntiControllerApplication");
} }
// @Override // @Override
// public void init(ServletConfig config) throws ServletException { // public void init(ServletConfig config) throws ServletException {
// WebSocketEngine.getEngine().register(app); // WebSocketEngine.getEngine().register(app);
// logger.debug("registered BuntiControllerApplication"); // LOGGER.debug("registered buntiControllerApplication");
// } // }
// //
// @Override // @Override
// public void destroy() { // public void destroy() {
// WebSocketEngine.getEngine().unregister(app); // WebSocketEngine.getEngine().unregister(app);
// logger.debug("unregistered BuntiControllerApplication"); // LOGGER.debug("unregistered buntiControllerApplication");
// } // }
} }

View File

@ -14,7 +14,7 @@ import com.sun.grizzly.websockets.WebSocketListener;
*/ */
public class BuntiControllerWebSocket extends DefaultWebSocket { public class BuntiControllerWebSocket extends DefaultWebSocket {
Logger logger = LoggerFactory.getLogger(BuntiControllerWebSocket.class); private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerWebSocket.class);
public BuntiControllerWebSocket(ProtocolHandler protocolHandler, WebSocketListener[] listeners) { public BuntiControllerWebSocket(ProtocolHandler protocolHandler, WebSocketListener[] listeners) {
super(protocolHandler, listeners); super(protocolHandler, listeners);

File diff suppressed because one or more lines are too long

View File

@ -488,11 +488,11 @@ minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onS
function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv}, b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},
setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g, setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,
"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker", "\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setRawData.datepicker",
function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c== function(e,f,h){b.settings[f]=h}).bind("getRawData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c==
"focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker(): "focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():
d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++)if(f[g].length>h){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a, d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++)if(f[g].length>h){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,
b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+= b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setRawData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getRawData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+=
1;this._dialogInput=d('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/ 1;this._dialogInput=d('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/
2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b= 2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=
d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e= d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=