Administrator
2023-12-19 f41d94d3e05e221182623361d967f884737c0171
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
@@ -83,10 +83,13 @@
                                log.info("共模拟了" + totalRtuClientCount + "台RTU");
                                Collection<MyThreadJob> collection = jobMap.values() ;
                                int connectedCount = 0 ;
                                for(MyThreadJob job : collection){
                                    connectServer(job) ;
                                    connectedCount++ ;
                                    log.info("当前建立与通信中间件连接的RTU数量为:" + connectedCount);
                                }
                                log.info("启动所有RTU连接通信中间件");
                                log.info("所有RTU已与通信中间件建立连接");
                                while (true){
                                    int noConnectedCount = checkConnected() ;
@@ -99,6 +102,7 @@
                                }
                                startJob() ;
                                while(true){
                                    if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){
                                        Long seconds = (System.currentTimeMillis() - startTime)/1000 ;
@@ -176,30 +180,27 @@
    }
    private void startJob(){
        new Thread(new Runnable(){
            @Override
            public void run() {
                try {
                    int notOverCount;
                    while(true){
                        notOverCount = 0 ;
                        Collection<MyThreadJob> collection = jobMap.values() ;
                        for(MyThreadJob job : collection){
                            if(!job.isOver){
                                notOverCount++ ;
                                pool.putJob(job);
                            }
                        }
                        if(notOverCount > 0){
                            log.info("当前还有" + notOverCount + "台RTU未完成任务");
                            Thread.sleep(ServerProperties.sendInterval * 1000);
                        }else{
                            break ;
        new Thread(() -> {
            try {
                int notOverCount;
                while(true){
                    notOverCount = 0 ;
                    Collection<MyThreadJob> collection = jobMap.values() ;
                    for(MyThreadJob job : collection){
                        if(!job.isOver){
                            notOverCount++ ;
                            pool.putJob(job);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    if(notOverCount > 0){
                        log.info("当前还有" + notOverCount + "台RTU未完成任务");
                        Thread.sleep(ServerProperties.sendInterval * 1000);
                    }else{
                        break ;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
    }