How to create a Working server in 4 really easy steps and 1 slightly more demanding step
This page demonstrates the Opc Server Wizard which is part of the prOpcKit for OPC server and client programming using Borland Delphi. The source code to this example is included in the prOpcKit evaluation download.
Start off with an empty project. Save the project as Wizzy1.dpr and Unit1.pas as MainUnit.pas. Rename Form1 to 'MainForm'.
Select New | Other from the 'File' Menu. This opens the 'Object Repository'.

Select the OpcServer wizard and click OK.

For this simple example, all we need do is fill in the Name, Description and Vendor fields. Click OK. This will generate a new unit called 'Unit1'. Save this unit as 'OpcServerUnit'. The resultant code is shown below.
|
The point of an Opc server is to publish named tags to Opc clients. To do this we declare our tags as published properties of the 'nameserver' object declared for us by the Opc Server Wizard. In this example we are going to publish the height and width of the main form as our tags. Declare two properties called 'FormHeight' and 'FormWidth' and implement them exactly as you would for any object properties. You can use the 'Code Completion' feature of the IDE to create the declarations and stubs of the property 'getter' and 'setter' procedures. This is the only step that actually involves any work.
|
In order to get this code to compile we need to add 'MainUnit' to the implementation uses clause. Compile the program. 'Wizzy1.TWizzyServer.1' is finished.
Register the server, as you would with any COM server by running it with a command-line parameter of /regserver.
Open your favourite OpcClient to test the server. Mine is 'Visual Opc Tracer' from Terravic.

Connect to the Wizzy1.TWizzyServer.1 server on the local machine. Resize the main form of the server and notice that the values of FormHeight and FormWidth displayed in the client will update. Do a write to either of these variables and notice that the size of the Server's main form changes.
If you want the source code to this example, it is included in the prOpcKit evaluation download. For an explanation of how to build a simple client to connect to the server see Using the Very Simple Client.
Return to prOpcKit
Return to PREL Home