本文整理汇总了Java中tuwien.auto.calimero.exception.KNXIllegalArgumentException类的典型用法代码示例。如果您正苦于以下问题:Java KNXIllegalArgumentException类的具体用法?Java KNXIllegalArgumentException怎么用?Java KNXIllegalArgumentException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KNXIllegalArgumentException类属于tuwien.auto.calimero.exception包,在下文中一共展示了KNXIllegalArgumentException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGroupAPDU
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a group service application layer protocol data unit containing
* all items of a DPT translator.
* <p>
* The transport layer bits in the first byte (TL / AL control field) are
* set 0. The maximum length used for the ASDU is not checked.<br>
* For DPTs occupying <= 6 bits in length the optimized (compact) group
* write / response format layout is used.
*
* @param service application layer group service code
* @param t DPT translator with items to put into ASDU
* @return group APDU as byte array
*/
private byte[] createGroupAPDU(final int service, final DPTXlator t) {
// check for group read
if (service == 0x00) {
return new byte[2];
}
// only group response and group write are allowed
if (service != 0x40 && service != 0x80) {
throw new KNXIllegalArgumentException("not an APDU group service");
}
// determine if data starts at byte offset 1 (optimized) or 2 (default)
final int offset = t.getItems() == 1 && t.getTypeSize() == 0 ? 1 : 2;
final byte[] buf = new byte[t.getItems() * Math.max(1, t.getTypeSize()) + offset];
buf[0] = (byte) (service >> 8);
buf[1] = (byte) service;
return t.getData(buf, offset);
}
示例2: getMedium
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a medium settings type for the supplied medium identifier.
* <p>
*
* @param id a medium identifier from command line option
* @return medium settings object
* @throws KNXIllegalArgumentException on unknown medium identifier
*/
private static KNXMediumSettings getMedium(String id)
{
if (id.equals("tp0"))
return TPSettings.TP0;
else if (id.equals("tp1"))
return TPSettings.TP1;
else if (id.equals("p110"))
return new PLSettings(false);
else if (id.equals("p132"))
return new PLSettings(true);
else if (id.equals("rf"))
return new RFSettings(null);
else
throw new KNXIllegalArgumentException("unknown medium");
}
示例3: createEMI
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
private byte[] createEMI(int mc, KNXAddress dst, Priority p, byte[] nsdu)
{
if (nsdu.length > 16)
throw new KNXIllegalArgumentException(
"maximum TPDU length is 16 in standard frame");
// TP1, standard frames only
final byte[] buf = new byte[nsdu.length + 7];
buf[0] = (byte) mc;
// ack don't care
buf[1] = (byte) (p.value << 2);
// on dst null, default address 0 is used
// (null indicates system broadcast in link API)
final int d = dst != null ? dst.getRawAddress() : 0;
buf[4] = (byte) (d >> 8);
buf[5] = (byte) d;
buf[6] = (byte) (hopCount << 4 | (nsdu.length - 1));
if (dst instanceof GroupAddress)
buf[6] |= 0x80;
for (int i = 0; i < nsdu.length; ++i)
buf[7 + i] = nsdu[i];
return buf;
}
示例4: readProperty
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
public byte[] readProperty(Destination dst, int objIndex, int propID, int start,
int elements) throws KNXTimeoutException, KNXRemoteException,
KNXDisconnectException, KNXLinkClosedException
{
if (objIndex < 0 || objIndex > 255 || propID < 0 || propID > 255 || start < 0
|| start > 0xFFF || elements < 0 || elements > 15)
throw new KNXIllegalArgumentException("argument value out of range");
final byte[] asdu = new byte[4];
asdu[0] = (byte) objIndex;
asdu[1] = (byte) propID;
asdu[2] = (byte) ((elements << 4) | ((start >>> 8) & 0xF));
asdu[3] = (byte) start;
final byte[] apdu = sendWait2(dst, priority, DataUnitBuilder.createAPDU(
PROPERTY_READ, asdu), PROPERTY_RESPONSE, 4, 14);
// check if number of elements is 0, indicates access problem
final int number = (apdu[4] & 0xFF) >>> 4;
if (number == 0)
throw new KNXRemoteException("property access failed/forbidden");
if (number != elements)
throw new KNXInvalidResponseException("number of elements differ");
final byte[] prop = new byte[apdu.length - 6];
for (int i = 0; i < prop.length; ++i)
prop[i] = apdu[i + 6];
return prop;
}
示例5: readPropertyDesc
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
public byte[] readPropertyDesc(Destination dst, int objIndex, int propID,
int propIndex) throws KNXTimeoutException, KNXRemoteException,
KNXDisconnectException, KNXLinkClosedException
{
if (objIndex < 0 || objIndex > 255 || propID < 0 || propID > 255 || propIndex < 0
|| propIndex > 255)
throw new KNXIllegalArgumentException("argument value out of range");
final byte[] send = DataUnitBuilder.createAPDU(PROPERTY_DESC_READ, new byte[] {
(byte) objIndex, (byte) propID, (byte) (propID == 0 ? propIndex : 0) });
final byte[] apdu = sendWait2(dst, priority, send, PROPERTY_DESC_RESPONSE, 7, 7);
// max_nr_elem field is a 4bit exponent + 12bit unsigned
// on problem this field is 0
if (apdu[6] == 0 && apdu[7] == 0)
throw new KNXRemoteException(
"got no property description (object non-existant?)");
return new byte[] { apdu[2], apdu[3], apdu[4], apdu[5], apdu[6], apdu[7], apdu[8] };
}
示例6: readADC
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
public int readADC(Destination dst, int channelNr, int repeat)
throws KNXTimeoutException, KNXDisconnectException, KNXRemoteException,
KNXLinkClosedException
{
if (channelNr < 0 || channelNr > 63 || repeat < 0 || repeat > 255)
throw new KNXIllegalArgumentException("ADC arguments out of range");
if (dst.isConnectionOriented())
tl.connect(dst);
else
logger.error("doing read ADC in connectionless mode, " + dst.toString());
final byte[] apdu =
sendWait(dst, priority, DataUnitBuilder.createCompactAPDU(ADC_READ,
new byte[] { (byte) channelNr, (byte) repeat }), ADC_RESPONSE, 3, 3);
if (apdu[2] == 0)
throw new KNXRemoteException("error reading value of A/D converter");
return ((apdu[3] & 0xff) << 8) | apdu[4] & 0xff;
}
示例7: authorize
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
public byte authorize(Destination dst, byte[] key) throws KNXDisconnectException,
KNXTimeoutException, KNXRemoteException, KNXLinkClosedException
{
if (key.length != 4)
throw new KNXIllegalArgumentException("length of authorize key not 4 bytes");
if (dst.isConnectionOriented())
tl.connect(dst);
else
logger.error("doing authorize in connectionless mode, " + dst.toString());
final byte[] apdu =
sendWait(dst, priority, DataUnitBuilder.createAPDU(AUTHORIZE_READ, key),
AUTHORIZE_RESPONSE, 1, 1);
final int level = apdu[2] & 0xff;
if (level > 15)
throw new KNXInvalidResponseException(
"authorization level out of range [0..15]");
return (byte) level;
}
示例8: writeKey
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
public void writeKey(Destination dst, int level, byte[] key)
throws KNXTimeoutException, KNXDisconnectException, KNXRemoteException,
KNXLinkClosedException
{
// level 255 is free access
if (level < 0 || level > 254 || key.length != 4)
throw new KNXIllegalArgumentException(
"level out of range or key length not 4 bytes");
if (dst.isConnectionOriented())
tl.connect(dst);
else
logger.error("doing write key in connectionless mode, " + dst.toString());
final byte[] apdu =
sendWait(dst, priority, DataUnitBuilder.createAPDU(KEY_WRITE, new byte[] {
(byte) level, key[0], key[1], key[2], key[3] }), KEY_RESPONSE, 1, 1);
if ((apdu[1] & 0xFF) == 0xFF)
throw new KNXRemoteException(
"access denied: current access level > write level");
}
示例9: createDestination
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* {@inheritDoc} Only one destination can be created per remote address. If a
* destination with the supplied remote address already exists for this transport
* layer, a {@link KNXIllegalArgumentException} is thrown.<br>
* A transport layer can only handle one connection per destination, because it can't
* distinguish incoming messages between more than one connection.
*/
public Destination createDestination(IndividualAddress remote,
boolean connectionOriented, boolean keepAlive, boolean verifyMode)
{
if (detached)
throw new KNXIllegalStateException("TL detached");
synchronized (proxies) {
if (proxies.containsKey(remote))
throw new KNXIllegalArgumentException("destination already created: "
+ remote);
final AggregatorProxy p = new AggregatorProxy(this);
final Destination d =
new Destination(p, remote, connectionOriented, keepAlive, verifyMode);
proxies.put(remote, p);
logger.trace("destination " + remote + " ready for use");
return d;
}
}
示例10: createGroupAPDU
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a group service application layer protocol data unit containing all
* items of a DPT translator.
* <p>
* The transport layer bits in the first byte (TL / AL control field) are set 0. The
* maximum length used for the ASDU is not checked.<br>
* For DPTs occupying <= 6 bits in length the optimized (compact) group write /
* response format layout is used.
*
* @param service application layer group service code
* @param t DPT translator with items to put into ASDU
* @return group APDU as byte array
*/
private static byte[] createGroupAPDU(int service, DPTXlator t)
{
// check for group read
if (service == 0x00)
return new byte[2];
// only group response and group write are allowed
if (service != 0x40 && service != 0x80)
throw new KNXIllegalArgumentException("not an APDU group service");
// determine if data starts at byte offset 1 (optimized) or 2 (default)
final int offset = (t.getItems() == 1 && t.getTypeSize() == 0) ? 1 : 2;
final byte[] buf = new byte[t.getItems() * Math.max(1, t.getTypeSize()) + offset];
buf[0] = (byte) (service >> 8);
buf[1] = (byte) service;
return t.getData(buf, offset);
}
示例11: sendData
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
private void sendData(byte[] data) throws IOException, KNXPortClosedException
{
if (data.length > 255)
throw new KNXIllegalArgumentException("data length > 255 bytes");
if (state == CLOSED)
throw new KNXPortClosedException("connection closed");
final byte[] buf = new byte[data.length + 7];
int i = 0;
buf[i++] = START;
buf[i++] = (byte) (data.length + 1);
buf[i++] = (byte) (data.length + 1);
buf[i++] = START;
buf[i++] = (byte) (INITIATOR | sendFrameCount | FRAMECOUNT_VALID | USER_DATA);
for (int k = 0; k < data.length; ++k)
buf[i++] = data[k];
buf[i++] = checksum(buf, 4, data.length + 1);
buf[i++] = END;
state = ACK_PENDING;
os.write(buf);
os.flush();
}
示例12: setFrame
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* {@inheritDoc}<br>
* If a maximum size is set and the queue already reached maximum size, if
* {@link #isOverwrite()} evaluates to<br> - <code>true</code>, <code>frame</code>
* will replace the oldest inserted frame<br> - <code>false</code>,
* <code>frame</code> is ignored and not queued.
*/
public synchronized void setFrame(CEMILData frame)
{
if (!frame.getDestination().equals(getKey()))
throw new KNXIllegalArgumentException("frame key differs from this key");
if (!max)
ensureCapacity();
else if (!overwrite && size == timestamps.length)
return;
final CEMILData[] c = (CEMILData[]) value;
// notify on first time queue fills up
final boolean notifyListener = max && size == c.length - 1;
resetTimestamp();
c[next] = frame;
timestamps[next] = getTimestamp();
++next;
next %= c.length;
if (size < c.length)
++size;
if (notifyListener)
fireQueueFilled();
}
示例13: CEMIDevMgmt
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a new device management message from a byte stream.
* <p>
*
* @param data byte stream containing a cEMI device management message
* @param offset start offset of cEMI frame in <code>data</code>
* @param length length in bytes of the whole device management message
* @throws KNXFormatException if no device management frame found or invalid frame
* structure
*/
public CEMIDevMgmt(byte[] data, int offset, int length) throws KNXFormatException
{
final ByteArrayInputStream is = new ByteArrayInputStream(data, offset, length);
checkLength(is, 1);
try {
checkSetMC((short) is.read());
}
catch (final KNXIllegalArgumentException e) {
throw new KNXFormatException(e.getMessage());
}
if (mc == MC_RESET_REQ || mc == MC_RESET_IND)
initReset(is);
else {
initHeader(is);
initBody(is);
}
}
示例14: ServiceAck
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a new service acknowledge out of a byte array.
* <p>
*
* @param serviceType service acknowledge type identifier describing the acknowledge
* in <code>data</code>, 0 <= type <= 0xFFFF
* @param data byte array containing a service acknowledge structure
* @param offset start offset of acknowledge in <code>data</code>
* @throws KNXFormatException if buffer is too short for acknowledge, on unsupported
* service type or connection header structure
*/
public ServiceAck(int serviceType, byte[] data, int offset) throws KNXFormatException
{
super(serviceType);
if (serviceType < 0 || serviceType > 0xffff)
throw new KNXIllegalArgumentException(
"service ack type out of range [0..0xffff]");
if (data.length - offset < CONN_HEADER_SIZE)
throw new KNXFormatException("buffer too short for service ack");
int i = offset;
if ((data[i++] & 0xFF) != CONN_HEADER_SIZE)
throw new KNXFormatException("unsupported connection header");
channelid = (short) (data[i++] & 0xFF);
seq = (short) (data[i++] & 0xFF);
status = (short) (data[i++] & 0xFF);
}
示例15: RoutingLostMessage
import tuwien.auto.calimero.exception.KNXIllegalArgumentException; //导入依赖的package包/类
/**
* Creates a new routing lost message indication.
* <p>
*
* @param lostMessages number of KNXnet/IP routing messages lost
* @param deviceState router device state, the router KNX property in object type 11,
* PID 69
*/
public RoutingLostMessage(int lostMessages, short deviceState)
{
super(KNXnetIPHeader.ROUTING_LOST_MSG);
if (lostMessages < 0 || lostMessages > 0xFFFF)
throw new KNXIllegalArgumentException(
"lost message count out of range [0..0xFFFF]");
if (deviceState < 0 || deviceState > 0xFF)
throw new KNXIllegalArgumentException(
"device state field out of range [0..0xFF]");
// bits 2 to 7 are reserved for now...
if (deviceState > 0x03)
ServiceType.logger.info("Bits 2..7 not supported in device state");
lost = lostMessages;
state = deviceState;
}