Skip to main content

Run and Validate

Run a normal inspection
  1. In Quality → Schedule → Active Checks, add an Offline Lab Inspection for asset QA Station and open it.
  2. On the Analyzer tab, click Get Analyzer Data, then Take Measurement. Particle Size and Particle Density fill in, and Standard Deviation and Coverage are calculated.
  3. On the Calibration tab, enter the analyzer calibration date.
  4. Submit. The check stays in Submitted because the sheet requires sign-off. Approve it.

The test fail action didn't fire, and couldn't as nothing on the sheet has a spec yet. You'll add one through a revision.

Add a tolerance to Particle Size
  1. In Configuration → Quality → Check Sheets, set Offline Lab Inspection to In Revision and open it.
  2. Open Particle Size and set its specification to Tolerance: LEL 0, LSL 25, LCL 50, Target 75, UCL 100, USL 125, UEL 150.
  3. Save, close, and release the sheet.
Force a failure
  1. Add another Offline Lab Inspection for QA Station, and capture the analyzer data.
  2. Overwrite Particle Size with 10. It's below the LSL of 25 but above the entry limit of 0, so Kanoa accepts it and marks it as failed.
  3. Enter the calibration date, add a comment for the failure, and submit.
  4. Watch for the message that a follow-up check was issued. The retest check sheet is issued when the failed check is submitted, before anyone approves it.
  5. Approve the lab inspection. Then in Active Checks, open the QA Station Inspection Failure check, add an image, and submit it.
  6. Add one more Offline Lab Inspection. The Calibration tab now shows the date you entered last time.
Reference Materials: Tolerance limits and how values are evaluated

Tolerances​

One or more specifications (or tolerances) can be added to an attribute. A tolerance can be applied to all items by leaving the Asset, Item and Item Set fields blank. Otherwise, the Asset and Item selectors can be used to set tolerances by individual item, asset or item set. To add a new tolerance, click the

Add Tolerance button on the left of the Tolerance tab.

When a check is to be taken, it will first check if a tolerance exists for the current item. If no tolerance is found, it will check if the current item belongs to an item set that has a tolerance. If no item set tolerance has been configured, it will use the tolerance defined for all items.

Only enabled tolerances are used. Clear a tolerance's Enabled checkbox to stop it applying without deleting it; the next best-fit enabled tolerance is used instead. A new tolerance starts enabled, and the table's Enabled column shows each one's setting.

Attributes

Tolerance Parameters

  • LEL Lower Entry Limit: Defines the minimum value that can be entered.
  • LSL Lower Spec Limit: Defines the lower Pass / Fail condition. Failing values will be highlighted red.
  • LCL Lower Control Limit: Defines the lower limit condition. Values below the LCL will be considered as passing but will be highlighted orange.
  • Target: Defines the expected ideal value
  • UCL Upper Control Limit: Defines the upper limit condition. Values exceeding the UCL will be considered as passing but will be highlighted orange.
  • USL - Upper Spec Limit: Defines the upper Pass / Fail condition. Failing values will be highlighted red.
  • UEL - Upper Entry Limit: Defines the maximum value that can be entered.
note

Tolerance parameter values must make logical sense or will be highlighted in red as a warning. For instance, the Upper Entry Limit cannot be smaller than the Lower Entry Limit.

Check your work

Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks for an approved inspection with every reading and the calibration date, the Particle Size tolerance added through a revision, an approved failed inspection with a comment, the completed QA Station Inspection Failure check it issued, and the calibration date carried over to the newest inspection. Each check prints PASS or FAIL with what to fix. It doesn't change anything.

Show the check script
checkLesson-labRun.py
# Kanoa Quality Training - check "Fill Out The Check Sheet" (Offline Lab 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 = 'Offline Lab Inspection'
HELPER = 'QA Station Inspection Failure'
ASSET = 'CoreForge\\Philadelphia\\Finishing\\QA Station'
LIMITS = ['lel', 'lsl', 'lcl', 'tgt', 'ucl', 'usl', 'uel']
TOLERANCE = [0, 25, 50, 75, 100, 125, 150]
ANALYZER = ['Particle Size', 'Particle Density', 'Standard Deviation', 'Coverage']
CALIBRATION = 'Analyzer Calibration Date'
FORCED_VALUE = 10

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 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 findItem(items, name):
exact = [i for i in items if text(field(i, 'chkItemName')) == name]
close = [i for i in items if key(field(i, 'chkItemName')) == key(name)]
return (exact or close or [None])[0]

def spec(item):
try:
return dict(system.util.jsonDecode(text(field(item, 'specification')))) if text(field(item, 'specification')) else {}
except:
return {}

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 value(byName, name):
vals = [field(r, 'chkItemValue') for r in byName.get(name, []) if text(field(r, 'chkItemValue'))]
return vals[0] if vals else None

def failed(event, byName):
if (num(field(event, 'failedChecks')) or 0) > 0:
return True
return any(text(field(r, 'chkItemStateName')).upper() == 'FAIL' for rs in byName.values() for r in rs)

