Script Executing trouble

I have a script that is supposed to zero out the doffings value at 8am but according to the power chart time recorder its not happening at that time:

It looks like it happens around 1AM the next day:

the script is executing on a boolean tag that has this as the expression:

if(dateFormat(now(), "HH:mm") = "08:05" || dateFormat(now(), "HH:mm") = "20:05", True, False)

The script is as follows:

opcTagPath2=[
		"[default]BitWinders/BitWinder_1/LH/dwActualNumberOfDoffings",
		"[default]BitWinders/BitWinder_1/RH/dwActualNumberOfDoffings",
		"[default]BitWinders/BitWinder_2/LH/dwActualNumberOfDoffings",
		"[default]BitWinders/BitWinder_2/RH/dwActualNumberOfDoffings"]
			
opcTagValue2 = [0] * len(opcTagPath2)

system.tag.writeBlocking(opcTagPath2,opcTagValue2)

It looks like everything should work, but its not. Can someone help me troubleshoot this?

This should probably be a Gateway Scheduled Event Script.

Either way, I just learned about a better way of doing this:

Note that unless you have filtered the code prior to the code you shared, it will execute when the value changes, but also when the quality changes, so you probably want to insure that the value has actually made a False to True transition.

Also, verify that your Gateway, Database, and Local machine all have the same Date Time settings.

1 Like

It is a Gateway script:

Ah, you didn’t say that you were prior to 8.1.6.

My mistake sir. I am 8.1.0

1 Like

No worries, I’m sure you’ve heard it a lot, but if you can upgrade, it would definitely behoove you.

The local times look correct, here is my gateway:
image

My trend chart does show its executing at 1pm and 1am.

Put in on a gateway timer script to check hourly with fixed rate set. Also check for time at the hourly level vs down to a minute. See the post @lrose shared.

I assume the issue with your script which checks the time and where it is located. Wherever it is located is not checking or triggering correctly. I would try that script in the script console.

The first code block is the expression for the expression tag. = is correct in the expression language for comparisons.

I don't think the expression tag value not changing is the issue, but rather that the script is not resulting as expected.

I have changed the expression boolean tag to different time values and it becomes true between the new values. I have also put the the script in the console ant returns look correct.

This sounds like a time difference issue. If you pull the historical data and manually convert the t_stamp using the same settings that the Gateway is using, is it in the correct time?

Is the gateway for any reason in a different time zone than the database? This just feels like a time zone conversion issue.

2 Likes

After alot of checking and double checking, I have noticed that the script is running at the time I want it to. BUT the time range on the power chart is off for whatever reason. Should I use a time series chart or something else for a more accurate time range display? Or us there some other reason that that time is off? Thanks alot for the help.