本文整理汇总了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);
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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.
}
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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.
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}