ZengTao
2024-03-18 7a4da65b270b1eb8dadf1fbf46b09f25274f5422
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.example.springboot.component;
 
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianServiceNew;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.device.PlcParameterObject;
import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.AlbaniaMapper;
import com.example.springboot.mapper.SpianMapper;
 
public class PlcHoldNew extends Thread {
 
  private AlarmMapper alarmMapper;
 
  @Autowired
  private JdbcConnections jdbcConnections;
  private AlbaniaMapper albaniaMapper;
  private SpianServiceNew spianService;
  int aaa;
 
  @Override
  public void run() {
 
    while (this != null) {
      try {
 
        Thread.sleep(100);
      } catch (InterruptedException e) {
        // \\ TODO Auto-generated catch block
        e.printStackTrace();
      }
      
      // if (S7control.getinstance().CheckConnected() == false) {
      spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
      albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
      spianService.selectAll(albaniaMapper.SelectGlass());
      //读取DB14区文件
      PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
 
      
      String ExportTOMES1=plcmes.getPlcParameter("ExportTOMES1").getValue();//出片请求一线
      String ExportToMES2=plcmes.getPlcParameter("ExportToMES2").getValue();//出片请求二线
      String PLCToMES=plcmes.getPlcParameter("PLCToMES").getValue();//进片请求
      String B01State=plcmes.getPlcParameter("B01State").getValue();//运送车请求
      String TastState=plcmes.getPlcParameter("MESToPLCStatus1").getValue();//任务完成
  
      
      //一号线请求
      if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) {
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        spianService.selectout(1);
      }
      //二线号请求时
      if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) {
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        spianService.selectout(2);
      }
      //进片请求时
      if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        
        spianService.selectAll(albaniaMapper.SelectGlass());
      }
      
 
      //任务完成时
      if(TastState.equals("1")==true){
        
        //完成确认字
        for(int i=1;i<7;i++){
          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//依次获取任务类型
          String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//依次获取任务类型
          if(Tastover.equals("1")){
 
            //调用完成任务 Glassid
            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//完成确认字
          }
        }
      }
 
  
      // 查询数据库
      // 推送到前端
 
      // }
    }
  }
 
}