Sample

Sepasoft MES Module Suite

Sample Object

The sample object holds all of the information associated with one quality sample.  Information regarding the configuration, data collected, and additional factors are provided below.

Information

These two functions are commonly used in scripts to create new samples:

Methods


 

calcScheduledFinish()

Description

Based on the scheduled start date and time and the duration of time to take this sample, calculates the date and time this sample is scheduled to be complete. The getScheduledFinish() value is updated after calling this function. The duration of time required to take a sample is defined in the sample definition. For automatic samplings, this value does not apply.

Syntax

calcScheduledFinish()


  • Parameters

None

  • Returns

Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
print sample.calcScheduledFinish()
Output
>>>
None
>>>

 getApproved()

Description

Returns true if this sample has been approved. Depending on the settings in the sample definition, samples may be automatically or manually approved.

Syntax

getApproved()


  • Parameters

None

  • Returns

True, if the sample has been approved.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getApproved()
Output
>>>
True
>>>
 

getApprovedBy()

Description

Returns the person’s name who approved this sample. For automatically recorded samples, this will be “Auto”.

Syntax

getApprovedBy()


  • Parameters

None

  • Returns

String approvedBy - Name of the person who approved this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getApprovedBy()
Output
>>>
sepasoftadmin
>>>

 getApprovedDateTime()

Description

Returns the date and time that this sample was approved. For automatically approved samples, this will be the same as the getEntryDateTime() value.

Syntax

getApprovedDateTime()


  • Parameters

None

  • Returns

