mirror of
https://github.com/luoyan35714/OPC_Client.git
synced 2026-04-18 00:01:30 +08:00
Add the utgard performance test
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
package com.freud.opc.jeasyopc.perf;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javafish.clients.opc.JEasyOpc;
|
||||
import javafish.clients.opc.JOpc;
|
||||
import javafish.clients.opc.component.OpcGroup;
|
||||
import javafish.clients.opc.component.OpcItem;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.freud.opc.jeasyopc.perf.listener.JeasyOPCListener;
|
||||
|
||||
public class Async10OPCPerfTest {
|
||||
|
||||
private static final int NUMBER = 1000;
|
||||
|
||||
private static final int WAN_NUMBER = 1;
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Async10OPCPerfTest.class);
|
||||
|
||||
private static JEasyOpc opc;
|
||||
private static OpcGroup opcGroup;
|
||||
private static OpcItem item;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
LOGGER.info("===================Aync Log Start=============================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
|
||||
for (int i = 1; i <= WAN_NUMBER; i++) {
|
||||
testSteps(i);
|
||||
}
|
||||
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("===================Aync Log end=============================");
|
||||
}
|
||||
|
||||
private static void testSteps(int count) throws Exception {
|
||||
|
||||
LOGGER.info("Step-" + count + "W:");
|
||||
LOGGER.info("startDate[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
JOpc.coInitialize();
|
||||
|
||||
opc = new JEasyOpc("localhost", "Matrikon.OPC.Simulation", "JOPC");
|
||||
|
||||
opcGroup = new OpcGroup("group1", true, 1 * 1000, 0.0f);
|
||||
|
||||
for (int i = 1; i <= count * NUMBER; i++) {
|
||||
item = new OpcItem("Random.Real" + i, true, "");
|
||||
opcGroup.addItem(item);
|
||||
}
|
||||
|
||||
LOGGER.info("Item traversal Date[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
|
||||
JeasyOPCListener listener = new JeasyOPCListener();
|
||||
|
||||
opcGroup.addAsynchListener(listener);
|
||||
|
||||
opc.addGroup(opcGroup);
|
||||
|
||||
opc.start();
|
||||
|
||||
synchronized (listener) {
|
||||
listener.wait(1000);
|
||||
}
|
||||
|
||||
opc.unregisterGroups();
|
||||
opc.terminate();
|
||||
JOpc.coUninitialize();
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.freud.opc.jeasyopc.perf;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javafish.clients.opc.JEasyOpc;
|
||||
import javafish.clients.opc.JOpc;
|
||||
import javafish.clients.opc.component.OpcGroup;
|
||||
import javafish.clients.opc.component.OpcItem;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.freud.opc.jeasyopc.perf.listener.JeasyOPCListener;
|
||||
|
||||
public class Async20OPCPerfTest {
|
||||
|
||||
private static final int NUMBER = 10000;
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Async20OPCPerfTest.class);
|
||||
|
||||
private static JEasyOpc opc;
|
||||
private static OpcGroup opcGroup;
|
||||
private static OpcItem item;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
LOGGER.info("===================Sync Log Start=============================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
for (int i = 1; i <= 1; i++) {
|
||||
testSteps(i);
|
||||
}
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("===================Sync Log end=============================");
|
||||
}
|
||||
|
||||
private static void testSteps(int count) throws Exception {
|
||||
|
||||
LOGGER.info("Step-" + count + "W:");
|
||||
LOGGER.info("startDate[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
long start = System.currentTimeMillis();
|
||||
JOpc.coInitialize();
|
||||
|
||||
opc = new JEasyOpc("localhost", "Matrikon.OPC.Simulation", "JOPC");
|
||||
|
||||
opcGroup = new OpcGroup("group1", true, 1 * 1000, 0.0f);
|
||||
|
||||
for (int i = 1; i < count * NUMBER; i++) {
|
||||
item = new OpcItem("Random.Real" + i, true, "");
|
||||
|
||||
opcGroup.addItem(item);
|
||||
}
|
||||
|
||||
LOGGER.info("Item traversal Date[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
|
||||
JeasyOPCListener listener = new JeasyOPCListener();
|
||||
opcGroup.addAsynchListener(listener);
|
||||
|
||||
opc.addGroup(opcGroup);
|
||||
opc.start();
|
||||
|
||||
synchronized (listener) {
|
||||
listener.wait(4000);
|
||||
}
|
||||
|
||||
// LOGGER.info("Read startDate[" + new Date() + "],CurrentMillis:"
|
||||
// + System.currentTimeMillis());
|
||||
// long readStart = System.currentTimeMillis();
|
||||
//
|
||||
// LOGGER.info("EndDate[" + new Date() + "],CurrentMillis:"
|
||||
// + System.currentTimeMillis());
|
||||
//
|
||||
// long end = System.currentTimeMillis();
|
||||
|
||||
// LOGGER.info("total used[" + (end - start) + "],readUsed["
|
||||
// + (end - readStart) + "]");
|
||||
|
||||
opc.terminate();
|
||||
|
||||
JOpc.coUninitialize();
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.freud.opc.jeasyopc.perf;
|
||||
|
||||
public class PublishOPCPerfTest {
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.freud.opc.jeasyopc.perf;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javafish.clients.opc.JEasyOpc;
|
||||
import javafish.clients.opc.JOpc;
|
||||
import javafish.clients.opc.component.OpcGroup;
|
||||
import javafish.clients.opc.component.OpcItem;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class SyncOPCPerfTest {
|
||||
|
||||
private static final int NUMBER = 10000;
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(SyncOPCPerfTest.class);
|
||||
|
||||
private static JEasyOpc opc;
|
||||
private static OpcGroup opcGroup;
|
||||
private static OpcItem item;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
LOGGER.info("===================Sync Log Start=============================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
testSteps(i);
|
||||
}
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("================================================");
|
||||
LOGGER.info("===================Sync Log end=============================");
|
||||
}
|
||||
|
||||
private static void testSteps(int count) throws Exception {
|
||||
LOGGER.info("Step-" + count + "W:");
|
||||
LOGGER.info("startDate[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
long start = System.currentTimeMillis();
|
||||
JOpc.coInitialize();
|
||||
|
||||
opc = new JEasyOpc("localhost", "Matrikon.OPC.Simulation", "JOPC");
|
||||
|
||||
opcGroup = new OpcGroup("group1", true, 3 * 1000, 0.0f);
|
||||
|
||||
for (int i = 1; i < count * NUMBER; i++) {
|
||||
item = new OpcItem("Random.Real" + i, true, "");
|
||||
opcGroup.addItem(item);
|
||||
}
|
||||
|
||||
LOGGER.info("Item traversal Date[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
|
||||
opc.addGroup(opcGroup);
|
||||
|
||||
opc.connect();
|
||||
opc.registerGroups();
|
||||
|
||||
synchronized (SyncOPCPerfTest.class) {
|
||||
SyncOPCPerfTest.class.wait(2000);
|
||||
}
|
||||
|
||||
LOGGER.info("Read startDate[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
long readStart = System.currentTimeMillis();
|
||||
opc.synchReadGroup(opcGroup);
|
||||
|
||||
LOGGER.info("EndDate[" + new Date() + "],CurrentMillis:"
|
||||
+ System.currentTimeMillis());
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
LOGGER.info("total used[" + (end - start) + "],readUsed["
|
||||
+ (end - readStart) + "]");
|
||||
|
||||
opc.unregisterGroups();
|
||||
opc.terminate();
|
||||
JOpc.coUninitialize();
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.freud.opc.jeasyopc.perf.listener;
|
||||
|
||||
import javafish.clients.opc.JCustomOpc;
|
||||
import javafish.clients.opc.asynch.AsynchEvent;
|
||||
import javafish.clients.opc.asynch.OpcAsynchGroupListener;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class JeasyOPCListener implements OpcAsynchGroupListener {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(JeasyOPCListener.class);
|
||||
|
||||
@Override
|
||||
public void getAsynchEvent(AsynchEvent event) {
|
||||
// LOGGER.info("EndDate[" + new Date() + "],CurrentMillis:"
|
||||
// + System.currentTimeMillis());
|
||||
// LOGGER.info(((JCustomOpc) event.getSource()).getFullOpcServerName()
|
||||
// + "=>" + "Package: " + event.getID() + ",count:"
|
||||
// + event.getOPCGroup().getItemCount());
|
||||
//
|
||||
System.out.println(((JCustomOpc) event.getSource())
|
||||
.getFullOpcServerName() + "=>");
|
||||
System.out.println("Package: " + event.getID());
|
||||
System.out.println(event.getOPCGroup());
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# JCustomOpc properties
|
||||
#----------------------
|
||||
# library path
|
||||
library.path = ./lib/JCustomOpc
|
||||
|
||||
# translation, see:
|
||||
# javafish.clients.opc.Translate
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# Translate properties
|
||||
resource = javafish.clients.opc.lang.resource
|
||||
locale = en
|
||||
+1
@@ -0,0 +1 @@
|
||||
# czech localization
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# english localization
|
||||
|
||||
# exception localization
|
||||
GROUP_EXISTS_EXCEPTION = The group exists on OPC Server:
|
||||
GROUP_NO_EXISTS_EXCEPTION = The group doesn't exist:
|
||||
ITEM_EXISTS_EXCEPTION = The item exists on OPC Group:
|
||||
ITEM_NO_EXISTS_EXCEPTION = The item doesn't exist:
|
||||
CONNECTIVITY_EXCEPTION = The connection to the OPC Server has failed:
|
||||
COINITIALIZE_EXCECPTION = CoInitialize COM object exception.
|
||||
COUNINITIALIZE_EXCECPTION = CoUninitialize COM object exception.
|
||||
HOST_EXCEPTION = Host not found:
|
||||
UNABLE_BROWSE_BRANCH_EXCEPTION = Unable to browse a branch.
|
||||
UNABLE_BROWSE_LEAF_EXCEPTION = Unable to browse a leaf (item).
|
||||
UNABLE_IBROWSE_EXCEPTION = Unable to initialize IBrowse.
|
||||
NOT_FOUND_SERVERS_EXCEPTION = OPC servers not found on
|
||||
UNABLE_ADD_GROUP_EXCEPTION = Unable to register group to server:
|
||||
UNABLE_ADD_GROUP_EXCEPTION_UNKNOWN = Unable to register some group to server.
|
||||
UNABLE_ADD_ITEM_EXCEPTION = Unable to register item to group:
|
||||
UNABLE_ADD_ITEM_EXCEPTION_UNKNOWN = Unable to register some item to group.
|
||||
COMPONENT_NOT_FOUND_EXCEPTION = The component (group/item) wasn't found:
|
||||
UNABLE_REMOVE_GROUP_EXCEPTION = Unable to remove group:
|
||||
UNABLE_REMOVE_GROUP_EXCEPTION_UNKNOWN = Unable to remove some group.
|
||||
UNABLE_REMOVE_ITEM_EXCEPTION = Unable to remove item:
|
||||
SYNCH_READ_EXCEPTION = Synchronous reading error.
|
||||
SYNCH_WRITE_EXCEPTION = Synchronous writing error.
|
||||
ASYNCH_10_READ_EXCEPTION = Asynchronous read error (register AdviseSink).
|
||||
ASYNCH_20_READ_EXCEPTION = Asynchronous read error (register CallBack).
|
||||
ASYNCH_10_UNADVISE_EXCEPTION = Asynchronous unadvise 1.0 error.
|
||||
ASYNCH_20_UNADVISE_EXCEPTION = Asynchronous unadvise 2.0 error.
|
||||
GROUP_UPDATETIME_EXCEPTION = Update time of group cannot be changed:
|
||||
GROUP_ACTIVITY_EXCEPTION = Activity of group cannot be changed:
|
||||
ITEM_ACTIVITY_EXCEPTION = Activity of item cannot be changed:
|
||||
VARIANT_TYPE_EXCEPTION = Variant typecast exception.
|
||||
VARIANT_TYPE_COMPARE_EXCEPTION = Variant compare exception (not Comparable types).
|
||||
|
||||
# jeasyopc translation
|
||||
JEASYOPC_CONNECTED = The OPC Client is connected.
|
||||
JEASYOPC_DISCONNECTED = The OPC Client is disconnected.
|
||||
JEASYOPC_GRP_REG = OPC Groups are registered.
|
||||
JEASYOPC_GRP_UNREG = OPC Groups are unregistered successfully.
|
||||
JEASYOPC_ASYNCH20_START = Asynchronous mode 2.0 is started.
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# Portuguese localization
|
||||
|
||||
# exception localization
|
||||
GROUP_EXISTS_EXCEPTION = O grupo existe no servidor OPC:
|
||||
GROUP_NO_EXISTS_EXCEPTION = O grupo não existe:
|
||||
ITEM_EXISTS_EXCEPTION = O item existe no grupo OPC:
|
||||
ITEM_NO_EXISTS_EXCEPTION = O item não existe:
|
||||
CONNECTIVITY_EXCEPTION = A ligação ao servidor OPC falhou:
|
||||
COINITIALIZE_EXCECPTION = Excepção CoInitialize no objecto COM.
|
||||
COUNINITIALIZE_EXCECPTION = Excepção CoUninitialize no objecto COM.
|
||||
HOST_EXCEPTION = Servidor não encontrado:
|
||||
UNABLE_BROWSE_BRANCH_EXCEPTION = Impossível fazer browse ao branch.
|
||||
UNABLE_BROWSE_LEAF_EXCEPTION = Impossível fazer browse ao item.
|
||||
UNABLE_IBROWSE_EXCEPTION = Impossível inicializar IBrowse.
|
||||
NOT_FOUND_SERVERS_EXCEPTION = Servidor OPC não encontrado em
|
||||
UNABLE_ADD_GROUP_EXCEPTION = Impossível registar grupo no servidor:
|
||||
UNABLE_ADD_GROUP_EXCEPTION_UNKNOWN = Impossível registar algum grupo no servidor.
|
||||
UNABLE_ADD_ITEM_EXCEPTION = Impossível registar item no grupo:
|
||||
UNABLE_ADD_ITEM_EXCEPTION_UNKNOWN = Impossível registar algum item no grupo.
|
||||
COMPONENT_NOT_FOUND_EXCEPTION = O componente (grupo/item) não foi encontrado:
|
||||
UNABLE_REMOVE_GROUP_EXCEPTION = Impossível remover grupo:
|
||||
UNABLE_REMOVE_GROUP_EXCEPTION_UNKNOWN = Impossível remover algum grupo.
|
||||
UNABLE_REMOVE_ITEM_EXCEPTION = Impossível remover item:
|
||||
SYNCH_READ_EXCEPTION = Erro de leitura síncrono.
|
||||
SYNCH_WRITE_EXCEPTION = Erro de escrita síncrono.
|
||||
ASYNCH_10_READ_EXCEPTION = Erro de leitura assíncrono (register AdviseSink).
|
||||
ASYNCH_20_READ_EXCEPTION = Erro de leitura assíncrono (register CallBack).
|
||||
ASYNCH_10_UNADVISE_EXCEPTION = Asynchronous unadvise 1.0 error.
|
||||
ASYNCH_20_UNADVISE_EXCEPTION = Asynchronous unadvise 2.0 error.
|
||||
GROUP_UPDATETIME_EXCEPTION = Tempo de actualização do grupo não pode ser mudado:
|
||||
GROUP_ACTIVITY_EXCEPTION = Actividade do grupo não pode ser mudada:
|
||||
ITEM_ACTIVITY_EXCEPTION = Actividade do item não pode ser mudada:
|
||||
VARIANT_TYPE_EXCEPTION = Variant typecast exception.
|
||||
VARIANT_TYPE_COMPARE_EXCEPTION = Variant compare exception (tipos não implementam Comparable).
|
||||
|
||||
# jeasyopc translation
|
||||
JEASYOPC_CONNECTED = O cliente OPC está ligado.
|
||||
JEASYOPC_DISCONNECTED = O cliente OPC está desligado.
|
||||
JEASYOPC_GRP_REG = Grupos OPC registados.
|
||||
JEASYOPC_GRP_UNREG = Grupos OPC desregistados.
|
||||
JEASYOPC_ASYNCH20_START = Modo Asynchronous 2.0 iniciado.
|
||||
@@ -0,0 +1,13 @@
|
||||
log4j.rootCategory=INFO,stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n
|
||||
|
||||
log4j.appender.jeasyopc=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.jeasyopc.File=jeasyopc_result.log
|
||||
log4j.appender.jeasyopc.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.jeasyopc.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n
|
||||
|
||||
log4j.logger.com.freud.opc.jeasyopc.perf=DEBUG,jeasyopc
|
||||
log4j.logger.com.freud.opc.jeasyopc.perf.listener=DEBUG,jeasyopc
|
||||
Reference in New Issue
Block a user