Samples:
TcJavaToAds return nErr; } public long getHandleBySymbol(JNIByteBuffer hdlbuff, JNIByteBuffer symbuff){ long nErr = 0; //get handle by symbol name (symbol like "MAIN.iCounter" name in symbuff) if (port != 0) nErr = AdsCallDllFunction.adsSyncReadWriteReq(addr, 0xF003, 0x0, hdlbuff.getUsedBytesCount(), hdlbuff, //buffer for getting handle symbuff.getUsedBytesCount(), symbuff); //buffer containg symbolpath else nErr = 1864; // error 1864 (0x748) ads-port not opened return nErr; } public long readByHandle(JNIByteBuffer databuff, long symHandle){ long nErr = 0; if (port != 0) { // read variable by handle if (symHandle != 0) nErr = AdsCallDllFunction.adsSyncReadReq(addr, 0xF005, symHandle, databuff.getUsedBytesCount(), databuff); else nErr = 1809; // error 1809 (0x711) invalid symbol handle } else nErr = 1864; // error 1864 (0x748) ads-port not opened return nErr; } public long writeByHandle(JNIByteBuffer databuff, long symHandle){ long nErr = 0; if (port != 0) { //write variable by handle if (symHandle != 0) nErr = AdsCallDllFunction.adsSyncWriteReq(addr, 0xF005, symHandle, databuff.getUsedBytesCount(), databuff); else nErr = 1809; // error 1809 (0x711) invalid symbol handle } else nErr = 1864; // error 1864 (0x748) ads-port not opened return nErr; } public long readBySymbol(JNIByteBuffer databuff, JNIByteBuffer symbuff){ JNIByteBuffer hdlbuff = new JNIByteBuffer(4); long nErr = 0; long symHandle = 0; if (port != 0) { //get handle by symbol name (symbol like "MAIN.iCounter" name in symbuff) nErr = AdsCallDllFunction.adsSyncReadWriteReq(addr, 0xF003, 0x0, hdlbuff.getUsedBytesCount(), hdlbuff, //buffer for getting handle symbuff.getUsedBytesCount(), symbuff); //buffer containg symbolpath if (nErr != 0) return nErr; //get handle byte[] byteArr = new byte[4]; byteArr = hdlbuff.getByteArray(); symHandle = Convert.ByteArrToInt(byteArr); // read variable by handle nErr = AdsCallDllFunction.adsSyncReadReq(addr, 0xF005, symHandle, databuff.getUsedBytesCount(), databuff); } else nErr = 1864; // error 1864 (0x748) ads-port not opened return nErr; } TX1000 30 Version:
1.1