Beruflich Dokumente
Kultur Dokumente
1 FEBRUARY, 2002
For additional information on this manual, this OPC server, or Matrikon, please contact: Address: Matrikon
CONFIDENTIAL The information contained here in is confidential and proprietary to Matrikon. It may not be disclosed or transferred, directly or indirectly, to any third party without the explicit written permission of Matrikon. All rights reserved. No part of this document may be reproduced, stored in a retrieval system, translated, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of Matrikon.
ii
User's Manual
1.
INTRODUCTION .........................................................................................................................1 1.1 1.2 1.3 1.4 1.5 SYSTEM REQUIREMENTS.....................................................................................................1 SYSTEM ARCHITECTURE .....................................................................................................2 OPC OVERVIEW.................................................................................................................3 DOCUMENT CONVENTIONS ............................................................................................3 ERROR HANDLING.............................................................................................................4
2.
USER INTERFACE ........................................................................................................................5 2.1 MAIN WINDOW..................................................................................................................5 2.1.1 SAVING THE CONFIGURATION.................................................................................6 2.1.2 2.1.3 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 LOADING THE CONFIGURATION .............................................................................7 CREATING A NEW CONFIGURATION ......................................................................7 ADDING AN OPC SERVER CONNECTION ..............................................................9 VIEWING AN OPC SERVERS PROPERTIES .............................................................10 DELETING AN OPC SERVER CONNECTION ..........................................................10 ADDING A GROUP ..................................................................................................11 VIEWING AND EDITING GROUP PROPERTIES .......................................................13 ACTIVATING AND DISABLING GROUPS ................................................................13 DELETING A GROUP.................................................................................................14 ADDING AN ITEM .....................................................................................................14 DELETING AN ITEM ...................................................................................................16
2.3 ODBC DATABASE CONNECTIONS ................................................................................17 2.3.1 ADDING A DATABASE CONNECTION...................................................................19 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.4 2.4.1 DELETING A DATABASE CONNECTION .................................................................20 ADDING A QUERY....................................................................................................20 DELETING A QUERY ..................................................................................................22 ADDING A TRIGGERED WRITE ................................................................................22 DELETING A TRIGGERED WRITE ..............................................................................25 GENERAL ...................................................................................................................26
2.4.2 LOGGING..................................................................................................................26 2.5 USING CUSTOM QUERIES................................................................................................28 2.5.1 THE CUSTOM QUERY FORM ....................................................................................28 EXECUTING SIMPLE QUERIES ...........................................................................28 USING AN OPC ITEM IN A QUERY...................................................................30 CREATING AN INSERT QUERY USING AN OPC ITEM ....................................32 WRITE TO OPC ITEMS USING A SELECT STATEMENT ......................................33 ADDING THE QUERY.........................................................................................34 EDITING/DELETING AN EXISTING QUERY .......................................................34 2.5.1.1 2.5.1.2 2.5.1.3 2.5.1.4 2.5.1.5 2.5.1.6
iii
Matrikon Inc
User's Manual
2.5.2 QUERY OPTIONS PANEL ..........................................................................................35 2.5.2.1 QUERY EXECUTION OPTIONS ..........................................................................35 2.5.2.2 2.5.2.3 2.5.2.4 2.5.2.5 2.6 2.6.1 2.6.2 3. OPC ITEM DELIMITERS.......................................................................................35 QUERY TEXT OPTIONS .......................................................................................35 OPC RETURN ITEMS...........................................................................................35 QUOTATION MARKS .........................................................................................35
USING STORED PROCEDURES ........................................................................................36 ADDING A STORED PROCEDURE...........................................................................36 VIEWING/EDITING STORED PROCEDURES ............................................................37
WALKTHROUGH OF STORING PROCESS VALUES IN AN ODBC DATABASE ....................39 3.1 CONNECT TO THE MATRIKON OPC SERVER FOR SIMULATION .................................39 3.1.1 3.2 MATRIKON OPC SERVER FOR SIMULATION ..........................................................39 BROWSE FOR SOME POINTS...........................................................................................40
3.2.1 MATRIKON OPC SERVER FOR SIMULATION ..........................................................40 3.3 CONFIGURE THE ODBC DATABASE...............................................................................42 3.3.1 3.3.2 3.4 MICROSOFT ACCESS CONFIGURATION ...............................................................42 MICROSOFT SQL CONFIGURATION.......................................................................45
3.5 STORE PROCESS DATA IN DATABASE............................................................................49 3.5.1 STORING DATA IN MICROSOFT ACCESS ..............................................................49 3.5.1.1 3.5.1.2 UPDATE QUERY .................................................................................................50 INSERT QUERY....................................................................................................52
3.5.2 STORING DATA IN MICROSOFT SQL ......................................................................53 3.5.2.1 UPDATE QUERY .................................................................................................54 3.5.2.2 3.5.3 INSERT QUERY....................................................................................................55 STORING DATA IN MICROSOFT EXCEL ..................................................................56
iv
Matrikon Inc
User's Manual
1. INTRODUCTION
The Matrikon OPC Client for ODBC enables any ODBC-compliant database to exchange process data with an OPC Server. This application uses standard SQL queries. There are two main uses for the OPC Client for ODBC: Archive process values from an OPC server to an ODBC database. An ODBC database can become a miniature process historian, and this application can place the data in permanent storage. Any trending or analysis tool can then be used to retrieve the data from the ODBC database. Populate an OPC Server with data from an ODBC database. For example, gas chromatograph data, stored in a database, can be written into an OPC server by way of this application.
Other features include: Support for ODBC compliant databases such as Microsoft Access, Microsoft SQL, Oracle, Sybase, etc. Communication between multiple ODBC databases with multiple OPC servers, including concurrent sessions with the same server SQL-based query engine that allows both reading and writing Real-time editor that allows query changes even while the application is running Point-and-click interface supporting drag and drop operation Support for transaction-based updates Runs as a Windows NT Service Supports stored procedures XML configuration file
Matrikon Inc
User's Manual
Matrikon Inc
User's Manual
OPC Interface
OPC Server OPC Server OPC Server
Device A
Device B
Device C
Once an OPC server is written for a particular device, it can be reused by any application that is able to act as an OPC client. OPC servers use Microsofts OLE technology (also known as the Component Object Model, or COM) to communicate with clients. COM technology permits a standard for real-time information exchange between software applications and process hardware to be defined.
Matrikon Inc
User's Manual
Matrikon Inc
User's Manual
2. USER INTERFACE
The OPC Client for ODBC can be started through the Windows Start menu (Start Programs Matrikon OPC OPC ODBC Client ODBC OPC Client), or by double-clicking the executable file, ODBCOPCCLIENT.exe. This will run the COM component in a command-line window on your desktop. In addition, an icon for the COM component will appear in the system tray. When the system tray icon is right-clicked, a menu will appear with the options Configure and Shutdown. Selecting Shutdown will close the ODBC OPC Client, and selecting Configure will load the GUI for configuring the client.
Matrikon Inc
User's Manual
Once started, the OPC Client for ODBC displays the main window, through which all settings and configurations are accessed. The main window is shown in Figure 2 above. The main window consists of three panes of information. The top-left pane contains information related to OPC server connections. This includes a list of the available OPC servers, a list of the OPC servers to which the client is connected, and properties for a specific OPC server, OPC group, or OPC item. The top-right pane contains information related to ODBC database connections. This includes an interface for adding a database connection, a list of the ODBC databases that the client is connected to, and an interface for adding a triggered write. The bottom pane contains information related to SQL queries. This includes the current query for a specified OPC item tag, or an interface for defining the query of an OPC item tag. There is also a menu bar at the top of the main window, which includes the File, View, Session, and Help menus. Below the menu is a toolbar, as shown in Figure 3 - The Toolbar below. Its buttons, from left to right, are New Configuration, Open Configuration, Save Configuration, Add OPC server, Delete OPC server, Add Group, Delete Group, Add Item, Delete Item, and Delete Database.
Figure 3 - The Toolbar To close the ODBC OPC client configuration window, select Exit from the File menu or close the main window. To shut down the OPC Client for ODBC from the configuration window, select ShutDown from the File menu. All the settings in the Options dialog will be saved. If the Save current configuration on shutdown option were selected, then all connection information will be saved. The Client will then perform an orderly shutdown, releasing any allocated resources before terminating.
If there already is a current configuration file, then this button will save the configuration to that file, otherwise a dialog will appear asking the user to specify a name and path.
Matrikon Inc
User's Manual
Figure 5 - The "Load Configuration" Button Enter the name and path of the XML file that you want to load the configuration from.
A dialog will appear asking if you want to save your current configuration. Press <<Yes>> to save your current configuration and create a new one, press <<No>> to overwrite your current configuration with a new one, or press <<Cancel>> to return to your current configuration.
Matrikon Inc
User's Manual
Figure 7 - Connected Servers The Connected Servers tab displays the OPC servers that the client is currently connected, in tree format. Each OPC server can have any number of groups defined, and each group can have any combination of available OPC items in it. An example of this is shown in Figure 8 below.
Matrikon Inc
User's Manual
Figure 9 The Add OPC server Button 3. After pressing the OPC button, a dialog will appear like in Figure 10 below.
4. At the bottom of the dialog, select the computer that contains the OPC server to which a connection is required. By default, the Local Host option is selected (the Local Host is the computer you are currently using). To connect to a computer over the network, select the second option and choose a Machine Name from the drop-down menu or select the third option and type it manually into the corresponding text field. 5. At the top of the dialog, select an OPC server name to connect to. This can be done from the drop-down menu or by typing it manually into the text field. The available servers is dependent upon the Machine Name selected. 6. Press the <<Commit>> button after all the information is entered. If the OPC Server was not already running, then the OPC Client for ODBC will start the OPC server automatically. The new OPC server will be added to the tree view under the Connected Servers tab display. If you try to add an OPC server to which the OPC Client for ODBC is already connected, a dialog box will inform you that a connection is already established. A new redundant connection will not be made.
Note
Matrikon Inc
User's Manual
Figure 12 - The "Delete OPC Server" Button A dialog will pop up asking if you are sure that you want to delete the selected OPC server and associated items. Press <<OK>> to delete the server, or <<Cancel>> if you change your mind. After pressing <<OK>>, the client will disconnect from the OPC server and its name will be removed from the display.
10
Matrikon Inc
User's Manual
Figure 13 - The "Add Group" Button A dialog will appear for configuring the group that you wish to add. See Figure 14 below for an example.
11
Matrikon Inc
User's Manual
Value The group name can be any name desired, so long as it is not the same as an existing groups name. The group name, then, serves as an identifier for the user. Choose a name that makes sense to the users. The update rate specifies how often the OPC Server should try to retrieve data for the items within this group. Note that the update rate is not a guarantee. That is, an OPC server will try to retrieve data for this groups items at the specified rate, but the actual rate may be slower if the server is busy or if communications from server to data source are hampered. The deadband field allows the user to tell the OPC server what constitutes a change in asynchronous communications. That is, if the deadband is 10%, the value of items in this group must change by at least 10% of their current value before the server will notify the client of any changes. The I/O type refers to how data for items in this group will be retrieved from the OPC Server. Selecting synchronous tells the client to make a request for data and wait until the server retrieves it. Selecting asynchronous means that the client makes a request for data, but does not wait for the server to retrieve the data. Rather, the server responds with an update only after retrieval, and only if item values in the group have changed. The create active box allows the user to decide if the group should be active immediately following creation. Unchecking this box means the group will be created in an inactive state. Any items added to an inactive group will not be polled by an OPC server.
Update Rate
Deadband
IO Type
Create Active
Press <<Commit>> to add the group once the information has been entered, or <<Close>> to cancel the add group function. If you do not specify a group name, then the client will not allow you to add the group.
12
Matrikon Inc
User's Manual
Figure 15 - OPC group properties To edit these properties, press the <<Update>> button and a form similar to the one in Figure 14 will appear. You can change the group information in the text field boxes (except for the Group name and I/O Type) and then press <<Commit>> to apply the changes. From the display of group properties, press <<Close>> to return to the display of connected servers.
13
Matrikon Inc
User's Manual
Figure 16 - The "Delete Group" Button A dialog box will pop up asking if want to delete the selected OPC group and associated queries. Press <<OK>> to delete the group, or <<Cancel>> to cancel the delete. After pressing <<OK>>, the group will be deleted as well as any queries made under its items.
Figure 17 - The "Add Item" Button A dialog box now will appear for configuring the item that you wish to add. Enter the Item ID, or press <<Browse>> to search for the ID of the item you wish to add. You can also select whether the item is an array, the data type of the item, and the access path of the item. You can press <<Commit>> to add the item once the information has been entered, or <<Close>> to cancel the add item function. See Figure 18 and Figure 19 below.
14
Matrikon Inc
User's Manual
Option Item ID
Value The item ID is server specific. Refer to the server documentation on item IDs it supports. Item IDs are names that correspond to a discrete piece or item of data the server can retrieve. Typically, the data type should be left at Empty/Default, which causes the client to use the servers data type for the item. Otherwise, the client will attempt to convert the data type of the incoming data to the selected type. The access path is server specific. Refer to the server documentation on whether the access path is used. Leave it blank if it is not used. Access paths normally are used to allow the user more control in specifying how or where data can be obtained for an item.
Data Type
Access Path
15
Matrikon Inc
User's Manual
Figure 20 - The "Delete Item" Button A dialog box will appear asking for confirmation. Press <<OK>> to delete the item, or <<Cancel>> otherwise. After pressing <<OK>>, the item and its query will be deleted.
16
Matrikon Inc
User's Manual
Figure 21 - The Add Database Tab Display The Connected Databases tab displays all the databases that the client is connected to through ODBC, in a tree-view structure. Expanding each database will show the properties and tables associated with it. Expanding each property or table will show the fields within it. See Figure 22 below.
17
Matrikon Inc
User's Manual
The Triggered Writes tab displays two things: an interface for setting the triggered write properties, and a list of all the triggered writes. The triggered write properties are shown by default and pressing the <<Close>> button will switch views to the list of all triggered writes. Figure 23 and Figure 24 show both views. See section 2.3.5 for more information on configuring triggered writes.
18
Matrikon Inc
User's Manual
Option Name Data Source Name User Name Password Timeout Read Only
Value Name of the ODBC connection. This name can be selected arbitrarily. The name of the data source, which can be obtained from the ODBC Data Sources in the Windows Control Panel. The name of the user that the OPC Client for ODBC must use to connect to the database. The password for the above user name. The amount of time (in seconds) that the OPC Client for ODBC must wait for the ODBC data source before declaring a timeout. Specifies if the OPC Client for ODBC will only be permitted to read from the database, or if it can write as well.
The data sources can be configured by pressing the <<Configure>> button. Press <<Apply>> and the OPC Client for ODBC will attempt to connect to the database. A dialog box will appear telling you if the ODBC connection was successful or not. If the connection was successful, the database will be added to the Connected Databases tab in the right pane.
Note
If you try to add a database connection with the same name as one that the OPC Client for ODBC already has, the dialog box will inform you that the ODBC connection was not successful. 19
Matrikon Inc
User's Manual
Figure 26 - The "Delete Database" Button A dialog box will appear asking for confirmation. Press <<OK>> to delete the database connection, or <<Cancel>> otherwise. After pressing <<OK>>, the database connection will be deleted and removed from the list of databases in the Connected Databases tab.
20
Matrikon Inc
User's Manual
After you drag and drop the item, a form will appear in the bottom pane for configuring the item query. See Figure 28 below.
Figure 28 - Add Item Query Form On the Add Item Query form, general information about the OPC server and ODBC database is shown on the left. To the right of the general information, you can select between an update and insert query type. An update query will update one record in your database with the OPC item at the groups update rate, whereas an insert query will insert new records in your database at the groups update rate. Below the query type selection, enter the desired number of queries per transaction. The rest of the form is used for selecting the table columns you wish to match the OPC item properties. There are four item properties (name, value, quality, and timestamp), so a maximum of four values will be written to the database at the update rate. If you are adding an update query, you can specify which property/column you wish the query to check for when determining which record to update, by putting a check under the Key column in the form. Once you have entered all the query information, press <<Add Query>>. A dialog will appear indicating whether adding the query was successful or not. If it was successful, the ODBC client will start exchanging information from the server to the database. You can view the query in the bottom pane if you click the item you added it to. See Figure 29 below for an example of this.
21
Matrikon Inc
User's Manual
If you wish to define your own query, you can do so by pressing the <<Custom>> button in the Add Item Query form. Figure 30 below shows the form that appears when you do this.
Figure 30 - Adding a Custom Query When adding a custom query, the SQL command is entered into the left text box of the form. Once you enter the command, press <<Add Query>> and a dialog will appear indicating whether adding the query was successful or not.
Value Select the SQL database from the drop-down scroll menu Select the table containing the triggering field Select the database column that contains the name of the value used for triggering Select the database column that contains the value used for triggering Enter the time interval (in seconds) between client polls to the database
22
Matrikon Inc
User's Manual
Press <<Apply>> and a dialog box will pop up indicating whether setting the properties was successful or not. Figure 31 shows the properties interface in the client and the corresponding view of the SQL database. The Table name, Key Column name, and Value Column name in the properties match the layout of the database.
Figure 31 - Triggered Write Properties and Corresponding Database If setting the triggered write properties was successful, then press <<Close>> to view the list of triggered writes. If a failure occurred, check that the database is SQL and set up properly. Determine which record, in the SQL database and table you selected, that you wish the ODBC client to poll. If the table you selected is empty, then add a record with a name (in the key column) and value (in the value column).
23
Matrikon Inc
User's Manual
Select the Connected Servers tab display in the left pane and add an item that you wish the ODBC client to write to when triggered. Once the item is added, click and drag the item to the right pane and drop it on the list of triggered writes. See Figure 32 below for an example.
Figure 32 Drag and Drop Item to Triggered Writes List An interface will appear in the right pane as shown below. The name of the value in the database must be entered into the Mapped Name field. Once this is done, press <<Apply>> and a dialog will appear telling you if your mapping was successful or not. If it was successful, the triggered write mapping will appear in the list.
Figure 33 - Entering the Mapped Name Whenever the value in the specified record is updated, the ODBC client will write that value to the corresponding item on the OPC Server the next time it polls the database. Matrikons OPC Explorer can be used to monitor the triggered write on the server.
24
Matrikon Inc
User's Manual
25
Matrikon Inc
User's Manual
2.4.1 GENERAL
The general tab contains options for saving and loading connection configurations through an XML file, as well as how data is transmitted from the OPC server.
2.4.2 LOGGING
The Logging tab contains options for configuring the logging settings. The log level sets the severity of messages that is logged, with Low being the least number of log messages (where only the most severe are logged), and High being a large number of messages.
Note
The Debug setting is used for a complete dump of this application while it is running. Therefore, it is not recommended that the Debug setting be used except in situations where Matrikons technical support is involved. This is because a tremendous amount of information will be written to the hard drive, and will significantly decrease this applications performance. This is highly undesirable during normal operation. 26
Matrikon Inc
User's Manual
There are also options for displaying log activity to the command screen, committing all log file writes, and overwriting old log information from previous sessions. The log file must be specified in this tab and is named OdbcOpc Client.log by default.
27
Matrikon Inc
User's Manual
UPDATE... In the Query Text edit box enter the following update OPC set value = 55 where name = Random.Int1. Executing the query gives the results shown in Figure 37. As you will note, the success of the query is reported in the status bar on the bottom of the Query Results tab. In this case the query succeeded, but there were no rows returned as a result of the query, so there will be no column headers shown on the Query Results tab. Entering the original select * statement yields the results in Figure 38. Note that all the values for Random.Int1 are now 55. As you can see, the OPC Client for ODBC can act as a query analyser for a user's databases. The range of queries that can be executed by the client is limited only by the database that you are connected to and the ODBC driver that you are using to connect to the database.
28
Matrikon Inc
User's Manual
29
Matrikon Inc
User's Manual
30
Matrikon Inc
User's Manual
Figure 39. Creating an OPC Item for use in a Query. In order to access a value from a newly configured OPC Item you must append immediately after the End Delimiter one of the following: .n, .v, .t, or .q. These will access the OPC Items Name, Value, Timestamp and Quality respectively. From the example above: <<i:item1>>.n accesses item1s NAME. <<i:item1>>.v accesses item1s VALUE. <<i:item1>>.t accesses item1s TIMESTAMP. <<i:item1>>.q accesses item1s QUALITY.
Note From the example, you may use item1 as many times as you wish in the query itself and each instance of item1 may reference ANY ONE of the OPC Items values.
31
Matrikon Inc
User's Manual
Note(s) These are only example column and table names. Some databases, such as Access, have reserved words such as VALUE. When trying to validate a query on an Access database with the reserved word value in the string will fail. In other words: dont name a column value if you are using Microsoft Access!
Enter the following string into the Query Text box, substituting your specific table and column name where appropriate: Insert into my_opc_table (opcname, opcvalue, opcquality, opctimestamp) values (<<i:item1>>.n, <<i:item1>>.v, <<i:item1>>.q, <<i:item1>>.t)
Figure 40. Insert query with and OPC item The next step is to select an OPC Item that will provide the values for the query (see above: Using an OPC Item in a Query).
32
Matrikon Inc
User's Manual
When a user wishes to write a result set associated with a column to an OPC Item, you must specify the column in the following fashion: <<c:column_name_as_appears_in_table>>
By using a c instead of an i (as used to access OPC Items) the Data Values tab sheet will now allow the user to select an OPC Item to write the column result to. The number of <<c:***>> expressions that can be put in a query is not limited. Note(s) There is no .n, .v, .q, or .t required in this syntax as there is for OPC Items. The query may return multiple rows. The Query Options panel has an option which allows a user to deal with this possibility (see below Query Options Panel:Opc Return Items). In the above example query, there are no OPC Items used in the query that will trigger its execution upon their arrival. In this case, ensure that the query is scheduled to occur by selecting the 'Execute Query At Time Interval' in the Query Options Panel.
33
Matrikon Inc
User's Manual
As you will note: the query name, query string and arguments for the query are all displayed in the tree view. In order to edit or delete an existing query, right-click on the query name in the Current Queries tree view and select edit or delete. If you select: delete - you will be prompted to confirm the query deletion. edit - the original query will be displayed on the form. The Add query button will change to Update, and the Execute query button will change to Cancel. If you select: o o Update - the changes made to the query are applied. Cancel - any changes made to the query are discarded.
Note To use an existing query as a template for a new query, follow the procedure for editing it above, then hit the Cancel button and give the query a new name and new OPC items (optional) and press Add.
34
Matrikon Inc
User's Manual
By choosing Execute Query At Time Interval, the client will actually read the item's values at the rate specified and attempt to execute the query. This is a good way to trigger a query when one of the values in the query rarely changes.
35
Matrikon Inc
User's Manual
Figure 43 - Stored Procedures Dialog 4) Under the 'Add Procedure' tab, select the desired database from the 'Database' list. 5) Select the desired stored procedure from the 'Procedure Name' list. 6) The method signature of the stored procedure is displayed in the lower pane. Under the 'Argument Name' field 'INVAL' indicates an in parameter, 'OUTVAL' indicates and out parameter, and 'INOUTVAL' indicates an in/out parameter.
36
Matrikon Inc
User's Manual
7) For each argument, select the argument type from the 'Argument Type' list. This determines what value to pass as a parameter to the stored procedure. The available argument types are: Item Value Item Name Item Quality Item Timestamp Constant Number Constant String
Note Stored procedures will not be executed until all of the specified OPC Items have changed values. This includes items specified for 'OUT' argument values. As such, it is recommended that a 'Constant' be specified for the initial argument value for all 'OUT' parameters, as this will ensure that the procedure is triggered whenever the input items change. Note that this applies only to the initial argument value for 'OUT' parameters and not the argument value for the 'Output Result to Item' field.
8) For each argument, choose an 'Argument Value'. This may be an OPC Item or a constant value, depending on the choice made in the 'Argument Type' list. For: an item - Click the tag button to select an OPC Item ID. a constant - Type in the value in the space provided
9) Click the 'Add' button to add the stored procedure to the client's list of stored procedures.
37
Matrikon Inc
User's Manual
Figure 44 - Stored Procedures Dialog (Current Procedures) 5) A tree view of stored procedures is displayed. To edit a stored procedure: 1) View the stored procedure you wish to edit (see previous section). 2) Click on the procedure you wish to edit (i.e. the icon), and then right-click on the same.
3) A pop-up menu is displayed. Choose the 'Edit' option from this menu. 4) The stored procedure will be transferred to the 'Add Procedure' tab, and the 'Add' button will change to 'Update'. 5) Edit the procedure as required. 6) Clicking: 'Update' - will apply any changes made to the stored procedure 'Cancel' - discards changes made to the stored procedure
38
Matrikon Inc
User's Manual
Figure 45 - Select the OPC Simulation Server Double-click the server name and it will be added to the Connected Servers display tab as show in Figure 46 below.
39
Matrikon Inc
User's Manual
Figure 47 - Add a Group to the Server Once the group has been added, it will appear in the Connected Servers display tab as shown in Figure 48 below.
Figure 48 - The Group Added Now add the OPC items to the group that was just created. Use the browser by pressing the <<Browse>> button as shown in Figure 18. Under the Random folder, add the tags ArrayOfReal8, ArrayOfString,
40
Matrikon Inc
User's Manual
Boolean, Int1, Money, Qualities, Real4, String, Time, and UInt1. The Connected Servers display tab will show the OPC items that you have added as seen in Figure 49 below.
41
Matrikon Inc
User's Manual
Figure 50 - Create a Blank Access Database Microsoft Access will next prompt you to name your database. Enter a name (in this example we will use TestODBC.mdb) and press the <<Create>> button to continue.
42
Matrikon Inc
User's Manual
A menu for setting up the new database will appear as shown in Figure 52 below. Select the Create table in Design view option.
Figure 52 Setting up the new database The design view will appear for Table1. Enter four field names: one for the item name, one for the item value, one for the item quality, and one for the item timestamp. Make sure all fields have a data type of Text.
Figure 53 - Designing the Table Close the table window and Access will prompt you to save your table design. Press <<Yes>> and choose a name for your table (this example kept the default name Table1). Access will then give a warning that no primary key was defined press <<No>>. The table records can be viewed at any time by double-clicking the table name in the database window shown in Figure 52. Close Microsoft Access. The database must be registered with the operating system. Run the program odbcad32.exe from Start Run. Go to the System DSN tab display and press the <<Add>> button as shown in Figure 54 below.
43
Matrikon Inc
User's Manual
Figure 54 - Adding a Data Source In the Create New Data Source window that appears, select the Microsoft Access Driver and press the <<Finish>> button.
Figure 55 - Select the Microsoft Access Driver Enter a name for the data source (the name AccessODBC is used in this example) and press the <<Select>> button to browse for the Access Database file that was previously saved.
44
Matrikon Inc
User's Manual
Figure 57 - Selecting a Database Once a database has been selected for the data source, press <<OK>> to exit the ODBC Data Source Administrator. The Access database is now ready to accept process data from the ODBC OPC client.
45
Matrikon Inc
User's Manual
Figure 58 - Enterprise Manager Click the New button circled red in Figure 58 above. Enter a name for the database table (this example will use the name Table1). The table design window will appear next as seen in Figure 59.
Figure 59 - Designing the Table Enter column names for the OPC item name, value, quality, and timestamp. Make sure they have data types of varchar. Once this is complete, close the design table window and save the changes made.
46
Matrikon Inc
User's Manual
The database must now be registered with the operating system. Run the ODBC Data Source Administrator as described in section 3.3.1. Go to the System DSN tab display and press the <<Add>> button as shown in Figure 54. In the Create New Data Source window that appears, select the SQL Driver and press the <<Finish>> button.
Figure 60 Select the SQL Driver A configuration window will appear as shown in Figure 61 below. Enter a name for the SQL data source (the name LocalServer is used in this example). Select the same server that you viewed in Enterprise Manager.
Figure 61 Configuring the SQL Server DNS Continue through the configuration process, making sure all the properties are correct. Press <<OK>> to exit the ODBC Data Source Administrator. The SQL database is now ready to accept process data from the ODBC OPC client.
47
Matrikon Inc
User's Manual
Figure 63 - Establishing a connection to the SQL Database Once the database connections are made, a tree-view of the database tables and properties will be shown in the Connected Databases tab view. See Figure 64 for an example of this.
48
Matrikon Inc
User's Manual
49
Matrikon Inc
User's Manual
Once the OPC Item is dropped onto a table, a configuration display for the query appears in the bottom pane (see Figure 66).
Figure 67 - Entering data into Key Fields In the query configuration display of the OPC Client for ODBC, select Update under the title Query Type in the configuration display. Next, select from the Table Column drop-down boxes which database fields should contain the name, value, quality, and timestamp of the OPC Item. Enable the Key check box for the NAME property.
50
Matrikon Inc
User's Manual
The display should look similar to the one in Figure 68 below after configuring the query.
Figure 68 - Update Query for MS Access Press the <<Add Query>> button and the query will begin. Refresh the Access database table and the most recent data will be seen in the correct records.
Figure 69 - OPC Items updated in MS Access Delete the query by selecting the Random.Money OPC Item in the Connected Servers tab display, right clicking the query in the bottom pane, and selecting the Delete Query option (see Figure 70 below).
51
Matrikon Inc
User's Manual
Figure 71 - Insert Query for MS Access Press the <<Add Query>> button and the query will begin. Refresh the Access database table and records will be seen inserted for every received process value.
Figure 72 - OPC Items inserted in MS Access Delete the query as described at the end of section 3.5.1.1.
52
Matrikon Inc
User's Manual
Figure 73 - Dragging and Dropping an OPC Item Once the OPC Item is dropped onto a table, a configuration display for the query appears in the bottom pane (see Figure 74).
53
Matrikon Inc
User's Manual
Figure 75 - Entering Data into key fields In the query configuration display of the OPC Client for ODBC, select Update under the title Query Type in the configuration display. Next, select from the Table Column drop-down boxes which database fields should contain the name, value, quality, and timestamp of the OPC Item. Enable the Key check box for the NAME property. The display should look similar to the one in Figure 76 below after configuring the query.
Figure 76 - Update Query for MS Access Press the <<Add Query>> button and the query will begin. Refresh the SQL database table and the most recent data will be seen in the correct records.
Figure 77 - OPC Items updated in MS SQL Delete the query by selecting the Random.Int1 OPC Item in the Connected Servers tab display, right clicking the query in the bottom pane, and selecting the Delete Query option (see Figure 70 for an example).
54
Matrikon Inc
User's Manual
Figure 78 - Insert Query for MS SQL Press the <<Add Query>> button and the query will begin. Refresh the SQL database table and records will be seen inserted for every received process value.
55
Matrikon Inc
User's Manual
And an insert:
insert into [Sheet1$] Values(<<i:Ran>>.n,<<i:Ran>>.v, <<i:Ran>>.q,<<i:Ran>>.t)
56