# Event Handling ## Overview This feature is responsible for Integrating IPC-Hermes Events. !!! note "Supported Events" BoardArrived BoardDeparted ReplyWorkOrderInfo !!! note "Supported Requests" QueryWorkOrderInfo ## 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 | ### IoTMetadataDefinition Resource Level Configuration At the **Resource** level, there are several configuration we can make to set our connection with the IPC-Hermes Equipment and with the Equipment. | Resource | Resource Type | Area | Name | Value | Description | | --------------------- | ------------- | ---- | ----------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | *MES Hermes Resource* | | | **Event Name**_useservice | | On event call Service with. Format: signature, input key name, output key name and resource key name. Example `Cmf.Custom.ProjectName.Orchestration.InputObjects.HERMESInput, Cmf.Custom.ProjectName.Orchestration \| api/ProjectName/HERMESRequest \| inputkey,outputkey,resourcekey`. MessageToSend, MessageToSend and ResourceName are the default values. | | *MES Hermes Resource* | | | **Event Name**_usedee | | On event call a DEE with single input and output. Format: `DEEName \| Order \| inputkey,resourcekey`. MessageReceived and ResourceName are the default values. | | *MES Hermes Resource* | | | **Event Name**_paramlisttodee | | On event call a DEE with Multiple Inputs and Outputs. Format `DEEName \| Order \| Input Keys \| Output Keys`. Example `CustomIoTTrackIn \| order \| MachineId,MagazineId,QueryId\| QueryId,BoardId,WorkOrderId,BatchId` | | *MES Hermes Resource* | | | **Event Name**_UseTrackInOperation | | If defined with key **Event Name**_paramlisttodee the value will be sent in an DEE input `Operation`. Accepted values: `complexdispatchandtrackin` and `complextrackin`. | | *MES Hermes Resource* | | | **Event Name**_UseTrackOutOperation | | If defined with key **Event Name**_paramlisttodee the value will be sent in an DEE input `Operation`. Accepted values: `complextrackout` and `complextrackoutandmovenext`. | | *MES Hermes Resource* | | | hermes_createnotification | | If this key is defined, when an error happens during the processing of an event, a DEE will be called, to generate an notification. | | *MES Hermes Resource* | | | hermes_notification_deeaction | | Name of the DEE to handle Notification on Error. | | *MES Hermes Resource* | | | hermes_notificationtemplate | | Notification Template. | !!! warning "Every time you change these values you must restart the Automation Controller." --- ## How It Works When a new IPC-Hermes Event or Request is received we will parse it in a common workflow. ### When **EventName**_useservice is defined we will: * Parse the Event data and send it in a single input, defined by the user, to the specified Service. * Store the Output key content for further use. If the defined key is not returned an exception will be thrown. ??? Example "Configuration Event" | Resource | ResourceType | Area | Name | Value | | ------------ | ------------ | ---- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | AOIConveyor1 | | | BoardArrived_useservice | Cmf.Custom.ProjectName.Orchestration.InputObjects.HERMESInput, Cmf.Custom.ProjectName.Orchestration \| api/ProjectName/HERMESRequest \| Content,Result | With this configuration, when a BoardArrived event is received, we will call `api/ProjectName/HERMESRequest` with the following inputs: * **Content**: *full Event data* * **ResourceName**: AOIConveyor1 ### When **EventName**_usedee is defined we will: * Parse the Event data and send it in a single input, defined by the user, to the specified DEE. * Store the `Output key` content for further use. If the defined key is not returned an exception will be thrown. More than one DEE can be called if multiple **Event Name**_usedee are set. The order can be defined by the user. For each of these calls ConnectIoT expects `Result` as the output. * `Result` is *true* or *Success*: Everything was ok. * `Result` is anything else: process was not completed. ??? Example "Configuration Example: Event" | Resource | ResourceType | Area | Name | Value | | ------------ | ------------ | ---- | ------------------- | --------------------------------------------------------- | | AOIConveyor1 | | | BoardArrived_usedee | CustomTemplateBoardTrackIn \|1\|Content,Result, Equipment | | AOIConveyor1 | | | BoardArrived_usedee | CustomTemplateBoardDC \|2\|Content,Result | With this configuration, when a BoardArrived event is received, we will call in order: * CustomTemplateBoardTrackIn, with the following inputs. * **Content**: *full Event data* * **Equipment**: AOIConveyor1 * CustomTemplateBoardDC, with the following inputs. * **Content**: *full Event data* * **ResourceName**: AOIConveyor1 For each of these calls ConnectIoT expects `Result` as the output. ### When **EventName**_paramlisttodee is defined we will: * Parse the Event data acording to the list of parameters defined for `Input Keys`. * Store the `Output keys` content for further use. More than one DEE can be called if multiple **EventName**_paramlisttodee are set. The order can be defined by the user. ??? Example "Configuration Example: Event" | Resource | ResourceType | Area | Name | Value | | ------------ | ------------ | ---- | -------------------------------- | --------------------------------------------------------- | | AOIConveyor1 | | | BoardArrived_paramlisttodee | CustomTemplateBoardTrackIn \|1\|MachineId,BoardId | | AOIConveyor1 | | | BoardArrived_UseTrackInOperation | ComplexTrackIn | | AOIConveyor1 | | | BoardArrived_paramlisttodee | CustomTemplateBoardDC \|2\|BoardId,Length,Width,Thickness | With this configuration, when a BoardArrived event is received, we will call in order: * CustomTemplateBoardTrackIn, with the following inputs. * **MachineId**: Event.MachineId * **BoardId**: Event.BoardId * **Operation**: ComplexTrackIn * **ResourceName**: AOIConveyor1 * CustomTemplateBoardDC, with the following inputs. * **BoardId**: Event.BoardId * **Length**: Event.Length * **Width**: Event.Width * **Thickness**: Event.Thickness * **ResourceName**: AOIConveyor1 ??? Example "Configuration Example: Request Reply" | Resource | ResourceType | Area | Name | Value | | ------------ | ------------ | ---- | --------------------------- | -------------------------------------------------------------------------------------------------------------- | | AOIConveyor1 | | | QueryWorkOrderInfo_paramlisttodee | CustomTemplateQueryWorkOrderInfo\|1\|MachineId,MagazineId,QueryId,BoardId\|QueryId,BoardId,WorkOrderId,BatchId | With this configuration, when a QueryWorkOrderInfo event is received, we will call: * CustomTemplateBoardTrackIn, with the following inputs. * **MachineId**: Event.MachineId * **MagazineId**: Event.MagazineId * **QueryId**: Event.QueryId * **BoardId**: Event.BoardId * **ResourceName**: AOIConveyor1 After DEE's successful process the Response Event will be triggered: * Response will be built with the DEE output: * Event.QueryId: output.**QueryId** * Event.BoardId: output.**BoardId** * Event.WorkOrderId: output.**WorkOrderId** * Event.Width: output.**Width** * Event.Thickness: output.**Thickness**