220 likes | 367 Views
Getting Started with OPC .NET 3.0. OPC .NET Software. Client Interface. Server Interface. Generic Client. Client Base. OPC COM Server. Server Base. OPC Wrapper. WCF. Class API. Class API Client. Alternate Server Implementation. Adhoc Client. Ad- hoc API.
E N D
OPC .NET Software Client Interface Server Interface Generic Client Client Base OPC COM Server Server Base OPC Wrapper WCF Class API Class API Client Alternate Server Implementation Adhoc Client Ad- hoc API Standard code for all servers Developer-specific code Standard code for the client
Step 1: Build the Solution • The OPC .NET 3.0 Solutions are distributed as VS 2008 Solutions set for X86 (32-bit) compilation. • This format is used to allow developers to convert to VS2010 if desired. Opening the solution in VS2010 will cause Visual Studio to automatically convert the solution. • Converting from VS2010 back to VS2008 is not supported by Visual Studio, so OPC .NET code is not distributed as VS2010.
Step 2: Configure the Projects • Open the “Configure and Running” tutorials for the Discovery Server, the Wrapper, and the Generic Clients
Step 3: Run the Servers • Run the Discovery Server and the Wrapper as Console Applications. • This will provide a console window for you to see all requests and responses handled by these servers.
“Failed to Start COM Servers” • Getting the Wrapper message “Failed to Start COM Servers” indicates that the CoCreateInstance() call to the wrapped COM server failed. • This message will not be shown if the Wrapper was able to connect to at least one wrapped server. • The first place to look is to verify that the Wrapper’s app.config file has the correct ProgId for the wrapped server(s) and that the Wrapper has the privilege to connect.
Step 4: Run the Xi Client GenericApp • Start this program and select or type in the URL of the Wrapper. “localhost” can be used as the hostname if the client and wrapper are on the same machine • If you are running the Discovery Server, you can click the Discover Servers button, and then select a server from the returned list.
Step 5: Get Server Endpoints • Click the GetEndpoints button. This will cause the ClientBase to extract the WSDL from the Wrapper and discover its connection parameters. • When it returns, it will update the bindings (protocols) that can be used to access the server, sorting them in the most efficient (performance-wise) order
Step 6: Connect to the Wrapper • Wait for GetEndpoints to return (this could take a few minutes because of the initial JIT compiling required). • Click the Connect button. This will cause the ClientBase to attempt to connect to the server. • Alternatively, select a different binding from the drop-down box before clicking Connect
Common Connection Problems • The most frequent problem is the client not having the proper credentials to connect to the server. Verify that the client user is authorized to connect to the Wrapper. This is a Windows privilege. • If the Wrapper is running XP, make sure that the FolderOptions for the Windows Explorer are not set to “Use Simple File Sharing”
Common Connection Problems • Verify the clocks in the client and server machine are within 5 minutes of each other. Otherwise, WCF will not connect to protect against playback attempts. • If the “Failed to Start COM Servers” is received at this point, it means that the wrapped COM server failed to authorize the client user. This could be a privilege level issue or a licensing issue, depending on the wrapped server
Common Connection Problems • Proxy authentication failure – • Can be caused by using a proxy server setup in Internet Options • Can be caused when a machine name is used in local machine communications, and the DNS server invokes the proxy server during authentication. Use the bypassOnLocal key in the app.config file of the client.
Step 7: Examine the Server • Wait for the tabbed dialog to be displayed • Click the various tree nodes on the Server Properties Tab and examine the contents • Note that you can right-click the Status tree node and click Refresh to get updated status. • The status will show you if you were able to connect to all wrapped servers.
Step 8: Browse the Server • Click the Object Tree tab • Double-click Root, and wait for the response • Continue double-clicking to browse the returned nodes
Step 9: Open Read, Write, or Subscribe Access to the Wrapper • Click the Communications Endpoints tab • Check the boxes for the operations you want to perform. Select the protocol you want to use, typically this will be the protocol that you used to connect to the server • The callback rate at the top indicates the keep-alive time for callbacks. It has no effect if the callback entry is not checked
Step 10: Create a Data List • Click the Data Lists tab • Click the New button to create a new Data List (a DA Group). • When it returns, the created data list will be added to the upper list box • Note that you can set the Update Rate before you create the list, or you can create the list and then change the UpdateRate and click the Modify button at any time
Step 11: Enable the Data List • Select the Data List in the upper list box • Click the Enable button. • Check the Read, Write, and/or Subscribe check boxes. • The check boxes that will be available correspond to those that you checked on the Communications Endpoints tab • If you fail to check one of these, you will not be able to access the Data List for that purpose
Step 12: Add Items to the Data List • Click either the Add button or the Add From File button • Clicking the Add button will allow you to browse for the data items to add • Clicking the Add From File button will allow you to select a file that contains a list of DA Item IDs (see the Text Files folder in the Solution for examples)
Step 13: Enable Data Items • Click either the Selections or All radio button • If you clicked Selections, you must select one or more data items that were added to the lower list box. • Click Enable to permit access to the data items of interest
Step 14: Subscribing to Data Values • If Subscribe was checked for the Data List, the values should be automatically updated at the Update Rate. • If they do not, it is probably because the Wrapper is being run from the debugger, and the debugger has set COM Security such that COM callbacks from the DA server are not permitted. • Repeat the above procedures after restarting the Wrapper outside the debugger
Step 15: Read/Write Data Values • Click the Read button to read the data item values. • Click the Write button to write a new value. If you do not first read the value, the Client Base may not know the data type of the data item, and you will have to select the correct data type • Note that the Write button will not update the local item’s value. You will have to read the item value to verify that it was correctly updated.
Congratulations • You have successfully started the Wrapper and been able to access data items from it.