Skip to main content

Trigger and Notify

Add the Mode-Change Trigger​

A Mode Change trigger issues a check when an asset enters a mode. The production run supplies both the asset and the item, which fills in the context the FAI requires.

Add the mode-change trigger
  1. Open Machining - First Article Inspection and go to the Triggers tab.
  2. Add a trigger of type Mode Change with mode Production.
  3. Set Delay 0, Coming Due 5, Over Due 5 and Grace 5 minutes.
  4. Save and release the check sheet.
Reference Materials: Trigger Types

Trigger Types​

  • Manual: A check sheet can be manually created without this trigger, however if manual trigger is created, it will specify how much time a user has to take the checks once it has been scheduled.

  • Mode Change: When the mode changes on an asset i.e. from Changeover to Production, this trigger will schedule a check sheet if it meets the specified mode/shift, other options. An optional From Mode limits it to a change from that mode, so a check sheet can run on Changeover to Production but not on Maintenance to Production.

  • Product Change: When the product changes on an asset, this check sheet will be scheduled if the currently running product is specified by the check sheet.

    • Every Product: Quality check is required every time the product changes
    • Unique Products Per Shift: Quality check is required only once per product per shift
    • Once Per Shift: Only one quality check will be performed per shift
  • Re-Test: Set the delay, coming due etc. when a check sheet is scheduled due to a re-test being required.

  • Shift Change: Check sheet will be scheduled if the current shift meets the shift settings of this trigger.

  • Timed Interval: This check sheet will be triggered periodically based on the mode and shift settings.

  • Recurring: The check sheet is scheduled on a repeating calendar rule (every weekday at 6:00, the first Monday of the month, ...). Times are in the asset's site time zone, so 6:00 stays 6:00 at the plant across daylight-saving changes, whatever time zone the gateway runs in.

  • State Change: The check sheet is scheduled when an asset has been in one of the chosen states for at least the minimum time (For at least n mins), for example a check after a line has been Blocked for 10 minutes. It's scheduled once each time the asset goes into the state, so a short stop that clears before the minimum time doesn't trigger a check.

  • Infeed Count, Outfeed Count, Waste Count: The check sheet is scheduled every n counts of the asset's infeed, outfeed or waste counter.

  • General Count: The same, for one of the asset's general counters, by its name.

    For the count triggers, the count starts when the trigger is added and never resets: it carries on across product and shift changes, and what's left over after each n counts toward the next. When n counts are reached while a check sheet is still open, that check is skipped. Counts made while the check sheet doesn't apply (another shift, product, mode or tool than its settings) aren't counted.

State Change and the count triggers are checked by the quality timer, so a check sheet is scheduled within one timer interval of the state's minimum time or the count being reached.

Note If a trigger causes a new check sheet to be scheduled when there is already an existing check sheet scheduled, it will set the current check sheet to aborted if it has not already been started and create the new check sheet.

Trigger and Complete an FAI​

Trigger and complete an FAI
info

An automatic check only helps if the operator sees it. The Notifications card on the Operator Station's info panel counts checks that are due, and uncoded downtime, and opens them with one click. The Event Notifications dashboard widget lists the same.

  1. Open Machine 1's operation page, and tap the mode card on the info panel to open Run Control.
  2. In Run Control, set the mode to Changeover, then select SC-2024 on the Product tab and click Start Run. The machine enters Production. Close Run Control.
  3. Within a minute, the info panel's Notifications card says 1 quality check coming due; after the trigger's 5 Coming Due minutes it says due. Tap it, then click the check in the list to open Active Checks with Machine 1 selected.
  4. Open the FAI and confirm the asset and item are filled in.
  5. Enter three diameters near 25 mm, two lengths, and a visual result, then submit.
  6. Complete a second FAI on another machine. Trigger a third and leave it unfinished, so the next lesson has some late checks to analyze.

Check Your Work​

Check your work

Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks that the FAI is released with an enabled Production Mode Change trigger and the timers from this lesson, that a run start has issued an FAI with its machine and part filled in, that FAIs are completed on two machines with every measurement, and that one is left unfinished. Each check prints PASS or FAIL with what to fix. It doesn't change anything.

