本文整理匯總了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.");
}
}