当前位置: 首页>>代码示例>>Java>>正文


Java EventPublisher.postUpdate方法代码示例

本文整理汇总了Java中org.openhab.core.events.EventPublisher.postUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java EventPublisher.postUpdate方法的具体用法?Java EventPublisher.postUpdate怎么用?Java EventPublisher.postUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openhab.core.events.EventPublisher的用法示例。


在下文中一共展示了EventPublisher.postUpdate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	
	int status = properties.getState();
	
	logger.debug("Unit state {}", status);
	
	int level = prevLevel;
	String display = "Off";
	
	if (status == UNIT_ON) {
		level = 100;
		display = "On";
	} else if ((status >= UNIT_SCENE_A) && (status <= UNIT_SCENE_L)) {
		level = 100;
		display = String.format("Scene %c", status - UNIT_SCENE_A + 'A');
	} else if ((status >= UNIT_DIM_1) && (status <= UNIT_DIM_9)) {
		display = String.format("Dim %d", level);
	} else if ((status >= UNIT_BRIGHTEN_1) && (status <= UNIT_BRIGHTEN_9)) {
		display = String.format("Brighten %d", level);
	} else if ((status >= UNIT_LEVEL_0) && (status <= UNIT_LEVEL_100)) {
		level = status - UNIT_LEVEL_0;
		display = String.format("Level %d", level);
	}

	if (item instanceof DimmerItem) {
		logger.debug("updating percent type {}", level);
		publisher.postUpdate(item.getName(), new PercentType(level));
	} else if (item instanceof SwitchItem) {
		logger.debug("updating switch type {}",
				level > 0 ? OnOffType.ON : OnOffType.OFF);
		publisher.postUpdate(item.getName(), level > 0 ? OnOffType.ON
				: OnOffType.OFF);
	} else if (item instanceof StringItem) {
		logger.debug("updating string type {}",display);
		publisher.postUpdate(item.getName(), new StringType(display));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:40,代码来源:Unit.java

示例2: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	String str = " ";

	switch (config.getObjectType()) {

	case AUDIOSOURCE_TEXT:
		str = formatAudioText();
		break;
	case AUDIOSOURCE_TEXT_FIELD1:
		str = getAudioText(0);
		break;
	case AUDIOSOURCE_TEXT_FIELD2:
		str = getAudioText(1);
		break;
	case AUDIOSOURCE_TEXT_FIELD3:
		str = getAudioText(2);
		break;
	default:
		return;
	}

	if (item instanceof StringItem) {
		publisher.postUpdate(item.getName(), new StringType(str));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:28,代码来源:AudioSource.java

示例3: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	int setting = 0;
	switch (config.getObjectType()) {
	case AUX_CURRENT:
		setting = celsius ? MessageUtils.omniToC(properties.getCurrent())
				: MessageUtils.omniToF(properties.getCurrent());
		break;
	case AUX_HIGH:
		setting = celsius ? MessageUtils.omniToC(properties
				.getHighSetpoint()) : MessageUtils.omniToF(properties
				.getCurrent());
		break;
	case AUX_LOW:
		setting = celsius ? MessageUtils.omniToC(properties
				.getLowSetpoint()) : MessageUtils.omniToF(properties
				.getCurrent());
		break;
	case AUX_STATUS:
		setting = properties.getStatus();
		break;
	default:
		return;
	}
	logger.debug("updating item {} for type {} to  {}", item.getName(),
			config.getObjectType(), setting);
	if (item instanceof NumberItem) {
		publisher.postUpdate(item.getName(), new DecimalType(setting));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:32,代码来源:Auxiliary.java

示例4: handleEvent

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
	int tpiCode = -1;
	APIMessage tpiMessage = null;
	String strStatus = "Status Unknown!";
	
	if(event != null) {
		tpiMessage = event.getAPIMessage();
		tpiCode = Integer.parseInt(tpiMessage.getAPICode());
		strStatus = tpiMessage.getAPIName();
		logger.debug("handleEvent(): Zone Item Name: {}", item.getName());

		if(config != null) {
			if(config.getDSCAlarmItemType() != null) {
				switch(config.getDSCAlarmItemType()) {
					case ZONE_ALARM_STATUS:
						zoneProperties.setState(StateType.ALARM_STATE, (tpiCode == 601) ? 1:0, strStatus);
						publisher.postUpdate(item.getName(), new StringType(strStatus));
						break;
					case ZONE_TAMPER_STATUS:
						zoneProperties.setState(StateType.TAMPER_STATE, (tpiCode == 603) ? 1:0, strStatus);
						publisher.postUpdate(item.getName(), new StringType(strStatus));
						break;
					case ZONE_FAULT_STATUS:
						zoneProperties.setState(StateType.FAULT_STATE, (tpiCode == 605) ? 1:0, strStatus);
						publisher.postUpdate(item.getName(), new StringType(strStatus));
						break;
					case ZONE_GENERAL_STATUS:
						zoneProperties.setState(StateType.GENERAL_STATE, (tpiCode == 609) ? 1:0, strStatus);
						publisher.postUpdate(item.getName(), (zoneProperties.getState(StateType.GENERAL_STATE) == 1) ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
						break;
					default: 
						logger.debug("handleEvent(): Zone item not updated.");
						break;
				}
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:43,代码来源:Zone.java

示例5: postUpdate

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
/**
 * Posts a status update for a specified item to the event bus.
 * 
 * @param itemName the name of the item to send the status update for
 * @param stateAsString the new state of the item
 */
static public Object postUpdate(String itemName, String stateString) {
	ItemRegistry registry = (ItemRegistry) ScriptActivator.itemRegistryTracker.getService();
	EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
	if(publisher!=null && registry!=null) {
		try {
			Item item = registry.getItem(itemName);
			State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
			publisher.postUpdate(itemName, state);
		} catch (ItemNotFoundException e) {
			logger.warn("Item '" + itemName + "' does not exist.");
		}
	}
	return null;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:21,代码来源:BusEvent.java

示例6: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	int num = 0;
	String str = "";
	int source = new Integer(properties.getSource());

	switch (config.getObjectType()) {
	case AUDIOZONE_MUTE:
		num = properties.isMute() ? 1 : 0;
		break;
	case AUDIOZONE_POWER:
		num = properties.isOn() ? 1 : 0;
		break;
	case AUDIOZONE_SOURCE:
		num = properties.getSource();
		break;
	case AUDIOZONE_VOLUME:
		num = properties.getVolume();
		break;
	case AUDIOZONE_TEXT:
		if (sourceValid(source))
			str = audioSources.get(source).formatAudioText();
		break;
	case AUDIOZONE_TEXT_FIELD1:
		if (sourceValid(source))
			str = audioSources.get(source).getAudioText(0);
		break;
	case AUDIOZONE_TEXT_FIELD2:
		if (sourceValid(source))
			str = audioSources.get(source).getAudioText(1);
		break;
	case AUDIOZONE_TEXT_FIELD3:
		if (sourceValid(source))
			str = audioSources.get(source).getAudioText(2);
		break;
	case AUDIOZONE_KEY:
		num = -1;
		break;
	default:
		return;
	}

	if (item instanceof DimmerItem) {
		logger.debug("updating percent type {}", num);
		publisher.postUpdate(item.getName(), new PercentType(num));
	} else if (item instanceof NumberItem) {
		logger.debug("updating number type {}", num);
		publisher.postUpdate(item.getName(), new DecimalType(num));
	} else if (item instanceof SwitchItem) {
		logger.debug("updating switch type {}", num > 0 ? OnOffType.ON
				: OnOffType.OFF);
		publisher.postUpdate(item.getName(), num > 0 ? OnOffType.ON
				: OnOffType.OFF);
	} else if (item instanceof StringItem) {
		logger.debug("updating string type {}", str);
		publisher.postUpdate(item.getName(), new StringType(str));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:60,代码来源:AudioZone.java

示例7: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	int setting = 0;
	String str = "";
	switch (config.getObjectType()) {
	case AREA_ENTRY_TIMER:
		setting = properties.getEntryTimer();
		break;
	case AREA_EXIT_TIMER:
		setting = properties.getExitTimer();
		break;
	case AREA_STATUS_ENTRY_DELAY:
		setting = properties.getEntryDelay();
		break;
	case AREA_STATUS_EXIT_DELAY:
		setting = properties.getExitDelay();
		break;
	case AREA_STATUS_MODE:
		setting = properties.getMode();
		str = omni ? (setting < omniText.length ? omniText[setting]
				: "Unknown")
				: (setting < luminaText.length ? luminaText[setting]
						: "Unknown");
		break;
	case AREA_STATUS_ALARM:
		setting = properties.getAlarms();

		for (int i = 0; i < alarms.length; i++) {
			if(((setting >> i) & 1) > 0){
				if (str.length() > 0)
					str += " | ";
				str += alarms[i];
			}
		}
		
		break;
	default:
		break;
	}
	logger.debug("updating item {} for type {} to  {}", item.getName(),
			config.getObjectType(), setting);
	if (item instanceof NumberItem) {
		publisher.postUpdate(item.getName(), new DecimalType(setting));
	} else if (item instanceof StringItem) {
		publisher.postUpdate(item.getName(), new StringType(str));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:49,代码来源:Area.java

示例8: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	int current = ((properties.getStatus() >> 0) & 0x03);
	int latched = ((properties.getStatus() >> 2) & 0x03);
	int arming = ((properties.getStatus() >> 4) & 0x03);

	String latchedTxt = (latched < LATCHED_TEXT.length ? LATCHED_TEXT[latched]
			: "?");
	String armingTxt = (arming < ARMING_TEXT.length ? ARMING_TEXT[arming]
			: "?");
	String currentTxt = (current < CURRENT_TEXT.length ? CURRENT_TEXT[current]
			: "?");

	int setting = 0;
	String str = "";
	switch (config.getObjectType()) {
	case ZONE_STATUS_ARMING:
		setting = arming;
		str = armingTxt;
		break;
	case ZONE_STATUS_CURRENT:
		setting = current;
		str = currentTxt;
		break;
	case ZONE_STATUS_LATCHED:
		setting = latched;
		str = latchedTxt;
		break;
	case ZONE_STATUS_ALL:
		str = currentTxt + " | " + latchedTxt + " | " + armingTxt;
		break;
	default:
		break;
	}
	if (item instanceof NumberItem) {
		publisher.postUpdate(item.getName(), new DecimalType(setting));
	} else if (item instanceof StringItem) {
		publisher.postUpdate(item.getName(), new StringType(str));
	} else if (item instanceof ContactItem) {
		publisher.postUpdate(item.getName(),
				current == 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:45,代码来源:Zone.java

示例9: updateItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
@Override
public void updateItem(Item item, OmniLinkBindingConfig config,
		EventPublisher publisher) {
	int setting = 0;
	String mode = null;
	switch (config.getObjectType()) {
	case THERMO_COOL_POINT:
		setting = celsius ? MessageUtils.omniToC(properties
				.getCoolSetpoint()) : MessageUtils.omniToF(properties
				.getCoolSetpoint());
		break;
	case THERMO_TEMP:
		setting = celsius ? MessageUtils.omniToC(properties
				.getTemperature()) : MessageUtils.omniToF(properties
				.getTemperature());
		break;
	case THERMO_HEAT_POINT:
		setting = celsius ? MessageUtils.omniToC(properties
				.getHeatSetpoint()) : MessageUtils.omniToF(properties
				.getHeatSetpoint());
		break;
	case THERMO_FAN_MODE:
		setting = properties.isFan() ? 1 : 0;
		break;
	case THERMO_HOLD_MODE:
		setting = properties.isHold() ? 1 : 0;
		break;
	case THERMO_SYSTEM_MODE:
		setting = properties.getMode();
		if (setting < MODES.length)
			mode = MODES[setting];
		break;
	default:
		return;
	}
	logger.debug("updating item {} for type {} to  {}", item.getName(),
			config.getObjectType(), setting);
	if (item instanceof NumberItem) {
		publisher.postUpdate(item.getName(), new DecimalType(setting));
	} else if (item instanceof SwitchItem) {
		publisher.postUpdate(item.getName(), setting > 0 ? OnOffType.ON
				: OnOffType.OFF);

	} else if (item instanceof StringItem && mode != null) {
		publisher.postUpdate(item.getName(), new StringType(mode));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:48,代码来源:Thermostat.java

示例10: refreshItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void refreshItem(Item item, DSCAlarmBindingConfig config, EventPublisher publisher) {
	logger.debug("refreshItem(): Partition Item Name: {}", item.getName());

	int state;
	String strStatus = "";
	boolean trigger;
	OnOffType onOffType;

	if(config != null) {
		if(config.getDSCAlarmItemType() != null) {
			switch(config.getDSCAlarmItemType()) {
				case PARTITION_STATUS:
					state = partitionProperties.getState(StateType.GENERAL_STATE);
					strStatus = partitionProperties.getStateDescription(StateType.GENERAL_STATE);
					publisher.postUpdate(item.getName(), new StringType(strStatus));
					break;
				case PARTITION_ARM_MODE:
					state = partitionProperties.getState(StateType.ARM_STATE);
					strStatus = partitionProperties.getStateDescription(StateType.ARM_STATE);
					publisher.postUpdate(item.getName(), new DecimalType(state));
					break;
				case PARTITION_ARMED:
					trigger = partitionProperties.getTrigger(TriggerType.ARMED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case PARTITION_ENTRY_DELAY:
					trigger = partitionProperties.getTrigger(TriggerType.ENTRY_DELAY);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case PARTITION_EXIT_DELAY:
					trigger = partitionProperties.getTrigger(TriggerType.EXIT_DELAY);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case PARTITION_IN_ALARM:
					trigger = partitionProperties.getTrigger(TriggerType.ALARMED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case PARTITION_OPENING_CLOSING_MODE:
					state = partitionProperties.getState(StateType.OPENING_CLOSING_STATE);
					strStatus = partitionProperties.getStateDescription(StateType.OPENING_CLOSING_STATE);
					if(item instanceof NumberItem) {
						publisher.postUpdate(item.getName(), new DecimalType(state));
					}
					if(item instanceof StringItem) {
						publisher.postUpdate(item.getName(), new StringType(strStatus));
					}
					break;
				default:
					logger.debug("refreshItem(): Partition item not updated.");
					break;
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:63,代码来源:Partition.java

示例11: refreshItem

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void refreshItem(Item item, DSCAlarmBindingConfig config, EventPublisher publisher) {
	logger.debug("refreshItem(): Zone Item Name: {}", item.getName());

	int state;
	String strStatus = "";
	boolean trigger;
	OnOffType onOffType;

	if(config != null) {
		if(config.getDSCAlarmItemType() != null) {
			switch(config.getDSCAlarmItemType()) {
				case ZONE_ALARM_STATUS:
					state = zoneProperties.getState(StateType.ALARM_STATE);
					strStatus = zoneProperties.getStateDescription(StateType.ALARM_STATE);
					publisher.postUpdate(item.getName(), new StringType(strStatus));
					break;
				case ZONE_TAMPER_STATUS:
					state = zoneProperties.getState(StateType.TAMPER_STATE);
					strStatus = zoneProperties.getStateDescription(StateType.TAMPER_STATE);
					publisher.postUpdate(item.getName(), new StringType(strStatus));
					break;
				case ZONE_FAULT_STATUS:
					state = zoneProperties.getState(StateType.FAULT_STATE);
					strStatus = zoneProperties.getStateDescription(StateType.FAULT_STATE);
					publisher.postUpdate(item.getName(), new StringType(strStatus));
					break;
				case ZONE_GENERAL_STATUS:
					state = zoneProperties.getState(StateType.GENERAL_STATE);
					publisher.postUpdate(item.getName(), state == 1 ? OpenClosedType.OPEN : OpenClosedType.CLOSED);
					break;
				case ZONE_BYPASS_MODE:
					state = zoneProperties.getState(StateType.ARM_STATE);
					publisher.postUpdate(item.getName(), new DecimalType(state));
					break;
				case ZONE_IN_ALARM:
					trigger = zoneProperties.getTrigger(TriggerType.ALARMED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case ZONE_TAMPER:
					trigger = zoneProperties.getTrigger(TriggerType.TAMPERED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case ZONE_FAULT:
					trigger = zoneProperties.getTrigger(TriggerType.FAULTED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				case ZONE_TRIPPED:
					trigger = zoneProperties.getTrigger(TriggerType.TRIPPED);
					onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
					publisher.postUpdate(item.getName(), onOffType);
					break;
				default: 
					logger.debug("refreshItem(): Zone item not updated.");
					break;
			}
		}
	}
	
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:67,代码来源:Zone.java

示例12: handleEvent

import org.openhab.core.events.EventPublisher; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void handleEvent(Item item, DSCAlarmBindingConfig config, EventPublisher publisher, DSCAlarmEvent event) {
	APIMessage apiMessage = null;
	int apiCode = -1;
	boolean boolState;
	int state;
	OnOffType onOffType;

	if(event != null) {
		apiMessage = event.getAPIMessage();
		apiCode = Integer.parseInt(apiMessage.getAPICode());
		String str = "";
		logger.debug("handleEvent(): Panel Item Name: {}", item.getName());

		if(config != null) {
			if(config.getDSCAlarmItemType() != null) {
				switch(config.getDSCAlarmItemType()) {
					case PANEL_CONNECTION:
						state = panelProperties.getSystemConnection();
						publisher.postUpdate(item.getName(), new DecimalType(state));
						break;
					case PANEL_MESSAGE:
						if(apiMessage != null) {
							str = apiMessage.getAPIDescription();
							panelProperties.setSystemMessage(str);
						}
						publisher.postUpdate(item.getName(), new StringType(str));
						break;
		
					case PANEL_SYSTEM_ERROR:
						panelProperties.setSystemError(1);
						panelProperties.setSystemErrorCode(0);
						int systemErrorCode = 0;
						
						if(apiMessage != null) {
							systemErrorCode = Integer.parseInt(apiMessage.getAPIData());
							panelProperties.setSystemErrorCode(systemErrorCode);
							panelProperties.setSystemErrorDescription(apiMessage.getError());
							str = String.format("%03d", panelProperties.getSystemErrorCode()) + ": " + panelProperties.getSystemErrorDescription();
							publisher.postUpdate(item.getName(), new StringType(str));
						}
						break;
					case PANEL_TROUBLE_MESSAGE:
						if(apiMessage != null) {
							str = apiMessage.getAPIDescription();
							panelProperties.setTroubleMessage(str);
						}
						publisher.postUpdate(item.getName(), new StringType(str));
						break;
					case PANEL_TROUBLE_LED:
						if(apiMessage != null) {
							boolState = (apiCode == 840) ? true:false;
							panelProperties.setTroubleLED(boolState);
							
							onOffType = boolState ? OnOffType.ON : OnOffType.OFF;
							publisher.postUpdate(item.getName(), onOffType);
						}
						break;
					case PANEL_TIME:
						if(apiMessage != null) {
							panelProperties.setSystemTime(apiMessage.getAPIData());
							str = panelProperties.getSystemTime();
							publisher.postUpdate(item.getName(), new DateTimeType(str));
						}
						break;
					default:
						logger.debug("handleEvent(): Panel item not updated.");
						break;
				}
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:77,代码来源:Panel.java


注:本文中的org.openhab.core.events.EventPublisher.postUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。