# Setup OIB ## Overview This feature is responsible for handling the connection setup between the Automation Driver and the OIB (Operations Information Broker) equipment. During initialization, the driver reads configuration parameters from the `IoTMetadataDefinition` Smart Table, initializes all OIB extensions, and establishes the connection to the OIB Configuration Manager. --- ## How to Configure To configure the OIB connection, a set of keys must be set in the **IoTMetadataDefinition** Smart Table at the **Area** level. ### Relevant Artifacts The table below describes the artifacts involved in this configuration: | Name | Type | Is Mandatory | Data Type | Description | | :-------------------- | :--------- | :----------: | :-------- | :--------------------------------------------------- | | IoTMetadataDefinition | SmartTable | Yes | | Metadata configuration for OIB equipment integration | --- ### IoTMetadataDefinition Area Level Configuration At the **Area** level, the following configuration keys must be set in `IoTMetadataDefinition` to control the OIB driver behavior. #### General Settings | Resource | Resource Type | Area | Name | Value | Description | | ------------------ | ------------- | ---- | ---------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------- | | *MES OIB Resource* | | | OIB_sdkVersion | e.g. `OIB_65` | Base version of the OIB SDK to use. Supported values: `OIB_60`, `OIB_62`, `OIB_63`, `OIB_64`, `OIB_65` | | *MES OIB Resource* | | | OIB_logUnhandledEvents | `True` / `False` | Log all received events, even if they are not handled by the controller | | *MES OIB Resource* | | | OIB_enableOibTraceData | `True` / `False` | Log all OIB trace data as debug log | | *MES OIB Resource* | | | OIB_dumpMessagesReceived | `True` / `False` | Dump debug log of received messages | | *MES OIB Resource* | | | OIB_dumpMessagesReceivedPath | e.g. `${tmp}` | Path where to dump received messages (use `${tmp}` for user temporary directory) | #### Network Settings | Resource | Resource Type | Area | Name | Value | Description | | ------------------ | ------------- | ---- | -------------------- | -------------- | ----------------------------------------------------------------------------------------------------------- | | *MES OIB Resource* | | | OIB_localInterface | Hostname or IP | Hostname (or IP) where OIB callbacks will be registered. Leave empty to use `OIB_localNetworkName` | | *MES OIB Resource* | | | OIB_localNetworkName | Network name | Network Name (part of, case sensitive) used to fetch IP information. Leave empty to use registered hostname | #### Line & Station Resolution | Resource | Resource Type | Area | Name | Value | Description | | ------------------ | ------------- | ---- | ------------------------- | --------------- | -------------------------------------------------------------------------------------------------------------- | | *MES OIB Resource* | | | OIB_lineNameResolver | RegEx pattern | RegEx to resolve the line name from its full path. E.g. `.*\\(.*)` extracts `Line 1` from `Production\Line 1` | | *MES OIB Resource* | | | OIB_stationNameResolver | RegEx pattern | RegEx to resolve the station name from its full path. E.g. `.*\\(.*)` extracts `SX4 01` from `Stations\SX4 01` | | *MES OIB Resource* | | | OIB_linesToHandle | Comma-separated | List of lines to handle using this driver. Leave empty for all. | | *MES OIB Resource* | | | OIB_linesToIgnore | Comma-separated | List of lines to ignore using this driver. Leave empty for none. | | *MES OIB Resource* | | | OIB_LineNameStationName_* | Entity name | Maps OIB line name and station name to MES Resource. | #### Timing & Port Settings | Resource | Resource Type | Area | Name | Value (Default) | Description | | ------------------ | ------------- | ---- | ------------------------- | --------------- | ------------------------------------------------------------------------------ | | *MES OIB Resource* | | | OIB_defaultCommandTimeout | `60000` | Default timeout (ms) for driver commands | | *MES OIB Resource* | | | OIB_callbackBasePort | `4000` | Base port number for callbacks. Each OIB service uses this port plus an offset | | *MES OIB Resource* | | | OIB_coreHeartbeatInterval | `60000` | Interval (ms) between heartbeat frames sent to OIB core | #### Configuration Manager Settings (OIB Core Service) | Resource | Resource Type | Area | Name | Value (Default) | Description | | ------------------ | ------------- | ---- | ------------------------------------ | --------------- | -------------------------------------------------------------------------------------------------------------------- | | *MES OIB Resource* | | | OIB_configurationManagerAddress | `localhost` | Hostname (or IP) where the OIB ConfigurationManager is listening | | *MES OIB Resource* | | | OIB_configurationManagerPort | `1406` | Port where the OIB ConfigurationManager is listening | | *MES OIB Resource* | | | OIB_configurationManagerCallbackPort | `0` | Callback port for ConfigurationManager. Use `0` for a free port starting at `OIB_callbackBasePort` | #### Docking Stations Settings | Resource | Resource Type | Area | Name | Value | Description | | ------------------ | ------------- | ---- | --------------------------- | --------------------------- | ---------------------------------------------------- | | *MES OIB Resource* | | | OIB_enableDockingStations | `None` / `OnePerEnterprise` | Enable support for Docking Stations features | | *MES OIB Resource* | | | OIB_dockingStationsToHandle | Comma-separated | List of Docking Stations to handle using this driver | | *MES OIB Resource* | | | OIB_dockingStationsToIgnore | Comma-separated | List of Docking Stations to ignore using this driver | !!! Info "For more information check the OIB driver documentation." --- ### OIB Extensions Configuration Each OIB extension can be individually configured via `IoTMetadataDefinition`. The key naming convention follows the pattern: * **OIB_** The following extensions are available and initialized by default: | Extension Name | Assembly | Default Enable Mode | Notes | | :----------------------- | :------------------------------------------------------------ | :------------------ | :------------------------------------------------------------------------------------------------------------- | | `BoardGateKeeper` | `Cmf.Connect.IoT.Driver.Oib.BoardGateKeeper..dll` | `OnePerLine` | `replyTimeout`: 60000, `registerMode`: UnregisterFirst | | `SetupCenter` | `Cmf.Connect.IoT.Driver.Oib.SetupCenter..dll` | `OnePerEnterprise` | `subscriptionExpiration`: 4, `eventsExpiration`: 60 | | `Traceability` | `Cmf.Connect.IoT.Driver.Oib.Traceability..dll` | `OnePerLine` | `operationMode`: Interlocking, `replyTimeout`: 60000, `registerMode`: UnregisterFirst, `eventsExpiration`: 300 | | `Eventing` | `Cmf.Connect.IoT.Driver.Oib.Eventing..dll` | `OnePerEnterprise` | `subscriptionMode`: Permanent, `eventsExpiration`: 60 | | `ProcessData` | `Cmf.Connect.IoT.Driver.Oib.ProcessData..dll` | `OnePerEnterprise` | `subscriptionMode`: Permanent, `eventsExpiration`: 60 | | `LineControl` | `Cmf.Connect.IoT.Driver.Oib.LineControl..dll` | `OnePerLine` | `subscriptionMode`: Permanent, `eventsExpiration`: 60 | | `PrinterControl` | `Cmf.Connect.IoT.Driver.Oib.PrinterControl..dll` | `OnePerEnterprise` | `replyTimeout`: 60000 | | `PackagingUnit` | `Cmf.Connect.IoT.Driver.Oib.PackagingUnit..dll` | `OnePerLine` | `replyTimeout`: 60000 | | `LineControlInterceptor` | `Cmf.Connect.IoT.Driver.Oib.LineControlInterceptor..dll` | `OnePerLine` | `replyTimeout`: 60000, `registerMode`: UnregisterFirst | | `DisplayService` | `Cmf.Connect.IoT.Driver.Oib.DisplayService..dll` | `OnePerEnterprise` | Optional `clientRegistrationId`, `unregisterOnDisposeFinalize`: false, `newRegistrationOnRestoreFailed`: true | #### Per-Extension Configurable Settings The following settings can be overridden per extension via `IoTMetadataDefinition`: | Key Pattern | Description | | :------------------------------------- | :---------------------------------------------------------------- | | `OIB__assembly` | Override the assembly DLL file name | | `OIB__path` | Override the file system path for the extension | | `OIB__enableMode` | Override the enable mode (`OnePerLine`, `OnePerEnterprise`, etc.) | | `OIB__operationMode` | Override the operation mode (e.g., `Interlocking`) | | `OIB__subscriptionNameSuffix` | Override the subscription name suffix | | `OIB__replyTimeout` | Override the reply timeout (ms) | | `OIB__eventsExpiration` | Override the events expiration time | | `OIB__callbackPort` | Override the callback port | | `OIB__callbackPortRange` | Override the callback port range | | `OIB__disabled` | Set to `True` to disable and remove the extension from the setup | ??? Example "Extension Configuration Example" To change the operation mode of the Traceability extension and disable the PrinterControl extension: | Resource | Resource Type | Area | Name | Value | | ------------------ | ------------- | ---- | ------------------------------ | ------------ | | *MES OIB Resource* | | | OIB_Traceability_operationMode | Interlocking | | *MES OIB Resource* | | | OIB_PrinterControl_disabled | True | --- ## How to Use On Automation startup, the following sequence is executed: 1. The **OnInitialize** driver event fires. 2. The `IoTMetadataDefinitionPersisted` table mappings are **reset**. 3. The **Area** entity instance is loaded to retrieve the linked area name. 4. The repository location is fetched from system configurations (`Cmf/System/Configuration/ConnectIoT/RepositoryLocation/`). 5. The `IoTMetadataDefinition` Smart Table is resolved using the **Area** context to retrieve all OIB parameters. 6. All configured parameters are emitted to the **Equipment Configuration** task. 7. OIB extensions are initialized with default values, then overridden with any values found in `IoTMetadataDefinition`. 8. Disabled extensions are removed from the list. 9. The **Equipment Configuration** task is activated and triggers the **Connect** command. !!! Warning "Every time you change `IoTMetadataDefinition` **Area** values you must restart the Automation Manager." --- ## Implementation Details During **Equipment Setup**, the controller performs the following actions: * Stores the **Area Name** in persistent data store under key `LinkedEntityName`. * Resets table mappings for `IoTMetadataDefinitionPersisted` and `IoTStateModelContextPersisted`. * Resolves the `IoTMetadataDefinition` Smart Table filtered by the current **Area**. * For each entry with a key starting with `OIB_LineNameStationName_`, the following persistent data store keys are initialized per station entity: * `CurrentState_` * `StateChangingWait_` * `StatePending_` * `RecipeIsBeingChanged_` * `StationActiveRecipe_` * Extension settings are read from `IoTMetadataDefinition` and applied on top of the default values. * Extensions marked with `OIB__disabled = True` are filtered out before being passed to the Equipment Configuration task. * The final list of enabled extensions is emitted as `OIB_extensions` to the driver. * A custom template for `Traceability.Event.TraceabilityData` is registered, extending the default driver template with additional properties including `ErrorCode`, `Printers`, and `Lenses`. * The **Connect** command is triggered after the Equipment Configuration and custom template tasks complete successfully.