Build the Analyzer Check Sheet
qaStationTags.json: a QA Station folder with simulated analyzer tags qds/particleSize and qds/density.
- Navigate to Configuration → Ops → Assets
- Under
CoreForge\Philadelphia\Finishing, add an asset namedQA Stationof typeLine. Leave OEE disabled; the QA Station doesn't produce anything. - In Ignition Designer, in the
Kanoatag provider, select theCoreForge/Philadelphia/Finishingfolder and importqaStationTags.json(downloaded above). The file createsQA Station/qds. - Confirm
particleSizeanddensityare changing.
A test fail action runs when a check fails. It can email a person or team, or issue another check sheet. A follow-up check gives failure handling a structure, such as a photo, a disposition, or a corrective action, rather than relying on a comment.
- In Configuration → Quality → Check Sheets, add
QA Station Inspection Failurein theCoreForge\Operationsfolder. - Add one check item,
Inspection Image: TypeCheck, Data TypeImage, Enabled and Required. - Close the editor and release the sheet. Only released sheets can be issued by a test fail action.
check-sheet-qa-station-inspection-failure.json: the finished helper sheet.
- In Configuration → Quality → Attributes, create a
QAfolder underCoreForge, with the attributesParticle SizeandParticle Density. - Give
Particle Sizea data source on assetQA Stationwith tagqds/particleSize, andParticle Densityone with tagqds/density. Enable both and save.
-
In Configuration → Quality → Check Sheets, add
Offline Lab Inspectionin theCoreForge\Operationsfolder. -
On the Settings tab:
- Select Asset Required and choose
QA Station. - Select Sign Off Required.
- Set Issue Check Sheet to
QA Station Inspection Failure. Leave Notifications empty.
- Select Asset Required and choose
-
On the Checks tab, rename the default group
MaintoAnalyzer, and add these items to it. All are Enabled.Check item Type Data type Required Settings Get Analyzer DataTrigger Boolean No Particle SizeCheck Float Yes Attribute Particle Size, unitsnm, triggerGet Analyzer DataParticle DensityCheck Float Yes Attribute Particle Density, units%, format0.0, triggerGet Analyzer DataStandard DeviationCalculated Float No Aggregate: standard deviation of Particle SizeandParticle DensityCoverageCalculated Float No Eval: 'Analyzer\Particle Size'*'Analyzer\Particle Density' -
Add a group named
Calibrationwith one item,Analyzer Calibration Date: TypeCheck, Data TypeDatetime, Required and Persistent. -
Save and release.
check-sheet-offline-lab-inspection.json: The finishedOffline Lab Inspection
What each new feature does:
- Trigger item: works like a button in the check. Every item whose trigger is
Get Analyzer Datareads its attribute's data source at the same moment. - Calculated items: store derived values in the check, either an aggregate across items or a formula. In a formula, refer to items by group and name.
- Groups: split a long check into tabs.
- Persistent: fills in the value entered last time, which suits a calibration date that only changes occasionally.
- Sign Off Required: a submitted check waits in Submitted until someone with the Approve Checks function approves it.
Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks the QA Station asset and its analyzer tags, the QA Station Inspection Failure sheet, the Particle Size and Particle Density data sources, and the Offline Lab Inspection settings, groups and check items, including the triggers, calculations and the Persistent calibration date. 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 Analyzer Check Sheet" (Offline Lab Inspection, lesson 2)
#
# 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 time
ASSET = 'CoreForge\\Philadelphia\\Finishing\\QA Station'
TAG_FOLDER = '[Kanoa]CoreForge/Philadelphia/Finishing/QA Station/qds'
FOLDER = 'CoreForge\\Operations'
HELPER = 'QA Station Inspection Failure'
SHEET = 'Offline Lab Inspection'
ATTRIBUTES = [
# attribute path, data source tag under the QA Station folder
('CoreForge\\QA\\Particle Size', 'qds/particleSize'),
('CoreForge\\QA\\Particle Density', 'qds/density'),
]
GROUPS = ['Analyzer', 'Calibration']
ITEMS = [
# group, name, type, data type, required
('Analyzer', 'Get Analyzer Data', 'Trigger', 'Boolean', False),
('Analyzer', 'Particle Size', 'Check', 'Float', True),
('Analyzer', 'Particle Density', 'Check', 'Float', True),
('Analyzer', 'Standard Deviation', 'Calculated', 'Float', False),
('Analyzer', 'Coverage', 'Calculated', 'Float', False),
('Calibration', 'Analyzer Calibration Date', 'Check', 'Datetime', True),
]
COVERAGE = "'Analyzer\\Particle Size'*'Analyzer\\Particle Density'"
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 calc(item):
try:
return dict(system.util.jsonDecode(text(field(item, 'calculation')))) if text(field(item, 'calculation')) else {}
except:
return {}
def squash(v):
return ''.join(text(v).split()).replace('\\\\', '\\')
def exists(path):
try:
return bool(path) and system.tag.exists(path)
except:
return False
def normTag(path):
return text(path).replace('\\', '/').strip('/').lower()
def sheetBasics(name, sheet):
actual = text(field(sheet, 'chkShtName'))
check(actual == name, 'Check sheet %s exists' % name, "Found '%s'. Rename it to %s." % (actual, name))
folder = text(field(sheet, 'chkShtTypePath'))
check(folder == FOLDER, '%s is in the %s folder' % (name, FOLDER),
"It's in '%s'. On the Settings tab, set the folder to %s." % (folder or 'no folder', FOLDER))
state = text(field(sheet, 'chkShtVersionStateName'))
check(state == 'Released', '%s is Released' % name,
"It's %s. Close the editor and change its status to Released." % (state or 'not set'))
print '=' * 70
print 'Kanoa Quality Training - Build the Analyzer Check Sheet check'
print '=' * 70
# 1. The QA Station asset and its tags
print '\n-- QA Station'
assets = dict((text(field(r, 'assetPath', 'path')), r) for r in rows(system.kanoa.asset.getAssets({})))
station = assets.get(ASSET)
check(station is not None, 'QA Station exists under Finishing',
'In Configuration > Ops > Assets, add an asset named QA Station of type Line under CoreForge\\Philadelphia\\Finishing.')
if station is not None:
assetType = text(field(station, 'assetTypeName')).lower()
check(assetType == 'line', 'QA Station is a Line', "It's a '%s'. Open it and set its type to Line." % (assetType or 'blank'))
if truthy(field(station, 'oeeEnabled', 'oeeEnable')):
note("QA Station is OEE Enabled. The lesson leaves OEE disabled because it doesn't produce anything.")
tags = [TAG_FOLDER + '/' + n for n in ('particleSize', 'density')]
missing = [t.split('/')[-1] for t in tags if not exists(t)]
check(not missing, 'The analyzer tags exist (%s)' % TAG_FOLDER,
'Missing: %s. In the Designer, select CoreForge/Philadelphia/Finishing in the Kanoa provider and import qaStationTags.json.' % ', '.join(missing))
if not missing:
first = system.tag.readBlocking(tags)
time.sleep(2)
second = system.tag.readBlocking(tags)
still = [t.split('/')[-1] for t, a, b in zip(tags, first, second) if not a.quality.isGood() or a.value == b.value]
check(not still, 'The analyzer tags are changing', "%s didn't change in 2 seconds. Check they imported as expression tags." % ', '.join(still))
# 2. The helper check sheet
print '\n-- %s' % HELPER
helper, helperVersions = findSheet(HELPER)
if helper is None:
check(False, 'Check sheet %s exists' % HELPER, 'In Configuration > Quality > Check Sheets, add %s in the %s folder.' % (HELPER, FOLDER))
else:
sheetBasics(HELPER, helper)
image = findItem(rows(system.kanoa.quality.config.getChecks({'chkShtId': field(helper, 'chkShtId')})), 'Inspection Image')
ok = image is not None and text(field(image, 'dataTypeName')) == 'Image' and truthy(field(image, 'enabled')) and truthy(field(image, 'required'))
check(ok, 'It has an enabled, required Image item named Inspection Image',
'Add a check item Inspection Image: Type Check, Data Type Image, Enabled and Required.')
# 3. The analyzer attributes
print '\n-- Analyzer attributes'
attrs = rows(system.kanoa.quality.config.getAttributes({}))
for path, tag in ATTRIBUTES:
name = path.split('\\')[-1]
attr = ([a for a in attrs if text(field(a, 'path')) == path] or [None])[0]
if attr is None:
check(False, 'Attribute %s exists' % path, 'In Configuration > Quality > Attributes, add a QA folder under CoreForge and create %s in it.' % name)
continue
sources = [s for s in rows(system.kanoa.quality.config.getDataSource({'attributeId': field(attr, 'attributeId')}))
if text(field(s, 'assetPath')) == ASSET]
source = normTag(field(sources[0], 'sourceTagPath')) if sources else ''
ok = sources and (source == normTag(tag) or source.endswith('/' + normTag(tag))) and truthy(field(sources[0], 'enabled'))
check(ok, '%s reads %s on QA Station' % (name, tag),
("Its data source is '%s'%s. " % (text(field(sources[0], 'sourceTagPath')), '' if truthy(field(sources[0], 'enabled')) else ', disabled') if sources else '') +
'On its Data Source tab, add asset QA Station with tag %s, enabled.' % tag)
# 4. The Offline Lab Inspection
print '\n-- %s' % SHEET
sheet, versions = findSheet(SHEET)
if sheet is None:
check(False, 'Check sheet %s exists' % SHEET, 'In Configuration > Quality > Check Sheets, add %s in the %s folder.' % (SHEET, FOLDER))
else:
sheetBasics(SHEET, sheet)
chkShtId = field(sheet, 'chkShtId')
linked = [text(field(r, 'assetPath')) for r in rows(system.kanoa.quality.sheet.getAssets(chkShtId))]
check(truthy(field(sheet, 'assetReqd')) and ASSET in linked, 'Asset Required is selected with QA Station',
'On the Settings tab, select Asset Required and choose QA Station.')
check(truthy(field(sheet, 'signOffReqd')), 'Sign Off Required is selected', 'On the Settings tab, select Sign Off Required.')
helperIds = [field(v, 'chkShtId') for v in helperVersions]
check(field(sheet, 'reTestChkShtId') is not None and field(sheet, 'reTestChkShtId') in helperIds,
'Issue Check Sheet is %s' % HELPER, 'On the Settings tab, set Issue Check Sheet to %s.' % HELPER)
print '\n-- Groups and check items'
groups = [text(field(g, 'chkItemGroupName')) for g in rows(system.kanoa.quality.config.getGroups({'chkShtId': chkShtId}))]
missingGroups = [g for g in GROUPS if g not in groups]
check(not missingGroups, 'It has the groups Analyzer and Calibration',
'Missing %s. Rename the default group Main to Analyzer, and add a group named Calibration. Groups now: %s.'
% (', '.join(missingGroups), ', '.join(groups) or 'none'))
items = rows(system.kanoa.quality.config.getChecks({'chkShtId': chkShtId}))
trigger = findItem(items, 'Get Analyzer Data')
for group, name, itemType, dataType, required in ITEMS:
item = findItem(items, name)
if item is None:
check(False, '%s exists' % name, 'Add %s to the %s group.' % (name, group))
continue
problems = []
actual = text(field(item, 'chkItemName'))
if actual != name:
problems.append("rename '%s' to %s" % (actual, name))
if text(field(item, 'chkItemGroupName')) != group:
problems.append("move it to the %s group (it's in %s)" % (group, text(field(item, 'chkItemGroupName')) or 'none'))
if text(field(item, 'chkItemTypeName')) != itemType:
problems.append("set Type to %s (it's %s)" % (itemType, text(field(item, 'chkItemTypeName')) or 'blank'))
if text(field(item, 'dataTypeName')) != dataType:
problems.append("set Data Type to %s (it's %s)" % (dataType, text(field(item, 'dataTypeName')) or 'blank'))
if not truthy(field(item, 'enabled')):
problems.append('select Enabled')
if truthy(field(item, 'required')) != required:
problems.append('select Required' if required else 'clear Required')
if name == 'Particle Size' or name == 'Particle Density':
attr = 'CoreForge\\QA\\' + name
if text(field(item, 'attributePath')) != attr:
problems.append("assign the attribute %s (it's %s)" % (name, text(field(item, 'attributePath')) or 'none'))
units = 'nm' if name == 'Particle Size' else '%'
if text(field(item, 'engUnitName')).lower() != units:
problems.append("set Units to %s (it's %s)" % (units, text(field(item, 'engUnitName')) or 'blank'))
if name == 'Particle Density' and text(field(item, 'format')) != '0.0':
problems.append("set Format to 0.0 (it's %s)" % (text(field(item, 'format')) or 'blank'))
if trigger is None or field(item, 'chkItemTriggerId') != field(trigger, 'chkItemId'):
problems.append('set its trigger to Get Analyzer Data')
elif name == 'Standard Deviation':
c = calc(item)
vals = squash(c.get('values'))
if text(c.get('formulaType')).upper() != 'STDDEV' or 'ParticleSize' not in vals or 'ParticleDensity' not in vals:
problems.append('set the calculator to the standard deviation aggregate of Particle Size and Particle Density')
elif name == 'Coverage':
c = calc(item)
if text(c.get('formulaType')).upper() != 'EVAL' or squash(c.get('values')) != squash(COVERAGE):
problems.append("set the calculator to Eval with %s (it's %s)" % (COVERAGE, text(c.get('values')) or 'blank'))
elif name == 'Analyzer Calibration Date' and not truthy(field(item, 'persistence')):
problems.append('select Persistent')
check(not problems, '%s\\%s is set up' % (group, name), '; '.join(problems).capitalize() + '.')
passed = results.count(True)
print '\n' + '=' * 70
print 'Result: %d of %d checks passed' % (passed, len(results))
if passed == len(results):
print 'All good. Both lab check sheets are built and released.'
else:
print 'Fix the FAIL items above, then run this again.'
print '=' * 70



