当前位置:网站首页>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
边栏推荐
- 12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
- A set of C interview questions about memory alignment. Many people make mistakes!
- C read / write binary file
- 二进制文件版本控制工具选择难?看完这篇你会找到答案
- . net tip: talk about the problem that the scoped service cannot be obtained in the middleware structure
- Experiment 5 components and event handling
- 利用正反遍历来解决“字符的最短距离”问题
- 2022年做跨境电商五大技巧小分享
- 通过 zxing 生成二维码
- 搭建XAMPP时mysql端口被占用
猜你喜欢

xutils3修改了我提报的一个bug,开心

《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
![Use of ADB command [1]](/img/e6/fb8fd6956c226f75b831f8eb46277f.png)
Use of ADB command [1]

Web Course Design - his system

再战leetcode (290.单词规律)

Xamarin effect Chapter 22 recording effect

Knowledge of software testing~

OLED multi-level menu record

Tencent video price rise: earn more than 7.4 billion a year! Pay attention to me to receive Tencent VIP members, and the weekly card is as low as 7 yuan

The most detailed in the whole network, software testing measurement, how to optimize software testing cost and improve efficiency --- hot
随机推荐
Docker拉取mysql并连接
2022山东省安全员C证上岗证题库及在线模拟考试
Use split to solve the "most common words" problem
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案
Is it difficult to choose binary version control tools? After reading this article, you will find the answer
The most understandable life cycle of dependency injection
Drawing polygons with < polygon / > circular array in SVG tag
利用正反遍历来解决“字符的最短距离”问题
[vs Code] solve the problem that the jupyter file displays exceptions in vs code
Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions
Why is bi so important to enterprises?
C syntax sugar empty merge operator [?] And null merge assignment operator [? =]
2022T电梯修理考试模拟100题及在线模拟考试
A comprehensive understanding of static code analysis
Fight leetcode again (290. Word law)
Top 9 task management system in 2022
二进制文件版本控制工具选择难?看完这篇你会找到答案
7-11 重排链表 (25 分)
First in the binary tree