Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define a time interval for StripChart #2334

Closed
L-Roussel opened this issue Jul 22, 2022 · 4 comments
Closed

define a time interval for StripChart #2334

L-Roussel opened this issue Jul 22, 2022 · 4 comments

Comments

@L-Roussel
Copy link
Contributor

Hi,

I work on a stripchart widget and I want to display values over a time Interval, defined by two Timestamp, using a script.
Is it currently possible?

Maybe the time_range property value should be a TimeRelativeInterval instead of a String ?

@kasemir
Copy link
Collaborator

kasemir commented Jul 22, 2022

I want to ... use a script

See general script caveats in for example the https://controlssoftware.sns.ornl.gov/training/2022_USPAS/ display builder intro. In short, if you have to ask how to do a script, you'll likely have problems maintaining it as well, but here it is:

from org.csstudio.display.builder.representation.javafx.widgets import JFXBaseRepresentation
from java.time import Instant
from java.time.temporal import ChronoUnit

plot = JFXBaseRepresentation.getJFXNode(widget)
# You'll find that it's an RTTimePlot
print(plot.__class__.__name__)
# .. with a time range
print(plot.getXAxis().getValueRange())
start = Instant.now().minus(3, ChronoUnit.HOURS)
end = Instant.now().minus(1, ChronoUnit.HOURS)
plot.getXAxis().setValueRange(start, end)

@L-Roussel
Copy link
Contributor Author

It's not exactly what I've wanted to say, i'm sorry.
That script will not work for me here, It will just use the time_range value.
I think it's because in the same script and some others, I need to change other properties in the stripchart that trigger the function updateModel() in the StripchartRepresentation,
and these two lines are called :

final TemporalAmount rel_start = TimeParser.parseTemporalAmount(model_widget.propTimeRange().getValue());
model.setTimerange(TimeRelativeInterval.startsAt(rel_start));

erasing the old time range value.
That's why I'm talking about modifying the time_range property type, but maybe it'll cause problem as well.

@kasemir
Copy link
Collaborator

kasemir commented Jul 22, 2022

Well, then you'll have to update the handling of the "time_range" property.
For example, create a new "start" and "end" property that's parsed like the start and end of the data browser.
Remove the "time_range" property, increment the version number of the stripchart widget and have it translate the "time_range" property from older version files into the new "start" and "end" properties.

L-Roussel added a commit to L-Roussel/phoebus that referenced this issue Jul 26, 2022
kasemir added a commit that referenced this issue Jul 26, 2022
Issue #2334, 'start' and 'end' replace 'time_range' on Stripchart
@kasemir
Copy link
Collaborator

kasemir commented Jul 26, 2022

Looks like you fixed this with #2338

Thanks!

@kasemir kasemir closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants