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


Java PHLightState.setOn方法代码示例

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


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

示例6: 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

示例7: 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

示例8: 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

示例9: stepDown

import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void stepDown()
{
	// decrease luminosity by one step

	// 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);

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

		// create a new light state
		PHLightState newLightState = new PHLightState();

		// get the brightness
		int brightness = lightState.getBrightness();

		// decrease the brightness by step percentage, if less than 0 turn
		// the
		// lamp off
		brightness = (int) (brightness - (HueInfo.MAX_BRIGHTNESS
				* (double) this.stepPercentage / 100.0));

		if (brightness <= 0)
		{
			// turn off the lamp
			newLightState.setOn(false);

			// set brightness at zer
			brightness = 0;
		}

		// set the new light state
		newLightState.setBrightness(brightness);

		// set the new brightness
		bridge.updateLightState(light, newLightState);

		// notify level change
		this.notifyChangedLevel(DecimalMeasure
				.valueOf(brightness, Unit.ONE));

		// update the status
		this.updateStatus();
	}
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:57,代码来源:HueColorDimmableLightDriverInstance.java

示例10: stepUp

import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Override
public void stepUp()
{
	// increase luminosity by one step

	// 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);

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

		// create a new light state
		PHLightState newLightState = new PHLightState();

		// get the brightness
		int brightness = lightState.getBrightness();

		// decrease the brightness by step percentage, if less than 0 turn
		// the
		// lamp off
		brightness = (int) (brightness + (HueInfo.MAX_BRIGHTNESS
				* (double) this.stepPercentage / 100.0));

		if (!lightState.isOn())
			// turn off the lamp
			newLightState.setOn(true);

		if (brightness >= 0)
		{
			if (brightness >= HueInfo.MAX_BRIGHTNESS)
				// set brightness at 255
				brightness = HueInfo.MAX_BRIGHTNESS;
		}

		// set the new light state
		newLightState.setBrightness(brightness);

		// set the new brightness
		bridge.updateLightState(light, newLightState);

		// notify level change
		this.notifyChangedLevel(DecimalMeasure
				.valueOf(brightness, Unit.ONE));

		this.updateStatus();
	}
}
 
开发者ID:dog-gateway,项目名称:hue-drivers,代码行数:58,代码来源:HueColorDimmableLightDriverInstance.java

示例11: setLampState

import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
private void setLampState(String... parameters) {

        String valueStr = getArgumentValue("-on", parameters);
        String nameStr = getArgumentValue("-name", parameters);
        String ttStr = getArgumentValue("-tt", parameters);
        String iStr = getArgumentValue("-i", parameters);
        String rStr = getArgumentValue("-r", parameters);
        String gStr = getArgumentValue("-g", parameters);
        String bStr = getArgumentValue("-b", parameters);

        Boolean value = Boolean.valueOf(valueStr);

        for (PHLight light : bridge.getResourceCache().getAllLights()) {
            if (nameStr == null || nameStr.equals(light.getName())) {
                PHLightState lightState = new PHLightState();

                if (value != null) {
                    lightState.setOn(value);
                }

                if (ttStr != null) {
                    print("transition time:" + ttStr);
                    lightState.setTransitionTime(Integer.parseInt(ttStr));
                }

                if (iStr != null) {
                    print("brightness:" + iStr);
                    lightState.setBrightness(Integer.parseInt(iStr));
                }

                if (rStr != null || gStr != null || bStr != null) {

                    int r = getColorValue(rStr);
                    int g = getColorValue(gStr);
                    int b = getColorValue(bStr);

                    print(String.format("color red:%s green:%s blue:%s", r, g, b));

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

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

                }
                bridge.updateLightState(light, lightState);
            }
        }
    }
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:49,代码来源:PhilipsHueGogoCommand.java

示例12: start

import com.philips.lighting.model.PHLightState; //导入方法依赖的package包/类
@Validate
public void start() {

    active = true;


    Thread t1 = new Thread() {

        public void run() {
            boolean state = false;
            while (active) {
                System.out.println("philips client just started, lights :" + lights.size());

                PHBridgeResourcesCache cache = bridge.getResourceCache();

                for (PHLight light : lights) {

                    PHLightState lightState = new PHLightState();

                    lightState.setOn(!light.getLastKnownLightState().isOn());

                    bridge.updateLightState(light, lightState);
                }

                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    //Dont care
                }
            }

        }

    };
    t1.setDaemon(true);
    t1.start();


}
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:40,代码来源:PhilipsHueExampleBlink.java


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