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


Java PHLightState类代码示例

本文整理汇总了Java中com.philips.lighting.model.PHLightState的典型用法代码示例。如果您正苦于以下问题:Java PHLightState类的具体用法?Java PHLightState怎么用?Java PHLightState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: turnOn

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
void turnOn() {
  PHBridge bridge = hueSDK.getSelectedBridge();

  for (PHLight light : allLights) {
    PHLightState lightState = new PHLightState();
    lightState.setOn(true);

    if (light.getModelNumber().equals("LWB014")) {
      lightState.setBrightness(50);
    } else {
      float[] xy = PHUtilities.calculateXYFromRGB(255, 255, 255, light.getModelNumber());

      lightState.setX(xy[0]);
      lightState.setY(xy[1]);
      lightState.setBrightness(50);
    }

    bridge.updateLightState(light, lightState, lightListener);
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:21,代码来源:HueController.java

示例2: turnOff

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
void turnOff() {
  Log.d("HUE", "turn off...");

  PHLightState lightState = new PHLightState();
  lightState.setOn(false);

  if (allLights != null) {
    for (PHLight light : allLights) {
      PHBridge bridge = hueSDK.getSelectedBridge();

      if (light != null) {
        bridge.updateLightState(light, lightState, lightListener);
      }
    }
  }
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:17,代码来源:HueController.java

示例3: changeColor

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
void changeColor(int r, int g, int b, int pid) {
  Log.d("HUE", "change light color...");

  PHBridge bridge = hueSDK.getSelectedBridge();

  for (PHLight light : allLights) {
    PHLightState lightState = new PHLightState();

    if (r > 0 || g > 0 || b > 0) {
      lightState.setOn(true);
    } else {
      lightState.setOn(false);
    }

    float[] xy = PHUtilities.calculateXYFromRGB(r, g, b, light.getModelNumber());

    if (!light.getModelNumber().equals("LWB014")) {
      lightState.setX(xy[0]);
      lightState.setY(xy[1]);
    }

    bridge.updateLightState(light, lightState, lightListener);
  }

  isTurnOn[pid] = b > 0;
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:27,代码来源:HueController.java

示例4: makeLightState

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
private PHLightState makeLightState(Integer color, Double brightness, long[] flashing) {
    int[] colors = convertColor(color);

    // Brightness magnification conversion
    calcColorParam(colors, brightness);

    // Calculation of brightness.
    int calcBrightness = calcBrightnessParam(colors);

    PHLightState lightState = new PHLightState();
    lightState.setOn(true);
    lightState.setColorMode(PHLightColorMode.COLORMODE_XY);

    Color hueColor = new Color(color);
    lightState.setX(hueColor.mX);
    lightState.setY(hueColor.mY);
    lightState.setBrightness(calcBrightness);
    if (flashing != null) {
        lightState.setTransitionTime(1);
    }
    return lightState;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:23,代码来源:HueLightProfile.java

示例5: actionPerformed

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
    
    Color lightColour  = JColorChooser.showDialog(getContentPane(), "Choose Bulb Color", getBackground());

    if (lightColour !=null) {
        int selectedBulb = lightIdentifiersList.getSelectedIndex();
        if (selectedBulb !=-1) {
            int selectedIndex= lightIdentifiersList.getSelectedIndex();
            String lightIdentifer = allLights.get(selectedIndex).getIdentifier();
            
            PHLightState lightState = new PHLightState();
            float xy[] = PHUtilities.calculateXYFromRGB(lightColour.getRed(), lightColour.getGreen(), lightColour.getBlue(), "LCT001");
            lightState.setX(xy[0]);
            lightState.setY(xy[1]);
             
            phHueSDK.getSelectedBridge().updateLightState(lightIdentifer, lightState, null);  // null is passed here as we are not interested in the response from the Bridge. 
            
        }
    }
}
 
开发者ID:carstena,项目名称:game-to-philips-hue,代码行数:21,代码来源:LightColoursFrame.java

示例6: showRandomColorsOnAllLamps

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void showRandomColorsOnAllLamps() {
	for (PHBridge bridge : bridges) {
		PHBridgeResourcesCache resourceCache = bridge.getResourceCache();
		List<PHLight> allLights = resourceCache.getAllLights();
		Random rand = new Random();
		for (PHLight light : allLights) {
			PHLightState lightState = new PHLightState();
			lightState.setBrightness(HueConstants.MAX_BRI);
			lightState.setSaturation(HueConstants.MAX_SAT);
			lightState.setHue(rand.nextInt(HueConstants.MAX_HUE + 1));
			bridge.updateLightState(light, lightState);
		}
	}
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:16,代码来源:HueServiceImpl.java

示例7: setBrightness

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public void setBrightness(String name, int brightness) throws IOException
{
	PHLight light = this.lights.get(name);
	if (light == null)
		throw new IOException("No such light: " + name);
	PHLightState lightState = new PHLightState();
	lightState.setOn(brightness > 0);
	lightState.setBrightness(brightness, true);
	this.activeBridge.updateLightState(light, lightState);
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:11,代码来源:IntegrationPhilipsHue.java

示例8: onBridgeConnected

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void onBridgeConnected(PHBridge phBridge, String s) {
  Log.d("HUE", "Bridge Connected...");

  hueSDK.setSelectedBridge(phBridge);
  hueSDK.enableHeartbeat(phBridge, PHHueSDK.HB_INTERVAL);
  hueSDK.getLastHeartbeat()
      .put(phBridge.getResourceCache().getBridgeConfiguration().getIpAddress(),
          System.currentTimeMillis());

  setLastConnectIp(phBridge.getResourceCache().getBridgeConfiguration().getIpAddress());
  setUsername(s);

  allLights = phBridge.getResourceCache().getAllLights();

  for (PHLight light : allLights) {
    PHLightState lightState = light.getLastKnownLightState();

    Log.d("HUE",
        "id = " + light.getIdentifier() + " " + light.getModelNumber() + " " + light.getUniqueId()
            + " " + lightState.getBrightness() + " " + lightState.getSaturation());
    Log.d("HUE", "type = " + light.getLightType().name() + " " + light.getLightType().ordinal());
  }

  closeProgressDialog();

  turnOn();
}
 
开发者ID:tkrworks,项目名称:JinsMemeBRIDGE-Android,代码行数:29,代码来源:HueController.java

示例9: setColor

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public boolean setColor(PHLight light, int color) {
    if (bridge == null) {
        return false;
    }

    float[] xy = PHUtilities.calculateXYFromRGB(Color.red(color), Color.green(color), Color.blue(color), light.getModelNumber());
    PHLightState state = new PHLightState();
    state.setX(xy[0]);
    state.setY(xy[1]);
    state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
    state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
    bridge.updateLightState(light, state);
    return true;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:15,代码来源:HueAdapter.java

示例10: setBrightness

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public boolean setBrightness(PHLight light, int brightness) {
    if (bridge == null) {
        return false;
    }

    PHLightState state = new PHLightState();
    state.setBrightness(brightness);
    state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
    state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
    bridge.updateLightState(light, state);
    return true;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:13,代码来源:HueAdapter.java

示例11: setPower

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public boolean setPower(PHLight light, boolean power) {
    if (bridge == null) {
        return false;
    }

    PHLightState state = new PHLightState();
    state.setOn(power);
    state.setEffectMode(PHLight.PHLightEffectMode.EFFECT_NONE);
    state.setAlertMode(PHLight.PHLightAlertMode.ALERT_NONE);
    bridge.updateLightState(light, state);
    return true;
}
 
开发者ID:ConnectSDK,项目名称:SmartHomeSamplerAndroid,代码行数:13,代码来源:HueAdapter.java

示例12: randomLights

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
public void randomLights() {
    PHBridge bridge = phHueSDK.getSelectedBridge();
    PHBridgeResourcesCache cache = bridge.getResourceCache();

    List<PHLight> allLights = cache.getAllLights();
    Random rand = new Random();

    for (PHLight light : allLights) {
        PHLightState lightState = new PHLightState();
        lightState.setHue(rand.nextInt(MAX_HUE));
        bridge.updateLightState(light, lightState); // If no bridge response is required then use this simpler form.
    }
}
 
开发者ID:carstena,项目名称:game-to-philips-hue,代码行数:14,代码来源:Controller.java

示例13: on

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void on()
{
	// turns the lamp on

	// get the bridge object (asks it to the network driver to get the most
	// updated version) TODO: check if the received reference is kept up to
	// date
	PHBridge bridge = this.gateway.getBridge();

	// check not null
	if (bridge != null)
	{
		// not already on
		// get the light
		PHLight light = bridge.getResourceCache().getLights()
				.get(this.localId);

		// get the latest light state
		PHLightState lightState = light.getLastKnownLightState();

		// check current state
		if (!lightState.isOn())
		{
			// create a new state object
			PHLightState newLightState = new PHLightState();

			// set the state at on
			newLightState.setOn(true);

			// updated the state on the real device
			bridge.updateLightState(light, newLightState);
		}
	}

}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:37,代码来源:HueColorDimmableLightDriverInstance.java

示例14: off

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void off()
{
	// turns the lamp off

	// get the bridge object (asks it to the network driver to get the most
	// updated version) TODO: check if the received reference is kept up to
	// date
	PHBridge bridge = this.gateway.getBridge();

	// check not null
	if (bridge != null)
	{
		// not already on
		// get the light
		PHLight light = bridge.getResourceCache().getLights()
				.get(this.localId);

		// get the latest light state
		PHLightState lightState = light.getLastKnownLightState();

		// check current state
		if (lightState.isOn())
		{
			// create a new state object
			PHLightState newLightState = new PHLightState();

			// set the state at on
			newLightState.setOn(false);

			// updated the state on the real device
			bridge.updateLightState(light, newLightState);
		}
	}

}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:37,代码来源:HueColorDimmableLightDriverInstance.java

示例15: setColorHSB

import com.philips.lighting.model.PHLightState; //导入依赖的package包/类
@Override
public void setColorHSB(HSBColor colorHSB)
{
	// get the bridge object (asks it to the network driver to get the most
	// updated version) TODO: check if the received reference is kept up to
	// date
	PHBridge bridge = this.gateway.getBridge();

	// check not null
	if (bridge != null)
	{

		// get the light
		PHLight light = bridge.getResourceCache().getLights()
				.get(this.localId);

		// prepare the new lamp state
		PHLightState newLightState = new PHLightState();

		// update hue and saturation
		newLightState.setHue(colorHSB.getHue());
		newLightState.setSaturation(colorHSB.getSaturation());
		newLightState.setBrightness(colorHSB.getBrightness());

		// update the real device
		bridge.updateLightState(light, newLightState);

		// notify...

		// update the status
		this.updateStatus();

	}
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:35,代码来源:HueColorDimmableLightDriverInstance.java


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