Sepasoft MES Module Suite
system.mes.spc.controllimit.calcControlLimitValue(locationPath, definition, attributeName, limitName, [fromDate], [toDate], [spcData], [dataFormatName])
This function calculates values from control limits passed in with a dataset. Two versions of this function include providing the data as a Dataset or a date range to use when calculating the control limit. Only control limits that have a Calculation Script defined can be calculated.
![]() | To set the control limit value rather than calculate, use the setControlLimitValue function with the result from this function. |
![]() | By default, the system uses up to six decimal-point places in control-limit values: Use the Attribute Property format property to change the default |
Syntax
system.mes.spc.controllimit.calcControlLimitValue(locationPath, definition, attributeName, limitName, [fromDate], [toDate], [spcData], [dataFormatName])
Parameters
Parameter & Data Type | Description & Requirements |
locationPath String | Required. The path of the location where the limit value is being calculated. |
definition | Required. The SPC sample definition object that contains the limit value being calculated. |
attributeName String | Required. The name of the attribute for which the limit value is being calculated. |
limitName String | Required. The name of the specific control limit to calculate. |
fromDate Date | Optional. The beginning date of the data to use for the calculation. Must be included if not passing a dataset. This parameter is ignored if spcData is provided. |
toDate Date | Optional. The ending date of the data to use for the calculation. Must be included if not passing a dataset. This parameter is ignored if spcData is provided. |
spcData Dataset | Optional. A dataset object containing the SPC data to use for the calculation. Must be included if not passing a date range. The data must be an spc data dataset. If this parameter is provided, it is used for the calculation and the fromDate and toDate parameters are ignored. |
dataFormatName String | Required. The data format to use for the calculation (Calculation kind types or control chart type). |
Returns
Python Dictionary - A Dictionary containing data:dataset, calculatedValue:float value, message:message (if exists).
Code Example
In this example, the script first defines and retrieves all the necessary inputs. It gets the MESSampleDefinition object and sets string variables for the locationPath, attributeName, and limitName. It then establishes a date range spanning the last three days. All four required arguments (definition, locationPath, attributeName, limitName) are passed to the function, along with the date range parameters. Because the spcData argument is not provided, the function uses the fromDate and toDate arguments to query the necessary historical data for the calculation.
Python |
defName = 'Single Attribute' definition = system.mes.spc.definition.getSampleDefinition(defName) locationPath = 'Enterprise\\El Dorado Hills\\Packaging Area\\Packaging Line 1\\Inspection Station 1' attributeName = 'Diameter' limitName = 'Individual UCL' fromDate = system.date.addDays(system.date.now(), -3) toDate = system.date.now() returnValue = system.mes.spc.controllimit.calcControlLimitValue(definition, locationPath, attributeName, limitName, fromDate=fromDate, toDate=toDate) print type(returnValue) print returnValue |
Returns:
This output is the Python dictionary returned by the function. It confirms that the data key contains a dataset of 333 rows, the calculatedValue is 6.5206207252433135, and the message string is empty, indicating a successful calculation.
Python |
>>> <type 'dict'> {u'data': Dataset [333R x 13C], u'calculatedValue': 6.5206207252433135, u'message': u''} >>> |
Sepasoft MES Module Suite

