Skip to content

Commit

Permalink
Taking into account MR comments: do not apply offet on no speed anima…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Thomas ADAM <tadam@silicom.fr>
  • Loading branch information
tadam50 committed Mar 23, 2023
1 parent 7d86081 commit 7a4087b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AnimatedFeederInfoStyleProvider extends TopologicalStyleProvider {

private static final String ARROW_SPEED = "speed";

private static final String ARROW_ANIMATION_NO_SPEED = ARROW_ANIMATION + "-no-" + ARROW_SPEED;

private static final String ARROW_ANIMATION_LOW_SPEED = ARROW_ANIMATION + "-low-" + ARROW_SPEED;

private static final String ARROW_ANIMATION_AVERAGE_SPEED = ARROW_ANIMATION + "-average-" + ARROW_SPEED;
Expand All @@ -45,17 +47,21 @@ public List<String> getFeederInfoStyles(FeederInfo info) {
if (info instanceof DirectionalFeederInfo) {
DirectionalFeederInfo feederInfo = (DirectionalFeederInfo) info;
feederInfo.getRightLabel().ifPresent(label -> {
double power = feederInfo.getValue();
if (!Double.isNaN(power) && Math.abs(power) > 0) {
if (Math.abs(power) > threshold2) {
double value = Math.abs(feederInfo.getValue());
if (!Double.isNaN(value) && value > 0) {
if (value > threshold2) {
styles.add(ARROW_ANIMATION_HIGH_SPEED);
} else if (Math.abs(power) > threshold1) {
} else if (value > threshold1) {
styles.add(ARROW_ANIMATION_AVERAGE_SPEED);
} else {
styles.add(ARROW_ANIMATION_LOW_SPEED);
}
} else {
styles.add(ARROW_ANIMATION_NO_SPEED);
}
});
} else {
styles.add(ARROW_ANIMATION_NO_SPEED);
}
return styles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,32 @@
/* feeder info */
.sld-cell-direction-top .sld-arrow-in {
offset-rotate: 0deg;
offset-path: path('M 0,-10 0,10');
animation: move var(--sld-arrow-animation-duration, 0s) linear infinite;
offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10'));
animation: move var(--sld-arrow-animation-parameters, 0s);
}
.sld-cell-direction-top .sld-arrow-out {
offset-rotate: 0deg;
offset-path: path('M 0,10 0,-10');
animation: move var(--sld-arrow-animation-duration, 0s) linear infinite;
offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10'));
animation: move var(--sld-arrow-animation-parameters, 0s);
}
.sld-cell-direction-bottom .sld-arrow-in {
offset-rotate: 0deg;
offset-path: path('M 0,10 0,-10');
animation: move var(--sld-arrow-animation-duration, 0s) linear infinite;
offset-path: var(--sld-arrow-offset-path, path('M 0,10 0,-10'));
animation: move var(--sld-arrow-animation-parameters, 0s);
}
.sld-cell-direction-bottom .sld-arrow-out {
offset-rotate: 0deg;
offset-path: path('M 0,-10 0,10');
animation: move var(--sld-arrow-animation-duration, 0s) linear infinite;
offset-path: var(--sld-arrow-offset-path, path('M 0,-10 0,10'));
animation: move var(--sld-arrow-animation-parameters, 0s);
}
@keyframes move {
to {
offset-distance: 100%;
}
}
/* Set arrows animation speed (1: the slowest -> 3: the fastest) */
.sld-arrow-animation-low-speed { --sld-arrow-animation-duration: 3s }
.sld-arrow-animation-average-speed { --sld-arrow-animation-duration: 2s }
.sld-arrow-animation-high-speed { --sld-arrow-animation-duration: 1s }

/* Set arrows animation speeds */
.sld-arrow-animation-low-speed { --sld-arrow-animation-parameters: 3s infinite linear }
.sld-arrow-animation-average-speed { --sld-arrow-animation-parameters: 2s infinite linear }
.sld-arrow-animation-high-speed { --sld-arrow-animation-parameters: 1s infinite linear }
.sld-arrow-animation-no-speed { --sld-arrow-offset-path: path('') }
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,29 @@ public List<FeederInfo> getFeederInfos(FeederNode node) {
} else {
return Arrays.asList(
new DirectionalFeederInfo(ARROW_ACTIVE, l2.getTerminal().getP(), valueFormatter::formatPower, null),
new DirectionalFeederInfo(ARROW_REACTIVE, l2.getTerminal().getQ(), valueFormatter::formatPower, null));
new DirectionalFeederInfo(ARROW_REACTIVE, l2.getTerminal().getQ(), valueFormatter::formatPower, null),
new DirectionalFeederInfo(ARROW_REACTIVE, Double.NaN, valueFormatter::formatPower, null),
new FeederInfo() {
@Override
public String getUserDefinedId() {
return null;
}

@Override
public String getComponentType() {
return ARROW_ACTIVE;
}

@Override
public Optional<String> getLeftLabel() {
return Optional.of("Left");
}

@Override
public Optional<String> getRightLabel() {
return Optional.of("Right");
}
});
}
}
};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7a4087b

Please sign in to comment.