Sample Definition

Sepasoft MES Module Suite

Sample Definition

The MES Sample Definition object holds all of the information defining a type of sample. A sample definition specifies the attributes to collect, the locations where sample data is collected from, the control limits that apply, and the SPC Rules that apply.

When samples are created, they are based on a sample definition. When sample measurement values are recorded, the sample definition is used to validate the measurement values. Other operations also refer back to the sample definition such as automatic scheduling of samples, auto evaluation of rules, etc.

Creation Script Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

A sub-set, 'helper' object, SPC Definition, that executes faster (doesn't load the entire Sample Definition object) can be loaded by the SPC Settings function, getDefinition(). See SPC Definition for a list of available function.

Methods

getAutoApprove()

Description

Returns the default auto approve samples setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting.

Syntax

getAutoApprove() 

  • Parameters

None

  • Returns

 boolean autoApprove - True, if the default value of the auto approve setting for this sample definition is true and False otherwise.

getComingDueMinutes()

Description

Returns the default coming due minutes setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting. The value represents the number of minutes required before a sample is due until the sample is considered coming due. For automatically scheduled samples, they are created prior to actual due time by the number of minutes of this setting.

Syntax

getComingDueMinutes() 

  • Parameters

None

  • Returns

 double comingDueMinutes - The number of minutes required before a sample is due until it is coming due.

getDefaultSampleSize()

Description

Returns the number of measurements that this sample definition is configured for.

Syntax

getDefaultSampleSize() 

  • Parameters

None

  • Returns

Integer sampleSize - The number of measurements associated with this sample definition.

getDescription()

Description

Returns the description of this sample definition.

Syntax

getDescription() 

  • Parameters

None

  • Returns

String description - The description given to this sample definition.

getIntervalCount()

Description

Returns the default interval for automatically scheduled samples based on this sample definition. Allowed locations that belong to this sample definition are initialized with this default interval. The units are defined by the Interval type defined for this sample definition.

Syntax

getIntervalCount() 

  • Parameters

None

  • Returns

 double interval - The interval associated with this scheduled samples.

getIntervalDuration()

Description

Retrieves the configured default duration for a given sample definition. Can be overridden per sample definition location.

Syntax

getIntervalDuration() 

  • Parameters

None

  • Returns

 double duration - The configured default duration of samples associated with the sample definition.

getName()

Description

Gets the name of this sample definition.

Syntax

getName()

  • Parameters

None

  • Returns

String name - The name of the sample definition.

getOverdueMinutes()

Description

Returns the default overdue minutes setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting.

Syntax

getOverdueMinutes() 

  • Parameters

None

  • Returns

 double overdueMinutes - The value represents the number of minutes required after a sample is due until the sample is considered overdue.

isModified()

Description

Returns true if this sample definition has been modified.

Syntax

isModified() 

  • Parameters

None

  • Returns

True, if the sample definition is modified.  

isNew()

Description

Returns true if this sample definition is new.

Syntax

isNew() 

  • Parameters

None

  • Returns

  True if the specified sample definition is new.

setAutoApprove(autoApprove)

Description

Sets the default auto approve samples setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting.

Syntax

setAutoApprove(autoApprove) 

  • Parameters

boolean autoApprove - The default value of auto approve setting for this sample definition is set to the desired boolean.

  • Returns

Nothing

setComingDueMinutes(comingDueMin)

Description

Sets the default coming due minutes setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting. The value represents the number of minutes required before a sample is due until the sample is considered coming due. For automatically scheduled samples, they are created prior to actual due time by the number of minutes of this setting.

Syntax

setComingDueMinutes(comingDueMin) 

  • Parameters

double comingDueMinutes - The number of minutes required before a sample is due until it is coming due.

  • Returns

None

setDefaultSampleSize(measurementCount)

Description

Sets this number of measurement to be used when creating samples based on the sample definition.

Syntax

setDefaultSampleSize(measurementCount) 

Sets the upper limit for Sample Counts before the Sample Definition Manager throws a warning and restarts the Count with Sample Definition parent's default value.

Additional Information

Information

0 is not accepted as a Sample Definition measurement count


A Sample Attribute cannot have a measurement count higher than its parent's default measurement count -

if you give a Sample Attribute a measurement count bigger than its parent's, Sample Definition Manager warns you and then, resets the attribute's measurement count to its parent default measurement count.


If the attribute measurement count is less than the sample definition measurement count the user will be warned but the value of the attribute measurement count will not be reset


  • Parameters

Integer measurementCount - If this value is non-zero, this number becomes the upper limit for the measurement count for each Sample Definition Attribute. Example: If this value is 5 and a Sample Definition Attribute's Measurement Count is set to 10, only 5 samples will be allowed to be collected.

  • Returns

Nothing

setDescription(description)

Description

Sets the description of this sample definition.

Syntax

setDescription(description) 

  • Parameters

String description - The description given to this sample definition.

  • Returns

Nothing

setInterval(interval)

Description

Sets the default interval type. Allowed locations that belong to this sample definition are initialized with this default interval. The units are defined by the Interval type defined for this sample definition.  Allowed interval names can be retrieved from the Enterprise Object.

Syntax

setInterval(interval) 


  • Parameters

 String interval - The interval to be set for the specified samples.

Available Default Options are:

Every Value Change
Every x Value Changes
Manual
Once at Production End
Once at Production Start
Shift Change
Timed Interval (Days)
Timed Interval (Hours)
Timed Interval (Minutes)
Timed Interval (Seconds)
Valve Inspection 

  • Returns

Nothing

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

setIntervalCount(count)

Description

Sets the default interval frequency for a given sample associated with a sample definition - how often the sample should be scheduled. Can be overridden per sample definition location.

Syntax

  • Parameters

Float intervalCount - Float value to set how often a sample should be scheduled.

  • Returns

Nothing

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

setIntervalDuration(duration)

Description

Sets the default duration of a given sample when associated with the sample definition - how long the sample should take to be collected. Can be overridden per sample definition location.

  • Parameters

Float intervalDuration - Float value to determine the total estimated length of time a sample is to be collected.  It will be used to schedule the next sample.

  • Returns

Nothing

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

setName(name)

Description

Sets a name for this sample definition.

Error

It is recommended that once samples have been created using a specific name, the name should not be changed.

Syntax

setName(name) 


  • Parameters

String name - Name to be set to the sample definition.

  • Returns

 Nothing

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

setOverdueMinutes(overdueMin)

Description

Sets the default overdue minutes setting for this sample definition. Allowed locations that belong to this sample definition are initialized with this default setting. The value represents the number of minutes required after a sample is due until the sample is considered overdue.

Syntax

setOverdueMinutes(overdueMin) 

  • Parameters

 double overdueMinutes - The value represents the number of minutes required after a sample is due until the sample is considered overdue.

  • Returns

  Nothing

Attributes

getPropertyUUID()

Getting Sample Definition UUID

To get an attribute UUID, you can load the Sample Definition Object  to get the attribute property and then you can get the UUID of that property.

getPropertyUUID()

Python
# Get MESSampleDefinition, extends from AbstractMESObject
sampleDefinition = system.mes.spc.definition.getSampleDefinition('Individual')
# Get MESSampleAttributeProperty, extends from AbstractComplexProperty
attribute = sampleDefinition.getSampleAttributeProperty('X')
# Get UUID from AbstractMESComplexProperty getPropertyUUID()
attributeUUID = attribute.getPropertyUUID()
print attributeUUID





addAttribute(attribute)

Description

Adds a new attribute defined in the attribute parameter.

Syntax

addAttribute(attribute)


  • Parameters

Sttring attribute - The attribute name to be added to the sample definition.

  • Returns

SampleDefinitionAttribute attribute - Returns the created object for editing.

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

getAllSampleAttributeProperties()

Description

Returns a list of all sample attribute property objects associated with this sample definition. 

Syntax

getAllSampleAttributeProperties()

  • Parameters

None

  • Returns

A list of SampleDefinitionAttribute Objects for this sample definition.

getSampleAttributePropertyByUUID(uuid)

Description

Returns the attribute specified by the id parameter.

Syntax

getSampleAttributePropertyByUUID(uuid)

  • Parameters

String uuiid - The identifier of the sample definition attribute property to return for.

  • Returns

 SampleDefinitionAttribute - The sample definition attribute object specified by the uuid parameter.

getSampleAttributeProperty(attribute name)

Description

Returns the attribute with the same name as the name parameter.

Syntax

getSampleAttributeProperty(attrubute name)

  • Parameters

String name - Name of the attribute to be returned for.

  • Returns

SampleDefinitionAttribute - The attribute specified by the name parameter.

removeAttribute(name)

Description

Removes the attribute defined in the name parameter. Instead of attributes being permanently removed, their enabled flag is set to false.

Syntax

removeAttribute(name)

  • Parameters

String name - The name of the attribute to be removed from this sample definition.

  • Returns

Nothing

Location

addLocation(locationPath)

Description

Adds a new allowed location defined in the location parameter. By adding an allowed location to this sample definition, this type of sample will appear as an option for the location and the real time location will be saved along with associated samples. For example, shift, product code, ref No and additional factor information is saved along with the sample data.

Syntax

addLocation(locationPath)


  • Parameters

String locationPath - The location equipment path to be added to this sample definition.

  • Returns

Nothing

getAllSampleLocationProperties(includeRemoved)

Description

Returns a list of all allowed locations associated with this sample definition. If the includeRemoved parameter is true, the results will include removed allowed locations that have not been committed by saving the sample definition.

Syntax

getAllSampleLocationProperties(includeRemoved )


  • Parameters

boolean includeRemoved - Set it to True if the results should include the removed locations and False otherwise.

  • Returns

List of Sample Definition Location - A list of all the locations associated with this sample definition is returned.

getSampleLocationPropertyByPath(locationPath)

Description

Returns the sample definition location object associated with the sample definition.

Syntax

getSampleLocationPropertyByPath(locationPath)


  • Parameters

String locationPath- The equipment path of the location to return for.

  • Returns

SampleDefinitionLocation - The sample definition location object specified by the name parameter.

removeLocation(locationPath)

Description

Removes the location defined by the locationPath parameter. Allowed locations are permanently removed but can be added back. SPC data is not lost and will appear in the control charts and analysis.

Syntax

removeLocation(locationPath)


  • Parameters

String locationPath - The Equipment Path of the location to be removed.

  • Returns

None


Control limit properties

addLimit(limitName)

Description

Adds a new control limit defined in the limitName parameter. By adding a control limit to this sample definition, it will show as an option in the control charts and may also be used when evaluating rules. The limitName parameter must be a valid control limit that appears in the enterprise production equipment.

Syntax

addLimit(limitName)


  • Parameters

String limitName - The control limit to be added.

  • Returns

SampleDefinitionControlLimit controlLimit - Sample control limit.

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()

getAllSampleLimitProperties()

Description

Returns all control limits that have been selected for this sample definition.

Syntax

getAllSampleLimitProperties()

  • Parameters

None

  • Returns

A list of all control limits for the sample definition.

getSampleLimitProperty(limitName)

Description

Returns the control limit matching the name parameter.

Syntax

getSampleLimitProperty(limitName)

  • Parameters

String limitName- Name of the control limit.

  • Returns

SampleDefinitionControlLimit control limit - The control limit with the specified name.

removeLimit(limitName)

Description

Removes a control limit from a given sample definition object.

Syntax

removeLimit(limitName)

  • Parameters

String limitName- The control limit name to be removed.

  • Returns

Nothing

Rules

addRule(ruleName)

Description

Adds a Rule to the Sample Definition

Syntax

addRule(ruleName)

  • Parameters

String ruleName- The name of the rule to be set on the sample definition. List of rule names can be retrieved from the Enterprise object.

SPC Rule Names


  • Returns

Nothing

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.addRule('Out of Limits')
sampleDef.save()

getAllSampleRuleProperties()

Description

Return all SPC Rule attribute properties that have been selected for this sample definition.

Syntax

getAllSampleRuleProperties()

  • Parameters

None

  • Returns

A List of all Sample Rule Properties for the sample definition.

 

getSampleRuleProperty(name)

Description

Returns the rule that has the same name as the name parameter.

Syntax

getSampleRuleProperty(name)


  • Parameters

String name - The name of the rule to be returned for.

  • Returns

SampleDefinitionRule - The sample definition rule object specified by the name parameter.

Code Example

Code
defName = 'my sampleDef'
sampleDef = system.mes.spc.definition.getSampleDefinition(defName)
sampleDef.removeRule('Out of Limits')
sampleDef.save()
>>> 
{LookBackMethod=SAMPLE_COUNT, LookBackValue=0, Description=, SPCRuleUUID=056d2af4-6b09-4c3d-aa2c-a4d546305054}
>>> 

removeRule(ruleName)

Description

Removes the rule defined in the ruleName parameter.

Syntax

removeRule(ruleName)

  • Parameters

String ruleName - The rule name to be removed.

  • Returns

Nothing

Sepasoft MES Module Suite