当前位置:网站首页>Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
2022-04-23 03:15:00 【GeXueliu】
- My device
win10 pro 、kepserver. Prepare to use utgard Compiling opc Client and opcserver Running on the same laptop . therefore dcom You don't need to configure it ? - My configuration
I only in 【 The computer 】 A new user is created under the option :OpcServer password :123456. Other security policies 、 The firewall is not set ( Because it can't be set , my 【 Service components 】 Next 【 My computer 】 There is a red arrow on the , Right click No 【 attribute 】, So that's it , The reference is This blog ) - kepserver


- Code
It uses utgard library
package com.test;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.core.JIString;
import org.jinterop.dcom.core.JIVariant;
import org.junit.Test;
import org.openscada.opc.lib.common.AlreadyConnectedException;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.common.NotConnectedException;
import org.openscada.opc.lib.da.*;
import java.net.UnknownHostException;
import java.util.concurrent.Executors;
public class ConnectOpc2 {
final ConnectionInformation ci = new ConnectionInformation();
@Test
public void connect() throws AlreadyConnectedException, JIException, UnknownHostException, NotConnectedException, DuplicateGroupException, InterruptedException, AddFailedException {
ci.setHost("127.0.0.1");
ci.setDomain("");
ci.setUser("OPCServer");
ci.setPassword("123456");
ci.setClsid("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729");// See the first picture
// {7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729}
// {FF9F1A4B-E79A-43E6-B79E-166F5ACC2944}
// {5C905440-FD5D-4610-A532-D9C8CE4A0393}
// {467DE023-58B0-4A96-8C5C-AAC1AFD6C51D}
String itemId = " passageway 2. equipment 1.TAG2";// See the second picture
final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
try {
// connect to server
server.connect();
// add sync access, poll every 500 ms
final AccessBase access = new SyncAccess(server, 500);
access.addItem(itemId, (item, state) ->
System.out.println("Resut: " + state.toString()));
// start reading
access.bind();
// wait a little bit
Thread.sleep(10 * 1000);
// stop reading
access.unbind();
} catch (final JIException e) {
System.out.println(String.format("%08X: %s", e.getErrorCode(), server.getErrorMessage(e.getErrorCode())));
e.printStackTrace();
}
}
// final AccessBase access = new SyncAccess(server, 500);
//
// access.addItem(itemId, new DataCallback() {
// @Override
// public void changed(Item item, ItemState itemState) {
// int type = 0;
// try {
// type = itemState.getValue().getType(); // The type is actually a number , Defined with constants
// } catch (JIException e) {
// e.printStackTrace();
// }
// System.out.println(" The data type of the monitoring item is :-----" + type);
// System.out.println(" The timestamp of the monitoring item is :-----" + itemState.getTimestamp().getTime());
// System.out.println(" The details of the monitoring item are :-----" + itemState);
//
// // If you read yes short Type value
// if (type == JIVariant.VT_I2) {
// short n = 0;
// try {
// n = itemState.getValue().getObjectAsShort();
// } catch (JIException e) {
// e.printStackTrace();
// }
// System.out.println("-----short Type values : " + n);
// }
//
// // If you read a value of string type
// if (type == JIVariant.VT_BSTR) { // The type of string is 8
// JIString value = null;
// try {
// value = itemState.getValue().getObjectAsString();
// } catch (JIException e) {
// e.printStackTrace();
// } // Read by string
// String str = value.getString(); // Get a string
// System.out.println("-----String Type values : " + str);
// }
// }
// });
// // start reading, Start reading values
// access.bind();
// // wait a little bit, There is one 10 Second delay
// Thread.sleep(10 * 1000);
// // stop reading, Stop reading
// access.unbind();
}
5. result

6. The first reference is the technology brother's blog , It's very clear . But I can't keep up , Because of my 【 Component service 】 Under tabs 【 My computer 】 It looks like this , It's different from his .
Finally I saw someone say ,opc server and opc The client runs on the same computer , No configuration required dcom Then I don't know , It should be ok .
Hope to have utgard Connect opc server Big brother of experience , Guide . If you know Kingview as opcserver Better
版权声明
本文为[GeXueliu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220627323269.html
边栏推荐
- xutils3修改了我提报的一个bug,开心
- ThreadLocal 测试多线程变量实例
- Seminar playback video: how to improve Jenkins' ability to become a real Devops platform
- 交换二叉树中每个结点的左和右
- js递归树结构计算每个节点的叶子节点的数量并且输出
- 2022年做跨境电商五大技巧小分享
- Swap the left and right of each node in a binary tree
- How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
- Fundamentals of software testing and development
- OLED多级菜单记录
猜你喜欢
![[vs Code] solve the problem that the jupyter file displays exceptions in vs code](/img/f6/a91d03fd140eb5f7688b72e2e6f2bb.png)
[vs Code] solve the problem that the jupyter file displays exceptions in vs code

Impact of AOT and single file release on program performance
![General testing technology [1] classification of testing](/img/f1/d80b6793b6443cbc4048d7e6319f51.png)
General testing technology [1] classification of testing

软件测试相关知识~

Comprehensive calculation of employee information

2022G2电站锅炉司炉考试题库及在线模拟考试

由于3²+4²=5²,所以称‘3,4,5‘为勾股数,求n(包括n)以内所有勾股数数组。

为什么BI对企业这么重要?

《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案

After the mobile phone is connected to the computer, how can QT's QDIR read the mobile phone file path
随机推荐
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
Knowledge of software testing~
Test experience data
Flink实时数仓项目—DWS层设计与实现
2022a special equipment related management (elevator) work license question bank and simulation examination
The backtracking of stack is used to solve the problem of "the longest absolute path of file"
Yes Redis using distributed cache in NE6 webapi
C read / write binary file
搭建XAMPP时mysql端口被占用
ASP. Net 6 middleware series - execution sequence
由于3²+4²=5²,所以称‘3,4,5‘为勾股数,求n(包括n)以内所有勾股数数组。
Configuration table and page information automatically generate curd operation page
《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
2022年做跨境电商五大技巧小分享
IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统
Blazor University (12) - component lifecycle
Experiment 5 components and event handling
软件测试相关知识~
Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing