[hdpowerview] Change method names to match documentation (#12796)
* [hdpowerview] refactor method names Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
committed by
GitHub
parent
39d7abc824
commit
308bb3013a
@@ -101,7 +101,7 @@ public class ShadePosition {
|
|||||||
* Secondary, upper rail of a dual action shade: => NOT INVERTED
|
* Secondary, upper rail of a dual action shade: => NOT INVERTED
|
||||||
*/
|
*/
|
||||||
posKind1 = posKindCoords.ordinal();
|
posKind1 = posKindCoords.ordinal();
|
||||||
if (shadeCapabilities.supportsBlackoutShade()) {
|
if (shadeCapabilities.supportsSecondaryOverlapped()) {
|
||||||
position1 = MAX_SHADE - (int) Math.round((double) percent / 100 * MAX_SHADE);
|
position1 = MAX_SHADE - (int) Math.round((double) percent / 100 * MAX_SHADE);
|
||||||
} else {
|
} else {
|
||||||
position1 = (int) Math.round((double) percent / 100 * MAX_SHADE);
|
position1 = (int) Math.round((double) percent / 100 * MAX_SHADE);
|
||||||
@@ -142,7 +142,7 @@ public class ShadePosition {
|
|||||||
if (VANE_TILT_POSITION.equals(posKind1) && shadeCapabilities.supportsTiltOnClosed()) {
|
if (VANE_TILT_POSITION.equals(posKind1) && shadeCapabilities.supportsTiltOnClosed()) {
|
||||||
return PercentType.HUNDRED;
|
return PercentType.HUNDRED;
|
||||||
}
|
}
|
||||||
if (SECONDARY_POSITION.equals(posKind1) && shadeCapabilities.supportsBlackoutShade()) {
|
if (SECONDARY_POSITION.equals(posKind1) && shadeCapabilities.supportsSecondaryOverlapped()) {
|
||||||
return PercentType.HUNDRED;
|
return PercentType.HUNDRED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -153,12 +153,12 @@ public class ShadePosition {
|
|||||||
* Secondary, upper rail of a dual action shade: => NOT INVERTED
|
* Secondary, upper rail of a dual action shade: => NOT INVERTED
|
||||||
*/
|
*/
|
||||||
if (posKindCoords.equals(posKind1)) {
|
if (posKindCoords.equals(posKind1)) {
|
||||||
if (shadeCapabilities.supportsBlackoutShade()) {
|
if (shadeCapabilities.supportsSecondaryOverlapped()) {
|
||||||
return new PercentType(100 - (int) Math.round((double) position1 / MAX_SHADE * 100));
|
return new PercentType(100 - (int) Math.round((double) position1 / MAX_SHADE * 100));
|
||||||
}
|
}
|
||||||
return new PercentType((int) Math.round((double) position1 / MAX_SHADE * 100));
|
return new PercentType((int) Math.round((double) position1 / MAX_SHADE * 100));
|
||||||
}
|
}
|
||||||
if (PRIMARY_POSITION.equals(posKind1) && shadeCapabilities.supportsBlackoutShade()) {
|
if (PRIMARY_POSITION.equals(posKind1) && shadeCapabilities.supportsSecondaryOverlapped()) {
|
||||||
return PercentType.ZERO;
|
return PercentType.ZERO;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -351,7 +351,7 @@ public class ShadePosition {
|
|||||||
} else {
|
} else {
|
||||||
setPosition1(shadeCapabilities, posKindCoords, percent);
|
setPosition1(shadeCapabilities, posKindCoords, percent);
|
||||||
}
|
}
|
||||||
} else if (shadeCapabilities.supportsBlackoutShade()) {
|
} else if (shadeCapabilities.supportsSecondaryOverlapped()) {
|
||||||
setPosition1(shadeCapabilities, posKindCoords, percent);
|
setPosition1(shadeCapabilities, posKindCoords, percent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -40,16 +40,16 @@ public class ShadeCapabilitiesDatabase {
|
|||||||
*/
|
*/
|
||||||
private static final Map<Integer, Capabilities> CAPABILITIES_DATABASE = Arrays.asList(
|
private static final Map<Integer, Capabilities> CAPABILITIES_DATABASE = Arrays.asList(
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
new Capabilities(0).primary().tiltOnClosed() .text("Bottom Up"),
|
new Capabilities(0).primary() .tiltOnClosed() .text("Bottom Up"),
|
||||||
new Capabilities(1).primary().tiltOnClosed() .text("Bottom Up Tilt 90°"),
|
new Capabilities(1).primary() .tiltOnClosed() .text("Bottom Up Tilt 90°"),
|
||||||
new Capabilities(2).primary().tiltAnywhere().tilt180() .text("Bottom Up Tilt 180°"),
|
new Capabilities(2).primary() .tiltAnywhere().tilt180() .text("Bottom Up Tilt 180°"),
|
||||||
new Capabilities(3).primary().tiltOnClosed() .text("Vertical"),
|
new Capabilities(3).primary() .tiltOnClosed() .text("Vertical"),
|
||||||
new Capabilities(4).primary().tiltAnywhere().tilt180() .text("Vertical Tilt 180°"),
|
new Capabilities(4).primary() .tiltAnywhere().tilt180() .text("Vertical Tilt 180°"),
|
||||||
new Capabilities(5) .tiltAnywhere().tilt180() .text("Tilt Only 180°"),
|
new Capabilities(5) .tiltAnywhere().tilt180() .text("Tilt Only 180°"),
|
||||||
new Capabilities(6).primary() .text("Top Down") .primaryStateInverted(),
|
new Capabilities(6).primaryInverted() .text("Top Down"),
|
||||||
new Capabilities(7).primary() .secondary().text("Top Down Bottom Up"),
|
new Capabilities(7).primary() .secondary() .text("Top Down Bottom Up"),
|
||||||
new Capabilities(8).primary() .text("Duolite Lift") .withBlackoutShade(),
|
new Capabilities(8).primary() .secondaryOverlapped().text("Duolite Lift"),
|
||||||
new Capabilities(9).primary().tiltAnywhere() .text("Duolite Lift and Tilt 90°").withBlackoutShade(),
|
new Capabilities(9).primary() .tiltAnywhere() .secondaryOverlapped().text("Duolite Lift and Tilt 90°"),
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
new Capabilities()).stream().collect(Collectors.toMap(Capabilities::getValue, Function.identity()));
|
new Capabilities()).stream().collect(Collectors.toMap(Capabilities::getValue, Function.identity()));
|
||||||
|
|
||||||
@@ -149,15 +149,15 @@ public class ShadeCapabilitiesDatabase {
|
|||||||
private boolean supportsSecondary;
|
private boolean supportsSecondary;
|
||||||
private boolean supportsTiltOnClosed;
|
private boolean supportsTiltOnClosed;
|
||||||
private boolean supportsTiltAnywhere;
|
private boolean supportsTiltAnywhere;
|
||||||
private boolean supportsBlackoutShade;
|
private boolean supportsSecondaryOverlapped;
|
||||||
private boolean primaryStateInverted;
|
private boolean primaryInverted;
|
||||||
private boolean tilt180Degrees;
|
private boolean tilt180Degrees;
|
||||||
|
|
||||||
public Capabilities() {
|
public Capabilities() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Capabilities withBlackoutShade() {
|
protected Capabilities secondaryOverlapped() {
|
||||||
supportsBlackoutShade = true;
|
supportsSecondaryOverlapped = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,8 +190,9 @@ public class ShadeCapabilitiesDatabase {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Capabilities primaryStateInverted() {
|
protected Capabilities primaryInverted() {
|
||||||
primaryStateInverted = true;
|
supportsPrimary = true;
|
||||||
|
primaryInverted = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,21 +229,21 @@ public class ShadeCapabilitiesDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the Capabilities class instance supports a secondary shade.
|
* Check if the Capabilities class instance if the primary shade is inverted.
|
||||||
*
|
*
|
||||||
* @return true if the primary shade is inverted.
|
* @return true if the primary shade is inverted.
|
||||||
*/
|
*/
|
||||||
public boolean isPrimaryStateInverted() {
|
public boolean isPrimaryInverted() {
|
||||||
return primaryStateInverted;
|
return primaryInverted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the Capabilities class instance supports 'tilt when closed'.
|
* Check if the Capabilities class instance supports 'tilt on closed'.
|
||||||
*
|
*
|
||||||
* Note: Simple bottom up or vertical shades that do not have independent vane controls, can be tilted in a
|
* Note: Simple bottom up or vertical shades that do not have independent vane controls, can be tilted in a
|
||||||
* simple way, only when they are fully closed, by moving the shade motor a bit further.
|
* simple way, only when they are fully closed, by moving the shade motor a bit further.
|
||||||
*
|
*
|
||||||
* @return true if the primary shade is inverted.
|
* @return true if the it supports tilt on closed.
|
||||||
*/
|
*/
|
||||||
public boolean supportsTiltOnClosed() {
|
public boolean supportsTiltOnClosed() {
|
||||||
return supportsTiltOnClosed && !supportsTiltAnywhere;
|
return supportsTiltOnClosed && !supportsTiltAnywhere;
|
||||||
@@ -251,19 +252,20 @@ public class ShadeCapabilitiesDatabase {
|
|||||||
/**
|
/**
|
||||||
* Check if the Capabilities class instance supports 180 degrees tilt.
|
* Check if the Capabilities class instance supports 180 degrees tilt.
|
||||||
*
|
*
|
||||||
* @return true if the primary shade supports 180 degrees.
|
* @return true if the tilt range is 180 degrees.
|
||||||
*/
|
*/
|
||||||
public boolean supportsTilt180() {
|
public boolean supportsTilt180() {
|
||||||
return tilt180Degrees;
|
return tilt180Degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the Capabilities class instance supports a secondary 'DuoLite' blackout shade.
|
* Check if the Capabilities class instance supports an overlapped secondary shade.
|
||||||
|
* e.g. a 'DuoLite' or blackout shade.
|
||||||
*
|
*
|
||||||
* @return true if the primary shade supports a secondary blackout shade.
|
* @return true if the shade supports a secondary overlapped shade.
|
||||||
*/
|
*/
|
||||||
public boolean supportsBlackoutShade() {
|
public boolean supportsSecondaryOverlapped() {
|
||||||
return supportsBlackoutShade;
|
return supportsSecondaryOverlapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public class ShadePositionTest {
|
|||||||
assertTrue(db.getCapabilities(4).supportsTilt180());
|
assertTrue(db.getCapabilities(4).supportsTilt180());
|
||||||
assertTrue(db.getCapabilities(5).supportsTilt180());
|
assertTrue(db.getCapabilities(5).supportsTilt180());
|
||||||
assertFalse(db.getCapabilities(5).supportsPrimary());
|
assertFalse(db.getCapabilities(5).supportsPrimary());
|
||||||
assertTrue(db.getCapabilities(6).isPrimaryStateInverted());
|
assertTrue(db.getCapabilities(6).isPrimaryInverted());
|
||||||
assertTrue(db.getCapabilities(7).supportsSecondary());
|
assertTrue(db.getCapabilities(7).supportsSecondary());
|
||||||
assertTrue(db.getCapabilities(8).supportsBlackoutShade());
|
assertTrue(db.getCapabilities(8).supportsSecondaryOverlapped());
|
||||||
assertTrue(db.getCapabilities(9).supportsBlackoutShade());
|
assertTrue(db.getCapabilities(9).supportsSecondaryOverlapped());
|
||||||
|
|
||||||
assertEquals(db.getType(4).getCapabilities(), 0);
|
assertEquals(db.getType(4).getCapabilities(), 0);
|
||||||
assertEquals(db.getType(-1).getCapabilities(), -1);
|
assertEquals(db.getType(-1).getCapabilities(), -1);
|
||||||
@@ -61,9 +61,9 @@ public class ShadePositionTest {
|
|||||||
assertFalse(db.isTypeInDatabase(99));
|
assertFalse(db.isTypeInDatabase(99));
|
||||||
assertFalse(db.isCapabilitiesInDatabase(99));
|
assertFalse(db.isCapabilitiesInDatabase(99));
|
||||||
|
|
||||||
assertFalse(db.getCapabilities(0).isPrimaryStateInverted());
|
assertFalse(db.getCapabilities(0).isPrimaryInverted());
|
||||||
assertFalse(db.getCapabilities(-1).isPrimaryStateInverted());
|
assertFalse(db.getCapabilities(-1).isPrimaryInverted());
|
||||||
assertFalse(db.getCapabilities(99).isPrimaryStateInverted());
|
assertFalse(db.getCapabilities(99).isPrimaryInverted());
|
||||||
|
|
||||||
assertFalse(db.getCapabilities(0).supportsSecondary());
|
assertFalse(db.getCapabilities(0).supportsSecondary());
|
||||||
assertFalse(db.getCapabilities(-1).supportsSecondary());
|
assertFalse(db.getCapabilities(-1).supportsSecondary());
|
||||||
|
|||||||
Reference in New Issue
Block a user