Item Sets and Attribute Tolerances
Item Sets and the FAI Diameter Attribute
All nine machined parts are in one item class, CoreForge\WIP\Machined, but they belong to three families with different specs. An item set groups items when the item classes don't match the grouping you need. Each item can belong to only one item set.
- Navigate to Configuration → Quality → Item Sets and click the pencil icon (Edit Item Sets) on the left side to open the item set editor.
- Create three enabled item sets:
Coupling Pins,Precision RodsandShaft Cores. - Link
CP-2024,CP-6061andCP-7075toCoupling Pins, thePR-items toPrecision Rods, and theSC-items toShaft Cores.
An attribute is a named quality variable, such as a diameter, that check items can refer to. Its tolerances can be set per asset, item, item set, or for all items, so the check item doesn't need a hard-coded spec.
-
Navigate to Configuration → Quality → Attributes.
-
Create the folder
CoreForgeand a sub-folder underneath calledMachining. -
Create an attribute
FAI Diameterin the folderCoreForge\Machining. -
On its Tolerance tab, add one tolerance for each item set (all values in mm):
Item set LEL LSL LCL Target UCL USL UEL Coupling Pins9.85 9.90 9.95 10.00 10.05 10.10 10.15 Precision Rods14.80 14.88 14.94 15.00 15.06 15.12 15.20 Shaft Cores24.70 24.82 24.91 25.00 25.09 25.18 25.30 Show the FAI Diameter Attributes

-
Make sure Enabled is checked (it is for a new tolerance), and save.
A value between the control and spec limits passes but is highlighted as a warning. A value outside the spec limits (LSL/USL) fails. A value outside the entry limits (LEL/UEL) can't be entered.
Check Your Work
Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks that the three item sets are enabled with the right three parts each, that FAI Diameter is in CoreForge\Machining, and that it has an enabled tolerance for each item set with the limits in the table. Each check prints PASS or FAIL with what to fix. It doesn't change anything.
Show the check script
# Kanoa Quality Training - check "Item Sets and Attribute Tolerances" (First Article Inspection, 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.
ITEM_SETS = [
('Coupling Pins', ['CP-2024', 'CP-6061', 'CP-7075']),
('Precision Rods', ['PR-2024', 'PR-6061', 'PR-7075']),
('Shaft Cores', ['SC-2024', 'SC-6061', 'SC-7075']),
]
ATTRIBUTE = 'CoreForge\\Machining\\FAI Diameter'
LIMITS = ['lel', 'lsl', 'lcl', 'tgt', 'ucl', 'usl', 'uel']
TOLERANCES = {
'Coupling Pins': [9.85, 9.90, 9.95, 10.00, 10.05, 10.10, 10.15],
'Precision Rods': [14.80, 14.88, 14.94, 15.00, 15.06, 15.12, 15.20],
'Shaft Cores': [24.70, 24.82, 24.91, 25.00, 25.09, 25.18, 25.30],
}
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]
print '=' * 70
print 'Kanoa Quality Training - Item Sets and Attribute Tolerances check'
print '=' * 70
# 1. Item sets and their items
print '\n-- Item sets'
sets = rows(system.kanoa.quality.config.getItemSets({}))
setIds = {}
for name, items in ITEM_SETS:
found = [s for s in sets if text(field(s, 'itemSetName')) == name] or [s for s in sets if key(field(s, 'itemSetName')) == key(name)]
if not found:
check(False, 'Item set %s exists' % name, 'In Configuration > Quality > Item Sets, open the item set editor and add %s.' % name)
continue
s = found[0]
setIds[name] = field(s, 'itemSetId')
actual = text(field(s, 'itemSetName'))
check(actual == name, 'Item set %s exists' % name, "Found '%s'. Rename it to %s." % (actual, name))
check(truthy(field(s, 'enabled')), '%s is enabled' % name, 'Edit the item set and select Enabled.')
links = [l for l in rows(system.kanoa.quality.config.getItemSetLinks({'itemSetId': field(s, 'itemSetId')}))
if truthy(field(l, 'enabled')) or field(l, 'enabled') is None]
linked = sorted(text(field(l, 'itemName')) for l in links)
missing = [i for i in items if i not in linked]
extra = [i for i in linked if i not in items]
check(not missing and not extra, '%s has %s' % (name, ', '.join(items)),
'Link %s%s.' % (', '.join(missing) or 'nothing more', ('; unlink %s' % ', '.join(extra)) if extra else ''))
# 2. The FAI Diameter attribute
print '\n-- FAI Diameter attribute'
attrs = rows(system.kanoa.quality.config.getAttributes({}))
attr = ([a for a in attrs if text(field(a, 'path')) == ATTRIBUTE] or [None])[0]
if attr is None:
elsewhere = [text(field(a, 'path')) for a in attrs if key(field(a, 'attributeName')) == key('FAI Diameter')]
check(False, 'Attribute %s exists' % ATTRIBUTE,
("Found it at '%s'. Move it to the CoreForge\\Machining folder." % elsewhere[0]) if elsewhere else
'In Configuration > Quality > Attributes, create the folders CoreForge and Machining, then the attribute FAI Diameter in Machining.')
else:
check(True, 'Attribute %s exists' % ATTRIBUTE)
# 3. One tolerance per item set
print '\n-- Tolerances'
tols = rows(system.kanoa.quality.config.getTolerances({'attributeId': field(attr, 'attributeId')}))
for name, items in ITEM_SETS:
mine = [t for t in tols if text(field(t, 'itemSetName')) == name or (name in setIds and field(t, 'itemSetId') == setIds[name])]
# a tolerance for the item set alone, not also tied to an item, class or asset
plain = [t for t in mine if field(t, 'itemId') is None and field(t, 'itemClassId') is None and field(t, 'assetId') is None]
t = (plain or mine or [None])[0]
if t is None:
check(False, '%s has a tolerance' % name, "On FAI Diameter's Tolerance tab, add a tolerance for the item set %s." % name)
continue
wrong = ['%s %s (should be %s)' % (lim.upper(), text(field(t, lim)) or 'blank', exp)
for lim, exp in zip(LIMITS, TOLERANCES[name]) if num(field(t, lim)) is None or abs(num(field(t, lim)) - exp) > 0.0001]
check(not wrong, '%s tolerance is %s' % (name, ' / '.join('%g' % v for v in TOLERANCES[name])),
'Edit the %s tolerance: %s.' % (name, '; '.join(wrong)))
check(truthy(field(t, 'enabled')), '%s tolerance is enabled' % name, 'Edit the tolerance, select Enabled and save.')
if not plain:
note('The %s tolerance is also tied to an item, item class or asset. The lesson sets it for the item set only.' % name)
passed = results.count(True)
print '\n' + '=' * 70
print 'Result: %d of %d checks passed' % (passed, len(results))
if passed == len(results):
print 'All good. The item sets and FAI Diameter tolerances are set up.'
else:
print 'Fix the FAIL items above, then run this again.'
print '=' * 70

