Gateway script - not the same as written

Hi.
I have a gateway script, where i log a bunch of data to mssql.

on each sql run, i print out the sql string (ends up in wrapper.log)
the print out, is however NOT the same as written as i have in my ide/project.
If you compare what is written out on the print, and whats the script is putting together… a bunch of columns in the sql strings are missing from the query string.

Wrapper.log:

INFO   | jvm 1    | 2014/07/30 10:46:49 | INFO  [LocalDBManagerImpl            ] [10:46:49,948]: Created auto-backup of internal database "settings" in 340 ms
INFO   | jvm 1    | 2014/07/30 10:57:21 | 3184
INFO   | jvm 1    | 2014/07/30 10:58:30 | Loggar batch...
INFO   | jvm 1    | 2014/07/30 10:58:30 | 
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				INSERT INTO ignition.dbo.sandvik_batchlogg (
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				[dt]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[TO_nr]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[S_nr]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[capp_id]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[pulver_batch_nr]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[pulver_fatnr]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[pulver_sort]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[bv_uppvagning]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[av_uppvagning]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[event]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[event_info]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[silo_nr]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vikt_uppvagning]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vikt_finmatning]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vals_ytter_diam]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vals_inner_diam]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vals_vikt]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[vals_hojd]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[kommentar]
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				,[sammansatt])
INFO   | jvm 1    | 2014/07/30 10:58:30 | 				VALUES
INFO   | jvm 1    | 2014/07/30 10:58:30 | 					('2014-07-30 10:58:29.924',-3178, 3185, -20674, '115', 0, 467, 11.200000, -0.080000, 0, 'Ingen händelse under uppvägning', 1, 194.400009, 9.040000,0, 0, 0, 0, 'kommentar', 'sammansatt')
INFO   | jvm 1    | 2014/07/30 11:07:46 | INFO  [Project[sandvik]              ] [11:07:46,843]: Restarting gateway scripts...
INFO   | jvm 1    | 2014/07/30 11:07:58 | Loggar batch...
INFO   | jvm 1    | 2014/07/30 11:07:58 | 
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				INSERT INTO ignition.dbo.sandvik_batchlogg (
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				[dt]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[TO_nr]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[S_nr]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[capp_id]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[pulver_batch_nr]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[pulver_fatnr]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[pulver_sort]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[bv_uppvagning]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[av_uppvagning]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[event]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[event_info]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[silo_nr]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vikt_uppvagning]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vikt_finmatning]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vals_ytter_diam]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vals_inner_diam]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vals_vikt]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[vals_hojd]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[kommentar]
INFO   | jvm 1    | 2014/07/30 11:07:58 | 				,[sammansatt])
INFO   | jvm 1    | 2014/07/30 11:07:59 | 				VALUES
INFO   | jvm 1    | 2014/07/30 11:07:59 | 					('2014-07-30 11:07:58.937',-3178, 3185, -20674, '115', 0, 467, 11.200000, -0.080000, 0, 'Ingen händelse under uppvägning', 1, 194.400009, 9.040000,0, 0, 0, 0, 'kommentar', 'sammansatt')

The actual gateway script in the designer:

[code]import sys
from datetime import datetime, date

tmpTuplesEventInfo = (
‘Ingen händelse under uppvägning’,
‘Maskinen har nödstoppats under uppvägning’,
‘Maskinen har varit strömlös alt. andra delar varit strömlöst’,
‘Sekevensen har pausats mitt i’,
‘Timeout pga utebliven viktförändring på våg’,
‘Sekvensen avbröts’,
‘Reserv 6’,
‘Reserv 7’,
‘Reserv 8’,
‘Reserv 9’,
‘Reserv 10’,
‘Reserv 11’,
‘Reserv 12’)

if initialChange:
pass
elif newValue.value:
print “Loggar batch…”

#Läs loggdata från DB10-taggar
tmp_TimeStamp = str(datetime.now())[0:-3]
tmp_TO_nr = system.tag.read(“S7_300/DB10/I2_TONummer”)
tmp_S_nr = system.tag.read(“S7_300/DB10/I0_SNummer”)
tmp_capp_id = system.tag.read(“S7_300/DB10/I4_CappID”)
tmp_pulver_batchnr = system.tag.getTagValue(“S7_300/DB10/STRING22_BatchNummer”)
tmp_pulver_fatnr = system.tag.read(“S7_300/DB3/I46_FatNummer”)
tmp_pulver_sort = system.tag.read(“S7_300/DB10/I6_Pulversort”)
tmp_bv_uppvagning = system.tag.read(“S7_300/DB10/REAL8_Borvarde”)
tmp_av_uppvagning = system.tag.read(“S7_300/DB10/REAL12_ArVarde”)
tmp_event = system.tag.read(“S7_300/DB10/I16_Event”)
try:
tmp_event_info = tmpTuplesEventInfo[int(tmp_event.value)]
except:
tmp_event_info = “Event ej specificerat”
tmp_silo_nr = system.tag.read(“S7_300/DB10/I18_SiloNummer”)
tmp_vikt_uppvagning = system.tag.read(“S7_300/DB10/REAL30_ViktUppvagning”)
tmp_vikt_finmatning = system.tag.read(“S7_300/DB10/REAL34_ViktFinmatning”)
tmp_vals_ytter_diam = system.tag.read(“S7_300/DB10/I38_YtterDiamVals”)
tmp_vals_inner_diam = system.tag.read(“S7_300/DB10/I40_InnerDiamVals”)
tmp_vals_vikt = system.tag.read(“S7_300/DB3/REAL66_ViktVals”)
tmp_vals_hojd = system.tag.read(“S7_300/DB10/I42_HojdVals”)
tmp_kund_nr = system.tag.read(“S7_300/DB3/I70_KundNummer”)
tmp_kommentar = “kommentar”
tmp_sammansatt = “sammansatt”

