Hi All,
I’m using IGNITION 8.0.5 RC1
I have a script in Gateway Event Scripts that has to collect some tags and insert them inside the DB.
The script is the following:
if not initialChange:
if newValue.getValue():
Server = 'Ignition OPC UA Server'
#opcPathTest = '[S1500]DB1002,STRING140.100' #Nome Test
opcPathNCiclo = '[S1500]DB1005,DI8012.0' # Numero del ciclo
#Tag_N_Sample = '[S1500]DB1005,DI0.0' #campionamenti totali per il singolo ciclo ( per far un for mirato )
TagPathsPressure = ['[S1500]DB1005,REAL%2.1f' % x for x in range(4,4008,4)]
TagPathsTime = ['[S1500]DB1005,DI%2.1f' % x for x in range(4008,8012,4)]
#NomeTest = system.opc.readValue(Server,opcPathTest).value
NomeTest = system.tag.readBlocking(['[default]PLC/Esperimento/Name Test'])[0].value
N_Ciclo = system.opc.readValue(Server,opcPathNCiclo).value
#N_Sample = system.opc.readValue(Server,Tag_N_Sample).value
N_Sample = system.tag.readBlocking(['[default]PLC/Campionamenti/Impulsi TOT'])[0].value
PressureValues = [x.value for x in system.opc.readValues(Server,TagPathsPressure)]
TimeValues = [x.value for x in system.opc.readValues(Server,TagPathsTime)]
Query = system.db.runPrepQuery('SELECT [ID] FROM [Test_Impulso] WHERE [Name] = ?',[NomeTest])
ID_Test = Query[0][0]
for j in range(0,N_Sample):
stmt = 'INSERT INTO [ImpulsoToKeep]([ID_Test],[N_Ciclo],[Time],[Pressure]) VALUES (?,?,?,?)'
system.db.runPrepUpdate(stmt,[ID_Test,N_Ciclo,TimeValues[j],PressureValues[j]])
# Bit di HandShake
system.tag.writeBlocking(['[default]PLC/Esperimento/Reset Impulsi'],[False])
system.opc.writeValue(Server,'[S1500]DB1006,X14.4',0)
If I run the script inside the Script Console everything is done perfectly.
If it runs from the Gateway Event Script I received an error that says that it cannot insert NULL value inside the database, because this line PressureValues = [x.value for x in system.opc.readValues(Server,TagPathsPressure)]
is returning an array of None value.
Any idea?