print '=' * 70
print 'Kanoa Quality Training - Run and Validate the Offline Lab Inspection 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:
events = sheetEvents(versions)
details = [(e, eventItems(e)) for e in events]

# 1. A normal inspection, approved
print '\n-- Normal inspection'
approved = [(e, b) for e, b in details if text(field(e, 'chkShtStateName')) == 'Approved']
good = [(e, b) for e, b in approved if not failed(e, b)]
check(good, 'An inspection with no failures is Approved',
'Add an %s for QA Station, click Get Analyzer Data and Take Measurement, enter the calibration date, submit, then approve it.' % SHEET)
if good:
e, b = good[0]
empty = [n for n in ANALYZER if value(b, n) is None]
check(not empty, 'It has the analyzer readings and the calculated values',
'No value for %s. Click Get Analyzer Data, then Take Measurement, before submitting.' % ', '.join(empty))
check(value(b, CALIBRATION) is not None, 'It has the analyzer calibration date', 'Enter the date on the Calibration tab.')
submitted = [e for e, b in details if text(field(e, 'chkShtStateName')) == 'Submitted']
if submitted:
note('%d inspection(s) are waiting in Submitted. Approve them in Active Checks.' % len(submitted))

# 2. The Particle Size tolerance, added through a revision
print '\n-- Particle Size tolerance'
version = int(num(field(sheet, 'chkShtVersionNumber')) or 1)
state = text(field(sheet, 'chkShtVersionStateName'))
check(state == 'Released' and version > 1, 'The sheet is Released as a new revision (version %d)' % version,
'Set it to In Revision, add the tolerance, then set it back to Released.')
size = findItem(rows(system.kanoa.quality.config.getChecks({'chkShtId': field(sheet, 'chkShtId')})), 'Particle Size')
if size is None:
check(False, 'Particle Size exists', 'Add it as in the previous lesson.')
else:
s = spec(size)
tol = dict(s.get('tolerance') or {})
wrong = ['%s %s (should be %s)' % (lim.upper(), text(tol.get(lim)) or 'blank', exp)
for lim, exp in zip(LIMITS, TOLERANCE) if num(tol.get(lim)) != exp]
if text(s.get('specType')) != 'tolerance':
check(False, 'Particle Size has a Tolerance specification',
"Its specification is '%s'. Under Specification, choose Tolerance." % (text(s.get('specType')) or 'none'))
else:
check(not wrong, 'Particle Size tolerance is %s' % ' / '.join(str(v) for v in TOLERANCE), 'Edit the tolerance: %s.' % '; '.join(wrong))

# 3. The forced failure and the follow-up check
print '\n-- Forced failure'
failures = [(e, b) for e, b in details if failed(e, b)]
if not failures:
check(False, 'An inspection has failed',
'Add another inspection, capture the analyzer data, overwrite Particle Size with %d, comment and submit.' % FORCED_VALUE)
else:
e, b = failures[0]
check(True, 'An inspection has failed (Particle Size %s)' % text(value(b, 'Particle Size')))
if num(value(b, 'Particle Size')) != FORCED_VALUE:
note('The lesson overwrites Particle Size with %d, below the LSL of 25.' % FORCED_VALUE)
failRows = [r for rs in b.values() for r in rs if text(field(r, 'chkItemStateName')).upper() == 'FAIL']
if failRows:
check(any(text(field(r, 'comment')) for r in failRows), 'The failure has a comment', 'Add a comment for the failed value.')
state = text(field(e, 'chkShtStateName'))
check(state == 'Approved', 'The failed inspection is Approved', "It's %s. Approve it in Active Checks." % state)

helper, helperVersions = findSheet(HELPER)
followUps = sheetEvents(helperVersions) if helper is not None else []
check(followUps, 'The failure issued a %s check' % HELPER,
'Check the Offline Lab Inspection has Issue Check Sheet set to %s, which is released, then submit another failing inspection.' % HELPER)
if followUps:
done = [f for f in followUps if text(field(f, 'chkShtStateName')) == 'Approved']
withImage = [f for f in done if value(eventItems(f), 'Inspection Image') is not None]
check(withImage, 'The %s check is completed with an image' % HELPER,
'In Active Checks, open the %s check, add an image and submit it.' % HELPER)

# 4. Persistence of the calibration date
print '\n-- Persistent calibration date'
check(len(events) >= 3, 'Three inspections have been added (%d so far)' % len(events),
'Add one more %s to see the calibration date carried over.' % SHEET)
if len(details) >= 2:
latest = value(details[0][1], CALIBRATION)
check(latest is not None, 'The newest inspection already has the calibration date',
'Select Persistent on Analyzer Calibration Date (through a revision), then add another inspection.')

passed = results.count(True)
print '\n' + '=' * 70
print 'Result: %d of %d checks passed' % (passed, len(results))
if passed == len(results):
print 'All good. You have finished the Offline Lab Inspection.'
else:
print 'Fix the FAIL items above, then run this again.'
print '=' * 70