How to Change Client Screens based on Time of Day

I would like to have a client screen change to the Main Menu at 00:00:00 each day (if not already on the Main Menu).

Below is my last attempt using a Client Event Script - Timer

I thought this script would fire every 10 minutes the client was running and when the hour equal to 00 and the minute less tha 19 the screens would then swapTp the main menu or Navigation screen.

What have I done wrong and what would be the ccleanest way to change screens at midnight?

system.date.get* requires a date to get the specified part from. Replace your first two lines with these three:

date = system.date.now()
Hour = system.date.getHour24(date)
Minute = system.date.getMinute(date)

This won't keep it from working, but your script looks like it is running every 1,000 ms (the "600,000" shown in your screenshot above is just the name of the timer script). If someone is trying to use it during the first 18 minutes after midnight, the swap once a second would get a bit annoying!

1 Like

The immediate thing I see is that there is a space between swapTo and (“Navigation”).

That said, for triggered events like this I prefer to use tag change scripts instead of timer scripts.

Set up a tag with your trigger using timeBetween:

timeBetween(dateFormat({[System]Client/System/CurrentDateTime},"h:mm:ss a"), "12:00:00 am", "12:18:59 am")

Use a tag change script monitoring the trigger tag:

3 Likes

JordanCClark,
Do you typically use a tag within a PLC as your trigger?

Thanks for spotting my typo and set up errors.

You certainly can, but a client tag would be more robust.

My tag question was meant for Jordan.
I’m not sure what I understand Client Tag.
Would this be a Memory Tag?

I just saw, in the tag browser the client tags.

Okay gotcha. :slight_smile:
There are two scopes of tags. One type is scoped to the gateway. The OPC tags for example are are scoped to the gateway. gateway tags are global and be seen by all projects.

Below the Tags folder near the bottom, you should see a folder called “Client”. Client tags are tags that stay local to the Client running the project.

If you have the time, will you show me an example expression for the Client Tag (TriggerTag), Data Type Boolean that will be True when the current time is 00:01:00. Where the TagEditor Expression that is looking at the time will poll or execute every ten minutes.

I have the Client Event Script set up just like you described above, I’m having trouble getting my client tag (TriggerTag) to come true based on the current time

JordanCClark, thank you for your help, I was able to get an expression that worked.

1 Like

JordanCClark, I could sure use your help on this same issue.
My Tag is firing but the screens are not changing. I did several tests this morning and was unable to get the screens to change. Will you take a look at how I have the tag and Client Event Script setup and see if you can spot my error(s).
The first two pics are the Client Tag Editor windows.
The last two pics are the Client Event windows.

Case matters–“T” must be capitalized in “swapTo.” I believe newValue.getValue() requires the parenthesis on the end. Your script is not setting a value for OpenWindow so it is likely equal to None when your script fires. You could probably just drop the second condition, making your script:

if newValue.getValue() == True:
	system.nav.swapTo("Navigation")
2 Likes

All right Buddy! Worked perfectly.
Thank you for your help. I have a lot to learn.

2 Likes