Calendar approvedDateTime - Date and time that this sample was approved.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getApprovedDateTime()
Output
>>>
java.util.GregorianCalendar[time=1521242263000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=17,SECOND=43,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>>
 

getArea()

Description

Returns the production area associated with this sample.

Syntax

getArea()


  • Parameters

None

  • Returns

 String area - The production model area equipment associated with the sample. More details about the production model.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getArea()
Output
>>>
Packaging
>>>

 getDefUUID()

Description

Returns the definition UUID associated with this sample. (See Sample Definition object for more information).

Syntax

getDefUUID()


  • Parameters

None

  • Returns

String defUUID - The definition uuid of this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getDefUUID()
Output
>>>
317c12e9-7324-47a5-9505-c2768e1e48c5
>>>
 

getEnterprise()

Description

Returns the enterprise associated with this sample.

Syntax

getEnterprise()


  • Parameters

None

  • Returns

String enterprise - The enterprise name of this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getEnterprise()
Output
>>>
Nuts Unlimited
>>>

 getEntryDateTime()

Description

Returns the date and time that this sample was entered.

Syntax

getEntryDateTime()


  • Parameters

None

  • Returns

Calendar entryDateTime - Date and time for which the sample was entered.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getEntryDateTime()
Output
>>>
java.util.GregorianCalendar[time=1521242263000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=17,SECOND=43,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>> 
 

getLine()

Description

Returns the production line associated with this sample. This will be blank if the location the sample is taken is in a production area and not on a production line.

Syntax

getLine()


  • Parameters

None

  • Returns

 String line - The line associated with the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getLine()
Output
>>>
Packaging Line 1
>>> 
 

getLocation()

Description

Returns the location associated with this sample.

Syntax

getLocation()


  • Parameters

None

  • Returns

 String location - The location associated with this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getLocation()
Output
>>>
Line 1 Quality
>>> 
 

getLocationPath()

Description

Returns the full location path, including enterprise, site, area, line and location, associated with this sample.

Syntax

getLocationPath()


  • Parameters

None

  • Returns

 String locationPath - The location path of this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getLocationPath()
Output
>>>
Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality
>>> 
 

getNote()

Description

Returns the note associated with this sample. This is the note that may have been entered when the sample was entered. Even though this note can be viewed on the control charts or in analysis, it is not the same as the attribute note entered on the control charts.

Syntax

getNote()


  • Parameters

None

  • Returns

String note - Note associated with the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'ac4d02e6-2246-46e7-afbe-a8593370b21c'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getNote()
Output
>>>
hello
>>> 
 

getProductCode()

Description

Returns the product code associated with this sample. This is optional and may not apply if tracking quality by product code is not being used for the associated sample definition.

Syntax

getProductCode()


  • Parameters

None

  • Returns

 String productCode - The product code associated with the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getProductCode()
Output
>>>
PC009
>>> 
 

getRefNo()

Description

Returns the reference number associated with this sample. This is optional and can be used to track information like batch number, lot number, etc. Additional factors can also be used to track information.

Syntax

getRefNo()


  • Parameters

None

  • Returns

 String refNo - The reference number associated with the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getRefNo()
Output
>>>
4
>>> 
 

getSampleDefinition()

Description

Returns the definition associated with this sample. See Sample Definition object for more information.

Syntax

getSampleDefinition()


  • Parameters

None

  • Returns

SampleDefinition definition - Definition associated with the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSampleDefinition()
Output
>>>
com.sepasoft.mes.spc.common.core.SampleDefinition@169405f
>>>
 

getSampleTakenBy()

Description

Returns the person’s name who was responsible for taking the sample. By default, this is the person who is logged in when the sample is entered. For automatically recorded samples, this will be “Auto”.

Syntax

getSampleTakenBy()


  • Parameters

None

  • Returns

String sampleTakenBy - username of person who took the sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSampleTakenBy()
Output
>>>
sepasoftadmin
>>>
 

getSampleTakenDateTime()

Description

Returns the date and time that this sample was taken.

Syntax

getSampleTakenDateTime()


  • Parameters

None

  • Returns

Calendar sampleTakenDateTime - The date and time that the sample was taken.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSampleTakenDateTime()
Output
>>>
java.util.GregorianCalendar[time=1521242263000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=17,SECOND=43,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>>
 

getSampleUUID()

Description

Returns the UUID assigned to this sample. A UUID is a universally unique identifier that, once assigned to a sample, will never change. It is also unique in that no two samples will have the same UUID.

Syntax

getSampleUUID()


  • Parameters

None

  • Returns

String sampleUUID - The uuid of this sample.

Code Examples
Code Snippet
1
2
3
4
5
locationPath = 'Enterprise\\El Dorado Hills\\Test\\location1'
defName = 'ManualSingleMeasurement'
#creates a new sample
sample = system.mes.spc.sample.getNewByDefName(defName, locationPath)
print sample.getSampleUUID()
Output
>>>
d84b7ba3-7c71-4c31-85c9-8fcb84dd67b5
>>>

 getScheduledFinish()

Description

Returns the date and time that taking this sample is scheduled to be complete. For automatic samplings, this value does not apply and will be equal to None.

Syntax

getScheduledFinish()


  • Parameters

None

  • Returns

Calendar scheduledFinish - The date and time for the schedule to end.

Code Examples
Code Snippet
1
2
3
4
5
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
sampleDefName = 'Nut Defects'
sample = system.mes.spc.sample.data.getNewByDefName(sampleDefName, locationPath)
print sample.getScheduledFinish()
Output
>>>
java.util.GregorianCalendar[time=1521242263000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=17,SECOND=43,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>>
 

getScheduledStart()

Description

Returns the date and time that this sample is scheduled to be taken. For automatic samplings, this value does not apply and will be equal to None.

Syntax

getScheduledStart()


  • Parameters

None

  • Returns

Calendar scheduledStart - The date and time for the sample to start.

Code Examples
Code Snippet
1
2
3
4
5
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
sampleDefName = 'Nut Defects'
sample = system.mes.spc.sample.data.getNewByDefName(sampleDefName, locationPath)
print sample.getScheduledStart()
Output
>>>
java.util.GregorianCalendar[time=1521242263000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=17,SECOND=43,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>>
 

getSequenceDate()

Description

Returns the date and time that the shift the sample was taken during started.

Syntax

getSequenceDate()


  • Parameters

None

  • Returns

Calendar sequenceDate - Start date of the current active shift.

Code Examples
Code Snippet
1
2
3
4
5
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
sampleDefName = 'Nut Defects'
sample = system.mes.spc.sample.data.getNewByDefName(sampleDefName, locationPath)
print sample.getSequenceDate()
Output
>>>
java.util.GregorianCalendar[time=1521237600000,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=3,DAY_OF_MONTH=16,DAY_OF_YEAR=75,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=-28800000,DST_OFFSET=3600000]
>>>
 

getShift()

Description

Returns the shift the sample was taken.

Syntax

getShift()


  • Parameters

None

  • Returns

int shift - Shift for which the sample was taken.

Code Examples
Code Snippet
1
2
3
4
5
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
sampleDefName = 'Nut Defects'
sample = system.mes.spc.sample.data.getNewByDefName(sampleDefName, locationPath)
print sample.getShift()
Output
>>>
2
>>>

 getSite()

Description

Returns the physical production facility associated with this sample.

Syntax

getSite()


  • Parameters

None

  • Returns

String site - The site of this sample.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSite()
Output
>>>
Folsom
>>>

 getTag()

Description

Returns the optional tag value. This is typically used to assign ownership of which department has the responsibility to take this sample.

Syntax

getTag()


  • Parameters

None

  • Returns

String tag - Tag value that specifies the ownership.

Code Examples
Code Snippet
1
2
3
sampleUUID = 'ac4d02e6-2246-46e7-afbe-a8593370b21c'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.getTag()
Output
>>>
Weight
>>>
 

isModified()

Description

Returns true if any properties of this sample have been modified.

Syntax

isModified()


  • Parameters

None

  • Returns

True, if this sample have been modified.

Code Examples
Code Snippet
1
2
3
4
5
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
sampleDefName = 'Nut Defects'
sample = system.mes.spc.sample.data.getNewByDefName(sampleDefName, locationPath)
print sample.isModified()
Output
>>>
False
>>>
 

isNew()

Description

Returns true if this is a newly created sample.  When using system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, DefinitionName, locationPath) and a blank string is passed for sampleUUID, a new sample is created.  In this case, isNew() will return True. 

If a sample UUID is passed, the function loads a previously created sample and isNew() returns False.

Syntax

isNew()


  • Parameters

None

  • Returns

True, if this sample is newly created.

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
 
#If no SampleUUID is provided, a new Sample is created
sample = system.mes.spc.sample.data.getCreateSampleByName('', 'SampleDefName', locationPath)
sample.isNew()
Output
>>>
True
>>>
 

setApproved(approved)

Description

Set to true to approve this sample.

Syntax

setApproved(approved)


  • Parameters

boolean approved - True, if the sample is to be approved.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
7
8
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setApproved(True)
     
#get your current logged in user
sample.setApprovedBy('sepasoftadmin')
 
system.mes.spc.sample.update(sample,False)
 

setApprovedBy(approvedBy)

Description

Sets the person’s name who approved this sample.

Syntax

setApprovedBy(approvedBy)


  • Parameters

String approvedBy - username of the person who approved this sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
7
8
sampleUUID = 'a4c349f9-b894-4c65-81d6-c64c82cdd258'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setApproved(True)
     
#get your current logged in user
sample.setApprovedBy('sepasoftadmin')
 
system.mes.spc.sample.update(sample,False)

 setApprovedDateTime(approvedDateTime)

Description

Sets the date and time that this sample was approved.

Syntax

setApprovedDateTime(approvedDateTime)


  • Parameters

Calendar approvedDateTime - Date and time that this sample was approved.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
7
8
9
10
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -30)
 
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setApprovedDateTime(cal)

 setArea(area)

Description

Sets the production area associated with this sample.

Syntax

setArea(area)


  • Parameters

String area - The area associated with the sample.

  • Returns

Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setArea('Packaging')
 

setEnterprise(enterprise)

Description

Sets the enterprise associated with this sample. 

Syntax

setEnterprise(enterprise)


  • Parameters

String enterprise - The enterprise of this sample.

  • Returns

Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setEnterprise('Nuts Unlimited')
 

setEntryDateTime(entryDateTime)

Description

Sets the date and time that this sample was entered.

Syntax

setEntryDateTime(entryDateTime)


  • Parameters

DateTime - Date and time for which the sample was entered.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3' 
sample = system.mes.spc.sample.getSample(sampleUUID)
now = system.date.now()
sample.setEntryDateTime(now)
system.mes.spc.sample.update(sample,False)
 

setLine(line)

Description

Sets the production line associated with this sample.

Syntax

setLine(line)


  • Parameters

String line - The line associated with the sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setLine('Packaging Line 1')
 

setLocation(location)

Description

Sets the production location associated with this sample.

Syntax

setLocation(location) 


  • Parameters

String location - The location associated with the sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setLocation('Line 1 Quality')
 

setLocationPath(locationPath)

Description

Sets the enterprise, site, area, line and location from the locationPath parameter.

Syntax

setLocationPath(locationPath) 


  • Parameters

String locationPath - The locationPath of this sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setLocationPath('Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality')
 

setNote(note)

Description

Sets the note associated with this sample.

Syntax

setNote(note)


  • Parameters

String note - Note associated with the sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
sampleUUID = 'ac4d02e6-2246-46e7-afbe-a8593370b21c'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setNote('hello')
system.mes.spc.sample.update(sample, False)
 

setProductCode(productCode)

Description

Sets the product code associated with this sample. This can be filtered in Analysis.

Syntax

setProductCode(productCode) 


  • Parameters

String productCode - The product code associated with the sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3' 
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setProductCode('PC009')
 

setRefNo(refNo)

Description

Sets the reference number associated with this sample. This can be used as a filter property in analysis.

Syntax

setRefNo(refNo)


  • Parameters

String refNo - The reference number of this sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setRefNo('1111')
system.mes.spc.sample.update(sample,False)
 

setSampleDefinition(definition)

Description

Sets the definition associated with this sample. See Sample Definition object for more information.

Syntax

setSampleDefinition(definition)


  • Parameters

SampleDefinition definition - Definition associated with the sample.

  • Returns

 Nothing

 

setSampleTakenBy(sampleTakenBy)

Description

Sets the person’s name who was responsible for taking the sample.

Syntax

setSampleTakenBy(sampleTakenBy)


  • Parameters

String sampleTakenBy - Name of person who took the sample.

  • Returns

 Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setSampleTakenBy('Auto')
 

setSampleTakenDateTime(sampleTakenDateTime)

Description

Sets the date and time that this sample was taken.

Syntax

setSampleTakenDateTime(sampleTakenDateTime)


  • Parameters

Date sampleTakenDateTime - Date and time that the sample was taken.

  • Returns

Nothing

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3' 
sample = system.mes.spc.sample.getSample(sampleUUID)
now = system.date.now()
sample.setSampleTakenDateTime(now)
system.mes.spc.sample.update(sample,False)
 

setScheduledFinish(scheduleFinish)

Description

Sets the date and time that this sample is scheduled to be completed.

Syntax

setScheduledFinish(scheduleFinish)


  • Parameters

Calendar scheduleFinish - The date and time for the schedule to end.

  • Returns

Nothing

Code Snippet
1
2
3
4
5
6
7
8
9
10
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -30)
 
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setScheduledFinish(cal)
 

setScheduledStart(scheduleStart)

Description

Sets the date and time that this sample is scheduled to be taken.

Syntax

setScheduledStart(scheduleStart)


  • Parameters

Calendar scheduleStart - The date and time for the schedule to start.

  • Returns

Nothing

Code Snippet
1
2
3
4
5
6
7
8
9
10
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -30)
 
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setScheduledStart(cal)
 

setSequenceDate(sequenceDate)

Description

Sets the date and time that the shift the sample was taken during started.

Syntax

setSequenceDate(sequenceDate)


  • Parameters

Calendar sequenceDate - Start date of the current active shift.

  • Returns

 Nothing

Code Snippet
1
2
3
4
5
6
7
8
9
10
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -30)
 
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setSequenceDate(cal)
 

setShift(shift)

Description

Sets the shift the sample was taken.

Syntax

setShift(shift)


  • Parameters

int shift - The shift for which the sample was taken.

  • Returns

 Nothing

Code Snippet
1
2
3
4
5
6
7
8
9
10
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_MONTH, -30)
 
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setShift(2)

 setSite(site)

Description

Sets the physical production site associated with this sample.

Syntax

setSite(site)


  • Parameters

String site - The site of this sample.

  • Returns

Nothing

Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.setSite('Folsom')
 

setTag(tag)

Description

Sets the tag value. This is typically used to assign ownership of which department has the responsibility to take this sample. Not filterable in analysis. 

Syntax

setTag(tag)


  • Parameters

String tag - Tag value that specifies the ownership.

  • Returns

 Nothing

Code Snippet
1
2
3
4
sampleUUID = 'ac4d02e6-2246-46e7-afbe-a8593370b21c'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.setTag('QC Issue')
system.mes.spc.sample.update(sample, False)


Measurement Methods

 

getAllMeasurements()

Description

Returns the measurements associated with this sample. If a sample has been scheduled but the measurement data has not been recorded, the measurement entries will still exist. In this case, use the sampleDataExists() property to determine if the measurement data has been entered.

Syntax

getAllMeasurements()

  • Parameters

None

  • Returns

List - A list of all the measurements associated with this sample.

Code Example
getAllMeasurements()
sampleUUID = '69999f0a-49e2-407b-88b5-e56c8d8128d1'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getAllMeasurements()
Example Output
[10.851719699711.29232591811.2493760506]
 

getSampleData(measNo, attrName)

Description

Gets SampleData item for the specified measurement number and attribute.

Syntax

getSampleData(measNo, attrName)


  • Parameters

int measNo - The measurement number associated with the sample.

String attrName - Name of the attribute to return the maximum value for.

  • Returns

SampleData  data - SampleData item for the specified measurement number and attribute.

Code Examples
Code Snippet
1
2
3
4
sampleUUID = '69999f0a-49e2-407b-88b5-e56c8d8128d1'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSampleData(1,'Fill Level')
print type(sample.getSampleData(1,'Fill Level'))
Output
>>>
10.8517196997
<type 'com.sepasoft.quality.common.core.SampleData'>
>>>
 

getSampleDataValue(measNo, attrName)

Description

Returns a measurement value as a string for the specified measurement number and attribute name.

Syntax

getSampleDataValue(measNo, attrName) 


  • Parameters

int measNo - The measurement number associated with the sample.

String attrName - Name of the attribute to return the measurement value for.

  • Returns

String  value - Measurement value for the specified sample.

Code Examples
Code Snippet
1
2
3
4
sampleUUID = '69999f0a-49e2-407b-88b5-e56c8d8128d1'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getSampleDataValue(1'Fill Level')
print type(sample.getSampleDataValue(1'Fill Level'))
Output
>>>
10.8517196997
<type 'unicode'>
>>>

 getSampleDataValueFormatted(measNo, attrName, locale)

Description

Returns a measurement value as a string (with formatting applied) for the specified measurement number and attribute name.

Version Specific

Provided in 3.81.8 SP6 and later.

Syntax

getSampleDataValueFormatted(measNo, attrName, locale)

  • Parameters
    • int measNo - The measurement number associated with the sample.
    • String attrName - Name of the attribute to return the measurement value for.
    • string locale - Optional. Overrides the system's default Locale.
  • Returns

String value - Measurement value for the specified sample with formatting applied.

 

isDataModified()

Description

Returns true if any measurement values have been modified.

Syntax

isDataModified()

  

  • Parameters

None

  • Returns

True, if any of the measurement value was modified.

Code Examples
Code Snippet
1
2
3
4
5
6
#You pass your location path
locationPath = 'Nuts Unlimited\Folsom\Packaging\Packaging Line 1\Line 1 Quality'
#You pass your sampleUUID
sampleUUID = '716c05dd-ae1c-4ca3-bc0b-ea51226afec3'
sample = system.mes.spc.sample.data.getCreateSampleByName(sampleUUID, '', locationPath)
sample.isDataModified()
Output
>>>
False
>>>
 

isSampleDataValid()

Description

Returns true if the measurements have been entered and are valid.

Syntax

isSampleDataValid()


  • Parameters

None

  • Returns

 True, if the measurements have been entered and are valid.  To be True, all required attributes are entered, attribute names are not null, and measurement numbers are correct and unique.

Code Examples
Code Snippet
1
2
3
sampleUUID = '69999f0a-49e2-407b-88b5-e56c8d8128d1'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.isSampleDataValid()
Output
>>>
True
>>>

 sampleDataExists(sampleData)

Description

Returns true if the given sample data exist and False otherwise.

Syntax

sampleDataExists(sampleData)


  • Parameters

SampleData sampleData - The sample data to be checked.

  • Returns Boolean

True, if sample data exists and False otherwise.

Code Example
Script
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
sampleData = sample.getSampleData(1,'att1')
print sample.sampleDataExists(sampleData)
>>>  True >>> 
 

setSampleData(measNo, attrName, value)

Description

Sets a measurement value as a string for the specified measurement number and attribute name.

Syntax

setSampleData(measNo, attrName, value)


  • Parameters

int measNo - The measurement number associated with the sample. Note that the first measurement number starts at one, not zero.

String attrName - Name of the attribute to set the sample data for.

String value - Measurement value for the specified sample.

  • Returns

 True if successful, otherwise returns false.

Code Examples
Code Snippet
1
2
3
4
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.setSampleData(1,'att1','2.25')
system.mes.spc.sample.update(sample,True)
Output
>>>
True
>>>

Additional Factor Methods

 

addAddlFactor(factorName, factorValue, recordDateTime)

Description

Adds an additional factor object to this sample.

Syntax

addAddlFactor(factorName, factorValue, recordDateTime)

  • Parameters

String factorName - Name of the additional factor to be added.

String factorValue - Value of the additional factor to be added.

Date recordDateTime - Date and Time at which the additional factor should be added.

  • Returns

Nothing

Code Example
Script
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.setSampleData(1,'att1','2.26')
sample.addAddlFactor('LotID','123', system.date.now())
system.mes.spc.sample.update(sample,True)
 

addAddlFactor(factorName, factorValue, recordDateTime, enableOverwrite)

Description

Adds an additional factor object to this sample.

Syntax

addAddlFactor(factorName, factorValue, recordDateTime, enableOverwrite)


  • Parameters

String factorName - Name of the additional factor to be added.

String factorValue - Value of the additional factor to be added.

Date recordDateTime - Date and Time at which the additional factor should be added.

boolean enableOverwrite - Set to True to allow overwriting and False otherwise.

  • Returns

Nothing

Code example
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
sample.addAddlFactor('LotID','2224',system.date.now(),True)
system.mes.spc.sample.update(sample,False)
 

getAddlFactor(factorName)

Description

Gets the additional factor object specified by the factorName parameter and associated with this sample. Use this function to get the SampleAdditionalFactor object that can be used to change the value of the additional factor.

Syntax

getAddlFactor(factorName)


  • Parameters

String factorName - Name of the additional factor to be returned. This reflects the name of the additional factor that is configured in the designer.

  • Returns

SampleAdditionalFactor - Additional factor object associated with this sample.

Code Example
Script
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getAddlFactor('factor1')
>>>  com.sepasoft.production.spc.sample.QualitySampleAdditionalFactor@61f25e0b >>>
 

getAllAddlFactors()

Description

Returns the list of additional factor values associated with this sample.

Syntax

getAllAddlFactors()


  • Parameters

None

  • Returns

 List - A list of additional factor objects associated with this sample.

Code Example
Script
sampleUUID = 'd353b925-cfa3-48af-b563-6840aaa1a13d'
sample = system.mes.spc.sample.getSample(sampleUUID)
print sample.getAllAddlFactors()
for fact in sample.getAllAddlFactors():
    print fact.getName(), fact.getValue()
>>>  [com.sepasoft.production.spc.sample.QualitySampleAdditionalFactor@389b6789, com.sepasoft.production.spc.sample.QualitySampleAdditionalFactor@4a731e7d] factor2 123 factor1 123 >>> 




Sepasoft MES Module Suite