本文整理汇总了Java中tuwien.auto.calimero.exception.KNXException类的典型用法代码示例。如果您正苦于以下问题:Java KNXException类的具体用法?Java KNXException怎么用?Java KNXException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KNXException类属于tuwien.auto.calimero.exception包,在下文中一共展示了KNXException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Knx
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Start KNX communication via serial connection
*
* @param type according to your serial connection type
* @param device device, like "/dev/ttyUSB0" or "COM10"
* @throws KnxException in case of any problem
*/
public Knx(SerialType type, String device) throws KnxException {
try {
switch (type) {
case TPUART:
netlink = new KNXNetworkLinkTpuart(device, new TPSettings(), new ArrayList());
break;
case FT12:
case UNDEFINED:
log.error("SerialType [{}] not yet supported", type);
throw new KnxException("SerialType [" + type + "] not yet supported");
}
// setup knx connection
// netlink = new SlicKNXNetworkLinkIP(KNXNetworkLinkIP.TUNNELING, null, new InetSocketAddress(host, port), false, new TPSettings(false));
pc = new SlicKnxProcessCommunicatorImpl(netlink);
log.debug("Connected to knx via {}:{} and individualaddress {}", hostadr, port, individualAddress);
pc.addProcessListener(ggal);
} catch (KNXException ex) {
throw new KnxException("error creating serial link for type [" + type + "]", ex);
}
}
开发者ID:tuxedo0801,项目名称:slicKnx,代码行数:29,代码来源:Knx.java
示例2: writeDpt6
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* DPT 6 8-bit signed value
*
* @param isResponse
* @param ga
* @param value value [-128..127] ^= 8bit signed
* @throws de.root1.slicknx.KnxException
*/
public void writeDpt6(boolean isResponse, String ga, int value) throws KnxException {
if (value < -128 || value > 127) {
throw new IllegalArgumentException("value must be between -128..127, but was: " + value);
}
checkGa(ga);
try {
StateDP dp = new StateDP(new GroupAddress(ga), "6.001", 6, "6.001");
if (isResponse) {
pc.writeResponse(dp, Integer.toString(value));
} else {
pc.write(dp, Integer.toString(value));
}
} catch (KNXException ex) {
throw new KnxException("Error writing dpt7", ex);
}
}
开发者ID:tuxedo0801,项目名称:slicKnx,代码行数:26,代码来源:Knx.java
示例3: writeDpt7
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* DPT 7 16-bit unsigned value
*
* @param isResponse
* @param ga
* @param value value [0..65535] ^= 16bit unsigned
* @throws de.root1.slicknx.KnxException
* @throws IllegalArgumentException in case of wrong value
*/
public void writeDpt7(boolean isResponse, String ga, int value) throws KnxException {
if (value < 0 || value > 65535) {
throw new IllegalArgumentException("value must be between 0..65535, but was: " + value);
}
checkGa(ga);
try {
StateDP dp = new StateDP(new GroupAddress(ga), "7.001", 7, "7.001");
if (isResponse) {
pc.writeResponse(dp, Integer.toString(value));
} else {
pc.write(dp, Integer.toString(value));
}
} catch (KNXException ex) {
throw new KnxException("Error writing dpt7", ex);
}
}
开发者ID:tuxedo0801,项目名称:slicKnx,代码行数:28,代码来源:Knx.java
示例4: writeDpt8
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* DPT 8 16-bit signed value
*
* @param isResponse
* @param ga
* @param value value [-32768..32767] ^= 16bit signed
* @throws de.root1.slicknx.KnxException
* @throws IllegalArgumentException in case of wrong value
*/
public void writeDpt8(boolean isResponse, String ga, int value) throws KnxException {
if (value < -32768 || value > 32767) {
throw new IllegalArgumentException("value must be between -32768..32767, but was: " + value);
}
checkGa(ga);
try {
StateDP dp = new StateDP(new GroupAddress(ga), "8.001", 7, "8.001");
if (isResponse) {
pc.writeResponse(dp, Integer.toString(value));
} else {
pc.write(dp, Integer.toString(value));
}
} catch (KNXException ex) {
throw new KnxException("Error writing dpt8", ex);
}
}
开发者ID:tuxedo0801,项目名称:slicKnx,代码行数:28,代码来源:Knx.java
示例5: read
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
*
* @param ga
* @param dpt
* @return
*/
public String read(String ga, String dpt) throws KnxException {
checkGa(ga);
String[] dptSplit = dpt.split("\\.");
int mainDpt = Integer.parseInt(dptSplit[0]);
String subDpt = dptSplit[1];
try {
String value = pc.read(new StateDP(new GroupAddress(ga), "", mainDpt, dpt));
return value;
} catch (KNXException | InterruptedException ex) {
throw new KnxException("Error reading DPT" + dpt + " from " + ga, ex);
}
}
开发者ID:tuxedo0801,项目名称:slicKnx,代码行数:22,代码来源:Knx.java
示例6: discoverGateways
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Discover KNX IP gateways on the local network
*
* @param p_SourcePort
* The source port of the multicast
* @param p_Duration
* The duration of the search
* @return An ArrayList of discovered gateways
* @throws KNXException
*/
public static ArrayList<IPGateway> discoverGateways(int p_SourcePort,
int p_Duration) throws KNXException {
ArrayList<IPGateway> l_gateways = new ArrayList<IPGateway>();
Discoverer l_disco = new Discoverer(p_SourcePort, true);
l_disco.startSearch(p_Duration, true);
SearchResponse[] l_results = l_disco.getSearchResponses();
for (int i = 0; i < l_results.length; i++) {
String l_ipAddr = l_results[i].getControlEndpoint().getAddress()
.toString().substring(1);
String l_KNXAddr = l_results[i].getDevice().getAddress().toString();
short l_medium = l_results[i].getDevice().getKNXMedium();
String l_name = l_results[i].getDevice().getName();
l_gateways
.add(new IPGateway(l_KNXAddr, l_ipAddr, l_name, l_medium));
}
return l_gateways;
}
开发者ID:heia-fr,项目名称:wot_gateways,代码行数:33,代码来源:KNXDiscoverer.java
示例7: notifyListeners
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
public void notifyListeners(ProcessEvent p_evt) {
Iterator<Entry<String, Datapoint>> l_it = m_Listening.entrySet()
.iterator();
while (l_it.hasNext()) {
Map.Entry<String, Datapoint> l_entry = l_it.next();
if (l_entry.getValue().getMainAddress().getRawAddress() == p_evt
.getDestination().getRawAddress()) {
DPTXlator l_translator;
try {
l_translator = TranslatorTypes.createTranslator(l_entry
.getValue().getMainNumber(), l_entry.getValue()
.getDPT());
l_translator.setData(p_evt.getASDU());
setChanged();
notifyObservers(new DatapointEvent(l_entry.getValue(),
l_translator.getValue(), l_entry.getKey()));
break;
} catch (KNXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
开发者ID:heia-fr,项目名称:wot_gateways,代码行数:26,代码来源:KNXManagement.java
示例8: connectByIp
import tuwien.auto.calimero.exception.KNXException; //导入依赖的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));
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:KNXConnection.java
示例9: writeToKNX
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
private void writeToKNX(String itemName, Type value) {
Iterable<Datapoint> datapoints = getDatapoints(itemName, value.getClass());
if (datapoints != null) {
ProcessCommunicator pc = KNXConnection.getCommunicator();
if (pc != null) {
for (Datapoint datapoint : datapoints) {
try {
pc.write(datapoint, toDPTValue(value, datapoint.getDPT()));
logger.debug("Wrote value '{}' to datapoint '{}'", value, datapoint);
} catch (KNXException e) {
logger.warn("Value '{}' could not be sent to the KNX bus using datapoint '{}' - retrying one time: {}",
new Object[]{value, datapoint, e.getMessage()});
try {
// do a second try, maybe the reconnection was successful
pc = KNXConnection.getCommunicator();
pc.write(datapoint, toDPTValue(value, datapoint.getDPT()));
logger.debug("Wrote value '{}' to datapoint '{}' on second try", value, datapoint);
} catch (KNXException e1) {
logger.error("Value '{}' could not be sent to the KNX bus using datapoint '{}' - giving up after second try: {}",
new Object[]{value, datapoint, e1.getMessage()});
}
}
}
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:KNXBinding.java
示例10: run
import tuwien.auto.calimero.exception.KNXException; //导入依赖的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());
}
开发者ID:gskbyte,项目名称:kora,代码行数:25,代码来源:ProcComm.java
示例11: createLink
import tuwien.auto.calimero.exception.KNXException; //导入依赖的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);
}
开发者ID:gskbyte,项目名称:kora,代码行数:32,代码来源:ProcComm.java
示例12: readWrite
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
private void readWrite() throws KNXException
{
// check if we are doing a read or write operation
final boolean read = options.containsKey("read");
final GroupAddress main = (GroupAddress) options.get(read ? "read" : "write");
// encapsulate information into a datapoint
// this is a convenient way to let the process communicator
// handle the DPT stuff, so an already formatted string will be returned
final Datapoint dp = new StateDP(main, "", 0, getDPT());
if (read)
System.out.println("read value: " + pc.read(dp));
else {
// note, a write to a non existing datapoint might finish successfully,
// too.. no check for existence or read back of a written value is done
pc.write(dp, (String) options.get("value"));
System.out.println("write successful");
}
}
开发者ID:gskbyte,项目名称:kora,代码行数:19,代码来源:ProcComm.java
示例13: connectByIp
import tuwien.auto.calimero.exception.KNXException; //导入依赖的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));
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:20,代码来源:KNXConnection.java
示例14: KNXNetworkMonitorFT12
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Creates a new network monitor based on the FT1.2 protocol for accessing the KNX
* network.
* <p>
* The port identifier is used to choose the serial port for communication. These
* identifiers are usually device and platform specific.
*
* @param portID identifier of the serial communication port to use
* @param settings medium settings defining the specific KNX medium needed for
* decoding raw frames received from the KNX network
* @throws KNXException
*/
public KNXNetworkMonitorFT12(String portID, KNXMediumSettings settings)
throws KNXException
{
conn = new FT12Connection(portID);
try {
enterBusmonitor();
}
catch (final KNXAckTimeoutException e) {
conn.close();
throw e;
}
logger = LogManager.getManager().getLogService(getName());
logger.info("in busmonitor mode - ready to receive");
notifier = new MonitorNotifier(this, logger);
conn.addConnectionListener(notifier);
// configure KNX medium stuff
setKNXMedium(settings);
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:31,代码来源:KNXNetworkMonitorFT12.java
示例15: close
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
public void close()
{
synchronized (this) {
if (closed)
return;
closed = true;
}
try {
leaveBusmonitor();
}
catch (final KNXException e) {
logger.error("could not switch BCU back to normal mode", e);
}
conn.close();
notifier.quit();
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:17,代码来源:KNXNetworkMonitorFT12.java
示例16: KNXNetworkMonitorIP
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Creates a new network monitor based on the KNXnet/IP protocol for accessing the KNX
* network.
* <p>
*
* @param localEP the local endpoint to use for the link, this is the client control
* endpoint, use <code>null</code> for the default local host and an
* ephemeral port number
* @param remoteEP the remote endpoint of the link; this is the server control
* endpoint
* @param useNAT <code>true</code> to use network address translation in the
* KNXnet/IP protocol, <code>false</code> to use the default (non aware) mode
* @param settings medium settings defining the specific KNX medium needed for
* decoding raw frames received from the KNX network
* @throws KNXException on failure establishing the link
*/
public KNXNetworkMonitorIP(InetSocketAddress localEP, InetSocketAddress remoteEP,
boolean useNAT, KNXMediumSettings settings) throws KNXException
{
InetSocketAddress ep = localEP;
if (ep == null)
try {
ep = new InetSocketAddress(InetAddress.getLocalHost(), 0);
}
catch (final UnknownHostException e) {
throw new KNXException("no local host available");
}
conn = new KNXnetIPTunnel(KNXnetIPTunnel.BUSMONITOR_LAYER, ep, remoteEP, useNAT);
logger = LogManager.getManager().getLogService(getName());
logger.info("in busmonitor mode - ready to receive");
notifier = new MonitorNotifier(this, logger);
conn.addConnectionListener(notifier);
// configure KNX medium stuff
setKNXMedium(settings);
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:36,代码来源:KNXNetworkMonitorIP.java
示例17: KNXNetworkLinkFT12
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Creates a new network link based on the FT1.2 protocol for accessing the KNX
* network.
* <p>
* The port identifier is used to choose the serial port for communication. These
* identifiers are usually device and platform specific.
*
* @param portID identifier of the serial communication port to use
* @param settings medium settings defining device and medium specifics needed for
* communication
* @throws KNXException
*/
public KNXNetworkLinkFT12(String portID, KNXMediumSettings settings)
throws KNXException
{
conn = new FT12Connection(portID);
try {
linkLayerMode();
}
catch (final KNXAckTimeoutException e) {
conn.close();
throw e;
}
logger = LogManager.getManager().getLogService(getName());
notifier = new LinkNotifier(this, logger);
conn.addConnectionListener(notifier);
// configure KNX medium stuff
setKNXMedium(settings);
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:30,代码来源:KNXNetworkLinkFT12.java
示例18: close
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
public void close()
{
synchronized (this) {
if (closed)
return;
closed = true;
}
try {
normalMode();
}
catch (final KNXException e) {
logger.error("could not switch BCU back to normal mode", e);
}
conn.close();
notifier.quit();
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:17,代码来源:KNXNetworkLinkFT12.java
示例19: scanProperties
import tuwien.auto.calimero.exception.KNXException; //导入依赖的package包/类
/**
* Does a property description scan of the properties of one interface object.
* <p>
*
* @param objIndex interface object index in the device
* @param allProperties <code>true</code> to scan all property descriptions in the
* interface objects, <code>false</code> to only scan the object type
* descriptions, i.e. ({@link PID#OBJECT_TYPE})
* @return a list containing the property descriptions of type {@link Description}
* @throws KNXException on adapter errors while querying the descriptions
*/
public List scanProperties(int objIndex, boolean allProperties) throws KNXException
{
final List scan = new ArrayList();
// property with index 0 is description of object type
// rest are ordinary properties of the object
try {
for (int i = 0; i < 1 || allProperties; ++i)
scan.add(createDesc(objIndex, pa.getDescription(objIndex, 0, i)));
}
catch (final KNXException e) {
if (!KNXRemoteException.class.equals(e.getClass())) {
logger.error("scan properties failed", e);
throw e;
}
}
return scan;
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:29,代码来源:PropertyClient.java
示例20: createLink
import tuwien.auto.calimero.exception.KNXException; //导入依赖的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;
}
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:20,代码来源:KNXLinkManager.java
注:本文中的tuwien.auto.calimero.exception.KNXException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论