首先导包jeasyOPC.jar包 配置JCustomOpc.dll文件
测试代码如下:
//读取OPC数据
private void testOPC() throws Exception {
JOpc.coInitialize();//ICONICS.SimulatorOPCDA.2
JOpc jopc = new JOpc("localhost", "OMRON.OPC", "lxxxxxx");//第一个参数是本机地址,第一个参数是OPC服务器名,第三个参数是本机电脑用户名
OpcItem item1 = new OpcItem("Device.G.A", true, "");
// OpcItem item2 = new OpcItem("Random.Real8", true, "");
// OpcItem item3 = new OpcItem("Random.Real8", true, "");
OpcGroup group = new OpcGroup("Device", true, 10,