# Traceability Process Lense
## Overview
This functionality enables the use of **TraceabilityData** Event from OIB **Traceability** Extension to collect Process Lense Inspection data in MES.
## How To configure
### Relevant Artifacts
The table below describes the properties for this entity type:
| Name | Type | Is Mandatory | Data Type | Description |
| :-------------------- | :--------- | :----------: | :-------- | :-------------------------------------------------- |
| IoTMetadataDefinition | SmartTable | Yes | | Metadata configuration for equipment integration |
| CreateDefects | Service | Yes | | Template Service to handle Material Defect creation |
To enable TraceabilityData material Inspection functionality we need to configure the extension and any other relevant key as described below:
### IoTMetadataDefinition Area Level Configuration
Set the following keys at the **Area** level:
| Name | Type | Possible Values | Default Value | Description |
| --------------------------------------- | ------ | ------------------------------------------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| oib_Traceability_disabled | String | `true`
`false` | `true` | This will enable or disable the extension. |
| oib_Traceability_enablemode | String | `None`
`OnePerEnterprise`
`OnePerSite`
`OnePerLine` | `None` | How should activate Traceability instance:
`None` - No instance will be used
`OnePerEnterprise` - One Instance for all Lines (Enterprise level)
`OnePerSite` - One Instance for all Lines (Site level)
`OnePerLine` - One Instance per Line |
| oib_Traceability_subscriptionnamesuffix | String | | "" | Will be added to the subscription name. |
| oib_Traceability_operationmode | String | `Interlocking`, `Notification` or `Both` | Interlocking | How we will interact with the system. |
??? Example
| Resource | ResourceType | Area | Name | Value |
| -------- | ------------ | ------------------- | ------------------------------------------------- | ---------------- |
| | | SMT_Production Line | oib_Traceability_disabled | false |
| | | SMT_Production Line | oib_Traceability_enablemode | OnePerLine |
| | | SMT_Production Line | OIB_LineNameStationName_Line - TQ & TX2 & SX2_TX2 | SMT_Pick_Place_1 |
> Replace with the appropriate values depending on your setup.
### IoTMetadataDefinition Resource Level Configuration
- `useOIBToTrackIn`: If set with **TraceabilityData**, this event will automatically track in the Material at the MES Resource.
- `UseTrackInOperation`: Sets the Track In MES operation. Can be defined as `ComplexDispatchAndTrackIn` or `ComplexTrackIn`. Defaults to `ComplexTrackIn` if not defined.
- `useWaitForPreviousTrackout`: Sets a wait time for the previous Track Out event to finish.
- `useWaitIfRecipeIsBeingChanged`: Sets a wait time for the recipe change to finish on the current Resource.
- `DoPreviousTrackOut`: If defined with any value, the controller logic will attempt to Track Out the previous Material tracked in the Resource before proceeding with the Track In operation for the current Material.
- `useOIBToTrackOut`: If set with **TraceabilityData**, this event will automatically track out the Material at the MES Resource.
- `UseTrackOutOperation`: Sets the Track Out MES operation. Can be defined as `ComplexTrackOutAndMoveNext` or `ComplexTrackOut`. Defaults to `ComplexTrackOut` if not defined.
- `waitForTraceToDoTrackOut`: Sets a wait time for the Traceability data processing before Tracking Out.
- `waitForTrackInToDoTrackOut`: Sets a wait time for the Track In operation to conclude before Tracking Out.
- `useOIBProcessLensTraceData`: Toggle the processing of Process Lense data.
- `useInspectionToMaterialDefects`: Toggle the use of Process Lense data to create material defects.
- `usePanelPositionToMaterialDefects`: Toggle the use of Panel positions to identify the sub-material to whom we will associate the defect with. If true, it is assumed that the Material is a Parent and we will get the Sub Material using the position.
??? Example
| Resource | ResourceType | Area | Name | Value |
| ---------------- | ------------ | ---- | ------------------------------ | ---------------- |
| SMT_Pick_Place_1 | | | useOIBToTrackIn | TraceabilityData |
| SMT_Pick_Place_1 | | | useOIBToTrackOut | TraceabilityData |
| SMT_Pick_Place_1 | | | useOIBProcessLensTraceData | True |
| SMT_Pick_Place_1 | | | useInspectionToMaterialDefects | True |
## How To Use
Traceability informs MES what where the *Lense* findings during the inspection process at the Station.
## Implementation Details
During **Equipment Setup**, and according to the defined operation mode, a new *endpoint*, *subscription* or *both* will be created/registered in OIB Central Server. This registration becomes the connection to MES where the **Events** or **Requests** will be sent by the configured Stations.
Station TraceabilityData Received:
1. Resolves IoTMetadataDefinition for what tracking operations are configured.
2. Check if any Track In/Out Conditions are enabled.
3. Track In enabled:
- Try to Track in Material received into the MES Resource.
4. Inspection Processing.
- If `useOIBProcessLensTraceData` is set to **True** we will:
- If `useInspectionToMaterialDefects` is set to **True**, process the received data and use it to create MES Material Defects.
- If `useInspectionToMaterialDefects` is set to **False** or unset, we will process the data and do a PassFail data collection according to the Lense and Operator Inspection Results.
5. Track Out enabled:
- Try to Track out Material received out of the MES Resource.