当前位置: 首页>>代码示例>>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;未经允许,请勿转载。