Cause of logs (Restarting gateway scripts)

I use a Gateway Script through Tag Change, a log is created in a DB, but reviewing the saved data I noticed that 2 logs were created that should not be, looking at the Logs I noticed that at 11:51:01 and 11:51:47 the Log is executed: Restarting gateway scripts....

How can I prevent the Log: Restarting gateway scripts from executing?

imagen

You cannot prevent this. Gateway scripts must restart when a project is edited and saved.

In a tag change event, inspect the initialChange boolean in your logic to handle this case specially.

That is to say that when I make a change in any Gateway Script it would be restarted and therefore all the Gateway Scripts would be executed again?

Yes. When you save the project.

In v7.9, changes to shared scripts will make this happen in all projects. This is true even if you are using Staging mode, which only applies to Vision GUI resources.

In v8+, changes to scripts in inheritable projects will make this happen in all projects that inherit them.

2 Likes

HI pturmel
this is my code

import time
total = 0
tempa = 0
oldtotal = 0
def calculate_downtime(start):    
    global total, tempa, start_time, end_time,oldtotal
    if start == False and tempa == 0:  
        start_time = time.time()  
        tempa = 1  
    elif start == True:
         tempa = 0   
    if tempa == 1:  
        end_time = time.time()  
        total = (end_time - start_time) + oldtotal
        return total/60
    elif tempa == 0:
         oldtotal = total
         return oldtotal/60

When I save the project, the global variables above are reset to zero. How can I prevent them from being reset to zero

This is from another topic. The answer given in the other topic was to log your events to a database or historian and calculate from that history.

If you cannot do that, consider using datetime and 64-bit integer memory tags instead of script global variables to persistently hold your information.

Side note: Don't use python/jython standard libraries for things that Ignition and java provide, like dates and times, sockets, network protocols, and any form of character encoding/decoding. The jython libraries are trouble-prone, particularly for dates and times.

how can i use the memory tags,do I need to drag and drop it directly or do I need to use some command to use it?"

@chen_zhe, please stop hijacking other threads.

  • Maybe ask your question on an existing thread if it is relevant. This topic is about "Cause of logs". You have asked two questions on this thread - neither of which are on-topic.
  • If you are not sure, then start a new thread and paste a link to any threads that might be related.
  • Don't double-post.
  • Don't ping other users looking for help. Apart from the IA staff, we are all volunteers. Most of the people you would want to contact read all the questions anyway and will reply if they have time and are interested in the problem.

Thanks.