1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.dy.rtuMw.server.rtuData;
 
import com.dy.common.mw.UnitAdapterInterface;
import com.dy.common.mw.UnitInterface;
import com.dy.common.mw.UnitStartedCallbackInterface;
 
public class RtuDataUnit  implements UnitInterface {
 
    private static RtuDataUnit instance = new RtuDataUnit() ;
    
    public static RtuDataUnitAdapter adapter ;
    public static RtuDataUnitConfigVo confVo ;
 
    private RtuDataUnit(){} ;
    
    public static RtuDataUnit getInstance(){
        return instance ;
    }
    
    @Override
    public void setAdapter(UnitAdapterInterface adapter) throws Exception {
        if(adapter == null){
            throw new Exception("RTU数据处理模块适配器对象不能为空!") ;
        }
        RtuDataUnit.adapter = (RtuDataUnitAdapter)adapter ; 
        RtuDataUnit.confVo = RtuDataUnit.adapter.getConfig() ;
        if(RtuDataUnit.confVo == null){
            throw new Exception("RTU数据处理模块配置对象不能为空!") ;
        }
    }
 
    /**
     * 初始化上行数据处理任务池
     */
    @Override
    public void start(UnitStartedCallbackInterface callback) throws Exception {
        TaskPool.setTaskTreeCofig(new TreeParse().parseConfig(confVo.resourceLoader));
        callback.call(null) ;
        System.out.println("RTU数据处理模块成功启动");
    }
 
    @Override
    public void stop(UnitStartedCallbackInterface callback) throws Exception {
    }
 
}