本文整理汇总了Java中tuwien.auto.calimero.Priority.get方法的典型用法代码示例。如果您正苦于以下问题:Java Priority.get方法的具体用法?Java Priority.get怎么用?Java Priority.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tuwien.auto.calimero.Priority
的用法示例。
在下文中一共展示了Priority.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFromEMI
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new cEMI message out of the supplied EMI frame.
* <p>
*
* @param frame EMI frame
* @return the new cEMI message
* @throws KNXFormatException if no (valid) EMI structure was found or unsupported EMI
* message code
*/
public static CEMI createFromEMI(byte[] frame) throws KNXFormatException
{
// check for minimum frame length (i.e. busmonitor)
if (frame.length < 4)
throw new KNXFormatException("EMI frame too short");
final int mc = frame[0] & 0xff;
if (mc == CEMIBusMon.MC_BUSMON_IND) {
return new CEMIBusMon(frame[1] & 0xff, (frame[2] & 0xff) << 8 | frame[3] & 0xff,
false, truncate(frame, 4, frame.length - 4));
}
final Priority p = Priority.get(frame[1] >> 2 & 0x3);
final boolean ack = (frame[1] & 0x02) != 0;
final boolean c = (frame[1] & 0x01) != 0;
final int dst = (frame[4] & 0xff) << 8 | frame[5] & 0xff;
final KNXAddress a = (frame[6] & 0x80) != 0 ?
(KNXAddress) new GroupAddress(dst) : new IndividualAddress(dst);
final int hops = frame[6] >> 4 & 0x07;
final int len = (frame[6] & 0x0f) + 1;
final byte[] tpdu = truncate(frame, 7, Math.min(len, frame.length - 7));
// no long frames in EMI2
return c ? new CEMILData(mc, new IndividualAddress(0), a, tpdu, p, c)
: new CEMILData(mc, new IndividualAddress(0), a, tpdu, p, true, true, ack,
hops);
}
示例2: TP1LData
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new L-data frame out of a byte array.
* <p>
*
* @param data byte array containing the L-data frame
* @param offset start offset of frame structure in <code>data</code>, offset >=
* 0
* @throws KNXFormatException if length of data too short for frame, on no valid frame
* structure
*/
public TP1LData(byte[] data, int offset) throws KNXFormatException
{
final ByteArrayInputStream is =
new ByteArrayInputStream(data, offset, data.length - offset);
final int avail = is.available();
if (avail < MIN_LENGTH)
throw new KNXFormatException("data too short for L-data frame", avail);
final int ctrl = is.read();
// parse control field and check if valid
if ((ctrl & 0x53) != 0x10)
throw new KNXFormatException("invalid control field", ctrl);
type = LDATA_FRAME;
ext = (ctrl & 0x80) == 0;
repetition = (ctrl & 0x20) == 0;
p = Priority.get((ctrl >> 2) & 0x3);
final int ctrle = ext ? readCtrlEx(is) : 0;
src = new IndividualAddress((is.read() << 8) | is.read());
final int addr = (is.read() << 8) | is.read();
final int npci = is.read();
final int len;
if (ext) {
hopcount = (ctrle & 0x70) >> 4;
setDestination(addr, (ctrle & 0x80) != 0);
len = npci;
if (len == 255)
throw new KNXFormatException("escape-code in length field not supported");
}
else {
hopcount = (npci & 0x70) >> 4;
setDestination(addr, (npci & 0x80) != 0);
len = npci & 0x0f;
}
tpdu = new byte[len + 1];
if (is.read(tpdu, 0, tpdu.length) != tpdu.length)
throw new KNXFormatException("data too short for L-data TPDU");
fcs = is.read();
}
示例3: TP1LPollData
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new L-polldata frame out of a byte array.
* <p>
*
* @param data byte array containing the L-polldata frame
* @param offset start offset of frame structure in <code>data</code>, offset >=
* 0
* @throws KNXFormatException if length of data too short for frame, on no valid frame
* structure
*/
public TP1LPollData(byte[] data, int offset) throws KNXFormatException
{
final ByteArrayInputStream is =
new ByteArrayInputStream(data, offset, data.length - offset);
final int avail = is.available();
if (avail < MIN_LENGTH)
throw new KNXFormatException("data too short for L-polldata frame", avail);
final int ctrl = is.read();
// parse control field and check if valid
if (ctrl != 0xF0)
throw new KNXFormatException("invalid control field", ctrl);
type = LPOLLDATA_FRAME;
p = Priority.get((ctrl >> 2) & 0x3);
int addr = (is.read() << 8) | is.read();
src = new IndividualAddress(addr);
addr = (is.read() << 8) | is.read();
dst = new GroupAddress(addr);
final int len = is.read() & 0x0f;
expData = len;
fcs = is.read();
// do we really get poll data response here? don't know for sure..
if (expData <= is.available()) {
tpdu = new byte[expData];
is.read(tpdu, 0, expData);
}
}
示例4: Datapoint
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new datapoint from XML input.
* <p>
* If the current XML element position is no start tag, the next element tag is read.
* The datapoint element is then expected to be the current element in the reader. It
* reads the start tag and attributes of a datapoint element, and sets the reader to
* the next position.
*
* @param r a XML reader
* @throws KNXMLException if the XML element is no datapoint or could not be read
* correctly
*/
Datapoint(XMLReader r) throws KNXMLException
{
if (r.getPosition() != XMLReader.START_TAG)
r.read();
final Element e = r.getCurrent();
final int line = r.getLineNumber();
if (r.getPosition() != XMLReader.START_TAG || !e.getName().equals(TAG_DATAPOINT))
throw new KNXMLException("no KNX datapoint element", e != null ? e.getName()
: null, line);
stateBased = readDPType(r);
if ((name = e.getAttribute(ATTR_NAME)) == null)
throw new KNXMLException("missing attribute " + ATTR_NAME, null, line);
if ((dptID = e.getAttribute(ATTR_DPTID)) == null)
throw new KNXMLException("missing attribute " + ATTR_DPTID, null, line);
if (dptID.length() == 0)
dptID = null;
String a = null;
try {
a = e.getAttribute(ATTR_MAINNUMBER);
mainNo = Integer.decode(a).intValue();
a = e.getAttribute(ATTR_PRIORITY);
priority = Priority.get(a);
}
catch (final RuntimeException rte) {
throw new KNXMLException("malformed attribute, " + rte.getMessage(), a, line);
}
r.read();
}
示例5: PL110LData
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new L-data frame out of a byte array.
* <p>
*
* @param data byte array containing the L-data frame
* @param offset start offset of frame structure in <code>data</code>, offset >=
* 0
* @throws KNXFormatException if length of data too short for frame, on no valid frame
* structure
*/
public PL110LData(byte[] data, int offset) throws KNXFormatException
{
final ByteArrayInputStream is =
new ByteArrayInputStream(data, offset, data.length - offset);
final int avail = is.available();
if (avail < MIN_LENGTH)
throw new KNXFormatException("data too short for L-data frame", avail);
final int ctrl = is.read();
// parse control field and check if valid
if ((ctrl & 0x53) != 0x10)
throw new KNXFormatException("invalid control field", ctrl);
type = LDATA_FRAME;
ext = (ctrl & 0x80) == 0;
repetition = (ctrl & 0x20) == 0;
p = Priority.get((ctrl >> 2) & 0x3);
final int ctrle = ext ? readCtrlEx(is) : 0;
src = new IndividualAddress((is.read() << 8) | is.read());
final int addr = (is.read() << 8) | is.read();
final int npci = is.read();
final int len;
if (ext) {
hopcount = (ctrle & 0x70) >> 4;
setDestination(addr, (ctrle & 0x80) != 0);
len = npci;
if (len > 64)
throw new KNXFormatException("APDU length exceeds maximum of 64 bytes",
len);
}
else {
hopcount = (npci & 0x70) >> 4;
setDestination(addr, (npci & 0x80) != 0);
len = npci & 0x0f;
}
tpdu = new byte[len + 1];
if (is.read(tpdu, 0, tpdu.length) != tpdu.length)
throw new KNXFormatException("data too short for L-data TPDU");
fcs = is.read();
doa = new byte[2];
is.read(doa, 1, 1);
}
示例6: PL132LData
import tuwien.auto.calimero.Priority; //导入方法依赖的package包/类
/**
* Creates a new L-data frame out of a byte array.
* <p>
*
* @param data byte array containing the L-data frame
* @param offset start offset of frame structure in <code>data</code>, offset >=
* 0
* @throws KNXFormatException if length of data too short for frame, on no valid frame
* structure
*/
public PL132LData(byte[] data, int offset) throws KNXFormatException
{
final ByteArrayInputStream is =
new ByteArrayInputStream(data, offset, data.length - offset);
final int avail = is.available();
if (avail < MIN_LENGTH)
throw new KNXFormatException("data too short for L-data frame", avail);
doa = new byte[2];
is.read(doa, 0, 2);
final int ctrl = is.read();
// parse control field and check if valid
if ((ctrl & 0xC) != 0xC)
throw new KNXFormatException("invalid control field", ctrl);
type = LDATA_FRAME;
ext = (ctrl & 0x80) == 0;
repetition = (ctrl & 0x40) == 0;
p = Priority.get(ctrl & 0x3);
final boolean group = (ctrl & 0x20) == 0x20;
ack = (ctrl & 0x10) == 0x10;
// check fourth byte for extended control field
final int ctrle = ext ? readCtrlEx(is) : 0;
src = new IndividualAddress((is.read() << 8) | is.read());
setDestination((is.read() << 8) | is.read(), group);
final int npci = is.read();
final int len;
if (ext) {
hopcount = (ctrle & 0x70) >> 4;
len = npci;
if (len > 64)
throw new KNXFormatException("APDU length exceeds maximum of 64 bytes",
len);
}
else {
hopcount = (npci & 0x70) >> 4;
len = npci & 0x0f;
}
tpdu = new byte[len + 1];
if (is.read(tpdu, 0, tpdu.length) != tpdu.length)
throw new KNXFormatException("data too short for L-data TPDU");
fcs = is.read() << 8 | is.read();
}