日期:2014-05-20 浏览次数:20842 次
//初始化服务 JOpc.coInitialize(); //建立server对象 JOpc jOpc = new JOpc("10.10.0.158", "kingView.view","jopc1"); try { jOpc.connect(); } catch (ConnectivityException e) { // TODO Auto-generated catch block e.printStackTrace(); } OpcGroup group = new OpcGroup("group", true, 500, 0.0f); OpcItem item = new OpcItem("Door1", true, ""); group.addItem(item); jOpc.addGroup(group); try { jOpc.registerGroup(group); } catch (ComponentNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnableAddGroupException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { jOpc.registerItem(group, item); } catch (ComponentNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnableAddItemException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { jOpc.synchWriteItem(group, item); } catch (ComponentNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SynchWriteException e) { // TODO Auto-generated catch block e.printStackTrace(); }