Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Autosave function & OnDataChange Script

Autosave function & OnDataChange Script 7 months 3 days ago #2569

Hello,
i got an issue about tags values change during runtime won't be reflected again after restarting the PC. I tried to maneuver around it by creating some kind of autosave function like this :
sleep(300000);
saveproject(Tags.Directory);
and script setting in the attached image.
but somehow it didn't work or only worked once. any suggestion on how to resolve this issue? mainly because the runtime likes to hang during user operation but not when left alone.
Attachments:
Last Edit: 6 months 4 weeks ago by kurotsubaki. Reason: edit the title to be more precise
The administrator has disabled public write access.

Autosave function 7 months 2 days ago #2570

  • fatkhrus
  • fatkhrus's Avatar
  • Offline
  • Administrator
  • Posts: 826
  • Thank you received: 123
  • Karma: -107
Hello,

If you use such scripts in your project, it's not a surprise that Runtime is hanged periodically. You create script that run every Update interval (you setup it in Project properties) and create new Thread for every execution and according your code sleep 5 minutes. It could create a lot of Threads in parallel and overload your operation system. The right way to do what you want is to use currentdatetiminmil function from Data and time library (teslascada.com/HTML/date-and-time-library2.html), hold previous time in some Tag and calculate delta inside script. Or use System data and time tags (teslascada.com/HTML/tags.html) in the same way.

I hope you save project in some reserve file. It could be damaged if you save it in the file.

Best regards,
Ruslan
Last Edit: 7 months 2 days ago by fatkhrus.
The administrator has disabled public write access.

Autosave function 7 months 2 days ago #2571

Ah, that might be one of the causes of the performance issue i got. i have around 100 scripts that run on every cycle calculating some tags receiving data from PLC.
i did this because if i set it on OnDataChange, sometimes it doesn't calculate the updated value of a tag.
how do i declare which tag value the script with OnDataChange based itself upon? should i assign it to a variable beforehand?
just for additional information, sometimes i put the tag in the script inside an IF clause
The administrator has disabled public write access.

Autosave function 7 months 2 days ago #2572

  • fatkhrus
  • fatkhrus's Avatar
  • Offline
  • Administrator
  • Posts: 826
  • Thank you received: 123
  • Karma: -107
Property "Every cycle" itself could not be the reason of the problem. You can use it if you want. But don't use very big code in it and don't use functions like sleep. OnDataChange had some problems: when tag's value is changed its not updating the graphical object that bind to this tag. In last version, that we released today, we've added in Script properties "Run in UI" property that strictly run script and after that update graphical object. This should solve problem with no updating graphical objects, but it could be cause some lags in drawing screens.

Best regards,
Ruslan
The administrator has disabled public write access.
The following user(s) said Thank You: kurotsubaki

Autosave function 6 months 4 weeks ago #2574

Is this the cause of my OnDataChange script being triggered upon entering a screen?
I create a boolean tag based script that will redirect to another screen upon change from 0 to 1. but now i can't get to the screen as it redirects me immediately to the other screen when i open that screen. the script are as simplified as following
if (Tags.CurrState == 1) {
        print("State alert");
	callscreen("Other_screen");
} else if (Tags.CurrState == 0){
	print("State Alert Dismissed");
}
The goal is to manually enter an alert state and immediately go to the alert response page, then return to the page to manually switch it back again after the event is done.
the script property is general, ST, OnDataChange.
Last Edit: 6 months 4 weeks ago by kurotsubaki.
The administrator has disabled public write access.

Autosave function 6 months 4 weeks ago #2575

  • fatkhrus
  • fatkhrus's Avatar
  • Offline
  • Administrator
  • Posts: 826
  • Thank you received: 123
  • Karma: -107
It shouldn't according your code. If you use only this code and Tag CurrState isn't changed in any other parts of the project. Maybe it's better to use tag dependent script.
You can setup script:
Type: Tag
and bind this script to Tag in Tag properties (last tab). When condition become TRUE from FALSE your script is executed.
In the body you can just call screen:
callscreen("Other_screen");

Best regards,
Ruslan
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Go to top