You are on page 1of 7

Ignition Code Guideline

Rising Script:
Rising Script is a program used to change a “Dword” tag to 1000+(alarm number) when
a Boolean alarm changes to true (1).

1. Tag Path(s):
[default]GUFC4PM11_Pasteurizer/Device/Alarm/*

[default]GUFC4PM18_AutoPalletizer/Device/Alarm/*

[default]GUFC4PM21_Pasteurizer/Device/Alarm/*

[default]GUFC4PM28_AutoPalletizer/Device/Alarm/*

[default]GUFC4PM31_Pasteurizer/Device/Alarm/*

[default]GUFC4PM38_AutoPalletizer/Device/Alarm/*

Remarks:

• The “/*” adds every element (tag) in the parent folder to the tag path. (e.g.
Alarm/*, adds every element from alarm to the tag path)

2. Script:
#variable definition
my_tag = event.tagPath.getItemName()
device_Num = my_tag[-4:]
machine_Num = my_tag[-13:-11]

path = ["[default]GUFC4PM" + machine_Num]


Rising_edge = event.getCurrentValue().getValue()

#logic to write the alarm number+1000 in Dword


if Rising_edge == 1:
system.tag.writeBlocking(path, 1000 + int(device_Num))

Code Explanation:
• my_tag: a variable that gets the name of the tag that triggered (changed)
• device_Num: a variable that gets the number of the alarm
• machine_Num: a variable that gets the number of the machine
• path: a variable used to specify in which Dword tag should the change be written

1
Ignition Code Guideline

• Rising_edge: a variable that gets the current value of the alarm that triggered
• If the current value is 1, write in the Dword tag: 1000 + alarm number
• Device_Num must be cast to int in order to add it to 1000

2
Ignition Code Guideline

Pasteurizer to 0:
“Pasteurizer to 0” is a program used to change a “Dword” tag to 0 when a Boolean
alarm changes to false (0) if and only if all other sister alarms in the same parent folder are “0”.

1. Tag Path(s):
[default]GUFC4PM11_Pasteurizer/Device/Alarm/*
[default]GUFC4PM21_Pasteurizer/Device/Alarm/*
[default]GUFC4PM31_Pasteurizer/Device/Alarm/*
Remarks:

• The “/*” adds every element (tag) in the parent folder to the tag path. (e.g.
Alarm/*, adds every element from alarm to the tag path)

2. Script:
#variable definition

my_tag = event.tagPath.getItemName()

Rising_edge = event.getCurrentValue().getValue()

machine_Num = my_tag[-13:-11]

browse_Path = "[default]GUFC4PM" + machine_Num + "_Pasteurizer/Device/Alarm"


path = ["[default]GUFC4PM" + machine_Num]

path_List = []
i=0

#logic to browse parent folder when an alarm goes to 0 "Pasteurizer" machines


if Rising_edge == 0:

results = system.tag.browse (browse_Path)

#append all alarms in the machine to a list to read their values

3
Ignition Code Guideline

for result in results.getResults():


path_List.append (str(result['fullPath']))

read_values = system.tag.readBlocking(path_List)

#checking value of alarms from 1st to max and set Dword to 0 if all alarm values are 0
while read_values[i].value == False:

i += 1

if i not in range(len(read_values)):

system.tag.writeBlocking(path, 0)

break

Code Explanation:
• my_tag: a variable that gets the name of the tag that triggered (changed)
• Rising_edge: a variable that gets the current value of the alarm that triggered
• machine_Num: a variable that gets the number of the machine
• browse_Path: a variable used to note the parent folder of the alarm that
triggered
• path: a variable used to specify in which Dword tag should the change be
written
• Path_List: a list that will be used later in the code
• i: a variable that will be used in a loop in the code
• if current value is 0, browse the parent folder of the alarm that triggered
• a for loop that appends all subfolder alarms of the parent folder to a list,
path_List
• read_values: a variable that reads from the path_list
• a while loop that reads from the first item of the list only while the value is 0
• if all values of the path_list is 0, set the Dword tag (path) to 0

4
Ignition Code Guideline

Palletizer to 0:
“Palletizer to 0” is a program used to change a “Dword” tag to 0 when a Boolean alarm
changes to false (0) if and only if all other sister alarms in the same parent folder are “0”.

1. Tag Path(s):
[default]GUFC4PM11_Pasteurizer/Device/Alarm/*
[default]GUFC4PM21_Pasteurizer/Device/Alarm/*
[default]GUFC4PM31_Pasteurizer/Device/Alarm/*

Remarks:

• The “/*” adds every element (tag) in the parent folder to the tag path. (e.g.
Alarm/*, adds every element from alarm to the tag path)
• An exact replication of “Pasteurizer to 0” with the only change being in the
tag path as well as browse_Path

2. Script:
#variable definition
my_tag = event.tagPath.getItemName()
Rising_edge = event.getCurrentValue().getValue()
machine_Num = my_tag[-13:-11]

browse_Path = "[default]GUFC4PM" + machine_Num + "_AutoPalletizer/Device/Alarm"


path = ["[default]GUFC4PM" + machine_Num]
path_List = []
i=0

#logic to browse parent folder when an alarm goes to 0 "AutoPalletizer" machines


if Rising_edge == 0:
results = system.tag.browse (browse_Path)

#append all alarms in the machine to a list to read their values


for result in results.getResults():
path_List.append (str(result['fullPath']))
read_values = system.tag.readBlocking(path_List)

#checking value of alarms from 1st to max and set Dword to 0 if all alarm values are 0
while read_values[i].value == False:
i += 1

5
Ignition Code Guideline

if i not in range(len(read_values)):
system.tag.writeBlocking(path, 0)
break
Code explanation:
• my_tag: a variable that gets the name of the tag that triggered (changed)
• Rising_edge: a variable that gets the current value of the alarm that triggered
• machine_Num: a variable that gets the number of the machine
• browse_Path: a variable used to note the parent folder of the alarm that
triggered
• path: a variable used to specify in which Dword tag should the change be
written
• Path_List: a list that will be used later in the code
• i: a variable that will be used in a loop in the code
• if current value is 0, browse the parent folder of the alarm that triggered
• a for loop that appends all subfolder alarms of the parent folder to a list,
path_List
• read_values: a variable that reads from the path_list
• a while loop that reads from the first item of the list only while the value is 0
• if all values of the path_list is 0, set the Dword tag (path) to 0

6
Ignition Code Guideline

Counter:
A simple program that counts how many times a Boolean counter triggers.

1. Tag Path(s):
[default]counter/Device1/boolean counter01
[default]counter/Device1/boolean counter02

Remarks:
• A sample program and alarms used for testing

2. Script:
#variable definition

my_tag = event.tagPath.getItemName()

counter_Num = my_tag[-2:]
count = system.tag.readBlocking("[default]counter/Device1/DWord counter" +
counter_Num )[0].value

#Code execution

if event.getCurrentValue().getValue() == 1:

system.tag.writeBlocking("[default]counter/Device1/DWord counter" +
counter_Num, count+1)

You might also like