Enable WebSocket in OPC DA/AE/HDA Server with JSON return, FIRST TIME ever!
DCOM was developed more than 2 decades ago, which was the pillar of classic OPC. Young kids out of school today love dynamical languages (JavaScript/Python etc) since they are so easy to use. They are reluctunt to get their feet wet on the legacy DCOM technology. Luckily with the quick adoption of WebSocket in most modern popular languages, WebSocket makes it possible to glue dynamical languages and legacy DCOM together.
This revolutionary solution, WebSocket4OPC, brings unparalleled experience to your desktop and mobile device. It utilizes WebSocket as network transportation layer to communicate in full duplex. Comparing with DCOM's RPC protocol WebSocket is much easy to use and more efficient. With all built-in features provided by Microsoft IIS this solution can make OPC data accessible safely and securely through Internet. Remember - no DCOM to bother or worry, period!
.No DCOM when connecting to a classic OPC server
.Support dynamical languages (JavaScript/Python etc)
.Return in standard JSON format
.Intuitive and easy-to-remember commands instead of checking long REST API syntax
.No future DCOM vulnerability to worry
.Built-in account authentication by IIS
.Built-in secure connection by IIS
.Make native mobile APP development feasible
.No tedious 1250-page OPC UA documents to check
.No OPC UA certificate configuration
.No OPC UA firewall configuration
.Cross-platform gurantted(Linux/Mac/Windows)
.Deploy as Edge or Gateway device without any custom hardware
2. WebSocket feature for IIS need be enabled in the same server box
3. Microsoft VC++ Runtim for X64 required (download here and install if you don't have)
Download all files from server folder to your desired one. Launch a command line with administrator privilege and enter to your download folder. Run command "install.bat userAccount userPassword" to complete installation. userAccount/userPassword need be replaced with your own Windows account/password and make sure that account has administrator privilege. If you have previous installation, uninstall it first.
To verify, launch browser (Chrome/Safari/Edge) and enter URL "http://localhost/OPC/websocket.html"
Run command "uninstall.bat" in command line with administrator privilege from the your download folder to uninstall.
-
Browse
There are two sets of browse commands for DA and HDA servers respectively.
"browse" - Show all children tags under top level of DA server
"browseHDA" - Show all children tags under top level of HDA server
"browse:tagID" - Show all children tags for a tag of DA server
"browseHDA:tagID" - Show all children tags for a tag of HDA server
"browse:tagID -countsInPagenation -pageNumber" - Show a limited number of children tags in pagenation for a tag of DA server. For example there are 10,000 children tags available under a specific tag and command "browse: tagID -2000 -3" will display 2000 children tags from 4000th to 5999th to correspond to page 3 in DA server
"browseHDA:tagID -countsInPagenation -pageNumber" - Show a limited number of children tags in pagenation for a tag of HDA server. For example there are 10,000 children tags available under a specific tag and command "browseHDA: tagID -2000 -3" will display 2000 children tags from 4000th to 5999th to correspond to page 3 in HDA server
JSON returns {"parentNodeID":[{"n": "tagName1", "i": "tagID1", "b": 1}, {"n": "tagName2", "i": "tagID2", "b": 0}, ...]}
(parentNodeID - parent node id or "" at top level, n - name, i - ID, b - branch)When "browse: Random" command is sent response will be like,
When "browseHDA: Random" command is sent response will be like,
-
Read from/subscribe to DA server
2.1
"read: tagID1, tagID2, ..."- Read tags' latest values from DA server
JSON returns {"DA":[{"i": "tagID1", "v": "20.308", "t": 1643759756112, "q": 192}, {"i": "tagID2", "v": "4", "t": 1643769859342, "q": 192}, ...]}
(i - ID, v - value, t - time stamp in milliseconds of epoch UTC, q - quality)When "read: Random.Real4, Random.Int2" command is sent response will be like,
2.2
"subscribe: tagID1, tagID2, ..." - Add monitored tags to DA server and receive updates when new values are available
JSON returns {"DA":[{"i": "tagID1", "v": "20.308", "t": 1643759756112, "q": 192}, {"i": "tagID2", "v": "4", "t": 1643769859342, "q": 192}, ...]}
(i - ID, v - value, t - time stamp in milliseconds of epoch UTC, q - quality)When "subscribe:Saw-toothed Waves.Int1,Saw-toothed Waves.Int2" command is sent response will be like,
-
Unsubscribe tags from DA server
"unsubscribe" - Remove all monitored tags from DA server
"unsubscribe: tagID1, tagID2, ..." - Remove specific monitored tags from DA server
-
Subscribe to AE server
"subscribeAE" - Receive notification on alarms and events
JSON returns {"AE":[{"s":"tagName1","m":"tagName1 Deviation is Low","c":"DEVIATION","sc":"LO","t":1643760803334,"q":192,"tp":4,"ec":2,"st":200,"a":1,"at":""}, {"s":"tagName2","m":"tagName2 Limit is Normal","c":"PVLEVEL","sc":"HIHI","t":1643760808112,"q":192,"tp":4,"ec":1,"st":500,"a":1,"at":""}]}
(s - source, m - message, c - condition, sc - sub condition, t - time stamp in milliseconds of epoch UTC, q - quality, tp - type, ec - category, st - severity, a - acknowledgement, at - actor)When "subscribeAE" command is sent response will be like,
-
Unsubscribe from AE server
"unsubscribeAE" - Remove notification on alarms and events
-
Read history data from HDA server
6.1
"readRaw: tagID1, tagID2 -startTimeStamp -endTimeStamp" - Read tags' history raw data based on start and end time stamps
JSON returns {"HDA":[{"tagID1":[{"v":"24201","t":1665632091123,"q":262336}, {"v":"19168","t":1665632092334,"q":262336},...]}, {"tagID2":[{"v":"24","t":1665632091445,"q":262336}, {"v":"168","t":1665632092667,"q":262336},...]}]}
(v - value, t - time stamp in milliseconds of epoch UTC, q - quality which need be parsed with OPC HDA and DA masks to have results like Raw/Interpolated and Good/Bad)When "readRaw: Saw-toothed Waves.Int1,Saw-toothed Waves.Int2 -1672977528112 -1672977529338" command is sent response will be like,
6.2
"readAtTime: tagID1, tagID2, ..., tagIDx -timeStamp1 -timsStamp2 -timeStampX" - Read tags' history data based on various time stamps
JSON returns {"HDA":[{"tagID1":[{"v":"24201","t":1665632091231,"q":262336}, {"v":"19168","t":1665632092354,"q":262336},...]}, {"tagID2":[{"v":"24","t":1665632091341,"q":262336}, {"v":"168","t":1665632092321,"q":262336},...]}]}
(v - value, t - time stamp in milliseconds of epoch UTC, q - quality which need be parsed with OPC HDA and DA masks to have results like Raw/Interpolated and Good/Bad)When "readAtTime: Saw-toothed Waves.Int1,Saw-toothed Waves.Int2 -1672978265112 -1672978266338" command is sent response will be like,
-
Disconnect
"disconnect" - Close connection with server
-
Help
"help" or "?" - Display all supported commands and usages
- Write feature in DA upon request
- More HDA features available upon request
- Full-fledged open source native client for iOS