#Skriver till 
#print tmp_TimeStamp
#tmpQueryString = "INSERT INTO ignition.dbo.sandvik_batchlogg ([dt],[TO_nr],[S_nr],[capp_id],[pulver_batch_nr],[pulver_fatnr],[pulver_sort],[bv_uppvagning],[av_uppvagning],[event],[event_info],[silo_nr],[vikt_uppvagning],[vikt_finmatning],[vals_ytter_diam],[vals_inner_diam],[vals_vikt],[vals_hojd],[kundnr],[kommentar],[sammansatt]) VALUES ('GetDate()',%d, %d, %d,'%s', %d, %d, %f, %f, %d, '%s', %d, %f, %f,%d, %d, %d, %d, %d,'%s','%s')" % (
#tmp_TimeStamp,tmp_TO_nr.value,tmp_S_nr.value,tmp_capp_id.value,tmp_pulver_batchnr,tmp_pulver_fatnr.value,tmp_pulver_sort.value,tmp_bv_uppvagning.value,tmp_av_uppvagning.value,tmp_event.value,tmp_event_info,tmp_silo_nr.value,tmp_vikt_uppvagning.value,tmp_vikt_finmatning.value,tmp_vals_ytter_diam.value,tmp_vals_inner_diam.value,tmp_vals_vikt.value,tmp_vals_hojd.value,tmp_kund_nr.value,tmp_kommentar,tmp_sammansatt)
tmpQueryString = """
			INSERT INTO ignition.dbo.sandvik_batchlogg (
			[dt]
			,[TO_nr]
			,[S_nr]
			,[capp_id]
			,[pulver_batch_nr]
			,[pulver_fatnr]
			,[pulver_sort]
			,[bv_uppvagning]
			,[av_uppvagning]
			,[event]
			,[event_info]
			,[silo_nr]
			,[vikt_uppvagning]
			,[vikt_finmatning]
			,[vals_ytter_diam]
			,[vals_inner_diam]
			,[vals_vikt]
			,[vals_hojd]
			,[kundnr]
			,[kommentar]
			,[sammansatt])
			VALUES ('GetDate()',%d, %d, %d, '%s', %d, %d, %f, %f, %d, '%s', %d, %f, %f, %d, %d, %f, %d, %d, '%s', '%s')""" % (
					            int(tmp_TO_nr.value),
					                int(tmp_S_nr.value),
					                    int(tmp_capp_id.value),
					                         tmp_pulver_batchnr,
					                              int(tmp_pulver_fatnr.value),
					                                   int(tmp_pulver_sort.value),
					                                       toFloat(tmp_bv_uppvagning.value),
					                                           toFloat(tmp_av_uppvagning.value),
					                                               int(tmp_event.value),
					                                                   tmp_event_info,
					                                                        int(tmp_silo_nr.value),
					                                                             tmp_vikt_uppvagning.value,
					                                                                 tmp_vikt_finmatning.value,
					                                                                     int(tmp_vals_ytter_diam.value),
					                                                                         int(tmp_vals_inner_diam.value),
					                                                                            toFloat(tmp_vals_vikt.value),
					                                                                                 int(tmp_vals_hojd.value),
					                                                                                     int(tmp_kund_nr.value),
					                                                                                         tmp_kommentar,
					                                                                                              tmp_sammansatt)


try:	
	system.db.runUpdateQuery(tmpQueryString,"MSSqlLocal")
	system.tag.write("S7_300/DB3/X16_1_LoggData",0)
	system.tag.write("mem_FelVidBatchloggningTillDatabas",0)
except:
	system.tag.write("mem_FelVidBatchloggningTillDatabas",1)
	system.tag.write("S7_300/DB3/X16_1_LoggData",0)

print tmpQueryString		[/code]

Hi!

You can use the script playground to test your scripts and output results without having to resort to the logger. :slight_smile:

I would start with the portion of reading the tags and then print the values (maybe printing the quality would be good, too). See if you are getting good data for the rest of the script.

Was the project saved? What type of Gateway script is it? Gateway Timer Script?

The script playground works as expected. but in the real gateway script, it does not.

However. now the script playground complained about the toFloat. It didnt do that before lunch :/
Anyways… NOW when toFloat is removed, the log seems to do it all.

The script is a tag change type.
I would probably found the error(s) in the code if the wrapper had contained the same error messages the script playground shows… (tracert)

Is it a Tag Event Script or a Gateway Tag Change Script?

Gateway Tag Change Script

Okay, it is odd that the exception didn’t get logged to the wrapper.log file. I wonder what would happen if you put the error back into the code and saved the project and changed the tag value. Does the exception get logged to the wrapper.log file?