Build the Check Sheet
A check sheet is the reusable template for a check, like a blank form. Each question on the form is a check item. Nothing is recorded in this lesson; you're only building the form.
- Navigate to Configuration → Quality → Check Sheets.
- Click the add button and name the check sheet
Cleanliness Check. Click outside the field; Kanoa saves the sheet as soon as it has a name. - On the Settings tab, set the folder to
CoreForge\Safety, creating the folders with the folder button if they don't exist yet. Leave Asset Required, Item Required and Sign Off Required cleared.
- On the Checks tab, add a check item named
Machining Area: TypeCheck, Data TypeString, Enabled and Required selected. - Under Entry Options, choose
Textand add the responses:Cleanas Pass,Passableas Warning,Over-ClutteredandDirtyas Fail. - Save the check item.
- Use the duplicate button to copy
Machining Areathree times, and rename the copiesCoating Area,Mixing AreaandFinishing Area. - Confirm all four items have the same four responses.
The result category on each response is what makes the check pass or fail. A single Fail on a required item makes the whole check not OK. A Warning doesn't.
- Close the editor to return to the check sheet list. The new sheet's status is
Draft. - Change its status to
Released. - Open the sheet again and notice you can no longer change its items.
Operators can only run Released check sheets. Once a sheet is released, changes go through a new revision, so completed checks always point to the exact version that was used. You'll revise a sheet in the Receiving Inspection chapter.
Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks that Cleanliness Check is in CoreForge\Safety with Asset, Item and Sign Off Required cleared, that it's released, and that the four area items are enabled, required String checks with the Clean, Passable, Over-Cluttered and Dirty responses. Each check prints PASS or FAIL with what to fix. It doesn't change anything.
Show the check script
# Kanoa Quality Training - check "Build the Check Sheet" (Cleanliness Check, lesson 1)
#
# 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.
import re
SHEET = 'Cleanliness Check'
FOLDER = 'CoreForge\\Safety'
ITEMS = ['Machining Area', 'Coating Area', 'Mixing Area', 'Finishing Area']
RESPONSES = {'PASS': ['Clean'], 'WARNING': ['Passable'], 'FAIL': ['Dirty', 'Over-Cluttered'], 'NEUTRAL': []}
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 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 pickList(value):
"""The responses in each result category of a Text pick list."""
out = {}
for cat in ('PASS', 'WARNING', 'FAIL', 'NEUTRAL'):
m = re.search(r"""['"]%s['"]\s*:\s*\[(.*?)\]""" % cat, text(value))
found = re.findall(r"""'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)\"""", m.group(1)) if m else []
out[cat] = sorted(a or b for a, b in found)
return out
print '=' * 70
print 'Kanoa Quality Training - Build the Cleanliness Check check'
print '=' * 70
# 1. The check sheet and its settings
print '\n-- Check sheet'
sheet, versions = findSheet(SHEET)
if sheet is None:
check(False, 'Check sheet %s exists' % SHEET,
'In Configuration > Quality > Check Sheets, click the add button and name it %s.' % SHEET)
else:
actual = text(field(sheet, 'chkShtName'))
check(actual == SHEET, 'Check sheet %s exists' % SHEET, "Found '%s'. Rename it to %s." % (actual, SHEET))
folder = text(field(sheet, 'chkShtTypePath'))
check(folder == FOLDER, 'It is in the %s folder' % FOLDER,
"It's in '%s'. On the Settings tab, set the folder to %s (create the folders with the folder button)." % (folder or 'no folder', FOLDER))
for col, label in (('assetReqd', 'Asset Required'), ('itemReqd', 'Item Required'), ('signOffReqd', 'Sign Off Required')):
check(not truthy(field(sheet, col)), '%s is cleared' % label, 'On the Settings tab, clear %s.' % label)
state = text(field(sheet, 'chkShtVersionStateName'))
check(state == 'Released', 'It is Released',
"It's %s. Close the editor and change its status to Released." % (state or 'not set'))
# 2. The four check items and their responses
if sheet is not None:
print '\n-- Check items'
items = rows(system.kanoa.quality.config.getChecks({'chkShtId': field(sheet, 'chkShtId')}))
for name in ITEMS:
item = findItem(items, name)
if item is None:
check(False, '%s exists' % name,
'On the Checks tab, duplicate Machining Area and rename the copy %s.' % name)
continue
actual = text(field(item, 'chkItemName'))
problems = []
if actual != name:
problems.append("rename '%s' to %s" % (actual, name))
if text(field(item, 'chkItemTypeName')) != 'Check':
problems.append('set Type to Check')
if text(field(item, 'dataTypeName')) != 'String':
problems.append('set Data Type to String')
if not truthy(field(item, 'enabled')):
problems.append('select Enabled')
if not truthy(field(item, 'required')):
problems.append('select Required')
check(not problems, '%s is an enabled, required String check' % name, '; '.join(problems).capitalize() + '.')
listName = text(field(item, 'pickListName'))
responses = pickList(field(item, 'pickListValues'))
wrong = [cat for cat in RESPONSES if responses[cat] != sorted(RESPONSES[cat])]
if listName != 'Text':
check(False, '%s uses the Text entry options' % name,
"Its entry option is '%s'. Under Entry Options, choose Text." % (listName or 'none'))
else:
check(not wrong, '%s has the four responses' % name,
'Under Entry Options, set Clean as Pass, Passable as Warning, Over-Cluttered and Dirty as Fail. Now: %s'
% '; '.join('%s %s' % (cat, ', '.join(responses[cat]) or 'none') for cat in ('PASS', 'WARNING', 'FAIL', 'NEUTRAL')))
extra = [text(field(i, 'chkItemName')) for i in items if key(field(i, 'chkItemName')) not in [key(n) for n in ITEMS]]
if extra:
note('Other items on the sheet: %s. The lesson only has the four areas.' % ', '.join(extra))
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 Cleanliness Check is built and released.'
else:
print 'Fix the FAIL items above, then run this again.'
print '=' * 70
check-sheet-cleanliness-check.json: The finished Cleanliness Check


