Hi,
I know showing range of the trend visualization can be controlled with the date range picker and the time range picker.
Is there any way to control the range of the trend graph through variables? (like with start/end DATE_AND_TIME vars)
I want to change the range with date/time picker to show historical data.
Best regards,
π
3
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I guess the range can be managed using VisuElemsDateTime_Interfaces.IDateRangeSelectorClient.SetCurrentRange() method.
But I have no idea how to get the instance of the Trend element.
Does anyone know any way to get the instance by element ID, name or something?
π
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is my code to change showing date using Date/Time Picker element.
You can improve above as you like, for example, to listen event from Date Range Picker, to filter the event source element, or to specify one from multiple trend elements.
Call VisuElems.g_itfValueChangedListenerManager.AddValueChangedListener() to enable the listener.
Please tell me if you know any better or more simple way.
π
2
Last edit: ryusoup 2023-05-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been able to implement it (I modified it from Date to DT as I wish to be able to select the start date and time) except for the part where the pbNewValue is cast into the pDate (pDT in my case) and dereferenced.
I seem to only get the element in the DT that has changed (so pbNewValue is a pointer to the byte which has changed, if I set the minutes to 45 in the Date/Time Picker I get 45 as the pbNewValue).
I have had success with having the Date/Time Picker writing out to a global DT variable and changing the dTemp := pDate^ line to dTemp := GVL.StartDateTime. I know this is not good practice referencing global variables from a method like this but cannot work out how the changed DT variable can be referenced from the input parameters to the method.
You firstly tried as followings but it doesn't work, right?
pDT := pbNewValue;dTemp := pDT^;
It worked in my case.
CODESYS 3.5.17.30 and CODESYS Visualization 4.2.0.0 is my environment.
Actually, a date time picker element calls the event handler for several times while changing operation, but it triggers the event
with desired value on the last call. Doesn't it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your issue seems to be the same as mine: the display range does not exceed the recording trend range.
This appears to be a limitation of the current method...
In my case, I verified the date range in the trend storage and compared it with the 'timestampfrom' and 'timestampto'. If the requested range falls outside the recorded data, I activated a message to notify the user.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you guys possibly send a sample code or some snips to help with this?
I am either barking up the wrong tree expecting a different result here or I am missing something that this simple mind can't work out, but I cannot get this to work at all.
Everything you have shown and all else I believe is needed is there, but changing dates/times changes nothing...
π
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I know showing range of the trend visualization can be controlled with the date range picker and the time range picker.
Is there any way to control the range of the trend graph through variables? (like with start/end DATE_AND_TIME vars)
I want to change the range with date/time picker to show historical data.
Best regards,
more posts ...
I guess the range can be managed using VisuElemsDateTime_Interfaces.IDateRangeSelectorClient.SetCurrentRange() method.
But I have no idea how to get the instance of the Trend element.
Does anyone know any way to get the instance by element ID, name or something?
I too wish to know a way to do this. There is frustratingly no information on setting sane defaults for the date/time range.
I also would love a solution to this. The date range picker is ugly!
It would be great to be able to input a date range through a text field instead.
I resolved it myself.
To achieve this, create a FB which implements VisuElems.IValueChangedListener and Implement the method "ValueChanged".
This is my code to change showing date using Date/Time Picker element.
You can improve above as you like, for example, to listen event from Date Range Picker, to filter the event source element, or to specify one from multiple trend elements.
Call VisuElems.g_itfValueChangedListenerManager.AddValueChangedListener() to enable the listener.
Please tell me if you know any better or more simple way.
Last edit: ryusoup 2023-05-30
This is excellent. Thank you.
I have been able to implement it (I modified it from Date to DT as I wish to be able to select the start date and time) except for the part where the pbNewValue is cast into the pDate (pDT in my case) and dereferenced.
I seem to only get the element in the DT that has changed (so pbNewValue is a pointer to the byte which has changed, if I set the minutes to 45 in the Date/Time Picker I get 45 as the pbNewValue).
I have had success with having the Date/Time Picker writing out to a global DT variable and changing the dTemp := pDate^ line to dTemp := GVL.StartDateTime. I know this is not good practice referencing global variables from a method like this but cannot work out how the changed DT variable can be referenced from the input parameters to the method.
You firstly tried as followings but it doesn't work, right?
It worked in my case.
CODESYS 3.5.17.30 and CODESYS Visualization 4.2.0.0 is my environment.
Actually, a date time picker element calls the event handler for several times while changing operation, but it triggers the event
with desired value on the last call. Doesn't it?
Yes the element seems to call the handler a number of times but it seems to work fine (when I use a global variable for the DT).
Yes still no luck for me. The event is called and the trend updates but it just shows the last X minutes rather than from what I select in the picker.
I'm currently using CODESYS Control Win 3 x64 3.5.18.40 and CODESYS Visualisation 4.3.0.0 although my project/development environment is 3.5.19
My complete method is below along with some screenshots:
Your issue seems to be the same as mine: the display range does not exceed the recording trend range.
This appears to be a limitation of the current method...
In my case, I verified the date range in the trend storage and compared it with the 'timestampfrom' and 'timestampto'. If the requested range falls outside the recorded data, I activated a message to notify the user.
Hi Guru's,
Could you guys possibly send a sample code or some snips to help with this?
I am either barking up the wrong tree expecting a different result here or I am missing something that this simple mind can't work out, but I cannot get this to work at all.
Everything you have shown and all else I believe is needed is there, but changing dates/times changes nothing...
Hi ryusoup,
looking for the same functionality.
I tried to use your code but couldn't figure out all the details.
I tried to make it simpler, just force the uiYear/uiMonth etc. but couldn't make it work.
Could you please share some details how the whole struckture looks like?
Would be great if you share an example
UPD: found the issue. Your code works. Thanks for the posts
Last edit: ignat 2024-01-17