wuyouming666
2024-03-26 90110ed128dd9212caf3b7d5fb4a8d5f870d2905
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
58
59
60
61
62
63
package com.mes.service;
 
import com.mes.common.PlcTools.MockS7PLCtwo;
import com.mes.entity.DownGlassInfo;
import com.mes.entity.DownStorageCageDetails;
import com.mes.entity.device.PlcParameterObject;
import com.mes.mapper.DownWorkstationMapper;
import com.mes.tools.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
@Service
public class PlcService {
 
    @Autowired
    private DownWorkstationMapper downWorkstationMapper;
    private DownGlassInfoService downGlassInfoService;
 
 
 
    private List<DownGlassInfo> glassList; // 存放待处理的玻璃信息
    private List<DownStorageCageDetails> cageDetailsList; // 存放玻璃放置在缓存笼中的详细信息
    PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
    String Robot1PLCrequestword=plcread.getPlcParameter("A01Position").getValue();// 机械手1PLC请求字
    String Robot2PLCrequestword=plcread.getPlcParameter("A01Position").getValue();// 机械手2PLC请求字
    String GlassID=plcread.getPlcParameter("A01Position").getValue();// 玻璃id
    String Glasswidth=plcread.getPlcParameter("A01Position").getValue();//玻璃宽度
    String Glassheight=plcread.getPlcParameter("A01Position").getValue();//玻璃高度
    String Glassthickness=plcread.getPlcParameter("A01Position").getValue();//厚度
    String PLCwancheng = plcread.getPlcParameter("A01Position").getValue();// plc完成字
 
 
    public void performPlcActions() {
        downWorkstationMapper = WebSocketServer.applicationContext.getBean(DownWorkstationMapper.class);
        downGlassInfoService = WebSocketServer.applicationContext.getBean(DownGlassInfoService.class);
        PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
        int workstationId = 1;
        int deviceId = 2;
        int newWorkState = 9;
        downWorkstationMapper.updateWorkStateByWorkstationIdAndDeviceId(workstationId, deviceId, newWorkState);
 
        DownGlassInfo downGlassInfo = downGlassInfoService.getDownGlassInfoById(1);
 
        Boolean[] value4 = { false, true, true, true, true, true, false, false, false, false};
        List<Boolean> booldata2 = new ArrayList<>(Arrays.asList(value4));
        MockS7PLCtwo.getInstance().writebits("DB4.0.0", booldata2);
        List<Boolean> data4= MockS7PLCtwo.getInstance().readbits("DB4.0.0",10);
 
        System.out.println("读取的word值: " + data4);
        String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();
        byte[] getplcvalues = MockS7PLCtwo.getInstance().readByte("DB101.0", 2);
        System.out.println(Arrays.toString(getplcvalues));
        //System.out.println("读取的通讯word值: " + OutActivate);
        // 其他与 PLC 相关的操作...
    }
 
 
 
}