It is currently Thu Apr 24, 2014 6:26 pm




Post new topic Reply to topic  [ 3 posts ] 
 tag change oldvalue 
Author Message
Trooper
Trooper

Joined: Wed Jul 06, 2011 2:11 am
Posts: 18
Location: Madrid, Spain
Post tag change oldvalue
Hello I have a problem with the tag change event scritp.
I have a opc tag that is giving me the controller state of one inverter in a solar plant.
I need to register this states on the table of event. The problem is that the direfent states are given in one bit of the INT2, every bit on the word have a state. So i have made a script that check the value.

That working good, the problem is that with that when the int2 tag value change just in one bit, the rest of states are save in the event table too coz you can have more of one state in the same time. So in every single change in this tag, print this state and the rest of states that are still on. and making a lot of new rows in the event table that are repeat

nuevo=newValue.value

if nuevo & (1 << 0):
accion='Deactivation from Radio Signal'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))

if nuevo & (1 << 1):
accion='Deactivation caused by Overvoltage during limitation from power reduction'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))
.
.
.
.


I would like to do something like that:

nuevo=newValue.value
viejo=oldValue.value

if nuevo & (1 << 0) and not viejo & (1 << 0):
accion='Deactivation from Radio Signal'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))

if nuevo & (1 << 1) and not viejo & (1 << 1):
accion='Deactivation caused by Overvoltage during limitation from power reduction'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))

if nuevo & (1 << 2) and not viejo & (1 << 2):
accion='Voltage level to high for activation'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))

if nuevo & (1 << 3) and not viejo & (1 << 3):
accion='AC Power Limitation caused by over frequency'
target='Inverter 9 - LOCAL MVL9'
system.db.runUpdateQuery("INSERT INTO audit_events (EVENT_TIMESTAMP, ACTOR, ACTION, ACTION_TARGET, ACTION_VALUE, STATUS_CODE,ORIGINATING_SYSTEM, ORIGINATING_CONTEXT) VALUES (NOW(),'system info','%s','%s',%d,0,'project=solar_plant',2)" % (accion,target,nuevo))
.
.
.
.


But i can not find the property that give me the old value.

PD: sorry for my english


Thu Jun 21, 2012 5:19 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: tag change oldvalue
Unfortunately, we don't have the old value in tag change scripts. We only have the new one. You can always store the old value in the database or another memory tag.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Thu Jun 21, 2012 7:32 am
Profile WWW
Trooper
Trooper

Joined: Wed Jul 06, 2011 2:11 am
Posts: 18
Location: Madrid, Spain
Post Re: tag change oldvalue
Yes i already used that

nuevo=newValue.value
viejo=int(system.db.runScalarQuery("SELECT ACTION_VALUE FROM audit_events WHERE ACTION_TARGET ='Inverter 9 - LOCAL MVL9' ORDER BY EVENT_TIMESTAMP DESC LIMIT 1"))


But i think its nicer with one property oldValue. Anyway I would like to propose that for next generation of ignition your team programmer add one option to the tags for auto-create a event, not only Auditing.

Like when you configure the alarm to one tag but for auto made one event.
Its a very powerfull tool for check the states of the systems, and right now i have to use every time the tag change event script that takes a lot of time.

Thanks a lot!


Thu Jun 21, 2012 9:39 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: