Sepasoft MES Module Suite
sample.getSample(sampleUUID)
Overview
Returns an existing SPC sample identified by its UUID. The returned object includes the sample definition, measurement values, and additional factors loaded from the gateway database. Use this function when you already have a sample UUID and need to read or modify that sample.
Syntax
Python |
# Current system.mes.spc.sample API system.mes.spc.sample.getSample(sampleUUID) # Legacy SPC 2.0 API name system.quality.sample.data.getSample(sampleUUID) system.quality.sample.data.getSample(projectName, sampleUUID) |
Parameters
Parameter | Type | Required | Description |
|---|---|---|---|
sampleUUID | String | Required | UUID of the existing sample to load. |
Return Value
Type | Description |
|---|---|
CommonSample / QualitySample | A reference to the existing sample, including its definition, measurements, and additional factors. Returns None when no sample matches sampleUUID (for example, blank UUID, unknown UUID, or missing database record). |
Scope / Availability
Registered on the system.mes.spc.sample script module as getSample.
The equivalent getSample method is implemented by the legacy SPC 2.0 script class registered under system.quality.sample.data (including an optional projectName overload).
Gateway scripts execute locally on the gateway. Designer / Client calls use the quality RPC layer to load the sample on the gateway.
Behavior / Edge Cases
Lookup only: The function retrieves an existing sample; it does not create a new sample. Use getNewByDefUUID(), getNewByDefName(), or getCreateByDefUUID() / getCreateByDefName() when you need to create or resume-and-create samples.
Unknown sample UUID: When sampleUUID does not match a stored sample, the function returns None.
Loaded sample data: A successful lookup populates the sample definition, measurement data, and additional factors on the returned object so you can read or change values before calling update().
Example Usage
Minimal example
Python |
sample = system.mes.spc.sample.getSample("a1b2c3d4-e5f6-7890-abcd-ef1234567890") |
Complex example
Python |
sampleUUID = event.source.parent.getComponent("SampleUUID").text sample = system.mes.spc.sample.getSample(sampleUUID) if sample is None: raise ValueError("Sample not found for UUID: %s" % sampleUUID) refNo = sample.getRefNo() weight = sample.getSampleDataValue(1, "Weight") sample.setRefNo("WO-100145") sample.getSampleData(1, "Weight").setAttrValue(12.4) system.mes.spc.sample.update(sample, True) |
Related Functions
system.mes.spc.sample.getCreateByDefUUID() — Returns an existing sample when a sample UUID is supplied, or creates a new sample from a sample definition UUID.
system.mes.spc.sample.getCreateByDefName() — Returns an existing sample when a sample UUID is supplied, or creates a new sample from a sample definition name.
system.mes.spc.sample.getNewByDefUUID() — Always creates a new sample from a sample definition UUID and location path.
system.mes.spc.sample.getNewByDefName() — Always creates a new sample from a sample definition name and location path.
system.mes.spc.sample.getSampleList() — Returns a dataset of samples matching filter criteria.
system.mes.spc.sample.update() — Persists changes to a sample and optionally records values.
Sepasoft MES Module Suite