本文整理汇总了Java中org.owfs.jowfsclient.Enums.OwPersistence类的典型用法代码示例。如果您正苦于以下问题:Java OwPersistence类的具体用法?Java OwPersistence怎么用?Java OwPersistence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OwPersistence类属于org.owfs.jowfsclient.Enums包,在下文中一共展示了OwPersistence类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.owfs.jowfsclient.Enums.OwPersistence; //导入依赖的package包/类
/**
* Tries to connect either by IP or serial bus, depending on supplied config data.
*
* @return true if connection was established, false otherwise
*/
public static synchronized boolean connect() {
if (cvIp != null && cvPort > 0) {
OwfsConnectionFactory owfsConnectorFactory = new OwfsConnectionFactory(cvIp, cvPort);
OwfsConnectionConfig owConnectionConfig = new OwfsConnectionConfig(cvIp, cvPort);
owConnectionConfig.setTemperatureScale(cvTempScale);
owConnectionConfig.setPersistence(OwPersistence.ON);
owConnectionConfig.setBusReturn(OwBusReturn.ON);
owfsConnectorFactory.setConnectionConfig(owConnectionConfig);
try {
cvOwConnection = owfsConnectorFactory.createNewConnection();
cvOwConnection.listDirectory("/");
logger.info("Connected to owserver [IP '" + cvIp + "' Port '" + cvPort + "']");
cvIsEstablished = true;
return true;
} catch (Exception exception) {
logger.error("Couldn't connect to owserver [IP '" + cvIp + "' Port '" + cvPort + "']: ", exception.getLocalizedMessage());
cvIsEstablished = false;
return false;
}
} else {
logger.warn("Couldn't connect to owserver because of missing connection parameters [IP '{}' Port '{}'].", cvIp, cvPort);
return false;
}
}
示例2: setupOWFS
import org.owfs.jowfsclient.Enums.OwPersistence; //导入依赖的package包/类
/**
* Create the OWFSConnection configuration in a thread safe manner.
*/
public static void setupOWFS() {
if (owfsConnection != null) {
try {
owfsConnection.disconnect();
owfsConnection = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (!useOWFS)
{
return;
}
// Use the thread safe mechanism
BrewServer.LOG.info("Connecting to " + owfsServer + ":" + owfsPort);
try {
OwfsConnectionConfig owConfig = new OwfsConnectionConfig(owfsServer,
owfsPort);
owConfig.setPersistence(OwPersistence.ON);
owfsConnection = OwfsConnectionFactory
.newOwfsClientThreadSafe(owConfig);
useOWFS = true;
} catch (NullPointerException npe) {
BrewServer.LOG.warning("OWFS is not able to be setup. You may need to rerun setup.");
}
}