Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel

[Imported] Dynamic User Time Duration Input

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

Janeway Janeway

[Imported] Dynamic User Time Duration Input

>>Message imported from previous forum - Category:Scripts and Tips<<
User: admin, originally posted: 2018-10-19 19:37:43 Id:159
This is a re-posting from the obsoleted (October 2018) "Schneider Electric Telemetry & SCADA" forum.


Hi everyone. Looking for some help if possible. I have a ST program which generates a future time from current time using the following:_**

_Futuretime := ADD_DT_TIME(NOW(),T#15m)_

**_The T#15m is hard coded as you know. Is there any way I can create a way for a end user to input a time value in hours or minutes and then have it referenced within the calculation above without having to hard code the script 'T#15m' each time?? Thank you all in advance._**


You can use a variable, constant variable, or a internal point to hold the numeric value, Variables and Internal points are easy to write to. Internal points you can keep history on, but they do count against the point count, Variables are not points so they don't count. Constant Variables hold the value in a configuration property so you cannot just write to it using a method, you have to write a script on a graphic to set the property. The plus side, for me anyway, of a constant variable is you can preset the value in your template, and when you copy or do an export the value is retained.
I have used all three depending on the overall need.

I did this using a Constant Variable to set variables on a timer.
Here is the relevant ST:

_CPA_Concat_ENO : BOOL := FALSE;
CPA_String : STRING[255];
CPA_Time : TIME;
CPADelay AT %M(.CPA Delay.ConstantValue) : INT; (*Time SETTING in seconds*)
CPA_String := CONCAT( IN1 := 'T#',IN2 := INT_TO_STRING(SUB(IN1:= CPADelay, IN2:= 10)), IN3 := 's', ENO = CPA_Concat_ENO );

I have not used this with the ADD_DT_Time but I think that will be:

_Futuretime := ADD_DT_TIME(NOW(),CPA_Time)_

This was the script on my mimic:

_Function CPADelaySec
Dim frmEditBox, frmOKButton, frmCancelButton
Form.Init "Set Control Power Alarm Delay"
Form.AddStaticText 2,1, "Control Power ''Alarm Delay'' Setting"
Set frmEditBox = Form.AddEditBox(2,3,10,1)
frmEditBox.MaxLength = 10
frmEditBox.Align = 0
frmEditBox.Value = Server.GetOPCValue("...IO.Power Email Alarm.CPA Delay.ConstantValue")
Form.AddStaticText 14,3, "Seconds"
Set frmOKButton = Form.AddPushButton(25,3,"OK")
frmOKButton.Default = True
Set frmCancelButton = Form.AddPushButton(40,3,"Cancel")
If Form.Selection = "OK" Then
IF isNumeric(frmEditBox.Value) = True Then
Server.SetOPCValue "...IO.Power Email Alarm.CPA Delay.Value", Round(Cint(frmEditBox.Value))
iResponse = MsgBox("Value is not a Number." , vbOK + vbDefaultButton2, "Set Control Power Alarm Delay")
End If
End If
End Function_


Thank you very much for taking the time and trouble to respond. This response was very detailed.
I will try this._**


Author Icon
Hi Tony.
The answer that Geoff gave you is for a mimic script, which is different to an ST program. Either can work, but it depends on exactly what you're trying to acchieve.

Mimic scripts run on the client side, and only run when a particular mimic is open. ST programs run on the server side.

In the ST programs you can define some input variables and use those:

Input1 : TIME;

Or you can use a direct variable:

Input AT %I(..TimeDelay.CurrentValue): TIME;



Hi Dean. Very interesting response. Would you mind elaborating please? I'd like the end user to have the ability to handdress say for example with a value from 1 to 360 on a mimic and have that value stored and added to NOW() as minutes to create a future date time once the ST program executes therefore replacing the hard coded T#15m if you understand. I thought something like this should be a fundamental part of ClearSCADA such as using an internal time point or variable in the data tree then reference it within the script, however it does not appear to be so straightforward. Could you give me an example? It would be fantastic if I was able to get something to work. Thanks._**


You could also pass them in as individual components (hours, mins, secs) and use the MAKE_TIME function.


Hi Adam. Thank you for this suggestion.


Whether you do it in ST or mimic script depends mostly on whether you want to run the logic once; or if the user enters the time once, and then the logic runs in the background on a schedule or a point changing.

If it's the latter, then I would allow some points from the database to be controlled from a mimic, then bring them in as direct variables.

Attached is a zipped export with an extremely quick example. (Time Offset Example 1.zip) Note that the value of the integer point will be lost if the system is exported and re imported. To avoid this you can use a parameter, but then you need to create a custom form in a mimic script.


Hi Dean. Amazing Sir! Thank you very much for taking the time and effort to respond. I wish to store a time variable in the data tree and allow it to be handressed by a user from a mimic. On the same mimic there is a button to launch a ST program which disables alarms on a series of analogue points. Part of this ST program is to set a future time which will trigger further ST to re enable the same point alarms once The current date time exceeds that future time. So I'm looking for a way to permit control room staff enter a value in minutes..or hours have that value stored then referenced by the ST program when executed to create a time out. if that makes sense.
I will import your attachment into my T&D server and try it out. Thank you once again._**


Hi Everyone.
I managed to get this working!
Thank you all very much for your assistance._**

Attached file: (editor/yi/mqtirw4u9hda.zip), Time Offset Example 1.zip File size: 236878