Do some cleanup
This commit is contained in:
parent
e786db9406
commit
27741a5330
|
@ -18,16 +18,16 @@ public class DeviceChangedEvent extends ApplicationEvent {
|
|||
this.options = options;
|
||||
}
|
||||
|
||||
public BuntiDevice getDevice() {
|
||||
public final BuntiDevice getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public Map<String, Object> getOptions() {
|
||||
public final Map<String, Object> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return "DeviceChangedEvent " + getDevice().getDeviceName();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import de.ctdo.bunti.artnet.packets.ArtNetPacket;
|
|||
public class ArtNetSocketImpl implements ArtNetSocket {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
public static final int DEFAULT_PORT = 0x1936;
|
||||
protected DatagramSocket socket;
|
||||
private DatagramSocket socket;
|
||||
|
||||
public ArtNetSocketImpl() {
|
||||
try {
|
||||
|
@ -33,12 +33,12 @@ public class ArtNetSocketImpl implements ArtNetSocket {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean unicastPacket(ArtNetPacket pack, String address) {
|
||||
public final boolean unicastPacket(ArtNetPacket pack, String address) {
|
||||
InetAddress targetAdress;
|
||||
try {
|
||||
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, targetAdress);
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package de.ctdo.bunti.artnet;
|
||||
|
||||
public class ByteUtils {
|
||||
protected final byte[] data;
|
||||
public final int length;
|
||||
private final byte[] data;
|
||||
private final int length;
|
||||
|
||||
public ByteUtils(byte[] data) {
|
||||
this.data = data;
|
||||
|
@ -44,7 +44,7 @@ public class ByteUtils {
|
|||
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;
|
||||
for (int i = 0; i < length && isEqual; i++) {
|
||||
isEqual = data[offset++] == other[i];
|
||||
|
@ -60,7 +60,7 @@ public class ByteUtils {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
public final byte[] getBytes() {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ public class SimpleArtNetSenderImpl implements SimpleArtNetSender {
|
|||
private int sequence = 0;
|
||||
|
||||
@Autowired
|
||||
public void setSocket(ArtNetSocket socket) {
|
||||
public final void setSocket(ArtNetSocket socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendDMXData(Map<Integer,Integer> dmxdata, String adr) {
|
||||
public final void sendDMXData(Map<Integer,Integer> dmxdata, String adr) {
|
||||
|
||||
ArtDmxPacket packet = new ArtDmxPacket();
|
||||
|
||||
|
|
|
@ -31,57 +31,57 @@ public class ArtDmxPacket extends ArtNetPacket {
|
|||
setData(new byte[530]);
|
||||
setHeader();
|
||||
setProtocol();
|
||||
data.setInt8(0x02, 13);
|
||||
getData().setInt8(0x02, 13);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actual packet size used. If an odd number DMX channels is
|
||||
* used, the packet size is made even automatically.
|
||||
*
|
||||
* @see artnet4j.packets.ArtNetPacket#getLength()
|
||||
* @see ArtNetPacket#getLength()
|
||||
*/
|
||||
@Override
|
||||
public int getLength() {
|
||||
public final int getLength() {
|
||||
return 18 + (1 == numChannels % 2 ? numChannels + 1 : numChannels);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of DMX channels
|
||||
*/
|
||||
public int getNumChannels() {
|
||||
public final int getNumChannels() {
|
||||
return numChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sequenceID
|
||||
*/
|
||||
public int getSequenceID() {
|
||||
public final int getSequenceID() {
|
||||
return sequenceID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subnetID
|
||||
*/
|
||||
public int getSubnetID() {
|
||||
public final int getSubnetID() {
|
||||
return subnetID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the universeID
|
||||
*/
|
||||
public int getUniverseID() {
|
||||
public final int getUniverseID() {
|
||||
return universeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parse(byte[] raw) {
|
||||
public final boolean parse(byte[] raw) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setDMX(byte[] dmxData, int numChannels) {
|
||||
public final void setDMX(byte[] dmxData, int numChannels) {
|
||||
this.numChannels = numChannels;
|
||||
data.setByteChunk(dmxData, 18, numChannels);
|
||||
data.setInt16((1 == numChannels % 2 ? numChannels + 1 : numChannels),
|
||||
getData().setByteChunk(dmxData, 18, numChannels);
|
||||
getData().setInt16((1 == numChannels % 2 ? numChannels + 1 : numChannels),
|
||||
16);
|
||||
}
|
||||
|
||||
|
@ -89,34 +89,34 @@ public class ArtDmxPacket extends ArtNetPacket {
|
|||
* @param numChannels
|
||||
* the number of DMX channels to set
|
||||
*/
|
||||
public void setNumChannels(int numChannels) {
|
||||
public final void setNumChannels(int numChannels) {
|
||||
this.numChannels = numChannels > 512 ? 512 : numChannels;
|
||||
}
|
||||
|
||||
public void setSequenceID(int id) {
|
||||
public final void setSequenceID(int id) {
|
||||
sequenceID = id % 0xff;
|
||||
data.setInt8(id, 12);
|
||||
getData().setInt8(id, 12);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subnetID
|
||||
* the subnetID to set
|
||||
*/
|
||||
public void setSubnetID(int subnetID) {
|
||||
public final void setSubnetID(int subnetID) {
|
||||
this.subnetID = subnetID & 0x0f;
|
||||
}
|
||||
|
||||
public void setUniverse(int subnetID, int universeID) {
|
||||
public final void setUniverse(int subnetID, int universeID) {
|
||||
this.subnetID = subnetID & 0x0f;
|
||||
this.universeID = universeID & 0x0f;
|
||||
data.setInt16LE(subnetID << 4 | universeID, 14);
|
||||
getData().setInt16LE(subnetID << 4 | universeID, 14);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param universeID
|
||||
* the universeID to set
|
||||
*/
|
||||
public void setUniverseID(int universeID) {
|
||||
public final void setUniverseID(int universeID) {
|
||||
this.universeID = universeID & 0x0f;
|
||||
}
|
||||
}
|
|
@ -3,25 +3,30 @@ package de.ctdo.bunti.artnet.packets;
|
|||
import de.ctdo.bunti.artnet.ByteUtils;
|
||||
|
||||
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;
|
||||
|
||||
protected ByteUtils data;
|
||||
protected final PacketType type;
|
||||
private ByteUtils data;
|
||||
private final PacketType type;
|
||||
|
||||
|
||||
public final ByteUtils getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArtNetPacket(PacketType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
public final byte[] getRawData() {
|
||||
return data.getBytes();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return data.length;
|
||||
return getData().getLength();
|
||||
}
|
||||
|
||||
public PacketType getType() {
|
||||
public final PacketType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -40,11 +45,11 @@ public abstract class ArtNetPacket {
|
|||
* @param data
|
||||
* the data to set
|
||||
*/
|
||||
public void setData(byte[] data) {
|
||||
public final void setData(byte[] 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) {
|
||||
byte[] raw2 = new byte[maxLength];
|
||||
System.arraycopy(raw, 0, raw2, 0, maxLength);
|
||||
|
@ -53,17 +58,17 @@ public abstract class ArtNetPacket {
|
|||
setData(raw);
|
||||
}
|
||||
|
||||
protected void setHeader() {
|
||||
protected final void setHeader() {
|
||||
data.setByteChunk(HEADER, 0, 8);
|
||||
data.setInt16LE(type.getOpCode(), 8);
|
||||
}
|
||||
|
||||
protected void setProtocol() {
|
||||
protected final void setProtocol() {
|
||||
data.setInt16(PROTOCOL_VERSION, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return data.toHex(getLength());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
|||
private BuntiDevicesDAO devicesDAO;
|
||||
|
||||
@Autowired
|
||||
public void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
|
||||
public final void setDevicesDAO(BuntiDevicesDAO devicesDAO) {
|
||||
this.devicesDAO = devicesDAO;
|
||||
}
|
||||
|
||||
public void performJSONString(String json) {
|
||||
public final void performJSONString(String json) {
|
||||
|
||||
JSONObject jsonobj = JSONObject.fromObject(json);
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
|||
}
|
||||
|
||||
@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);
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class BuntiControllerImpl implements BuntiController, ApplicationEventPub
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
|
||||
public final void setApplicationEventPublisher(ApplicationEventPublisher publisher) {
|
||||
this.applicationEventPublisher = publisher;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
|
|||
|
||||
|
||||
@Override
|
||||
public Collection<BuntiDMXDevice> getAllDMXDevices() {
|
||||
public final Collection<BuntiDMXDevice> getAllDMXDevices() {
|
||||
List<BuntiDMXDevice> liste = new ArrayList<BuntiDMXDevice>();
|
||||
for (BuntiDevice device : devices) {
|
||||
if( device instanceof BuntiDMXDevice ) {
|
||||
|
@ -46,7 +46,7 @@ public class BuntiDevicesDAOImpl implements BuntiDevicesDAO {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BuntiDevice getDeviceById(int deviceId) {
|
||||
public final BuntiDevice getDeviceById(int deviceId) {
|
||||
for (BuntiDevice dev : devices) {
|
||||
if(dev.getDeviceId() == deviceId) {
|
||||
return dev;
|
||||
|
|
|
@ -11,7 +11,7 @@ import de.ctdo.bunti.model.BuntiSwitchingDevice;
|
|||
public class DeviceMixerImpl implements DeviceMixer, ApplicationListener<DeviceChangedEvent> {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(DeviceChangedEvent arg0) {
|
||||
public final void onApplicationEvent(DeviceChangedEvent arg0) {
|
||||
|
||||
if( arg0.getDevice() instanceof BuntiSwitchingDevice) {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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_MIN = 0;
|
||||
|
@ -19,17 +19,23 @@ public class DMX {
|
|||
|
||||
/**
|
||||
* Checks the DMX Value boundaries
|
||||
*
|
||||
* @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;
|
||||
if(value > DMX_CHANNEL_VALUE_MAX) value = DMX_CHANNEL_VALUE_MAX;
|
||||
if (value < DMX_CHANNEL_VALUE_MIN) {
|
||||
return DMX_CHANNEL_VALUE_MIN;
|
||||
}
|
||||
if (value > DMX_CHANNEL_VALUE_MAX) {
|
||||
return DMX_CHANNEL_VALUE_MAX;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the DMX Channel boundaries
|
||||
*
|
||||
* @param channel The channel to check
|
||||
* @return True if channel is valid. Otherwise false.
|
||||
*/
|
||||
|
@ -38,5 +44,4 @@ public class DMX {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,41 +12,41 @@ public class DMXChannel {
|
|||
this.value = 0;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
public final int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
public final void setValue(int value) {
|
||||
this.value = value;
|
||||
lastChangedTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getLastChangedTimestamp() {
|
||||
public final long getLastChangedTimestamp() {
|
||||
return lastChangedTimestamp;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
public final int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(int offset) {
|
||||
public final void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public final void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void hasbeenSendOut() {
|
||||
public final void hasbeenSendOut() {
|
||||
this.lastChangedTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return "DMXChannel " + getName() + "," + getOffset() + "," + getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,14 +12,14 @@ import java.util.Map;
|
|||
*/
|
||||
public class DMXChannels {
|
||||
|
||||
protected Map<Integer,DMXChannel> channelByNumber = new HashMap<Integer, DMXChannel>();
|
||||
protected Map<String,DMXChannel> channelByName = new HashMap<String, DMXChannel>();
|
||||
private Map<Integer,DMXChannel> channelByNumber = new HashMap<Integer, DMXChannel>();
|
||||
private Map<String,DMXChannel> channelByName = new HashMap<String, DMXChannel>();
|
||||
|
||||
/**
|
||||
* Returns the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
public int getCount() {
|
||||
public final int getCount() {
|
||||
return this.channelByNumber.size();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class DMXChannels {
|
|||
* @param name channel name
|
||||
* @return channel or null if not found
|
||||
*/
|
||||
public DMXChannel getChannelByName(String name) {
|
||||
public final DMXChannel getChannelByName(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class DMXChannels {
|
|||
* @param number number
|
||||
* @return channel or null if not found
|
||||
*/
|
||||
public DMXChannel getChannelByNumber(int number) {
|
||||
public final DMXChannel getChannelByNumber(int number) {
|
||||
return this.channelByNumber.get(number);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class DMXChannels {
|
|||
* @param channel channel to add
|
||||
* @return true on success, false on error
|
||||
*/
|
||||
public boolean addChannel(DMXChannel channel) {
|
||||
public final boolean addChannel(DMXChannel channel) {
|
||||
// object cannot be null
|
||||
if (channel == null) {
|
||||
return false;
|
||||
|
@ -76,7 +76,7 @@ public class DMXChannels {
|
|||
* @param offset offset
|
||||
* @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);
|
||||
if (tmpChannel != null) {
|
||||
this.channelByName.remove(tmpChannel.getName());
|
||||
|
@ -89,7 +89,7 @@ public class DMXChannels {
|
|||
* @param name channel name
|
||||
* @return removed channel or null if it does not exist
|
||||
*/
|
||||
public DMXChannel removeChannel(String name) {
|
||||
public final DMXChannel removeChannel(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class DMXChannels {
|
|||
* Returns an (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());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
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.HashMap;
|
||||
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
|
||||
|
||||
public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChangedEvent> {
|
||||
|
@ -28,12 +26,12 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
|||
private boolean hasDataChanged = true;
|
||||
|
||||
@Autowired
|
||||
public void setArtNetSender(SimpleArtNetSender artNetSender) {
|
||||
public final void setArtNetSender(SimpleArtNetSender artNetSender) {
|
||||
this.artNetSender = artNetSender;
|
||||
}
|
||||
|
||||
|
||||
public void initDMXData() {
|
||||
public final void initDMXData() {
|
||||
for (int i = 0; i <= DMX.DMX_CHANNELS_MAX; i++) {
|
||||
dmxMap.put(i, 0);
|
||||
}
|
||||
|
@ -41,8 +39,10 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
|||
|
||||
|
||||
@Scheduled(fixedDelay = 100) //TODO aendern auf 10ms
|
||||
public void sendOutDMXBuffer() {
|
||||
if( dmxMap.size() == 0) initDMXData();
|
||||
public final void sendOutDMXBuffer() {
|
||||
if (dmxMap.size() == 0) {
|
||||
initDMXData();
|
||||
}
|
||||
|
||||
if (hasDataChanged) {
|
||||
artNetSender.sendDMXData(dmxMap, ARTNET_DEVICE_ADDRESS);
|
||||
|
@ -52,7 +52,7 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
|||
// 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;
|
||||
|
||||
if (dmxDev.setValuesFromOptions(options)) {
|
||||
|
@ -60,23 +60,25 @@ public class DMXMixerImpl implements DMXMixer, ApplicationListener<DeviceChanged
|
|||
dmxMap.putAll(dmxDev.getChannelData());
|
||||
|
||||
LOGGER.info("setValuesFromOptions on " + device);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LOGGER.info("setValuesFromOptions on " + device + " failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDMX512Channel(int channel, int value) {
|
||||
if(!DMX.checkChannelBoundaries(channel)) return;
|
||||
value = DMX.sanitizeDMXValue(value);
|
||||
public final void setDMX512Channel(int channel, int value) {
|
||||
if (!DMX.checkChannelBoundaries(channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dmxMap.put(channel, value);
|
||||
dmxMap.put(channel, DMX.sanitizeDMXValue(value));
|
||||
hasDataChanged = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(DeviceChangedEvent arg0) {
|
||||
public final void onApplicationEvent(DeviceChangedEvent arg0) {
|
||||
if (arg0.getDevice() instanceof BuntiDMXDevice) {
|
||||
updateDevice(arg0.getDevice(), arg0.getOptions());
|
||||
|
||||
|
|
|
@ -7,29 +7,29 @@ import java.util.Map.Entry;
|
|||
import de.ctdo.bunti.dmx.*;
|
||||
|
||||
public abstract class BuntiDMXDevice extends BuntiDevice {
|
||||
protected int startAddress;
|
||||
private int startAddress;
|
||||
private long lastSendOut;
|
||||
protected DMXChannels dmxChannels = new DMXChannels();
|
||||
private DMXChannels dmxChannels = new DMXChannels();
|
||||
|
||||
public BuntiDMXDevice(int deviceId, int startAddress, String name) {
|
||||
super(deviceId,name);
|
||||
this.startAddress = startAddress;
|
||||
this.deviceName = name;
|
||||
this.deviceId = deviceId;
|
||||
|
||||
}
|
||||
|
||||
public long getLastSendOut() {
|
||||
public final long getLastSendOut() {
|
||||
return lastSendOut;
|
||||
}
|
||||
|
||||
public void setSendOutNow() {
|
||||
public final void setSendOutNow() {
|
||||
this.lastSendOut = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public int getStartAddress() {
|
||||
public final int getStartAddress() {
|
||||
return startAddress;
|
||||
}
|
||||
|
||||
public void setStartAddress(int startAddress) {
|
||||
public final void setStartAddress(int startAddress) {
|
||||
this.startAddress = startAddress;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
|||
* @param name The channel name to change the value.
|
||||
* @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);
|
||||
if(dx != null) {
|
||||
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.
|
||||
* @return The desired channel value.
|
||||
*/
|
||||
protected int getChannelValueByName(String name) {
|
||||
protected final int getChannelValueByName(String name) {
|
||||
DMXChannel dx = dmxChannels.getChannelByName(name);
|
||||
if(dx != null) {
|
||||
return dx.getValue();
|
||||
|
@ -122,7 +122,7 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setValuesFromOptions(Map<String, Object> options) {
|
||||
public final boolean setValuesFromOptions(Map<String, Object> options) {
|
||||
|
||||
for (Entry<String, Object> opt : options.entrySet()) {
|
||||
|
||||
|
@ -142,8 +142,12 @@ public abstract class BuntiDMXDevice extends BuntiDevice {
|
|||
return true;
|
||||
}
|
||||
|
||||
public final boolean addChannel(DMXChannel channel){
|
||||
return dmxChannels.addChannel(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BuntiDMXDevice " + deviceId + ", " + deviceName;
|
||||
return "BuntiDMXDevice " + getDeviceId() + ", " + getDeviceName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,27 +3,37 @@ package de.ctdo.bunti.model;
|
|||
import java.util.Map;
|
||||
|
||||
public abstract class BuntiDevice {
|
||||
protected int deviceId;
|
||||
protected String deviceName;
|
||||
private int deviceId;
|
||||
private String deviceName;
|
||||
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;
|
||||
}
|
||||
|
||||
public long getLastChanged() {
|
||||
public final long getLastChanged() {
|
||||
return lastChanged;
|
||||
}
|
||||
|
||||
protected void lastChangedNow() {
|
||||
protected final void lastChangedNow() {
|
||||
this.lastChanged = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
public final String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
public final void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,15 @@ import java.util.Map;
|
|||
|
||||
public class BuntiSwitchingDevice extends BuntiDevice {
|
||||
|
||||
|
||||
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() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -17,7 +26,7 @@ public class BuntiSwitchingDevice extends BuntiDevice {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setValuesFromOptions(Map<String, Object> options) {
|
||||
public final boolean setValuesFromOptions(Map<String, Object> options) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5,43 +5,44 @@ import de.ctdo.bunti.dmx.DMXChannel;
|
|||
|
||||
public class Par56Spot extends BuntiDMXDevice {
|
||||
|
||||
private final static String CHANNEL_MODE = "mode";
|
||||
private final static String CHANNEL_RED = "red";
|
||||
private final static String CHANNEL_GREEN = "green";
|
||||
private final static String CHANNEL_BLUE = "blue";
|
||||
private final static String CHANNEL_SPEED = "speed";
|
||||
private static final String CHANNEL_MODE = "mode";
|
||||
private static final String CHANNEL_RED = "red";
|
||||
private static final String CHANNEL_GREEN = "green";
|
||||
private static final String CHANNEL_BLUE = "blue";
|
||||
private static final String CHANNEL_SPEED = "speed";
|
||||
|
||||
public Par56Spot(int deviceId, int startAddress, String deviceName) {
|
||||
super(deviceId, startAddress, deviceName);
|
||||
|
||||
dmxChannels.addChannel(new DMXChannel(0, CHANNEL_MODE));
|
||||
dmxChannels.addChannel(new DMXChannel(1, "red"));
|
||||
dmxChannels.addChannel(new DMXChannel(2, CHANNEL_GREEN));
|
||||
dmxChannels.addChannel(new DMXChannel(3, CHANNEL_BLUE));
|
||||
dmxChannels.addChannel(new DMXChannel(4, CHANNEL_SPEED));
|
||||
|
||||
addChannel(new DMXChannel(0, CHANNEL_MODE));
|
||||
addChannel(new DMXChannel(1, "red"));
|
||||
addChannel(new DMXChannel(2, CHANNEL_GREEN));
|
||||
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);
|
||||
}
|
||||
public void setColorGreen(int value) {
|
||||
public final void setColorGreen(int value) {
|
||||
setChannelValueByName(CHANNEL_GREEN, value);
|
||||
}
|
||||
public void setColorBlue(int value) {
|
||||
public final void setColorBlue(int value) {
|
||||
setChannelValueByName(CHANNEL_BLUE, value);
|
||||
}
|
||||
public int getColorRed() {
|
||||
public final int getColorRed() {
|
||||
return getChannelValueByName(CHANNEL_RED);
|
||||
}
|
||||
public int getColorGreen() {
|
||||
public final int getColorGreen() {
|
||||
return getChannelValueByName(CHANNEL_GREEN);
|
||||
}
|
||||
public int getColorBlue() {
|
||||
public final int getColorBlue() {
|
||||
return getChannelValueByName(CHANNEL_BLUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchOff() {
|
||||
public final void switchOff() {
|
||||
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setColorRed(DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setColorGreen(DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
|
@ -50,7 +51,7 @@ public class Par56Spot extends BuntiDMXDevice {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void switchOn() {
|
||||
public final void switchOn() {
|
||||
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setColorRed(DMX.DMX_CHANNEL_VALUE_MAX);
|
||||
setColorGreen(DMX.DMX_CHANNEL_VALUE_MAX);
|
||||
|
@ -59,8 +60,8 @@ public class Par56Spot extends BuntiDMXDevice {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Par56Spot " + deviceId + ", " + deviceName + " " +
|
||||
public final String toString() {
|
||||
return "Par56Spot " + getDeviceId() + ", " + getDeviceName() + " " +
|
||||
"[" + getColorRed() + "," + getColorGreen() + "," + getColorBlue() + "]";
|
||||
}
|
||||
|
||||
|
|
|
@ -5,54 +5,54 @@ import de.ctdo.bunti.dmx.DMXChannel;
|
|||
|
||||
public class Strobe1500 extends BuntiDMXDevice {
|
||||
|
||||
private final static String CHANNEL_SPEED = "speed";
|
||||
private final static String CHANNEL_INTENSITY = "intensity";
|
||||
private final static String CHANNEL_MODE = "mode";
|
||||
private static final String CHANNEL_SPEED = "speed";
|
||||
private static final String CHANNEL_INTENSITY = "intensity";
|
||||
private static final String CHANNEL_MODE = "mode";
|
||||
|
||||
public Strobe1500(int deviceId, int startAddress, String deviceName) {
|
||||
super(deviceId, startAddress, deviceName);
|
||||
|
||||
this.dmxChannels.addChannel(new DMXChannel(0, CHANNEL_SPEED));
|
||||
this.dmxChannels.addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
|
||||
this.dmxChannels.addChannel(new DMXChannel(2, CHANNEL_MODE));
|
||||
addChannel(new DMXChannel(0, CHANNEL_SPEED));
|
||||
addChannel(new DMXChannel(1, CHANNEL_INTENSITY));
|
||||
addChannel(new DMXChannel(2, CHANNEL_MODE));
|
||||
}
|
||||
|
||||
public void setSpeed(int value) {
|
||||
public final void setSpeed(int value) {
|
||||
setChannelValueByName(CHANNEL_SPEED, value);
|
||||
}
|
||||
public void setIntensity(int value) {
|
||||
public final void setIntensity(int value) {
|
||||
setChannelValueByName(CHANNEL_INTENSITY, value);
|
||||
}
|
||||
public void setMode(int value) {
|
||||
public final void setMode(int value) {
|
||||
setChannelValueByName(CHANNEL_MODE, value);
|
||||
}
|
||||
public int getSpeed() {
|
||||
public final int getSpeed() {
|
||||
return getChannelValueByName(CHANNEL_SPEED);
|
||||
}
|
||||
public int getIntensity() {
|
||||
public final int getIntensity() {
|
||||
return getChannelValueByName(CHANNEL_INTENSITY);
|
||||
}
|
||||
public int getMode() {
|
||||
public final int getMode() {
|
||||
return getChannelValueByName(CHANNEL_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchOff() {
|
||||
public final void switchOff() {
|
||||
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchOn() {
|
||||
public final void switchOn() {
|
||||
setChannelValueByName(CHANNEL_MODE, DMX.DMX_CHANNEL_VALUE_MIN);
|
||||
setChannelValueByName(CHANNEL_SPEED, DMX.DMX_CHANNEL_VALUE_MAX);
|
||||
setChannelValueByName(CHANNEL_INTENSITY, DMX.DMX_CHANNEL_VALUE_MAX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Strobe1500 " + deviceId + ", " + deviceName +
|
||||
public final String toString() {
|
||||
return "Strobe1500 " + getDeviceId() + ", " + getDeviceName() +
|
||||
"[" + getSpeed() + "," + getIntensity() + "," + getMode() + "]";
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,15 @@ import de.ctdo.bunti.control.BuntiController;
|
|||
@Controller
|
||||
public class TestController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
|
||||
BuntiController buntiController;
|
||||
private BuntiController buntiController;
|
||||
|
||||
@Autowired
|
||||
public void setBuntiController(BuntiController buntiController) {
|
||||
public final void setBuntiController(BuntiController buntiController) {
|
||||
this.buntiController = buntiController;
|
||||
}
|
||||
|
||||
@RequestMapping("/foobar")
|
||||
public ModelAndView blafasel() {
|
||||
public final ModelAndView blafasel() {
|
||||
Map<String,Object> options = new HashMap<String,Object>();
|
||||
|
||||
options.put("red", 124);
|
||||
|
@ -59,7 +59,7 @@ public class TestController {
|
|||
}
|
||||
|
||||
@RequestMapping("/foobar2")
|
||||
public ModelAndView blafasel2() {
|
||||
public final ModelAndView blafasel2() {
|
||||
|
||||
|
||||
Map<String,Object> options = new HashMap<String,Object>();
|
||||
|
|
|
@ -12,23 +12,23 @@ import com.sun.grizzly.websockets.WebSocketListener;
|
|||
|
||||
@Component
|
||||
public class BuntiControllerApplication extends WebSocketApplication {
|
||||
Logger logger = LoggerFactory.getLogger(BuntiControllerApplication.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerApplication.class);
|
||||
|
||||
@Override
|
||||
public WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) {
|
||||
public final WebSocket createWebSocket(ProtocolHandler protocolHandler, WebSocketListener... listeners) {
|
||||
BuntiControllerWebSocket socket = new BuntiControllerWebSocket(protocolHandler, listeners);
|
||||
// BuntiControllerImpl.getInstance().addListener(socket);
|
||||
return socket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicationRequest(Request request) {
|
||||
public final boolean isApplicationRequest(Request request) {
|
||||
final String uri = request.requestURI().toString();
|
||||
return uri.endsWith("/bunti");
|
||||
}
|
||||
|
||||
@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;
|
||||
// BuntiControllerImpl.getInstance().removeListener(ws);
|
||||
}
|
||||
|
|
|
@ -9,32 +9,32 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class BuntiControllerServlet { // extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
Logger logger = LoggerFactory.getLogger(BuntiControllerServlet.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BuntiControllerServlet.class);
|
||||
|
||||
private BuntiControllerApplication app;
|
||||
|
||||
@Autowired
|
||||
public void setApp(BuntiControllerApplication app) {
|
||||
public final void setApp(BuntiControllerApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BuntiControllerApplication() {
|
||||
public void buntiControllerApplication() {
|
||||
// WebSocketEngine.getEngine().register(app);
|
||||
// logger.debug("registered BuntiControllerApplication");
|
||||
// LOGGER.debug("registered buntiControllerApplication");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void init(ServletConfig config) throws ServletException {
|
||||
// WebSocketEngine.getEngine().register(app);
|
||||
// logger.debug("registered BuntiControllerApplication");
|
||||
// LOGGER.debug("registered buntiControllerApplication");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void destroy() {
|
||||
// WebSocketEngine.getEngine().unregister(app);
|
||||
// logger.debug("unregistered BuntiControllerApplication");
|
||||
// LOGGER.debug("unregistered buntiControllerApplication");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.sun.grizzly.websockets.WebSocketListener;
|
|||
*/
|
||||
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) {
|
||||
super(protocolHandler, listeners);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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");
|
||||
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,
|
||||
"\\\\$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",
|
||||
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==
|
||||
"\\\\$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("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():
|
||||
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/
|
||||
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=
|
||||
|
|
Loading…
Reference in New Issue