Skip to end of metadata
Go to start of metadata

Overview

The SPC module provides methods to create samples through scripting without using any visual components.

Applies To and Version Info

This feature applies to the SPC module and is available in all versions.

Details

1. Create a sample definition
Create a sample definition called 'XBarTest' and assigned the location 'QCLab1'.
The definition is set for a maximum of 5 measurements max per attribute
It has two attributes, Attr1 and Attr2.
Attr1 is real type and is set for 1 measurement
Attr2 is real type and is set for 4 measurements



2. create a new sample from the definition
3. add sample data to the attributes and thier measurements
4. update/save the sample object

Scripting

The following code performs steps 2, 3 and 4:

# sample definition name
defName = 'XBarTest'
# location path that is assigned to the sample definition
locationPath = '[global]\Nuts Unlimited\Folsom\Packaging\QCLab1'
# create a new sample from the definition
sample = system.quality.sample.data.getNewByDefName(defName, locationPath) #https://help.sepasoft.com/docs/display/MHD/system.quality.sample.data.getNewByDefName
# use this sample object to set the data for the attributes and thier measurements
# https://help.sepasoft.com/docs/display/MHD/Sample

# this sample definition has two attributes, Attr1 and Attr2, and Attr1 has 1 measurement and Attr2 has 4 measurements
# read the values from existing tags
# NOTE: sample values are passed as strings, they are converted internally to the proper data type.
att1Val = system.tag.read('Quality/QualVal1').value
sample.setSampleData(1, 'Attr1', str(att1Val))

att2Val = system.tag.read('Quality/QualVal2').value
sample.setSampleData(1, 'Attr2', str(att2Val))
att3Val = system.tag.read('Quality/QualVal3').value
sample.setSampleData(2, 'Attr2', str(att3Val))
att4Val = system.tag.read('Quality/QualVal4').value
sample.setSampleData(3, 'Attr2', str(att4Val))
att5Val = system.tag.read('Quality/QualVal5').value
sample.setSampleData(4, 'Attr2', str(att5Val))

# only approved samples display on the chart
#sample.setApprovedBy(<name>)
#sample.setApprovedDate(<date>)
sample.setApproved(True)

# save the sample by calling it's update method
system.quality.sample.data.updateSample(locationPath, sample, True) # https://help.sepasoft.com/docs/display/MHD/system.quality.sample.data.updateSample


References

Get Sample By Definition Name

Keywords

SPC, Sample Definition, Sample Attribute


    Created By   Pete Low Created Date  Nov 20, 2018 18:59 Last Modified By   Pete Low Last Modifed Date   Nov 20, 2018 18:59


  • No labels