|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.forTcp; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuComResultCache; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuComResultNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataCache; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | 
|---|
|  |  |  | MidResultToRtu resToRtu = TcpDownCommandCache.matchFromHead(resFromRtu) ; | 
|---|
|  |  |  | if(resToRtu != null){ | 
|---|
|  |  |  | //匹配到下发的命令 | 
|---|
|  |  |  | resFromRtu.setCommandId(resToRtu.commandId) ; | 
|---|
|  |  |  | this.nextDeal(false, resFromRtu); | 
|---|
|  |  |  | resFromRtu.matchedCommand(resToRtu.rtuResultSendWebUrl, resToRtu.commandId) ; | 
|---|
|  |  |  | this.nextDealRtuData(false, resFromRtu); | 
|---|
|  |  |  | this.nextDealRtuComResult(resFromRtu); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.nextDeal(false, resFromRtu); | 
|---|
|  |  |  | this.nextDealRtuData(false, resFromRtu); | 
|---|
|  |  |  | //未匹配到下发的命令,命令在缓存因超时被清除了 | 
|---|
|  |  |  | RtuStatusDealer.commandFail2Success(resFromRtu.rtuAddr) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //主动上报数据 | 
|---|
|  |  |  | this.nextDeal(true, resFromRtu); | 
|---|
|  |  |  | this.nextDealRtuData(true, resFromRtu); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param reportOrResponse_trueOrFalse | 
|---|
|  |  |  | * @param resFromRtu | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void nextDeal(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){ | 
|---|
|  |  |  | private void nextDealRtuData(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RtuDataCache.cacheRtuUpData(reportOrResponse_trueOrFalse, new RtuDataNode(resFromRtu.data)); | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e.getMessage(), e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 进入单线程环境中运行 | 
|---|
|  |  |  | * @param resFromRtu | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void nextDealRtuComResult(MidResultFromRtu resFromRtu){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RtuComResultCache.cacheRtuComResult(new RtuComResultNode(resFromRtu.data)); | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e.getMessage(), e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|