AddSample Method
- Last UpdatedNov 06, 2025
- 2 minute read
AddSample() method adds a data log record to the Data_Log table, using the current values stored in the Data_Log_Value table as the sample values. This facilitates using the PLC to collect values from external servers and save them independently, and then trigger a new sample to be logged to the relevant Data_Log table.
Note: This method has been superseded by the SaveSample() method. That method provides two overloads for adding data log records, one using ID numbers to identify the data log group and entity and the other using the group description and entity and site names.
public static void AddSample(
int sessionId,
DBInt grpId,
int entId,
DBInt jobPos,
DBInt stepNo,
DBString lotNo,
DBString subLotNo
)
Parameters
- sessionId
- Required. Holds the session ID and thus the user who is making this method call.
- grpId
- Optional. Holds the ID of the data log group to be sampled.
- entId
- Required. Holds the ID of the entity where the sample is collected.
- jobPos
- Optional. Holds the job position. If > 1, then jobs are running on this entity.
- stepNo
- Optional. Holds the job step number that is associated with this sample.
- lotNo
- Optional. Holds the lot number that is associated with this sample.
- subLotNo
- Optional. Holds the sublot number that is associated with this sample.
Observe the following input parameter rules:
- Required non-DB* parameters: Must pass a value. Cannot be empty or null.
- Optional non-DB* parameters: Either enter a value or pass a null. If passing a null and a default value has been defined, the default value will be used for the parameter.
- Required DB* parameters: Must pass a value. To enter an empty value for the parameter, pass DB*.null (e.g., DBInt.null).
- Optional DB* parameters: To enter no value for the parameter (e.g., it is not being used), pass DB*.null (e.g., DBInt.null). To use the default value for the parameter if one has been defined for the object being added, pass a null.
The assumption in using this method is that all samples that need to be logged are collected and saved up front in the Data_Log_Value table before triggering this method to log the samples.
If the entity exists and there is a job currently running on the entity, then those job details are used while logging the sample data along with the current shift details for the entity. The method goes through each and every non-null value in the Data_Log_Value table that is assigned to this group, and copies the value to the appropriate valuen column in the Data_Log table to collect this sample.