I created the OPC DA input adapter and want to embed some statistic into it, but failed to find samples/sources/docs. It’s so time consuming to research the source files, I’m stacked in the middle.
Just to verify your question, you have an OPC DA adapter you created yourself, and you want to create statistics for your new adapter? We have a presentation from a GPA User’s Forum that talks about this you can reference:
Custom Adapters 101 - Tutorial Session 4 - 2013 GPA User’s Forum
Still looks accurate.
Thanks,
Ritchie
Also, here is a good example of an adapter that produces its own statistics. This is an adapter that launches an executable process, then tracks its CPU usage, memory usage and up-time as three new statistics:
- Register adapter instance with statistics engine: gsf/Source/Libraries/Adapters/FileAdapters/ProcessLauncher.cs - line 802
- Define statistics function that gets last CPU usage of process: gsf/Source/Libraries/Adapters/FileAdapters/ProcessLauncher.cs - line 953
- Define statistics function that gets last memory usage of process: gsf/Source/Libraries/Adapters/FileAdapters/ProcessLauncher.cs - line 964
- Define statistics function that gets total up time of process: gsf/Source/Libraries/Adapters/FileAdapters/ProcessLauncher.cs - line 975
Here are the records added to the Statistic
table to make this work:
ID | Source | SignalIndex | Name | Description | AssemblyName | TypeName | MethodName | Arguments | Enabled | DataType | DisplayFormat | IsConnectedState | LoadOrder |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
169 | Process | 1 | CPU Usage | Percentage of CPU currently used by the launched process. | FileAdapters.dll | FileAdapters.ProcessLauncher | GetProcessStatistic_CPUUsage | 1 | System.Double | {0:N3} | 0 | 1 | |
170 | Process | 2 | Memory Usage | Amount of memory currently used by the launched process in megabytes. | FileAdapters.dll | FileAdapters.ProcessLauncher | GetProcessStatistic_MemoryUsage | 1 | System.Double | {0:N3} | 0 | 2 | |
171 | Process | 3 | Up Time | Total number of seconds the launched process has been running. | FileAdapters.dll | FileAdapters.ProcessLauncher | GetProcessStatistic_UpTime | 1 | System.Double | {0:N3} | 0 | 3 |
Will look at them, thanks.