system.mes.spc.analysis.decodeFilters(filterList)

Sepasoft MES Module Suite

analysis.decodeFilters

Overview

The decodeFilters script function parses a list of SPC filter expressions into a map keyed by filter name. Each key can hold multiple values, which is useful when an SPC analysis spans several locations, product codes, or other filter dimensions. It is typically called after decodeList() to turn a comma- or pipe-separated filter string from SPCSettings into a structured map for scripting.

Syntax

JSON
system.mes.spc.analysis.decodeFilters(filterList)

Parameters

Parameter

Type

Required

Description

filterList

List

Required

A list of filter expression strings. Each item must use the form FilterName=FilterValue. Commonly produced by system.mes.spc.analysis.decodeList().

Return Value

Type

Description

Map

A map whose keys are filter names (for example, Location, Product Code, FromDate) and whose values are lists of strings containing all values assigned to that filter name. Returns an empty map when no valid expressions are found.

Filter Expression Format

Each item in filterList is split on the first = character:

Part

Description

Key

The filter name, such as Location, Product Code, FromDate, ToDate, UserToDate, Reference No, Shift, Sample Taken By, Sample Approved By, or a factor key prefixed with Factor:.

Value

The filter value, such as a location path, product code, or date string.

Behavior

Detail

Multiple values for one key

Repeated keys are grouped; all values are appended to the same list.

Invalid expressions

Items that do not contain exactly one = (key and value) are skipped.

Whitespace

Leading and trailing spaces are not trimmed from keys or values. Trim filter strings before calling when needed.

Scope / Availability

Context

Availability

Gateway scripts

Available via system.mes.spc.analysis

Client scripts

Available via system.mes.spc.analysis 

Designer scripts

Available via system.mes.spc.analysis 

Perspective / Vision

Available when the Quality module script module is installed

Example Usage

Minimal example

JSON
filterList = [
	'Location=Enterprise\\Site\\Area\\Quality Test Station 1',
	'Product Code=DEF'
]
filterMap = system.mes.spc.analysis.decodeFilters(filterList)
locationValues = filterMap.get('Location', [])

Parse filters from SPC settings

JSON
settings = system.mes.spc.analysis.loadStoredSPC('Weekly Weight Check')

# Split the stored filter string into individual expressions
filterList = system.mes.spc.analysis.decodeList(settings.getFilters())

# Group expressions by filter name
filterMap = system.mes.spc.analysis.decodeFilters(filterList)

# Read common filter values
locations = filterMap.get('Location', [])
productCodes = filterMap.get('Product Code', [])
fromDates = filterMap.get('FromDate', [])
toDates = filterMap.get('ToDate', [])

if locations:
	print 'Analyzing locations:', locations
if productCodes:
	print 'Product codes:', productCodes

Multiple values for the same filter

JSON
filters = (
	'Location=Enterprise\\Site\\Area\\Quality Test Station 1,'
	'Location=Enterprise\\Site\\Area\\Quality Test Station 2,'
	'Product Code=DEF'
)

filterList = system.mes.spc.analysis.decodeList(filters)
filterMap = system.mes.spc.analysis.decodeFilters(filterList)

# filterMap['Location'] contains both station paths
stations = filterMap.get('Location', [])
print 'Station count:', len(stations)

Related Functions

  • decodeList() — Splits a comma- or pipe-separated string into a list of filter expressions. Call this first when starting from an SPCSettings filter string.

  • encodeList() — Encodes a list of strings into a single pipe-separated string.
  • decodeParams() — Parses optional SPC parameters (not filters) into a map with one value per key.
  • createSettings() — Creates an SPCSettings object that accepts a filter string in its filters parameter.
  • getSPCResults() — Runs SPC analysis using an SPCSettings object whose filters can be parsed with decodeList() and decodeFilters().

Sepasoft MES Module Suite