在DCOM中无法通过openscada按名称查找组

时间:2018-12-12 16:13:13

标签: java dcom j-interop

我正在尝试写一个称为group的Group下的item的值。这个团体是一个公开团体,这很奇怪,我可以这样找到:

enumerateGroups(server, OPCENUMSCOPE.OPC_ENUM_PUBLIC);
public static void enumerateGroups(final OPCServer server,
            final OPCENUMSCOPE scope) throws IllegalArgumentException,
            UnknownHostException, JIException {
        System.out.println("Enum Groups: " + scope.toString());

        for (final String group : server.getGroups(scope).asCollection()) {
            System.out.println("Group: " + group);
        }
    }

在控制台上返回的

Enum Groups: OPC_ENUM_PUBLIC
Group: group

但是当我尝试通过这样的名称查找组时:

try {
        JISystem.setAutoRegisteration(true);
 JISession _session = null; 
         _session = JISession.createSession("localhost","user","password"); 

  final String itemId = "AO_02-01_Kortleser_101.Command.Send";

         final ConnectionInformation ci = new ConnectionInformation();
            ci.setHost("localhost");
//          ci.setDomain("");
            ci.setUser("user");
            ci.setPassword("password");
            ci.setClsid("55655C52-BC4F-48DD-B4EE-599E73D966BE");
        final Server server2 = new Server(ci, 
        Executors.newSingleThreadScheduledExecutor());
        server2.connect();

       // Add a new group
        final Group group = server2.findGroup("group");
        // Add a new item to the group
        final Item item = group.findItemByClientHandle(11);

        // add a thread for writing a value every 3 seconds
        ScheduledExecutorService writeThread = 
         Executors.newSingleThreadScheduledExecutor();
        final AtomicInteger i = new AtomicInteger(1);
        writeThread.scheduleWithFixedDelay(new Runnable() {

            public void run() {
                final JIVariant value = new JIVariant(i);
                try {
                    System.out.println(">>> " + "writing value " + i.get());
                    item.write(value);
                } catch (JIException e) {
                    e.printStackTrace();
                }
            }
        }, 5, 3, TimeUnit.SECONDS);

        // wait a little bit
        Thread.sleep(20 * 1000);
        writeThread.shutdownNow();
}
        catch(Exception e) {
            e.printStackTrace();
        }

例外图书馆:

 Recieved RESPONSE
org.openscada.opc.lib.da.UnknownGroupException
    at org.openscada.opc.lib.da.Server.findGroup(Server.java:320)
    at com.freud.dcom.utgard.cases.WriteTest.main(WriteTest.java:66)
des 12, 2018 5:08:31 PM org.jinterop.dcom.core.JISession postDestroy

这是我的OPC服务器的屏幕截图:

enter image description here

有人可以告诉我为什么找不到该组的原因,并且还有其他替代方法可以使用组来写入项目01_Kortleser_101.Command.Action和AO_02-01_Kortleser_101.Command.Send的值。

0 个答案:

没有答案