本文整理汇总了Java中org.openhab.library.tel.types.CallType类的典型用法代码示例。如果您正苦于以下问题:Java CallType类的具体用法?Java CallType怎么用?Java CallType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CallType类属于org.openhab.library.tel.types包,在下文中一共展示了CallType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleNewCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
private void handleNewCall(String itemName, Class<? extends Item> itemType, NewChannelEvent event) {
if (event.getCallerIdNum() == null || event.getExten() == null) {
logger.debug("calleridnum or exten is null -> handle new call aborted!");
return;
}
CallType call = new CallType(
new StringType(event.getCallerIdNum()),
new StringType(event.getExten()));
eventCache.put(event.getUniqueId(), call);
if (itemType.isAssignableFrom(SwitchItem.class)) {
eventPublisher.postUpdate(itemName, OnOffType.ON);
}
else if (itemType.isAssignableFrom(CallItem.class)) {
eventPublisher.postUpdate(itemName, call);
}
else {
logger.warn("handle call for item type '{}' is undefined", itemName);
}
}
示例2: handleHangupCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Removes <code>event</code> from the <code>eventCache</code> and posts
* updates according to the content of the <code>eventCache</code>. If
* there is no active call left we send an OFF-State (resp. empty
* {@link CallType} and ON-State (one of the remaining active calls)
* in all other cases.
*
* @param itemName
* @param itemType
* @param event
*/
private void handleHangupCall(String itemName, Class<? extends Item> itemType, HangupEvent event) {
eventCache.remove(event.getUniqueId());
if (itemType.isAssignableFrom(SwitchItem.class)) {
OnOffType activeState =
(eventCache.size() == 0 ? OnOffType.OFF : OnOffType.ON);
eventPublisher.postUpdate(itemName, activeState);
}
else if (itemType.isAssignableFrom(CallItem.class)) {
CallType call = (CallType)
(eventCache.size() == 0 ? CallType.EMPTY : eventCache.values().toArray()[0]);
eventPublisher.postUpdate(itemName, call);
}
else {
logger.warn("handleHangupCall - postUpdate for itemType '{}' is undefined", itemName);
}
}
示例3: testAsHistoricGeneric
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Test state deserialization, that is DynamoDBItem conversion to HistoricItem
*
* @param dbItem dynamo db item
* @param item parameter for DynamoDBItem.asHistoricItem
* @param expectedState Expected state of the historic item. DecimalTypes are compared with reduced accuracy
* @return
* @throws IOException
*/
public HistoricItem testAsHistoricGeneric(DynamoDBItem<?> dbItem, Item item, Object expectedState)
throws IOException {
HistoricItem historicItem = dbItem.asHistoricItem(item);
assertEquals("item1", historicItem.getName());
assertEquals(date, historicItem.getTimestamp());
assertEquals(expectedState.getClass(), historicItem.getState().getClass());
if (expectedState instanceof DecimalType) {
// serialization loses accuracy, take this into consideration
assertTrue(DynamoDBBigDecimalItem.loseDigits(((DecimalType) expectedState).toBigDecimal())
.compareTo(((DecimalType) historicItem.getState()).toBigDecimal()) == 0);
} else if (expectedState instanceof CallType) {
// CallType has buggy equals, let's compare strings instead
assertEquals(expectedState.toString(), historicItem.getState().toString());
} else {
assertEquals(expectedState, historicItem.getState());
}
return historicItem;
}
示例4: handleNewCallEvent
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Handle Answer or Media (ringing) events and add an entry to our cache
* @param event
*/
private void handleNewCallEvent(EslEvent event) {
String uuid = getHeader(event, UUID);
logger.debug("Adding Call with uuid " + uuid);
Channel channel = new Channel(event);
//we should not get duplicate events, but lets be safe
if(eventCache.containsKey(uuid))
return;
eventCache.put(uuid, channel);
itemMap.put(uuid, new LinkedList<FreeswitchBindingConfig>());
CallType call = channel.getCall();
logger.debug("new call to : {} from : {}",
call.getDestNum(), call.getOrigNum());
for (FreeswitchBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
FreeswitchBindingConfig config = provider
.getFreeswitchBindingConfig(itemName);
if (config.getType() == FreeswitchBindingType.ACTIVE) {
/*
* Add the item if it is filtered and matches or if it is
* un-filtered and inbound
*/
if ((config.filtered() && matchCall(channel,config.getArgument()))
|| (!config.filtered() && isInboundCall(channel))) {
itemMap.get(uuid).add(config);
newCallItemUpdate(config, channel);
}
}
}
}
}
示例5: getCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
public CallType getCall(){
String dest = getEventHeader(DEST_NUMBER);
String orig = getEventHeader(ORIG_NUMBER);
if(StringUtils.isBlank(dest))
dest = "unknown";
if(StringUtils.isBlank(orig))
orig = "unknown";
return new CallType(orig,dest);
}
示例6: handleEventType
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Processes a monitor event for a given binding type
*
* @param event
* the monitor event to process
* @param bindingType
* the binding type of the items to process
*/
private void handleEventType(MonitorEvent event, String bindingType) {
for (FritzboxBindingProvider provider : providers) {
for (String itemName : provider
.getItemNamesForType(bindingType)) {
Class<? extends Item> itemType = provider
.getItemType(itemName);
org.openhab.core.types.State state = null;
if (event.eventType.equals("DISCONNECT")) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF
: CallType.EMPTY;
} else if (event.eventType.equals("CONNECT")) {
if (bindingType
.equals(FritzboxBindingProvider.TYPE_ACTIVE)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.externalNo, event.line);
} else {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF
: CallType.EMPTY;
}
} else if (event.eventType.equals("RING")
&& bindingType
.equals(FritzboxBindingProvider.TYPE_INBOUND)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.externalNo,
event.internalNo);
} else if (event.eventType.equals("CALL")
&& bindingType
.equals(FritzboxBindingProvider.TYPE_OUTBOUND)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.internalNo,
event.externalNo);
}
if (state != null) {
eventPublisher.postUpdate(itemName, state);
}
}
}
}
示例7: fromState
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
public static DynamoDBItem<?> fromState(String name, State state, Date time) {
if (state instanceof DecimalType && !(state instanceof HSBType)) {
// also covers PercentType which is inherited from DecimalType
return new DynamoDBBigDecimalItem(name, ((DecimalType) state).toBigDecimal(), time);
} else if (state instanceof OnOffType) {
return new DynamoDBBigDecimalItem(name,
((OnOffType) state) == OnOffType.ON ? BigDecimal.ONE : BigDecimal.ZERO, time);
} else if (state instanceof OpenClosedType) {
return new DynamoDBBigDecimalItem(name,
((OpenClosedType) state) == OpenClosedType.OPEN ? BigDecimal.ONE : BigDecimal.ZERO, time);
} else if (state instanceof UpDownType) {
return new DynamoDBBigDecimalItem(name,
((UpDownType) state) == UpDownType.UP ? BigDecimal.ONE : BigDecimal.ZERO, time);
} else if (state instanceof DateTimeType) {
return new DynamoDBStringItem(name, DATEFORMATTER.format(((DateTimeType) state).getCalendar().getTime()),
time);
} else if (state instanceof UnDefType) {
return new DynamoDBStringItem(name, UNDEFINED_PLACEHOLDER, time);
} else if (state instanceof CallType) {
// CallType.format method instead of toString since that matches the format expected by the String
// constructor
return new DynamoDBStringItem(name, state.format("%s##%s"), time);
} else {
// HSBType, PointType and StringType
return new DynamoDBStringItem(name, state.toString(), time);
}
}
示例8: handleNewCallEvent
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Handle Answer or Media (ringing) events and add an entry to our cache
*
* @param event
*/
private void handleNewCallEvent(EslEvent event) {
String uuid = getHeader(event, UUID);
logger.debug("Adding Call with uuid " + uuid);
Channel channel = new Channel(event);
// we should not get duplicate events, but lets be safe
if (eventCache.containsKey(uuid)) {
return;
}
eventCache.put(uuid, channel);
itemMap.put(uuid, new LinkedList<FreeswitchBindingConfig>());
CallType call = channel.getCall();
logger.debug("new call to : {} from : {}", call.getDestNum(), call.getOrigNum());
for (FreeswitchBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
FreeswitchBindingConfig config = provider.getFreeswitchBindingConfig(itemName);
if (config.getType() == FreeswitchBindingType.ACTIVE) {
/*
* Add the item if it is filtered and matches or if it is
* un-filtered and inbound
*/
if ((config.filtered() && matchCall(channel, config.getArgument()))
|| (!config.filtered() && isInboundCall(channel))) {
itemMap.get(uuid).add(config);
newCallItemUpdate(config, channel);
}
}
}
}
}
示例9: getCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
public CallType getCall() {
String dest = getEventHeader(DEST_NUMBER);
String orig = getEventHeader(ORIG_NUMBER);
if (StringUtils.isBlank(dest)) {
dest = "unknown";
}
if (StringUtils.isBlank(orig)) {
orig = "unknown";
}
return new CallType(orig, dest);
}
示例10: handleDtmfEvent
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
private void handleDtmfEvent(String itemName, Class<? extends Item> itemType, DtmfEvent event,
AsteriskBindingConfig config) {
if (config.type.equals("digit") && event.isBegin()) {
CallType call = eventCache.get(event.getUniqueId());
if (call != null) {
String reqCid = config.getCallerId();
String reqExt = config.getExtension();
String reqDigit = config.getDigit();
String src = null;
String dst = null;
if (event.getDirection().toString().equals("Sent")) {
src = call.getDestNum().toString();
dst = call.getOrigNum().toString();
} else {
src = call.getOrigNum().toString();
dst = call.getDestNum().toString();
}
if ((reqCid == null || (reqCid != null && reqCid.equals(src)))
&& (reqExt == null || (reqExt != null && reqExt.equals(dst)))
&& (reqDigit.equals(event.getDigit().toString()))) {
if (itemType.isAssignableFrom(SwitchItem.class)) {
eventPublisher.postUpdate(itemName, OnOffType.ON);
} else {
logger.warn("DTMF event not applicable to item {}", itemName);
}
}
logger.info("DTMF event received. Digit '{}' sent from '{}' to '{}'", event.getDigit(), src, dst);
}
}
}
示例11: handleNewCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
private void handleNewCall(String itemName, Class<? extends Item> itemType, NewChannelEvent event,
AsteriskBindingConfig config) {
if (event.getCallerIdNum() == null || event.getExten() == null) {
logger.debug("calleridnum or exten is null -> handle new call aborted!");
return;
}
CallType call = new CallType(new StringType(event.getCallerIdNum()), new StringType(event.getExten()));
eventCache.put(event.getUniqueId(), call);
if (config.type.equals("active")) {
String reqCid = config.getCallerId();
String reqExt = config.getExtension();
if ((reqCid == null || (reqCid != null && reqCid.equals(event.getCallerIdNum().toString())))
&& (reqExt == null || (reqExt != null && reqExt.equals(event.getExten().toString())))) {
if (itemType.isAssignableFrom(SwitchItem.class)) {
eventPublisher.postUpdate(itemName, OnOffType.ON);
} else if (itemType.isAssignableFrom(CallItem.class)) {
eventPublisher.postUpdate(itemName, call);
} else {
logger.warn("Handle call for item '{}' is undefined", itemName);
}
}
}
}
示例12: handleHangupCall
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Removes <code>event</code> from the <code>eventCache</code> and posts
* updates according to the content of the <code>eventCache</code>. If
* there is no active call left we send an OFF-State (resp. empty)
* {@link CallType} and ON-State (one of the remaining active calls)
* in all other cases.
*
* @param itemName
* @param itemType
* @param event
*/
private void handleHangupCall(String itemName, Class<? extends Item> itemType, HangupEvent event,
AsteriskBindingConfig config) {
eventCache.remove(event.getUniqueId());
if (config.type.equals("active")) {
String reqCid = config.getCallerId();
String reqExt = config.getExtension();
if (reqCid == null && reqExt == null) { // if both requirements are null, toggle the switch or call the
// old way
if (itemType.isAssignableFrom(SwitchItem.class)) {
OnOffType activeState = (eventCache.size() == 0 ? OnOffType.OFF : OnOffType.ON);
eventPublisher.postUpdate(itemName, activeState);
} else if (itemType.isAssignableFrom(CallItem.class)) {
CallType call = (CallType) (eventCache.size() == 0 ? CallType.EMPTY
: eventCache.values().toArray()[0]);
eventPublisher.postUpdate(itemName, call);
} else {
logger.warn("handleHangupCall - postUpdate for item '{}' is undefined", itemName);
}
} else {
if ((reqCid == null || (reqCid != null && reqCid.equals(event.getCallerIdNum().toString())))
&& (reqExt == null || (reqExt != null && reqExt.equals(event.getExten().toString())))) {
if (itemType.isAssignableFrom(SwitchItem.class)) {
eventPublisher.postUpdate(itemName, OnOffType.OFF);
} else if (itemType.isAssignableFrom(CallItem.class)) {
eventPublisher.postUpdate(itemName, CallType.EMPTY);
} else {
logger.warn("handleHangupCall - postUpdate for item '{}' is undefined", itemName);
}
}
}
}
}
示例13: handleEventType
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
/**
* Processes a monitor event for a given binding type
*
* @param event
* the monitor event to process
* @param bindingType
* the binding type of the items to process
*/
private void handleEventType(MonitorEvent event, String bindingType) {
for (FritzboxBindingProvider provider : providers) {
for (String itemName : provider.getItemNamesForType(bindingType)) {
Class<? extends Item> itemType = provider.getItemType(itemName);
org.openhab.core.types.State state = null;
if (event.eventType.equals("DISCONNECT")) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF : CallType.EMPTY;
} else if (event.eventType.equals("CONNECT")) {
if (bindingType.equals(FritzboxBindingProvider.TYPE_ACTIVE)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.externalNo, event.line);
} else {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.OFF : CallType.EMPTY;
}
} else if (event.eventType.equals("RING")
&& bindingType.equals(FritzboxBindingProvider.TYPE_INBOUND)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.externalNo, event.internalNo);
} else if (event.eventType.equals("CALL")
&& bindingType.equals(FritzboxBindingProvider.TYPE_OUTBOUND)) {
state = itemType.isAssignableFrom(SwitchItem.class) ? OnOffType.ON
: new CallType(event.internalNo, event.externalNo);
}
if (state != null) {
eventPublisher.postUpdate(itemName, state);
}
}
}
}
示例14: AsteriskEventManager
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
public AsteriskEventManager() {
eventCache = new HashMap<String, CallType>();
}
示例15: initializeGeneralGlobals
import org.openhab.library.tel.types.CallType; //导入依赖的package包/类
private void initializeGeneralGlobals() {
engine.put("RuleSet", RuleSet.class);
engine.put("Rule", Rule.class);
engine.put("ChangedEventTrigger", ChangedEventTrigger.class);
engine.put("CommandEventTrigger", CommandEventTrigger.class);
engine.put("Event", Event.class);
engine.put("EventTrigger", EventTrigger.class);
engine.put("ShutdownTrigger", ShutdownTrigger.class);
engine.put("StartupTrigger", StartupTrigger.class);
engine.put("TimerTrigger", TimerTrigger.class);
engine.put("TriggerType", TriggerType.class);
engine.put("BusEvent", BusEvent.class);
engine.put("be", BusEvent.class);
engine.put("PersistenceExtensions", PersistenceExtensions.class);
engine.put("pe", PersistenceExtensions.class);
engine.put("oh", Openhab.class);
engine.put("State", State.class);
engine.put("Command", Command.class);
engine.put("ItemRegistry", scriptManager.getItemRegistry());
engine.put("ir", scriptManager.getItemRegistry());
engine.put("DateTime", DateTime.class);
engine.put("StringUtils", StringUtils.class);
engine.put("URLEncoder", URLEncoder.class);
engine.put("FileUtils", FileUtils.class);
engine.put("FilenameUtils", FilenameUtils.class);
engine.put("File", File.class);
// default types, TODO: auto import would be nice
engine.put("CallType", CallType.class);
engine.put("DateTimeType", DateTimeType.class);
engine.put("DecimalType", DecimalType.class);
engine.put("HSBType", HSBType.class);
engine.put("IncreaseDecreaseType", IncreaseDecreaseType.class);
engine.put("OnOffType", OnOffType.class);
engine.put("OpenClosedType", OpenClosedType.class);
engine.put("PercentType", PercentType.class);
engine.put("PointType", PointType.class);
engine.put("StopMoveType", StopMoveType.class);
engine.put("UpDownType", UpDownType.class);
engine.put("StringType", StringType.class);
}