本文整理汇总了Java中org.openhab.core.library.items.DimmerItem类的典型用法代码示例。如果您正苦于以下问题:Java DimmerItem类的具体用法?Java DimmerItem怎么用?Java DimmerItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DimmerItem类属于org.openhab.core.library.items包,在下文中一共展示了DimmerItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: mapToState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private State mapToState(double value, String itemName) {
if(itemRegistry!=null) {
try {
Item item = itemRegistry.getItem(itemName);
if(item instanceof SwitchItem && !(item instanceof DimmerItem)) {
return value==0.0d ? OnOffType.OFF : OnOffType.ON;
} else if(item instanceof ContactItem) {
return value==0.0d ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
}
} catch (ItemNotFoundException e) {
logger.debug("Could not find item '{}' in registry", itemName);
}
}
// just return a DecimalType as a fallback
return new DecimalType(value);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:RRD4jService.java
示例2: validateItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public void validateItemType(Item item, String bindingConfig)
throws BindingConfigParseException {
if (!(item instanceof SwitchItem || item instanceof DimmerItem)) {
throw new BindingConfigParseException(
"item '"
+ item.getName()
+ "' is of type '"
+ item.getClass().getSimpleName()
+ "', only Switch- and DimmerItems are allowed - please check your *.items configuration");
}
if (bindingConfig.length() != 6) {
throw new BindingConfigParseException(
"The configured address must consist of 2 bytes housecode and 1 byte device address");
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:FS20GenericBindingProvider.java
示例3: validateItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@Override
public void validateItemType(Item item, String bindingConfig)
throws BindingConfigParseException {
if (!(item instanceof NumberItem || item instanceof SwitchItem
|| item instanceof ContactItem || item instanceof StringItem
|| item instanceof DateTimeItem || item instanceof DimmerItem || item instanceof RollershutterItem)) {
throw new BindingConfigParseException(
"Item '"
+ item.getName()
+ "' is of type '"
+ item.getClass().getSimpleName()
+ "', only NumberItems, SwitchItems, ContactItems, DateTimeItem, StringItem, DimmerItem or RollershutterItem are allowed - please check your *.items configuration");
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:IhcGenericBindingProvider.java
示例4: createState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private State createState(Class<? extends Item> itemType,
String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(DimmerItem.class)) {
return PercentType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'",
itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:Enigma2Binding.java
示例5: mapCommandToItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private Class<? extends Item> mapCommandToItemType(Command command) {
if (command instanceof IncreaseDecreaseType) {
return DimmerItem.class;
} else if (command instanceof PercentType) {
return DimmerItem.class;
} else if (command instanceof DecimalType) {
return NumberItem.class;
} else if (command instanceof OnOffType) {
return SwitchItem.class;
} else if (command instanceof StringType) {
return StringItem.class;
} else {
logger.warn(
"No explicit mapping found for command type '{}' - return StringItem.class instead",
command.getClass().getSimpleName());
return StringItem.class;
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:19,代码来源:PulseaudioBinding.java
示例6: validateItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public void validateItemType(Item item, String bindingConfig)
throws BindingConfigParseException {
if (!(item instanceof SwitchItem
|| item instanceof NumberItem
|| item instanceof DimmerItem
|| item instanceof RollershutterItem
|| item instanceof StringItem)) {
throw new BindingConfigParseException(
"item '"
+ item.getName()
+ "' is of type '"
+ item.getClass().getSimpleName()
+ "', only SwitchItem, NumberItem, DimmerItem, RollershutterItem and StringItem are allowed - please check your *.items configuration");
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:20,代码来源:SamsungTvGenericBindingProvider.java
示例7: testOrFunction_differntTypes
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@Test
public void testOrFunction_differntTypes() {
DimmerItem dimmer1 = new DimmerItem("TestDimmer1");
dimmer1.setState(new DecimalType("42"));
DimmerItem dimmer2 = new DimmerItem("TestDimmer2");
dimmer2.setState(new DecimalType("0"));
SwitchItem switch1 = new SwitchItem("TestSwitch1");
switch1.setState(OnOffType.ON);
SwitchItem switch2 = new SwitchItem("TestSwitch2");
switch2.setState(OnOffType.OFF);
items.add(dimmer1);
items.add(dimmer2);
items.add(switch1);
items.add(switch2);
function = new ArithmeticGroupFunction.Or(OnOffType.ON, OnOffType.OFF);
State state = function.calculate(items);
State decimalState = function.getStateAs(items, DecimalType.class);
Assert.assertEquals(OnOffType.ON, state);
Assert.assertEquals(new DecimalType("2"), decimalState);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:24,代码来源:ArithmeticGroupFunctionTest.java
示例8: storeData
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@BeforeClass
public static void storeData() throws InterruptedException {
DimmerItem item = (DimmerItem) items.get(name);
item.setState(state1);
beforeStore = new Date();
Thread.sleep(10);
service.store(item);
afterStore1 = new Date();
Thread.sleep(10);
item.setState(state2);
service.store(item);
Thread.sleep(10);
afterStore2 = new Date();
logger.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore),
AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:20,代码来源:DimmerItemIntegrationTest.java
示例9: mapToState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private State mapToState(double value, String itemName) {
if (itemRegistry != null) {
try {
Item item = itemRegistry.getItem(itemName);
if (item instanceof SwitchItem && !(item instanceof DimmerItem)) {
return value == 0.0d ? OnOffType.OFF : OnOffType.ON;
} else if (item instanceof ContactItem) {
return value == 0.0d ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
} else if (item instanceof DimmerItem || item instanceof RollershutterItem) {
// make sure Items that need PercentTypes instead of
// DecimalTypes
// do receive the right information
return new PercentType((int) Math.round(value * 100));
}
} catch (ItemNotFoundException e) {
logger.debug("Could not find item '{}' in registry", itemName);
}
}
// just return a DecimalType as a fallback
return new DecimalType(value);
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:22,代码来源:RRD4jService.java
示例10: createState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private State createState(Class<? extends Item> itemType, String transformedResponse) {
try {
if (itemType.isAssignableFrom(NumberItem.class)) {
return DecimalType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return OnOffType.valueOf(transformedResponse);
} else if (itemType.isAssignableFrom(DimmerItem.class)) {
return PercentType.valueOf(transformedResponse);
} else {
return StringType.valueOf(transformedResponse);
}
} catch (Exception e) {
logger.debug("Couldn't create state of type '{}' for value '{}'", itemType, transformedResponse);
return StringType.valueOf(transformedResponse);
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:17,代码来源:Enigma2Binding.java
示例11: updateItemPWM
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
public void updateItemPWM(String itemName, String couplerName, int module, int values[]) {
for (WagoBindingProvider provider : providers) {
if (provider.providesBindingFor(itemName)) {
WagoBindingConfig conf = provider.getConfig(itemName);
if (conf.couplerName.equals(couplerName) && conf.module == module) {
State currentState = conf.getItemState();
State newState;
if (conf.getItem() instanceof DimmerItem) {
newState = new PercentType((int) ((float) values[conf.channel] / 1023 * 100));
} else if (conf.getItem() instanceof SwitchItem) {
if (values[conf.channel] == 0) {
newState = OnOffType.OFF;
} else {
newState = OnOffType.ON;
}
} else {
logger.debug("Unsupported Itemtype");
return;
}
if (!newState.equals(currentState)) {
eventPublisher.postUpdate(itemName, newState);
}
}
}
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:27,代码来源:WagoBinding.java
示例12: mapCommandToItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
private Class<? extends Item> mapCommandToItemType(Command command) {
if (command instanceof IncreaseDecreaseType) {
return DimmerItem.class;
} else if (command instanceof PercentType) {
return DimmerItem.class;
} else if (command instanceof DecimalType) {
return NumberItem.class;
} else if (command instanceof OnOffType) {
return SwitchItem.class;
} else if (command instanceof StringType) {
return StringItem.class;
} else {
logger.warn("No explicit mapping found for command type '{}' - return StringItem.class instead",
command.getClass().getSimpleName());
return StringItem.class;
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:18,代码来源:PulseaudioBinding.java
示例13: testRegisterWriteIncreaseWithRead2
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@Test
public void testRegisterWriteIncreaseWithRead2() throws BindingConfigParseException {
// Read index 1 (value=10) and index 0 (value=9).
// INCREASE command increments last read value (9) by one -> 10. Written to index 0
provider.processBindingConfiguration("test.items", new DimmerItem("Item1"),
String.format(">[%1$s:0],<[%1$s:1],<[%1$s:0]", SLAVE_NAME));
binding.execute(); // read
verify(eventPublisher).postUpdate("Item1", new DecimalType(10));
verify(eventPublisher).postUpdate("Item1", new DecimalType(9));
verifyNoMoreInteractions(eventPublisher);
binding.receiveCommand("Item1", IncreaseDecreaseType.INCREASE);
// Binding cannot execute the command since there is no polled value
// -> no change in registers
assertThat(spi.getRegister(0).getValue(), is(equalTo(10)));
assertThat(spi.getRegister(1).getValue(), is(equalTo(10)));
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:18,代码来源:WriteRegisterExtendedItemConfigurationTestCase.java
示例14: testRegisterWriteIncreaseWithRead3
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@Test
public void testRegisterWriteIncreaseWithRead3() throws BindingConfigParseException {
// same as testRegisterWriteIncreaseWithRead2 but order of read connections is flipped
provider.processBindingConfiguration("test.items", new DimmerItem("Item1"),
String.format(">[%1$s:0],<[%1$s:0],<[%1$s:1]", SLAVE_NAME));
binding.execute(); // read
verify(eventPublisher).postUpdate("Item1", new DecimalType(10));
verify(eventPublisher).postUpdate("Item1", new DecimalType(9));
verifyNoMoreInteractions(eventPublisher);
binding.receiveCommand("Item1", IncreaseDecreaseType.INCREASE);
// Binding cannot execute the command since there is no polled value
// -> no change in registers
assertThat(spi.getRegister(0).getValue(), is(equalTo(11)));
assertThat(spi.getRegister(1).getValue(), is(equalTo(10)));
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:17,代码来源:WriteRegisterExtendedItemConfigurationTestCase.java
示例15: validateItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException {
logger.debug("validating item '{}' against config '{}'", item, bindingConfig);
if (item instanceof SwitchItem) {
; // OK, nothing to validate
} else if (item instanceof ContactItem) {
; // OK, nothing to validate
} else if (item instanceof NumberItem) {
; // OK, nothing to validate
} else if (item instanceof RollershutterItem) {
; // OK, nothing to validate
} else if (item instanceof DimmerItem) {
; // OK, nothing to validate
} else {
throw new BindingConfigParseException(
"item '" + item.getName() + "' is of type '" + item.getClass().getSimpleName()
+ " - not yet implemented, please check your *.items configuration");
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:24,代码来源:SappGenericBindingProvider.java
示例16: updatePollingSwitchesState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* updates item repository for special polling switches
*/
private void updatePollingSwitchesState(SappBindingProvider provider) {
logger.debug("Updating poller switch states");
for (String itemName : provider.getItemNames()) {
try {
Item item = itemRegistry.getItem(itemName);
if (item instanceof SwitchItem && !(item instanceof DimmerItem)) {
SappBindingConfigSwitchItem sappBindingConfigSwitchItem = (SappBindingConfigSwitchItem) provider
.getBindingConfig(itemName);
if (sappBindingConfigSwitchItem.isPollerSuspender()) {
eventPublisher.postUpdate(itemName, pollingEnabled ? OnOffType.ON : OnOffType.OFF);
}
}
} catch (ItemNotFoundException e) {
logger.error("Item {} not found", itemName);
}
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:22,代码来源:SappBinding.java
示例17: resolveDataTypeFromItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
SimaticTypes resolveDataTypeFromItemType(Item item, String address) throws BindingConfigParseException {
Class<? extends Item> itemType = item.getClass();
if (itemType.isAssignableFrom(NumberItem.class)) {
switch (SimaticPLCAddress.create(address).dataType) {
case DWORD:
return SimaticTypes.DWORD;
case WORD:
return SimaticTypes.WORD;
default:
return SimaticTypes.BYTE;
}
} else if (itemType.isAssignableFrom(SwitchItem.class)) {
return SimaticTypes.BYTE;
} else if (itemType.isAssignableFrom(DimmerItem.class)) {
return SimaticTypes.BYTE;
} else if (itemType.isAssignableFrom(ColorItem.class)) {
logger.warn("Item %s has not specified datatype. Setted to RGB.", item.getName());
return SimaticTypes.RGB;
} else if (itemType.isAssignableFrom(StringItem.class)) {
logger.warn("Item %s has not specified datatype with length. Setted to ARRAY with length 32.",
item.getName());
return SimaticTypes.ARRAY;
} else if (itemType.isAssignableFrom(ContactItem.class)) {
return SimaticTypes.BYTE;
} else if (itemType.isAssignableFrom(RollershutterItem.class)) {
return SimaticTypes.WORD;
} else {
throw new BindingConfigParseException("Unsupported item type: " + item);
}
}
开发者ID:docbender,项目名称:openHAB-Simatic,代码行数:32,代码来源:SimaticGenericBindingProvider.java
示例18: objectToState
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* Converts a value to a {@link State} which is suitable for the given {@link Item}. This is
* needed for querying a {@link HistoricState}.
*
* @param value to be converted to a {@link State}
* @param itemName name of the {@link Item} to get the {@link State} for
* @return the state of the item represented by the itemName parameter,
* else the string value of the Object parameter
*/
private State objectToState(Object value, String itemName) {
String valueStr = String.valueOf(value);
if (itemRegistry != null) {
try {
Item item = itemRegistry.getItem(itemName);
if (item instanceof NumberItem) {
return new DecimalType(valueStr);
} else if (item instanceof ColorItem) {
return new HSBType(valueStr);
} else if (item instanceof DimmerItem) {
return new PercentType(valueStr);
} else if (item instanceof SwitchItem) {
return string2DigitalValue(valueStr).equals(DIGITAL_VALUE_OFF)
? OnOffType.OFF
: OnOffType.ON;
} else if (item instanceof ContactItem) {
return (string2DigitalValue(valueStr).equals(DIGITAL_VALUE_OFF))
? OpenClosedType.CLOSED
: OpenClosedType.OPEN;
} else if (item instanceof RollershutterItem) {
return new PercentType(valueStr);
} else if (item instanceof DateTimeItem) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(new BigDecimal(valueStr).longValue());
return new DateTimeType(calendar);
} else {
return new StringType(valueStr);
}
} catch (ItemNotFoundException e) {
logger.warn("Could not find item '{}' in registry", itemName);
}
}
// just return a StringType as a fallback
return new StringType(valueStr);
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:45,代码来源:InfluxDBPersistenceService.java
示例19: store
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
@Override
public void store(Item item, String alias) {
if (item.getState() instanceof UnDefType)
return;
if (alias == null)
alias = item.getName();
logger.debug("store called for {}", alias);
State state = item.getState();
if (item instanceof DimmerItem || item instanceof RollershutterItem) {
state = item.getStateAs(PercentType.class);
} else if (item instanceof ColorItem) {
state = item.getStateAs(HSBType.class);
}
MapDBItem mItem = new MapDBItem();
mItem.setName(alias);
mItem.setState(state);
mItem.setTimestamp(new Date());
MapDBItem oldItem = map.put(alias, mItem);
if (!commitSameState) {
if (oldItem != null) {
if (!oldItem.getState().toString().equals(state.toString())) {
needsCommit = true;
}
}
}
logger.debug("Stored '{}' with state '{}' in mapdb database", alias,
state.toString());
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:34,代码来源:MapDBPersistenceService.java
示例20: validateItemType
import org.openhab.core.library.items.DimmerItem; //导入依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public void validateItemType(Item item, String bindingConfig) throws BindingConfigParseException {
if (!(item instanceof SwitchItem || item instanceof NumberItem || item instanceof DimmerItem)) {
throw new BindingConfigParseException(
"item '"
+ item.getName()
+ "' is of type '"
+ item.getClass().getSimpleName()
+ "', only Number and Switch- and DimmerItems are allowed - please check your *.items configuration");
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:TellstickGenericBindingProvider.java
注:本文中的org.openhab.core.library.items.DimmerItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论