run Error:throw new DuplicateGroupException () 0xC004000C
package com.tt.test;
import java.net.UnknownHostException;
import java.util.concurrent.Executors;
import org.jinterop.dcom.common.JIException;
import org.jinterop.dcom.common.JISystem;
import org.jinterop.dcom.core.JIVariant;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.common.NotConnectedException;
import org.openscada.opc.lib.da.AccessBase;
import org.openscada.opc.lib.da.AddFailedException;
import org.openscada.opc.lib.da.Async20Access;
import org.openscada.opc.lib.da.AutoReconnectController;
import org.openscada.opc.lib.da.DataCallback;
import org.openscada.opc.lib.da.DuplicateGroupException;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.openscada.opc.lib.da.Server;
public class SCADA {
public static void main(String[] args){
AutoReconnectController autos = null;
try {
JISystem.setAutoRegisteration(true);
ConnectionInformation ci = new ConnectionInformation();
ci.setHost("192.168.39.35");
ci.setDomain("");//LFTG-ZJ
ci.setProgId("WLD6000.OPC.Server");
//ci.setProgId("Kepware.KEPServerEX.V5");
//ci.setClsid("b5d93f3c-03d7-4697-9f9a-448378794aba");
//ci.setClsid("B6EACB30-42D5-11D0-9517-0020AFAA4B3C");// simatic S7
ci.setUser("Administrator");
ci.setPassword("123");
final Server s = new Server(ci,Executors.newSingleThreadScheduledExecutor());
autos = new AutoReconnectController(s);
autos.connect();
Thread.sleep(100);
//s.setDefaultUpdateRate(6000);
// dumpTree(s.getTreeBrowser().browse(),0);
Group group = s.addGroup("group");
group.getName();
group.setActive(true);
//final Item item = group.addItem("Channel1.Device1.Tag1");
final Item item = group.addItem("WLD6000.OPC.RTU1.ggg");// simatic S7
// final Item item = group.addItem("Random.String");
item.setActive(true);
Thread.sleep(1000);
System.out.println("read value:"+item.read(false).getValue().getObjectAsUnsigned().getValue());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (JIException e) {
e.printStackTrace();
} catch (NotConnectedException e) {
e.printStackTrace();
} catch (DuplicateGroupException e) {
e.printStackTrace();
} catch (AddFailedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}finally{
autos.disconnect();
}
}
}
try
{
final OPCGroupStateMgt groupMgt = this.server.addGroup ( name, this.defaultActive, this.defaultUpdateRate, 0, this.defaultTimeBias, this.defaultPercentDeadband, this.defaultLocaleID );
return getGroup ( groupMgt );
}
catch ( final JIException e )
{
switch ( e.getErrorCode () )
{
case 0xC004000C:
throw new DuplicateGroupException ();
default:
throw e;
}
}