Professional Documents
Culture Documents
Technical Paper
Getting Started With Mule + ActiveMQ + jBPM
This Technical Paper describes the features of Mule and the configuration of Mule with ActiveMQ and jBPM.
Revision History Table - Revision Status lists the latest version and date for the various sections of the specification. Versions 0.X are prerelease draft versions. Versions 1.X to X.X are post release versions. The number to the left of the decimal in the version number indicates the major version number. The number to the right of the decimal in the version number indicates the minor version number. The major version number will change for the following reasons: Information added to document. Information removed from document. Rearrangement of sections in the document. Revisions to the scope or purpose of the document. The minor version number will change for the following reasons: Spelling corrections. Page layout or formatting corrections. Minor changes that do not affect the scope or purpose of the document.
Version 1.0 Date 09/05/12 Initial release Description
Table of Contents
1 Introduction.................................................................................................................................................................5 2 Overview......................................................................................................................................................................6 3 Creating the SQL Historian........................................................................................................................................8
3.1 IMPLEMENTATION OF A HISTORIAN SQL TABLE...............................................................................................8 3.2 CONFIGURATION OF THE HISTORIAN IN PA....................................................................................................8
4 Creating Local Result Set Tables........................................................................................................................10 5 Creating 601 Models in PA......................................................................................................................................11 6 Controls and Statements within RTIP....................................................................................................................13
6.1 DEFINE RTIP CONTROLS.......................................................................................................................13 6.1.1 Production Unit..............................................................................................................................13 6.1.2 Production Line ............................................................................................................................13 6.1.3 Department ..................................................................................................................................13 6.1.4 Batch Number...............................................................................................................................14 6.2 CREATE STATEMENT..............................................................................................................................14
Service creation and hosting expose and host reusable services, using Mule ESB as a lightweight service container Service mediation shield services from message formats and protocols, separate business logic from messaging, and enable location-independent service calls Message routing route, filter, aggregate, and re-sequence messages based on content and rules Data transformation exchange data across varying formats and transport protocols
SQL Historian.zip
ReadBeforeSQL
ReadBetweenSQL
TimeSQL
More information about SQL Historian can be found in the Proficy Plant Applications Administrator Documentation. The Tag-Ids is the number of the Result Set Example: A value change for the tag with Tag-Id equals 1 will activate the 601 model for the Production Event. Remark that it is needed to fill in a tag value for each tag in the SQL Historian before the tag can be seen from a browse tag window in PA administrator. The scripts in Insert Tag Values zip file can be used to insert the first values for Production Events, Variable Values, Grade Change, Downtime Events, User Defined Events, Waste Events and Production Plan.
601 Models.zip
The different models are triggering a stored procedure when a value change occurs for a specific tag in the SQL Historian. The stored procedure follows the structure below (this example is using the Production Event. The Local_RTIPProductionEvents is the local Result Set table and the Local_SQLHistorian is the SQL Historian table): CREATE Procedure spLocal_TriggerRTIPProductionEvents @ReturnStatus int OUTPUT, @ReturnMessage varchar(255) OUTPUT, @EC_Id int, @TriggerTimestamp datetime AS Declare @MaxTimeStamp DateTime -- In case a end-user inserts a new row during the execution of this SP Update Local_RTIPProductionEvents Set Flag = 1 Where Flag = 0 -- Select * from local Result Set table Select 1, Id, Transaction_Type, Event_Id, Event_Num, PU_Id, Convert(VarChar(30),TimeStamp,120), Applied_Product, Source_Event, Event_Status, Confirmed, User_Id, Post_Update, Conformance, TestPctComplete, StartTime, TransNum, TestingStatus, CommentId, EventSubTypeId, EntryOn, ApprovedUserId, SecondUserId, ApprovedReasonId, UserReasonId, UserSignOffId, ExtendedInfo From Local_RTIPProductionEvents Where Flag = 1 -- Deletes processed rows from the local Result Set table Delete From Local_RTIPProductionEvents Where Flag = 1 -- Set @MaxTimeStamp to the latest time where the specific tag in the SQL Historian was changed Select @MaxTimeStamp = Max(tTimeStamp) From Local_SQLHistorian Where Tag_Id = 1 -- Delete all tag changes from the SQL Historian but the last Delete From Local_SQLHistorian Where Tag_Id = 1 and tTimeStamp <> @MaxTimeStamp The zip file below includes the stored procedures for Production Events, Variable Values, Grade Change, Downtime Events, User Defined Events, Waste Events and Production Plan. These scripts need to be executed within a SQL Query Analyzer.
601 SPs.zip
The model has to be set up at any production unit in the Plant Model (one unit could be created only for this purpose). The models can be configured importing the Excel sheet below. Remember to substitute the Production Line, Production Unit, Event Subtype and name of the SQL Historian.
Configure Models.zip
Activate the models in the Proficy Plant Applications Administrator. Navigate to the unit where the Models have been attached. Select Configure Events, select the Configure Event Detection Models and active the models one-by-one.
Production Unit
1. 2. 3. 4. 5. The Production Unit control has been dragged from the system tree (see figure The Object Type has been selected as a combo box Both Unit Description and Unit Id columns has been displayed Selected Item Column is Unit Description Selected Value Column is Unit Id
Production Line
1. 2. 3. 4. 5. 6. The Production Line control has been dragged from the system tree The Object Type has been selected as a combo box Both Line Description and Line Id columns has been displayed Selected Item Column is Line Description Selected Value Column is Line Id The Select Value Property has been linked to the Line Id of the Production Unit control
Department
1. 2. 3. 4. 5. 6. The Department control has been dragged from the system tree The Object Type has been selected as a combo box Both Department Description and Department Id columns has been displayed Selected Item Column is Department Description Selected Value Column is Department Id The Select Value Property has been linked to the Department Id of the Production Line control
Figure 1
Batch Number
1. Add a textbox for the Batch Number input
Figure 2
Create Statement
The only task for the statement used from RTIP to Create, Update or Delete an event in PA is to insert the parameter values into the local Result Set table. This is done using a Call statement, executing a stored procedure. The Call statement will include input values coming from the end-user selections (in our example this will be the Production Unit Id and Batch Number). These input values can now be used directly as parameter values into the local Result Set table or used to derive other parameter values. In our example the stored procedure looks as follows: CREATE PROCEDURE spLocal_InsertBatch @BatchNum VarChar(25), @PUId Int AS
Declare @Max int, @BatchExist int, @Timestamp VarChar(30), @Event_Id int -- If no Batch Number has not been transferred to the SP, error message and return If @BatchNum is Null Begin Select 'No Batch Number' as Message Return End -- If no Production Unit has not been transferred to the SP, error message and return If @PUId is Null Begin Select 'No Production Unit' as Message Return End -- Does the Batch already exist in the PA database Select @BatchExist = Count(*) From Events where Event_Num = @BatchNum and PU_Id = @PUId -- Create the batch if it does not exist in the PA database If @BatchExist = 0 Begin Select @Timestamp = Convert(VarChar(30),GetDate(),120) -- Hot insert, inserts the Batch directly in the database Execute spServer_DBMgrUpdEvent @Event_Id OUTPUT, @BatchNum, @PUId, @Timestamp, Null, Null, 26, 1, 0, 6, Null, Null, Null, Null, Null, 0 --Send insert to bus (post = 1, Pre = 0) -- Sends the Batch to the client (Post_Update = 1) Insert into Local_RTIPProductionEvents (Id, Transaction_Type, Event_Id, Event_Num, PU_Id, TimeStamp, Applied_Product, Source_Event, Event_Status, Confirmed, User_Id, Post_Update, Conformance, TestPctComplete, StartTime, TransNum, TestingStatus, CommentId, EventSubTypeId, EntryOn, ApprovedUserId, SecondUserId, ApprovedReasonId, UserReasonId, UserSignOffId, ExtendedInfo, Flag) Values(1,1,@Event_Id,@BatchNum,@PUId,@Timestamp,Null, Null, 5, Null, 8, 1, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, 0) -- Increment the tag value for the Production Event tag Select @Max = Max(dValue) From Local_SQLHistorian Where Tag_Id = '1' Insert into Local_SQLHistorian (Tag_Id, sDescription, sEngUnits, Float, tTimeStamp, sValue, dValue, dQuality) Values('1','Production Events',Null, Null, Getdate(),Null,@Max+1,0) End -- If the Batch already exists, send error message and return If @BatchExist <> 0 Begin Select 'Batch already exists' as Message Return End -- Send success message Select 'Success Updating: ' + @BatchNum as Message This script needs to be executed in a SQL Query Analyzer and can be found in the zip-file below:
Insert Batch.zip
Before using the stored procedure in a Call statement it has to be included in a Schema (see RTIP documentation for how to create Schemas). Select the Schema where you want to include the stored procedure in the SQL Statement Builder, right click and select Add Table etc..
Figure 3 Select that the Schema contains Procedures. Click Next >.
Figure 4 Select the stored procedures that should be added to the Schema. Click Next > and Finish, and the stored procedure are now included. Select New Statement in the SQL Statement Builder and select Call as the type of SQL statement. Hereafter drag the stored procedure from the Schema folder into the empty Table Diagram frame.
Figure 5 Save the Statement and give it a name. RTIP has already built the Statement in the SQL Statement frame, and has selected names for the input parameters (par0_@BatchNum and par1_@PUId). RTIP concludes these input parameters by looking at the header of the stored procedure, but it is needed to execute the stored procedure from inside RTIP for RTIP to know what type of output it should expect. Execute Statement will prompt for values for the input parameters.
Figure 7 The result frame displays the output of the stored procedure (Message: Success Updating: ABC002). Return to the configure mode of the display with the input parameter, select the Data Source tab in the System Tree and drag the Statement just created into the display. Select the Object Type as Text Box and select to display the message column.
Figure 8
Select the Production Unit Combo Box and link the Selected Value property to the Message Text Box par1_@PUId.
Figure 9 Select the Batch Number Text Box and link the Text property to the Message Text Box par0_@BatchNum.
Figure 10
Now the two input values are linked to the input parameter of the statement. The last thing is a button to execute the statement. Insert the button and link the control to the Text Box Insert Batch (the Message Text Box).
Figure 11 Thats it. Now change the display to Run Mode and Select Department, Production Line, Production Unit and Insert Batch Number and Click on the Create Batch button to create a new Batch within the Proficy Plant Applications Database.
Figure 12