File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/BusiConstantTask.java |
| | |
| | | package com.dy.aceMw.server.tasks; |
| | | |
| | | import com.dy.aceMw.server.busi.AboutRtuNode; |
| | | import com.dy.aceMw.server.busi.TcpUpDataCache; |
| | | import com.dy.aceMw.server.rtuData.RtuDataNode; |
| | | import com.dy.aceMw.server.rtuData.RtuDataCache; |
| | | import com.dy.common.mw.core.CoreTask; |
| | | import com.dy.common.queue.Node; |
| | | import org.apache.logging.log4j.LogManager; |
| | |
| | | /** |
| | | * 对RTU上行数据进行业务处理 |
| | | */ |
| | | public class BusiConstantTask extends CoreTask { |
| | | private static final Logger log = LogManager.getLogger(BusiConstantTask.class.getName()); |
| | | public class FromRtuConstantTask extends CoreTask { |
| | | private static final Logger log = LogManager.getLogger(FromRtuConstantTask.class.getName()); |
| | | |
| | | /** |
| | | * 在单线程环境中运行 |
| | |
| | | @Override |
| | | public Integer excute() { |
| | | try{ |
| | | return dealRtuUpdata() ; |
| | | return dealRtuUpData() ; |
| | | }catch(Exception e){ |
| | | log.error(e); |
| | | } |
| | |
| | | /** |
| | | * 处理上行数据 |
| | | */ |
| | | public Integer dealRtuUpdata() { |
| | | Node first = TcpUpDataCache.getFirstQueueNode() ; |
| | | public Integer dealRtuUpData() { |
| | | Node first = RtuDataCache.getFirstQueueNode() ; |
| | | if(first != null){ |
| | | Integer count = TcpUpDataCache.size() ; |
| | | Node last = TcpUpDataCache.getLastQueueNode() ; |
| | | this.doDealRtuUpdata(first, last); |
| | | Integer count = RtuDataCache.size() ; |
| | | Node last = RtuDataCache.getLastQueueNode() ; |
| | | this.doDealRtuUpData(first, last); |
| | | return count ; |
| | | } |
| | | return null ; |
| | |
| | | * @param first 第一个节点 |
| | | * @param last 最后一个节点 |
| | | */ |
| | | private void doDealRtuUpdata(Node first, Node last){ |
| | | private void doDealRtuUpData(Node first, Node last){ |
| | | if(last != null){ |
| | | //在dealNode方法中,可能要把last从队列中移除,这时last.pre为空,所以提前把last.pre取出来 |
| | | Node pre = last.pre ; |
| | | dealNode(last) ; |
| | | if(first != null && first != last){ |
| | | doDealRtuUpdata(first, pre) ; |
| | | doDealRtuUpData(first, pre) ; |
| | | }else if(first != null && first == last){ |
| | | //停止 |
| | | }else if(first == null){ |
| | | //这种情况不会存在 |
| | | doDealRtuUpdata(null, pre) ; |
| | | doDealRtuUpData(null, pre) ; |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param node 节点 |
| | | */ |
| | | private void dealNode(Node node){ |
| | | AboutRtuNode obj = (AboutRtuNode)node.obj ; |
| | | RtuDataNode obj = (RtuDataNode)node.obj ; |
| | | obj.dealSelf() ; |
| | | TcpUpDataCache.removeNode(node); |
| | | RtuDataCache.removeNode(node); |
| | | } |
| | | |
| | | } |