本文整理汇总了Java中net.whistlingfish.harmony.config.Activity类的典型用法代码示例。如果您正苦于以下问题:Java Activity类的具体用法?Java Activity怎么用?Java Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Activity类属于net.whistlingfish.harmony.config包,在下文中一共展示了Activity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public int execute(String[] args) throws Exception {
if(devMode)
{
harmonyClient = null;
devResponse = new DevModeResponse();
}
else {
devResponse = null;
harmonyClient.addListener(new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
log.info(format("activity changed: [%d] %s", activity.getId(), activity.getLabel()));
}
});
harmonyClient.connect(args[0]);
}
port(Integer.valueOf(System.getProperty("server.port", "8081")));
int sleepTime = Integer.parseInt(System.getProperty("button.sleep", "100"));
harmonyApi = new HarmonyRest(harmonyClient, noopCalls, sleepTime, devResponse);
harmonyApi.setupServer();
while(true)
{
//no op
Thread.sleep(100000);
}
}
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:27,代码来源:HarmonyRestServer.java
示例2: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<HarmonyActivity> getActivities() {
Iterator<String> keys = hubs.keySet().iterator();
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
if(!validHarmony)
return null;
while(keys.hasNext()) {
String key = keys.next();
Iterator<Activity> activities = hubs.get(key).getMyHarmony().getActivities().iterator();
while(activities.hasNext()) {
HarmonyActivity anActivity = new HarmonyActivity();
anActivity.setActivity(activities.next());
anActivity.setHub(key);
activityList.add(anActivity);
}
}
return activityList;
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:18,代码来源:HarmonyHome.java
示例3: getCurrentActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<HarmonyActivity> getCurrentActivities() {
Iterator<String> keys = hubs.keySet().iterator();
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
if(!validHarmony)
return null;
while(keys.hasNext()) {
String key = keys.next();
Activity theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
HarmonyActivity anActivity = new HarmonyActivity();
anActivity.setActivity(theActivity);
anActivity.setHub(key);
activityList.add(anActivity);
}
return activityList;
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:16,代码来源:HarmonyHome.java
示例4: setActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public void setActivity(Activity activity) {
byte ptext[];
String theLabel = activity.getLabel();
try {
ptext = theLabel.getBytes("ISO-8859-1");
activity.setLabel(new String(ptext, "UTF-8"));
} catch (UnsupportedEncodingException e) {
activity.setLabel(theLabel);
}
this.activity = activity;
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:12,代码来源:HarmonyActivity.java
示例5: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<Activity> getActivities() {
log.debug("Harmony api activities list requested.");
if(devMode)
return devResponse.getActivities();
return harmonyClient.getConfig().getActivities();
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:8,代码来源:HarmonyHandler.java
示例6: getCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getCurrentActivity() {
log.debug("Harmony api current sctivity requested.");
if(devMode)
return devResponse.getCurrentActivity();
return harmonyClient.getCurrentActivity();
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:8,代码来源:HarmonyHandler.java
示例7: updateActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update all items who need to know about it
* @param activity
*/
private void updateActivity(Activity activity, String qualifier) {
logger.debug("updateActivity {}" + activity.getLabel());
for (HarmonyHubBindingProvider provider : providers) {
for(String itemName : provider.getItemNames()) {
HarmonyHubBindingConfig config = provider.getHarmonyHubBindingConfig(itemName);
if(config.matchesQualifier(qualifier) &&
config.getBindingType() == HarmonyHubBindingType.CurrentActivity) {
updateActivityForItem(itemName, config.getItemType(), activity);
}
}
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:HarmonyHubBinding.java
示例8: updateActivityForItem
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update an {@link Item} with its {@link State} state
* @param item
* @param state
* @param activity
*/
private void updateActivityForItem(String itemName, Class<? extends Item> itemType, Activity activity) {
if(itemType.isAssignableFrom(NumberItem.class)) {
eventPublisher.postUpdate(itemName, new DecimalType(activity.getId()));
} else {
eventPublisher.postUpdate(itemName, new StringType(activity.getLabel()));
}
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:14,代码来源:HarmonyHubBinding.java
示例9: updateActivityStatus
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private void updateActivityStatus(Activity activity, Activity.Status status) {
logger.debug("Received {} activity status for {}", status, activity.getLabel());
switch (status) {
case ACTIVITY_IS_STARTING:
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTING_TRIGGER, getEventName(activity));
break;
case ACTIVITY_IS_STARTED:
case HUB_IS_OFF:
// hub is off is received with power-off activity
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTED_TRIGGER, getEventName(activity));
break;
case HUB_IS_TURNING_OFF:
// hub is turning off is received for current activity, we will translate it into activity starting
// trigger of power-off activity (with ID=-1)
getConfigFuture().thenAccept(config -> {
if (config != null) {
Activity powerOff = config.getActivityById(-1);
if (powerOff != null) {
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTING_TRIGGER,
getEventName(powerOff));
}
}
}).exceptionally(e -> {
setOfflineAndReconnect("Getting config failed: " + e.getMessage());
return null;
});
break;
default:
break;
}
}
开发者ID:openhab,项目名称:openhab2-addons,代码行数:32,代码来源:HarmonyHubHandler.java
示例10: bind
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
@Override
public void bind(final HarmonyHubBinding binding) {
final String itemName = item.getName();
binding.registerListener(qualifier, itemName, new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
binding.postUpdate(itemName, new StringType(activity.getLabel()));
}
});
}
开发者ID:tuck182,项目名称:openhab-harmony-binding,代码行数:12,代码来源:BindingConfigCurrentActivity.java
示例11: updateActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update all items who need to know about it
*
* @param activity
*/
private void updateActivity(Activity activity, String qualifier) {
logger.debug("updateActivity {}" + activity.getLabel());
for (HarmonyHubBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
HarmonyHubBindingConfig config = provider.getHarmonyHubBindingConfig(itemName);
if (config.matchesQualifier(qualifier)
&& config.getBindingType() == HarmonyHubBindingType.CurrentActivity) {
updateActivityForItem(itemName, config.getItemType(), activity);
}
}
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:19,代码来源:HarmonyHubBinding.java
示例12: updateActivityForItem
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update an {@link Item} with its {@link State} state
*
* @param item
* @param state
* @param activity
*/
private void updateActivityForItem(String itemName, Class<? extends Item> itemType, Activity activity) {
if (itemType.isAssignableFrom(NumberItem.class)) {
eventPublisher.postUpdate(itemName, new DecimalType(activity.getId()));
} else {
eventPublisher.postUpdate(itemName, new StringType(activity.getLabel()));
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:15,代码来源:HarmonyHubBinding.java
示例13: getCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getCurrentActivity() {
return currentActivity;
}
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java
示例14: setCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public void setCurrentActivity(Activity currentActivity) {
this.currentActivity = currentActivity;
}
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java
示例15: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<Activity> getActivities() {
return harmonyConfig.getActivities();
}
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java
示例16: getActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getActivity() {
return activity;
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:4,代码来源:HarmonyActivity.java
示例17: execute
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private void execute(BridgeSettingsDescriptor mySettings, Boolean harmonyDevMode) throws Exception {
Boolean noopCalls = Boolean.parseBoolean(System.getProperty("noop.calls", "false"));
isDevMode = harmonyDevMode;
String modeString = "";
if (dummyProvider != null) {
log.debug("something is very wrong as dummyProvider is not null...");
}
if (isDevMode) {
modeString = " (development mode)";
} else if (noopCalls) {
modeString = " (no op calls to harmony)";
}
log.info("setup initiated " + modeString + "....");
if (isDevMode) {
harmonyClient = null;
devResponse = new DevModeResponse();
} else {
devResponse = null;
harmonyClient.addListener(new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
String webhook = myNameAndIP.getWebhook();
if(webhook != null) {
try {
// Replacing variables
webhook = webhook.replace(ACTIVIY_ID, activity.getId().toString());
webhook = webhook.replace(ACTIVIY_LABEL, URLEncoder.encode(activity.getLabel(), "UTF-8"));
log.info(format("calling webhook: %s", webhook));
// Calling webhook
httpClient.doHttpRequest(webhook, HttpGet.METHOD_NAME, null, null, null);
} catch (Exception e) {
log.warn("could not call webhook: " + webhook, e);
}
}
log.info(format("activity changed: [%d] %s", activity.getId(), activity.getLabel()));
}
});
harmonyClient.connect(myNameAndIP.getIp());
}
myHarmony = new HarmonyHandler(harmonyClient, noopCalls, devResponse);
}
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:44,代码来源:HarmonyServer.java
示例18: updateState
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private void updateState(Activity activity) {
logger.debug("Updating current activity to {}", activity.getLabel());
updateState(new ChannelUID(getThing().getUID(), HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY),
new StringType(activity.getLabel()));
}
开发者ID:openhab,项目名称:openhab2-addons,代码行数:6,代码来源:HarmonyHubHandler.java
示例19: getEventName
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private String getEventName(Activity activity) {
return activity.getLabel().replaceAll("[^A-Za-z0-9]", "_");
}
开发者ID:openhab,项目名称:openhab2-addons,代码行数:4,代码来源:HarmonyHubHandler.java
示例20: buildChannel
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private void buildChannel(HarmonyConfig config) {
try {
List<Activity> activities = config.getActivities();
// sort our activities in order
Collections.sort(activities, ACTIVITY_COMPERATOR);
// add our activities as channel state options
List<StateOption> states = new LinkedList<StateOption>();
for (Activity activity : activities) {
states.add(new StateOption(activity.getLabel(), activity.getLabel()));
}
ChannelTypeUID channelTypeUID = new ChannelTypeUID(
getThing().getUID() + ":" + HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY);
ChannelType channelType = new ChannelType(channelTypeUID, false, "String", "Current Activity",
"Current activity for " + getThing().getLabel(), null, null,
new StateDescription(null, null, null, "%s", false, states), null);
factory.addChannelType(channelType);
BridgeBuilder thingBuilder = editThing();
Channel channel = ChannelBuilder
.create(new ChannelUID(getThing().getUID(), HarmonyHubBindingConstants.CHANNEL_CURRENT_ACTIVITY),
"String")
.withType(channelTypeUID).build();
// replace existing currentActivity with updated one
List<Channel> currentChannels = getThing().getChannels();
List<Channel> newChannels = new ArrayList<Channel>();
for (Channel c : currentChannels) {
if (!c.getUID().equals(channel.getUID())) {
newChannels.add(c);
}
}
newChannels.add(channel);
thingBuilder.withChannels(newChannels);
updateThing(thingBuilder.build());
} catch (Exception e) {
logger.debug("Could not add current activity channel to hub", e);
}
}
开发者ID:openhab,项目名称:openhab2-addons,代码行数:45,代码来源:HarmonyHubHandler.java
注:本文中的net.whistlingfish.harmony.config.Activity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论