當前位置: 首頁>>代碼示例>>Java>>正文


Java OwPersistence類代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:31,代碼來源:OneWireConnection.java

示例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.");
    }
}
 
開發者ID:DougEdey,項目名稱:SB_Elsinore_Server,代碼行數:31,代碼來源:LaunchControl.java


注:本文中的org.owfs.jowfsclient.Enums.OwPersistence類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。