The uaPUS-AE / DANSrvAE A&E functionality needs to be added to the DA functionality in the NSPlugin.DLL.
A server with event functionality can be created:
- from the provided DA/AE sample servers
One sample defines a few items in the code, the other loads the item configuration from an XML file.
- by adding AE functionality to a previously created NSPlugin.DLL with DA functionality.
See below.
A basic implementation of the OPC AE specified event handling is in the NSPluginAEbase.dll
This DLL is dynamically loaded in the AlarmEventServer class in the sample server file EventServer.cs/vb. At run-time the DLL must be in teh same directory as the server executable.
The source code of the NSPluginAEbase.dll is provided with the license key. It is not provided in the evaluation version.
Adding AE Functionality to a DA Server:
- Open the Visual Studio project of the NSPlugin.dll of the DA server
- Add the DOTNET4 conditional compilation symbol in all project configuration
- Add the A&E functionality specification in the uaPLUS.exe.config file
<add key="Plugins" value="DA,">
- Open the application Visual Studio project and add the files Event*.cs/vb files from an a sample DA-AE plug-in to the project. This also copies the files into the application folder.
The files are:
EventServer.cs/vb
EventArea.cs/vb
EventCondition..cs/vb
EventSubscription.cs/vb
EventStringMatch.cs/vb
- Add the two methods:
- GetAEServerRegistryDef
- CreateEventServer
to the AppPlugin Class in the file ServerAdapt.cs/vb.
Samples of those methods are given below and in the DA/AE sample severs.
- Create the event sources by calling the
AlarmEventServer.RootEventArea.AddSource
method for each source. See the comments and samples below.
In a server with a static DA item address space, all event sources can be defined in the startup. In a server with a dynamic DA item address space the event sources added when the item is added, in case the item needs to act as an event source.
Event sources do not necessarily have to be DA items. The AE server can be implemented to use anything as an event source.
- Modify the event category and event condition definitions in the EventServer.cs/vb file.
- Modify the sample code in the event server classes to meet the application requirements.
Some applications may need only minor adaptations but complex AE servers may require substantial changes.
AE Initialization Methods in the AppPlugin Class
The AppPlugin class contains all customization methods for the DA server and for the AE server the initialization methods:
GetAEServerRegistryDef |
This method is called when the server is started for self registration and must return a SrvRegDef object with unique registration definitions for this AE server. The AppID is the same for all servers in this module and is defined in the DA server registry definitions. Sample implementation:
|
CreateEventServer |
Create an Alarms&Events Server instance. There is an EventServer class instance for each connected AE client. This method is called from the generic server, once for each connecting client. Default implementation:
|
Creation of event sources
The creation of event sources is an NSPlugin internal feature and can be implemented in any suitable way.
The sample implementation defines the method AddSource in the EventArea class.
The AlarmEventServer class has the static EventArea object RootEventArea. This is the root area for all server instances and it contains event areas and/or event sources.
The AddSource method is passed a qualified source name. The event source is added to the proper area and areas are created as needed.
Samples:
- Create a source of a simple event type (in the event category DeviceFailure )
itemDef.AESource = AlarmEventServer.RootEventArea.AddSource( itemDef.name, itemHandle, 400, AlarmEventServer.CatDeviceFailure, null );
- Create a source of a condition event with two sub conditions (in the event category Level and conditions SPLevel )
itemDef.AESource = AlarmEventServer.RootEventArea.AddSource( itemDef.name, itemHandle, 0, AlarmEventServer.CatLevel,
new ConditionDef[]{AlarmEventServer.CondSPLEVEL} );
itemDef.AESource.Conditions[0].SubConditions[0].Limit = 10.0;
itemDef.AESource.Conditions[0].SubConditions[0].Op = Operator.le ;
itemDef.AESource.Conditions[0].SubConditions[1].Limit = 40.0;
itemDef.AESource.Conditions[0].SubConditions[1].Op = Operator.ge ;