Configure Modes
Modes define the intended operation of an asset, whereas state indicates what actually happened. For example, an asset is scheduled to be in production (mode) for 10 hours. During that time it was running (state) for 9 hours and down (state) for 1 hour.
- Navigate to Configuration → Ops → Assets.
- On the Modes tab, click the + button to add a new mode.
- Configure the mode as follows:
- Name: Audit
- Enabled: True
- Type: Other
- Can Schedule: True
- Can Select: False (not manually selectable) This allows Audit to be scheduled, but an operator cannot set the mode of the line to Audit.
- Select
Spray Line 1and select all modes. Click the Link button to link these modes to this asset. - Select
Machine 1and select all modes except Audit. Click the Link button to link these modes to this asset. - Select
Manual Pack 1and select all modes except Audit. Click the Link button to link these modes to this asset.
Copy this script into the Ignition Designer Script Console (Tools → Script Console) and run it. It checks the Audit mode's settings, that Spray Line 1 has every mode linked, and that Machine 1 and Manual Pack 1 have every mode except Audit. Each check prints PASS or FAIL with what to fix. It doesn't change anything.
Show the check script
# Kanoa Ops Training - check "Configure Modes" (Base Configuration, lesson 5)
#
# 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.
AUDIT = 'Audit'
LINES = [
# asset path, should Audit be linked?
('CoreForge\\Philadelphia\\Coating\\Spray Line 1', True),
('CoreForge\\Philadelphia\\Machining\\Machine 1', False),
('CoreForge\\Philadelphia\\Finishing\\Manual Pack 1', False),
]
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 field(row, *names):
for n in names:
if n in row and row[n] is not None:
return row[n]
return None
def truthy(v):
return str(v).lower() in ('true', '1', 'yes')
def text(v):
return '' if v is None else unicode(v).strip()
def rows(fn, params):
return system.kanoa.utilities.convertDatasetToJSON(fn(params))
print '=' * 70
print 'Kanoa Ops Training - Configure Modes check'
print '=' * 70
modes = rows(system.kanoa.asset.getModes, {})
byName = dict((text(field(m, 'modeName')), m) for m in modes)
enabledModes = sorted(n for n, m in byName.items() if n and truthy(field(m, 'enabled')))
# 1. The Audit mode
print '\n-- The Audit mode'
audit = byName.get(AUDIT)
if audit is None:
near = [n for n in byName if n.lower() == AUDIT.lower()]
if near:
fix = "Found '%s'. Rename it to 'Audit' (names are case-sensitive)." % near[0]
else:
fix = "On the Modes tab of Configuration > Ops > Assets, click + and add a mode named Audit."
check(False, 'A mode named Audit exists', fix)
else:
check(True, 'A mode named Audit exists')
check(truthy(field(audit, 'enabled')), 'Audit is enabled', 'Edit Audit and set Enabled to True.')
modeType = text(field(audit, 'modeTypeName'))
check(modeType.lower() == 'other', 'Audit type is Other',
"It's '%s'. Edit Audit and set Type to Other." % (modeType or 'blank'))
check(truthy(field(audit, 'canSchedule')), 'Audit can be scheduled (Can Schedule = True)',
'Edit Audit and set Can Schedule to True.')
check(not truthy(field(audit, 'canSelect')), 'Audit cannot be selected by operators (Can Select = False)',
'Edit Audit and set Can Select to False, so Audit can be scheduled but not chosen by an operator.')
# 2. Mode links on the line assets
for assetPath, wantAudit in LINES:
asset = assetPath.split('\\')[-1]
print '\n-- Modes linked to %s' % asset
links = rows(system.kanoa.asset.getAssetModes, {'assetPath': assetPath})
linked = set(text(field(r, 'modeName')) for r in links
if text(field(r, 'assetPath')) in ('', assetPath)
and (field(r, 'linkEnabled') is None or truthy(field(r, 'linkEnabled'))))
expected = [m for m in enabledModes if m != AUDIT or wantAudit]
missing = [m for m in expected if m not in linked]
check(not missing, '%s has every mode%s linked' % (asset, '' if wantAudit else ' except Audit'),
'Select %s, select %s, and click Link.' % (asset, ', '.join(missing)))
if wantAudit:
check(AUDIT in linked, 'Audit is linked to %s' % asset,
'Select %s, select Audit, and click Link.' % asset)
else:
check(AUDIT not in linked, 'Audit is NOT linked to %s' % asset,
'Audit is only for Spray Line 1. Select %s, select Audit, and unlink it.' % asset)
passed = sum(1 for r in results if r)
print '\n' + '=' * 70
if passed == len(results):
print 'All %d checks passed. Configure Modes is complete.' % len(results)
else:
print '%d of %d checks passed. Fix the FAIL items above and run this again.' % (passed, len(results))
print '=' * 70
If you want to check your work, or skip ahead, you can import the updated asset hierarchy with the new modes instead of building it by hand.
Downloadcoreforge-asset-model-modes-export-3Import it on the asset configuration screen (Configuration → Ops → Assets). See Creating Assets.

