Global Variables Question

Hello all,

Just a question. I've been working in a Vision project but right now I have some doubts.

Currently the project works fine when I have the vision client active in the window where it update a database with some information when the propertyChange in a calendar changes each second and runs a query for saving data.

Right now is it necessary another window but when that new window is active in the vision client and the other is close the database stops saving data because it doesn't detect the change of the calendar.

I think right now I have to change my scripts with some global variables but I don't know how to do that. I just need that when Vision Client starts all my global variables start functioning no matter in what window the client is.

Thank you.

It sounds as though you have not designed your application correctly. If you need something to record every second then you should set that up in the gateway, not in the application. That way it will run even if there is no client open.

What are you trying to record? Is it PLC data from an OPC tag or something different?

1 Like

Thank you, that was a new requirement and I'm new in ignition so I didn't project that this could be happen.

Yes I will record data from a PLC detecting the waterflow of some flow meters.

Thank you

Try enabling history on your flowmeter tags, it may get you what you want. If you want a set timing interval then maybe look at using transaction groups to log to a DB table.


Transaction groups or tag history are absolutely the way to go here.

1 Like

Thank you, I'm going to work hard in this options and I will update you about the result.

Thank you again!


  • Have the PLC count the pulses from the meter using a counter with a rollover of 1,000,000 or whatever you like.
  • Read the PLC integer value with an OPC tag and set the scale factor in the tag properties.
  • Use Ignition's built-in historian or a transaction group or gateway scheduled event to record the count. Note that this means that if you miss one or more readings that you will still be able to calculate the total flow and an average rate between any two timestamps.

Decide how often you need to take a reading and plan a sensible historian strategy.


Thank you!

Well right now I configured a New Gateway Schedule Script, each minute the data is saved in the data base. I don't have the PLC right now so I used a Tag with random values to simulate the flow

def onScheduledEvent():
	time0 =
	tagValuesL1 = system.tag.readBlocking(['[Sample_Tags]Random/RandomDouble1'])
	valueL1 = tagValuesL1[0].value
	flowmeterL1 = "LFM1"
	parameters = {"date":time0, "value":valueL1,"flowmeter":flowmeterL1} 
	system.db.runNamedQuery("Insert Data", parameters)

	tagValuesL2 = system.tag.readBlocking(['[Sample_Tags]Random/RandomDouble2'])
	valueL2 = tagValuesL2[0].value
	flowmeterL2 = "LFM2"
	parameters2 = {"date":time0, "value":valueL2,"flowmeter":flowmeterL2} 
	system.db.runNamedQuery("Insert Data", parameters2)

With this I can save the data at the moment the gateway is started and it is not necessary to open Vision or perspective.

Thank you for all your help :smiley:

Create another test tag and create an event to read that and write back the value + random increment. That will give you a test "meter" to read with ever-increasing count.

You need to consider what will happen if the meter rolls over.


Thank you, I will!

I'm learning and surely I will be asking many more questions in this forum and I hope some day help people too!

1 Like