Show the check script
checkLesson-faiTrigger.py
# Kanoa Quality Training - check "Trigger and Notify" (First Article Inspection, lesson 3)
#
# Run in the Ignition Designer Script Console (Tools > Script Console), in the
# project that inherits KANOA_SCRIPTS. It only reads; it changes nothing.
# Every check prints PASS or FAIL with what to fix, then a summary.

SHEET = 'Machining - First Article Inspection'
MODE = 'Production'
TIMERS = [('delayMins', 'Delay', 0), ('comingDueMins', 'Coming Due', 5), ('overDueMins', 'Over Due', 5), ('graceMins', 'Grace', 5)]
AREA = 'CoreForge\\Philadelphia\\Machining\\'
FIRST_MACHINE = 'CoreForge\\Philadelphia\\Machining\\Machine 1'
UNFINISHED = ['Coming Due', 'Due', 'Overdue', 'In Progress', 'Missed']

results = []

def check(ok, what, fix=None):
results.append(bool(ok))
if ok:
print 'PASS %s' % what
else:
print 'FAIL %s' % what
if fix:
print ' -> %s' % fix

def note(what):
print 'NOTE %s' % what

def field(row, *names):
for n in names:
if n in row and row[n] is not None:
return row[n]
return None

def text(v):
return '' if v is None else unicode(v).strip()

def key(v):
return ' '.join(text(v).lower().split())

def truthy(v):
return str(v).lower() in ('true', '1', 'yes')

def num(v):
try:
return float(v)
except:
return None

def rows(data):
# Kanoa returns a dataset, a list of dictionaries, or None
if data is None:
return []
if hasattr(data, 'getRowCount'):
cols = list(data.getColumnNames())
return [dict((c, data.getValueAt(i, c)) for c in cols) for i in range(data.getRowCount())]
return [dict(r) for r in data]

def findSheet(name):
"""All versions of a check sheet, and the one to check: the Released version, or else the newest.
A revision renames the archived version '<name> - N' and the open one '<name> - In Revision',
so the other versions are found by their master sheet, not by name."""
sheets = rows(system.kanoa.quality.sheet.getSheets({}))
named = [s for s in sheets if text(field(s, 'chkShtName')) == name] or \
[s for s in sheets if key(field(s, 'chkShtName')) == key(name)]
if not named:
return None, []
masters = set(text(field(s, 'masterChkShtId', 'chkShtId')) for s in named)
versions = [s for s in sheets if text(field(s, 'masterChkShtId', 'chkShtId')) in masters]
versions.sort(key=lambda s: num(field(s, 'chkShtVersionNumber')) or 0)
released = [s for s in versions if text(field(s, 'chkShtVersionStateName')) == 'Released']
return (released or versions)[-1], versions

def millis(v):
return v.getTime() if hasattr(v, 'getTime') else 0

def sheetEvents(versions):
"""Every check event of any version of the sheet, newest first."""
out = []
for s in versions:
out += rows(system.kanoa.quality.event.getChkShtEvents({'chkShtId': field(s, 'chkShtId')}))
out.sort(key=lambda e: millis(field(e, 'scheduledDate', 'takenDate')), reverse=True)
return out

def eventItems(event):
"""The recorded values of a check event, by check item name."""
byName = {}
for r in rows(system.kanoa.quality.event.getChkShtEventItems({'chkShtEventId': field(event, 'chkShtEventId')})):
byName.setdefault(text(field(r, 'chkItemName')), []).append(r)
return byName

def readings(itemRows):
"""The measurements recorded for one check item."""
return [num(field(r, 'chkItemValue')) for r in itemRows or [] if num(field(r, 'chkItemValue')) is not None]

print '=' * 70
print 'Kanoa Quality Training - Trigger and Notify check'
print '=' * 70

