Creating Stored Procedure Calculations

  1. Browse into the Plant Model, then into A Production Unit and Group.

  2. Right-click on a Group and select "New Variable."

  3. Type in the name of the new Variable. Variable names must be unique within a given Production Unit.

  4. Right-click on the new variable and select "Create Calculation."

  5. From the Calculation Configuration window, select a Calculation Type of "Stored Procedure."

  6. Search for a Stored Procedure to attach to the calculation by selecting the "…" button on the "Stored Procedure" sub-tab.

  7. Select the "OK" when finished and return to the Calculation Configuration window.

  8. This example stored procedure has 3 inputs. A prototype of the stored procedure is provided in the window below the Stored Procedure selection. The first parameter of every Stored Procedure calculation is the OUTPUT parameter. The remainder of parameters are expected to be supplied by the calculation.

  9. Type in the number of inputs in the " Inputs" field.

  10. Select the "Inputs" sub-tab.

  11. Select the first Input with alias of "a" The attributes of this input will be displayed within the "Selected Input" frame.

  12. Select the "Modify" button, and identify the Name, Entity, and Attribute to be associated with the Input. In this example, the first parameter is expected to be a Unit Id, so select "This Variable" for the entity, "Parent PUId" for the Attribute, then select "Apply."

  13. Select the second Input, select "Modify" and specify "This Event" for the Entity, and "Start Time" for the Attribute. Select "Apply" when finished. This will pass in the start time of the calculation time period as the second parameter. The calculation time period will be identified later when editing the configuration of the variable this calculation is attached to.

  14. Select the third Input, select "Modify" and specify "This Event" for the Entity, and "End Time" for the Attribute. Select "Apply" when finished. This will pass in the end time of the calculation time period as the third parameter.

  15. Select "Save" to save the calculation and close the Calculation Configuration window.

  16. Set up the calculation interval. Select the Variable; right-click and select "Variable Sheet."

  17. In the Variable Sheet window, select "Time" for the Event Type, enter "440" for the Sampling Interval, and enter "80" for the Sampling Offset. This will create a daily calculation that will produce the total waste amount for the day at 8:00 am each day.

  18. When finished in the Variable Sheet, select the "Save" icon in the toolbar to make the current changes active.

See Also