懒羊羊
2024-03-13 b64ed2c784bde6dea9d18149ca706ebe532c857d
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
47
48
49
50
51
52
53
54
55
56
57
package com.jcdm.main.plcserver;
 
 
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService;
import com.jcdm.main.plcserver.conf.OPCElement;
import com.jcdm.main.plcserver.sub.OPCUaSubscription;
import com.kangaroohy.milo.service.MiloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
 
@Component
public class CustomRunner implements ApplicationRunner {
 
    @Autowired
    private MiloService miloService;
 
    @Autowired
    private IDaPassingStationCollectionService daPassingStationCollectionService;
 
    @Autowired
    private IDaCollectionParamConfService collectionParamConfService;
 
    @Autowired
    private IDaParamCollectionService daParamCollectionService;
 
    @Override
    public void run(ApplicationArguments args) throws Exception {
 
        OPCUaSubscription opcUaSubscription = new OPCUaSubscription(
                miloService,
                daPassingStationCollectionService,
                collectionParamConfService,
                daParamCollectionService);
 
        List<String> lists = getSubList();
        miloService.subscriptionFromOpcUa(lists,opcUaSubscription);
 
    }
 
    /**
     * 订阅内容
     */
    public List<String> getSubList(){
        List<String> lists = new ArrayList<>();
        lists.add(OPCElement.OP_OP010_RecordSN);//请求下发SN号
        lists.add(OPCElement.OP_OP230_RecordData);//请求记录数据
        lists.add(OPCElement.OP_OP240_RecordData);//请求记录数据
        return lists;
    }
}