本文整理汇总了Java中tuwien.auto.calimero.link.KNXNetworkLink类的典型用法代码示例。如果您正苦于以下问题:Java KNXNetworkLink类的具体用法?Java KNXNetworkLink怎么用?Java KNXNetworkLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KNXNetworkLink类属于tuwien.auto.calimero.link包,在下文中一共展示了KNXNetworkLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectByIp
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的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: detach
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
@Override
public KNXNetworkLink detach() {
// if we synchronize on method we would take into account
// a worst case blocking of response timeout seconds
synchronized (lnkListener) {
// wait of response time seconds
if (detached) {
return null;
}
detached = true;
}
lnk.removeLinkListener(lnkListener);
fireDetached();
logger.info("detached from " + lnk.getName());
LogManager.getManager().removeLogService(logger.getName());
return lnk;
}
示例3: run
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Runs the process communicator.
* <p>
* This method immediately returns when the process communicator is running. Call
* {@link #quit()} to quit process communication.
*
* @param l a process event listener, can be <code>null</code>
* @throws KNXException on problems creating network link or communication
*/
public void run(ProcessListener l) throws KNXException
{
// create the network link to the KNX network
final KNXNetworkLink lnk = createLink();
LogManager.getManager().addWriter(lnk.getName(), w);
// create process communicator with the established link
pc = new ProcessCommunicatorImpl(lnk);
if (l != null)
pc.addProcessListener(l);
registerShutdownHandler();
// user might specify a response timeout for KNX message
// answers from the KNX network
if (options.containsKey("timeout"))
pc.setResponseTimeout(((Integer) options.get("timeout")).intValue());
}
示例4: createLink
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Creates the KNX network link to access the network specified in
* <code>options</code>.
* <p>
*
* @return the KNX network link
* @throws KNXException on problems on link creation
*/
private KNXNetworkLink createLink() throws KNXException
{
final KNXMediumSettings medium = (KNXMediumSettings) options.get("medium");
if (options.containsKey("serial")) {
// create FT1.2 network link
final String p = (String) options.get("serial");
try {
return new KNXNetworkLinkFT12(Integer.parseInt(p), medium);
}
catch (final NumberFormatException e) {
return new KNXNetworkLinkFT12(p, medium);
}
}
// create local and remote socket address for network link
final InetSocketAddress local = createLocalSocket((InetAddress)
options.get("localhost"), (Integer) options.get("localport"));
final InetSocketAddress host = new InetSocketAddress((InetAddress)
options.get("host"), ((Integer) options.get("port")).intValue());
final int mode = options.containsKey("routing") ? KNXNetworkLinkIP.ROUTER
: KNXNetworkLinkIP.TUNNEL;
return new KNXNetworkLinkIP(mode, local, host, options.containsKey("nat"),
medium);
}
示例5: connectByIp
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的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));
}
示例6: detach
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
public KNXNetworkLink detach()
{
// if we synchronize on method we would take into account
// a worst case blocking of response timeout seconds
synchronized (lnkListener) {
// wait of response time seconds
if (detached)
return null;
detached = true;
}
lnk.removeLinkListener(lnkListener);
fireDetached();
logger.info("detached from " + lnk.getName());
LogManager.getManager().removeLogService(logger.getName());
return lnk;
}
示例7: getLink
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
public KNXNetworkLink getLink(String local,String gateway){
KNXLink link=new KNXLink(local,gateway);
if(linkPool.get(link)==null){
try {
linkPool.put(link,createLink(local, gateway));
} catch (KNXException e) {
e.printStackTrace();
LOG.error("KNX: Failed to create link from inet local {} to {}",local,gateway);
}
}
KNXNetworkLink knxLink=linkPool.get(link);
return knxLink;
}
示例8: createLink
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
private KNXNetworkLink createLink(String localhostIface,String gatewayIface) throws KNXException {
try {
InetAddress localhost = InetAddress.getByName(localhostIface);
InetAddress gatewayHost = InetAddress.getByName(gatewayIface);
final InetSocketAddress local = createLocalSocket(localhost, null);
final InetSocketAddress host = new InetSocketAddress(gatewayHost,
KNXnetIPConnection.IP_PORT);
final int mode = KNXNetworkLinkIP.TUNNEL;
LOG.info("Mode {} local {} host {}",new Object[]{mode,local,host});
return new KNXNetworkLinkIP(mode, local, host, false,
TPSettings.TP1);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return null;
}
示例9: dispose
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Disposes KNX Gateway Driver allocated resources, such as pooled network links.
*/
public static void dispose() {
try {
for (KNXNetworkLink link : connectionPool.values()) {
link.close();
}
} catch (Exception e) {
logger.error("Exception occurred while disposing KNX network link.", e);
}
}
示例10: disconnect
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
public static synchronized void disconnect() {
sShutdown = true;
if (sPC!=null) {
KNXNetworkLink link = sPC.detach();
if(sProcessCommunicationListener!=null) {
sPC.removeProcessListener(sProcessCommunicationListener);
sProcessCommunicationListener = null;
}
if (link!=null) {
sLogger.info("Closing KNX connection");
link.close();
}
}
}
示例11: quit
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Quits process communication.
* <p>
* Detaches the network link from the process communicator and closes the link.
*/
public void quit()
{
if (pc != null) {
final KNXNetworkLink lnk = pc.detach();
if (lnk != null)
lnk.close();
Runtime.getRuntime().removeShutdownHook(sh);
}
}
示例12: disconnect
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
public static synchronized void disconnect() {
sShutdown = true;
if (sPC != null) {
KNXNetworkLink link = sPC.detach();
if (sProcessCommunicationListener != null) {
sPC.removeProcessListener(sProcessCommunicationListener);
sProcessCommunicationListener = null;
}
if (link != null) {
sLogger.info("Closing KNX connection");
link.close();
}
}
}
示例13: detach
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
public KNXNetworkLink detach()
{
final KNXNetworkLink lnk = tl.detach();
if (lnk != null) {
logger.info("detached from " + lnk.getName());
LogManager.getManager().removeLogService(logger.getName());
}
detached = true;
return lnk;
}
示例14: RemotePropertyServiceAdapter
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Creates a new property adapter for remote property access.
*
* @param link KNX network link used for communication with the KNX network
* @param remote KNX individual address to access its interface objects
* @param l property adapter listener to get notified about adapter events, use
* <code>null</code> for no listener
* @param connOriented <code>true</code> to use connection oriented mode for access,
* <code>false</code> to use connectionless mode
* @throws KNXLinkClosedException if the network link is closed
*/
public RemotePropertyServiceAdapter(KNXNetworkLink link, IndividualAddress remote,
PropertyAdapterListener l, boolean connOriented) throws KNXLinkClosedException
{
mc = new ManagementClientImpl(link);
dst = mc.createDestination(remote, connOriented);
pal = l;
nll = pal != null ? new NLListener() : null;
if (nll != null)
link.addLinkListener(nll);
key = null;
}
示例15: TransportLayerImpl
import tuwien.auto.calimero.link.KNXNetworkLink; //导入依赖的package包/类
/**
* Creates a new transport layer attached to the supplied KNX network link.
* <p>
*
* @param link network link used for communication with a KNX network
* @throws KNXLinkClosedException if the network link is closed
*/
public TransportLayerImpl(KNXNetworkLink link) throws KNXLinkClosedException
{
if (!link.isOpen())
throw new KNXLinkClosedException();
lnk = link;
lnk.addLinkListener(lnkListener);
logger = LogManager.getManager().getLogService(getName());
listeners = new EventListeners(logger);
}