本文整理汇总了Java中tuwien.auto.calimero.IndividualAddress类的典型用法代码示例。如果您正苦于以下问题:Java IndividualAddress类的具体用法?Java IndividualAddress怎么用?Java IndividualAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndividualAddress类属于tuwien.auto.calimero包,在下文中一共展示了IndividualAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectByIp
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
private static KNXNetworkLink connectByIp(int ipConnectionType, String localIp, String ip, int port) throws KNXException, UnknownHostException, InterruptedException {
InetSocketAddress localEndPoint = null;
if (StringUtils.isNotBlank(localIp)) {
localEndPoint = new InetSocketAddress(localIp, 0);
} else {
try {
InetAddress localHost = InetAddress.getLocalHost();
localEndPoint = new InetSocketAddress(localHost, 0);
} catch (UnknownHostException uhe) {
sLogger.warn("Couldn't find an IP address for this host. Please check the .hosts configuration or use the 'localIp' parameter to configure a valid IP address.");
}
}
return new KNXNetworkLinkIP(ipConnectionType, localEndPoint, new InetSocketAddress(ip, port), false, new TPSettings(new IndividualAddress(sLocalSourceAddr), true));
}
示例2: connectByIp
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
private static KNXNetworkLink connectByIp(int ipConnectionType, String localIp, String ip, int port)
throws KNXException, UnknownHostException, InterruptedException {
InetSocketAddress localEndPoint = null;
if (StringUtils.isNotBlank(localIp)) {
localEndPoint = new InetSocketAddress(localIp, 0);
} else {
try {
InetAddress localHost = InetAddress.getLocalHost();
localEndPoint = new InetSocketAddress(localHost, 0);
} catch (UnknownHostException uhe) {
sLogger.warn(
"Couldn't find an IP address for this host. Please check the .hosts configuration or use the 'localIp' parameter to configure a valid IP address.");
}
}
return new KNXNetworkLinkIP(ipConnectionType, localEndPoint, new InetSocketAddress(ip, port), sUseNAT,
new TPSettings(new IndividualAddress(sLocalSourceAddr), true));
}
示例3: send
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
private void send(KNXAddress dst, Priority p, byte[] nsdu, boolean confirm)
throws KNXTimeoutException, KNXLinkClosedException
{
final CEMILData f;
final short mc = mode == TUNNEL ? CEMILData.MC_LDATA_REQ : CEMILData.MC_LDATA_IND;
final IndividualAddress src = medium.getDeviceAddress();
// use default address 0 in system broadcast
final KNXAddress d = dst == null ? new GroupAddress(0) : dst;
final boolean tp = medium.getMedium() == KNXMediumSettings.MEDIUM_TP0
|| medium.getMedium() == KNXMediumSettings.MEDIUM_TP1;
if (nsdu.length <= 16 && tp)
f = new CEMILData(mc, src, d, nsdu, p, true, hopCount);
else
f = new CEMILDataEx(mc, src, d, nsdu, p, true, dst != null, false, hopCount);
doSend(f, confirm);
}
示例4: readAddress
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
public synchronized IndividualAddress[] readAddress(boolean oneAddressOnly)
throws KNXTimeoutException, KNXRemoteException, KNXLinkClosedException
{
final List l = new ArrayList();
try {
svcResponse = IND_ADDR_RESPONSE;
tl.broadcast(false, Priority.SYSTEM, DataUnitBuilder.createCompactAPDU(
IND_ADDR_READ, null));
long wait = responseTimeout * 1000;
final long end = System.currentTimeMillis() + wait;
while (wait > 0) {
l.add(new IndividualAddress(waitForResponse(0, 0, wait)));
if (oneAddressOnly)
break;
wait = end - System.currentTimeMillis();
}
}
catch (final KNXTimeoutException e) {
if (l.isEmpty())
throw e;
}
finally {
svcResponse = 0;
}
return (IndividualAddress[]) l.toArray(new IndividualAddress[l.size()]);
}
示例5: createDestination
import tuwien.auto.calimero.IndividualAddress; //导入依赖的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;
}
}
示例6: createFromEMI
import tuwien.auto.calimero.IndividualAddress; //导入依赖的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);
}
示例7: create
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
private static CEMI create(int msgCode, IndividualAddress src, KNXAddress dst,
byte[] data, CEMILData original, boolean ext)
{
final int mc = msgCode != 0 ? msgCode : original.getMessageCode();
final IndividualAddress s = src != null ? src : original.getSource();
final KNXAddress d = dst != null ? dst : original.getDestination();
final byte[] content = data != null ? data : original.getPayload();
if (original instanceof CEMILDataEx) {
final CEMILDataEx f = (CEMILDataEx) original;
final CEMILDataEx copy =
new CEMILDataEx(mc, s, d, content, f.getPriority(), f.isRepetition(), f
.isDomainBroadcast(), f.isAckRequested(), f.getHopCount());
// copy additional info
final List l = f.getAdditionalInfo();
for (final Iterator i = l.iterator(); i.hasNext();) {
final CEMILDataEx.AddInfo info = (CEMILDataEx.AddInfo) i.next();
copy.addAdditionalInfo(info.getType(), info.getInfo());
}
return copy;
}
if (ext)
return new CEMILDataEx(mc, s, d, content, original.getPriority(), original
.isRepetition(), original.getHopCount());
return new CEMILData(mc, s, d, content, original.getPriority(), original
.isRepetition(), original.getHopCount());
}
示例8: DeviceDIB
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
/**
* Creates a device DIB out of a byte array.
* <p>
*
* @param data byte array containing device DIB structure
* @param offset start offset of DIB in <code>data</code>
* @throws KNXFormatException if no DIB found or invalid structure
*/
public DeviceDIB(byte[] data, int offset) throws KNXFormatException
{
super(data, offset);
if (type != DEVICE_INFO)
throw new KNXFormatException("DIB is not of type device info", type);
if (size < DIB_SIZE)
throw new KNXFormatException("device info DIB too short", size);
final ByteArrayInputStream is =
new ByteArrayInputStream(data, offset + 2, data.length - offset - 2);
knxmedium = (short) is.read();
devicestatus = (short) is.read();
address =
new IndividualAddress(new byte[] { (byte) is.read(), (byte) is.read(), });
projectInstallID = (is.read() << 8) | is.read();
is.read(serial, 0, serial.length);
is.read(mcaddress, 0, mcaddress.length);
is.read(mac, 0, mac.length);
// device friendly name is optional
final StringBuffer sbuf = new StringBuffer(30);
int i = 30;
for (int c = is.read(); i > 0 && c > 0; --i, c = is.read())
sbuf.append((char) c);
name = sbuf.toString();
}
示例9: setIndividualAddress
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
/**
* sets the own physical, individual address. f.i. "1.1.123"
*
* @param individualAddress individual address with dot-notation. f.i.
* "1.1.123"
* @throws KnxException
*/
public void setIndividualAddress(String individualAddress) throws KnxException {
try {
netlink.getKNXMedium().setDeviceAddress(new IndividualAddress(individualAddress));
this.individualAddress = individualAddress;
} catch (KNXFormatException ex) {
throw new KnxException("Error setting indiviaual address to " + individualAddress, ex);
}
}
示例10: getIndividualAddress
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
public static IndividualAddress getIndividualAddress(String address) throws KnxException {
try {
IndividualAddress ia = new IndividualAddress(address);
return ia;
} catch (KNXFormatException ex) {
throw new KnxException("Individual address format not correct.", ex);
}
}
示例11: KNXComm
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
/**
* Open a connection with the IP gateway
*
* @param p_GatewayIP
* The IP of the gateway
* @param p_GatewayKNXAddr
* The individual KNX address of the gateway
* @throws KNXException
* @throws SocketException
*/
private KNXComm(String p_GatewayIP, String p_GatewayKNXAddr)
throws KNXException, SocketException {
m_GatewayIP = p_GatewayIP;
m_settings = new KNXMediumSettings(new IndividualAddress(
p_GatewayKNXAddr)) {
@Override
public short getMedium() {
return KNXMediumSettings.MEDIUM_TP1;
}
};
// m_link = new KNXNetworkLinkIP(p_GatewayIP, l_settings);
openConnection();
}
示例12: TP1LData
import tuwien.auto.calimero.IndividualAddress; //导入依赖的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();
}
示例13: TP1LPollData
import tuwien.auto.calimero.IndividualAddress; //导入依赖的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);
}
}
示例14: writeAddress
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
public void writeAddress(byte[] serialNo, IndividualAddress newAddress)
throws KNXTimeoutException, KNXLinkClosedException
{
if (serialNo.length != 6)
throw new KNXIllegalArgumentException("length of serial number not 6 bytes");
final byte[] asdu = new byte[12];
for (int i = 0; i < 6; ++i)
asdu[i] = serialNo[i];
asdu[6] = (byte) (newAddress.getRawAddress() >>> 8);
asdu[7] = (byte) newAddress.getRawAddress();
tl.broadcast(false, Priority.SYSTEM, DataUnitBuilder.createAPDU(
IND_ADDR_SN_WRITE, asdu));
}
示例15: readDomainAddress
import tuwien.auto.calimero.IndividualAddress; //导入依赖的package包/类
public List readDomainAddress(byte[] domain, IndividualAddress start, int range)
throws KNXInvalidResponseException, KNXLinkClosedException, KNXTimeoutException
{
if (domain.length != 2)
throw new KNXIllegalArgumentException("length of domain address not 2 bytes");
if (range < 0 || range > 255)
throw new KNXIllegalArgumentException("range out of range [0..255]");
final byte[] addr = start.toByteArray();
return makeDOAs(readBroadcast(priority, DataUnitBuilder.createAPDU(
DOA_SELECTIVE_READ, new byte[] { domain[0], domain[1], addr[0], addr[1],
(byte) range }), DOA_RESPONSE, 2, 2, false));
}