I have this code as my gateway script but it is not inserting records to my desired table. Please someone help me figure out what's wrong with it.
if system.tag.readBlocking("[default]zzzTimezzz/demotest")[0].value == True:
excluded_twisters = []
for i in range(1, 63): # Iterate over all Twisters (1 to 62)
exclude_tag_path = ["[default]Twisters/TW%s/TW_Data_Shift/TW_Data_Prev_Shift_%s" % (i, shift) for i in range(1, 63)]
exclude_tag_value = system.tag.readBlocking(exclude_tag_path)[0].value == True
if not exclude_tag_value: # Check if the exclude tag is not true
excluded_twisters.append(i) # Add Twister number to the exclusion list
# Define the line of Twisters you want to process (excluding those in excluded_twisters)
line = [twister for twister in range(1, 63) if twister not in excluded_twisters]
# Rest of your script remains unchanged
for i in line:
tagPathLeft_Eff = "[default]Twisters/TW" + str(i) + "/Left/Shift_1/Previous_Efficiency"
tagPathRight_Eff = "[default]Twisters/TW" + str(i) + "/Right/Shift_1/Previous_Efficiency"
Left_Eff = system.tag.readBlocking(tagPathLeft_Eff)[0].value
Right_Eff = system.tag.readBlocking(tagPathRight_Eff)[0].value
Twisters = i
DateTime = system.date.now()
Shift = system.tag.readBlocking("[default]Twisters/Previous Shift")[0].value[0]
Supervisor_mapping = {
('J', True): 'Carol Brookeshire' if Twisters <= 32 else 'Lind Smith',
('K', True): 'Andrew Frazier' if Twisters <= 32 else 'Tracy Presley',
('L', True): 'Sandra McIntyre' if Twisters <= 33 else 'Tim Foley',
('M', True): 'Juanita Gordon' if Twisters <= 33 else 'Jan Kelly',
}
Supervisor = Supervisor_mapping.get((Shift, True), 'Unknown Supervisor')
system.db.runPrepUpdate("INSERT INTO Plt65_DayShift_Twisting_Efficiencies (Twisters, DateTime, Shift, Supervisor, Left_Eff, Right_Eff) VALUES(?,?,?,?,?,?)",
[Twisters, DateTime, Shift, Supervisor, Left_Eff, Right_Eff], 'IgnitionHUD')