--- alias: tutorials-weigh-and-dispense-scale-integration tags: - "11.3" description: "Messages and workflows that integrate an electronic scale with the Weigh and Dispense pages through the application message bus" --- # Electronic Scale Integration The Weigh and Dispense pages make some assumptions about the communication with the electronic scale through the application message bus. This page describes the structure of the messages and the integration workflows for positive and negative weighing. !!! info The scale Resource must integrate with the system, so that the Weigh and Dispense wizard receives the values of the scale automatically. For the configuration of the scale, see [[tutorials-weigh-and-dispense-scenario-configure]]. ## Message Structures ### 1. Instrument Configuration | Type | Subject | | --- | --- | | RequestReply | `Measurement.[ResourceId].Setup` | Table: Instrument configuration message ```json { "SendToSubject": "CMF.Resource.[ResourceId].[Guid]", "SetTare": true } ``` The `SetTare` property is `true` or `false`. ### 2. Begin Weighing | Type | Subject | | --- | --- | | RequestReply | `Measurement.[ResourceId].Start` | Table: Begin weighing message ```json { "SendToSubject": "CMF.Resource.[ResourceId].[Guid]", "Timeout": 6000, "ResetTare": true } ``` The `ResetTare` property is `true` or `false`. ### 3. Stop Weighing | Type | Subject | | --- | --- | | RequestReply | `Measurement.[ResourceId].Stop` | Table: Stop weighing message ```json { "SendToSubject": "CMF.Resource.[ResourceId].[Guid]" } ``` ### 4. Notify Weight Value | Type | Subject | | --- | --- | | RequestReply | The `SendToSubject` that the Begin Weighing request defines | Table: Notify weight value message ```json { "Timestamp": "2019-02-05T11:17:51.626Z", "Value": 1234.5678, "IsStable": false, "Extra": { "TareValue": 0, "WeightIncludesTare": false, "WeighingUnits": "Kg" } } ``` ### 5. Interface Events | Type | Subject | | --- | --- | | RequestReply | `Measurement.[ResourceId].Event` | Table: Interface events message The interface sends this message structure for the following events: - Dispense and Continue - Dispense and Reset - Dispense - Begin weighing - Complete weighing - Scale change - Weighing mode change, from positive to negative or from negative to positive - Undo - Page close, when the operator closes the page abruptly - Ingredient selection, when the operator switches ingredients or opens the Weigh and Dispense page The following examples show the message for three events. Example 1: Weighing mode change. ```json { "OperationType": 10, "Data": { "WeighingMode": "Negative" } } ``` Example 2: Ingredient selection. ```json { "OperationType": 13, "Data": { "tareValue": 0, "dispensedQuantity": 0, "requiredQuantity": 3, "bomProductName": "BomAutomationWD#IG.4ToFlour.6", "bomProductId": "2002110227330000006" } } ``` Example 3: Generic event. ```json { "OperationType": 6 } ``` ## Integration Workflows The following workflows describe the interaction between the Weigh and Dispense GUI, the equipment integration, and the scale. ### Positive Weighing ![Sequence diagram of the integration workflow for positive weighing between the GUI, the equipment integration, and the scale.](images/integration_workflow_positive_weighing.png) 1. When the Weigh and Dispense GUI starts, it sends a `Start` request to the equipment integration and sets `Reset` to `true`. The equipment integration resets the tare, if the scale supports it, and stores the `TareValue`. It reports the weight and the tare to the GUI with `ReportValue`, including whether the weight includes the tare. The GUI sets `GUIWeightValue` and `GUITareValue`. 2. When the operator selects **Set Tare & Begin**, the GUI sends `Configure (Positive)`. If the scale supports it, the equipment integration performs a remote tare and stores the `TareValue`. The GUI sets `GUITareValue` to `TareValue`. 3. The equipment integration reads the weight of the scale with `GetValue` and reports it to the GUI. When the weight includes the tare, the GUI calculates `GUIWeigh` as `WeightValue` minus `TareValue`. Otherwise, `GUIWeigh` is `WeightValue`. 4. On a partial or complete dispense, the GUI sends the `Start` request again, sets `Reset` to `true`, and the workflow repeats. ### Negative Weighing ![Sequence diagram of the integration workflow for negative weighing between the GUI, the equipment integration, and the scale.](images/integration_workflow_negative_weighing.png) 1. When the Weigh and Dispense GUI starts, it sends an `Initialize` request to the equipment integration and sets `Reset` to `true`. The equipment integration resets the tare, if the scale supports it, and stores the `TareValue`. It reports the weight and the tare to the GUI with `ReportValue`. The GUI sets `GUIWeightValue` and `GUITareValue`. 2. When the operator begins weighing, the GUI performs the action alone and sends no message to the equipment integration. When the weight includes the tare, the GUI sets `GUIGrossWeigh` to `WeightValue`. Otherwise, it sets `GUIGrossWeigh` to `WeightValue` plus `TareValue`. 3. For each new `ReportValue`, the GUI calculates `GUIWeightValue`. When the weight includes the tare, `GUIWeightValue` is `GUIGrossWeigh` minus `WeightValue`. Otherwise, it is `GUIGrossWeigh` minus the sum of `WeightValue` and `TareValue`. 4. On a partial or complete dispense, the GUI sends the `Initialize` request again, sets `Reset` to `true`, and the workflow repeats. ## Expected Result You know the messages and the workflows that the equipment integration must support, so that the Weigh and Dispense pages receive the values of an electronic scale.