sheet, versions = findSheet(SHEET)
if sheet is None:
check(False, 'Check sheet %s exists' % SHEET, 'Build it in the previous lesson first.')
else:
# 1. The mode-change trigger
print '\n-- Mode Change trigger'
triggers = rows(system.kanoa.quality.config.getChkShtTriggers({'chkShtId': field(sheet, 'chkShtId')}))
modeTriggers = [t for t in triggers if text(field(t, 'triggerTypeName')) == 'Mode Change']
if not modeTriggers:
check(False, 'It has a Mode Change trigger', 'On the Triggers tab, add a trigger of type Mode Change with mode %s.' % MODE)
else:
t = ([m for m in modeTriggers if text(field(m, 'modeName')) == MODE] or modeTriggers)[0]
check(text(field(t, 'modeName')) == MODE, 'The trigger is for mode %s' % MODE,
"It's for '%s'. Edit the trigger and set the mode to %s." % (text(field(t, 'modeName')) or 'no mode', MODE))
check(truthy(field(t, 'enabled')), 'The trigger is enabled', 'Edit the trigger and select Enabled.')
for col, label, expected in TIMERS:
actual = num(field(t, col))
check(actual == expected, '%s is %d minutes' % (label, expected),
"It's %s. Edit the Mode Change trigger and set %s to %d." % (text(field(t, col)) or 'blank', label, expected))
state = text(field(sheet, 'chkShtVersionStateName'))
check(state == 'Released', 'The check sheet is Released',
"It's %s. Close the editor and change its status to Released." % (state or 'not set'))

# 2. Inspections issued by the trigger
print '\n-- Inspections'
events = sheetEvents(versions)
triggered = [e for e in events if text(field(e, 'triggerTypeName')) == 'Mode Change']
check(triggered, 'A run start has issued an FAI (%d so far)' % len(triggered),
"In Run Control for Machine 1, set the mode to Changeover, pick SC-2024 on the Product tab and click Start Run. "
"If nothing appears, check Machine 1 has Enable Quality Triggers selected.")
if triggered:
withContext = [e for e in triggered if text(field(e, 'assetPath')) and text(field(e, 'itemName'))]
check(withContext, 'Issued FAIs have the machine and the part filled in',
'The run supplies them. Start the run with a product selected on the Product tab.')
if not [e for e in triggered if text(field(e, 'assetPath')) == FIRST_MACHINE]:
note('No FAI was issued on Machine 1 yet. The lesson starts with Machine 1.')

approved = [e for e in events if text(field(e, 'chkShtStateName')) == 'Approved']
machines = sorted(set(text(field(e, 'assetPath')).split('\\')[-1] for e in approved if text(field(e, 'assetPath')).startswith(AREA)))
check(len(machines) >= 2, 'FAIs are completed on two machines (%s)' % (', '.join(machines) or 'none'),
'Complete an FAI on Machine 1 and another on a second machine: enter three diameters, two lengths and a visual result, then submit.')
if approved:
byName = eventItems(approved[0])
diameters = readings(byName.get('Diameter'))
lengths = readings(byName.get('Length'))
check(len(diameters) >= 3 and len(lengths) >= 2, 'The latest completed FAI has three diameters and two lengths',
'It has %d diameter and %d length reading(s). Enter every measurement before submitting.' % (len(diameters), len(lengths)))
if not [r for r in byName.get('Visual Defect Check', []) if text(field(r, 'chkItemValue'))]:
note('The latest completed FAI has no visual result.')

unfinished = [e for e in events if text(field(e, 'chkShtStateName')) in UNFINISHED]
check(unfinished, 'An FAI is left unfinished, for the next lesson to analyze',
'Start a run on another machine and leave its FAI unfinished.')

passed = results.count(True)
print '\n' + '=' * 70
print 'Result: %d of %d checks passed' % (passed, len(results))
if passed == len(results):
print 'All good. Your FAI is triggered by production runs.'
else:
print 'Fix the FAIL items above, then run this again.'
print '=' * 70
Finished check sheet

check-sheet-machining-first-article-inspection.json: the finished FAI check sheet, including the FAI Diameter tolerances, to compare with your build.