|  |  | 
 |  |  |  | 
 |  |  | import com.dy.common.mw.UnitAdapterInterface; | 
 |  |  | import com.dy.common.mw.UnitInterface; | 
 |  |  | import com.dy.common.mw.UnitStartedCallbackInterface; | 
 |  |  | import com.dy.common.mw.UnitCallbackInterface; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | public class ProtocolUnit implements UnitInterface { | 
 |  |  | 
 |  |  |    /** | 
 |  |  |     * 启动模块 | 
 |  |  |     */ | 
 |  |  |    public void start(UnitStartedCallbackInterface callback) throws Exception { | 
 |  |  |    public void start(UnitCallbackInterface callback) throws Exception { | 
 |  |  |       //得到唯一实例, 并在生成唯一实例时,扫描注解类 | 
 |  |  |       AnnotationScan.getIntance() ; | 
 |  |  |        | 
 |  |  |       //各个协议驱动类扫描自己的功能码注解 | 
 |  |  |       HashMap<String, AnnotationDriverVo> drivers =  ProtocolCache.getDriverMap() ; | 
 |  |  |       Collection<String> colDrivers = drivers.keySet() ; | 
 |  |  |       Collection<String> keys = drivers.keySet() ; | 
 |  |  |       StringBuilder totalProtocols = new StringBuilder() ; | 
 |  |  |       for(String protocolName : colDrivers){ | 
 |  |  |       for(String protocolNameVersion : keys){ | 
 |  |  |          if(!totalProtocols.isEmpty()){ | 
 |  |  |             totalProtocols.append(",") ; | 
 |  |  |          } | 
 |  |  |          totalProtocols.append(protocolName) ; | 
 |  |  |          Driver dri = ProtocolCache.getDriver(protocolName) ; | 
 |  |  |          totalProtocols.append(protocolNameVersion) ; | 
 |  |  |          Driver dri = ProtocolCache.getDriver(protocolNameVersion) ; | 
 |  |  |          if(dri != null){ | 
 |  |  |             dri.scanAnnotationCode(); | 
 |  |  |             dri.setNotify(adapter.getSingleRtuInfoNotify(protocolNameVersion)); | 
 |  |  |          } | 
 |  |  |       } | 
 |  |  |       if(adapter.getConfig().showStartInfo){ | 
 |  |  | 
 |  |  |    } | 
 |  |  |  | 
 |  |  |    @Override | 
 |  |  |    public void stop(UnitStartedCallbackInterface callback) { | 
 |  |  |    public void stop(UnitCallbackInterface callback) { | 
 |  |  |    } | 
 |  |  |     | 
 |  |  |    /* |