小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

在Java環(huán)境中使用OpenSCADA的utgard子項(xiàng)目連接OPCserver

 gyb98 2011-08-15
 直接上代碼:運(yùn)行需要五個(gè)jar包:

分別是:j-Interop三個(gè),

utgrad兩個(gè),slf4j兩個(gè)。

 

package com.casit;

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.AddFailedException;
import org.openscada.opc.lib.da.AutoReconnectController;
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.Server;

public class SCADA {
 public static void main(String[] args){
  AutoReconnectController autos = null;
  try {
   JISystem.setAutoRegisteration(true);
   
   ConnectionInformation ci = new ConnectionInformation();
   ci.setHost("localhost");
   ci.setDomain("localhost");
   ci.setClsid("6E6170F0-FF2D-11D2-8087-00105AA8F840");
   ci.setUser("Administrator");
   ci.setPassword("123");
   
   
   final Server s = new Server(ci,Executors.newSingleThreadScheduledExecutor());
         autos = new AutoReconnectController(s);
   autos.connect();Thread.sleep(100);
   
   
//   dumpTree(s.getTreeBrowser().browse(),0);
   
   Group group = s.addGroup("test");
            group.setActive(true);
            final Item item = group.addItem("Channel1.Device1.D0");
            item.setActive(true);
            Thread.sleep(100);
            System.out.println("讀取值:"+item.read(false).getValue().getObjectAsUnsigned().getValue());
            JIVariant value = JIVariant.makeVariant(new Integer(777));
   item.write(value);
   
   
//   final AccessBase access = new Async20Access(s,100,false);
//            access.addItem ( "sim.test.D0", new DataCallbackDumper());
//            access.bind ();
//            Thread.sleep(100*1000);
//            access.unbind();
           

  } 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();
  }  
 }
}
中間注釋的部分采用監(jiān)聽模式。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多