From 3f4124093b81a6ccd6a393947cab2282ab13b248 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期五, 26 一月 2024 11:34:00 +0800
Subject: [PATCH] DB区josn文件上传
---
springboot-vue3/src/main/java/com/example/springboot/component/InitUtil.java | 10 --
springboot-vue3/src/main/resources/JsonFile/PlcRead.json | 2
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | 8 +-
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java | 31 ++++---
springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java | 3
springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java | 109 ++++++++++++++-------------
springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java | 25 ++++++
springboot-vue3/src/main/resources/JsonFile/PlcMes.json | 6
springboot-vue3/src/main/resources/JsonFile/Plcframe.json | 0
9 files changed, 111 insertions(+), 83 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/InitUtil.java b/springboot-vue3/src/main/java/com/example/springboot/component/InitUtil.java
index da7aa1c..b7824e9 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/InitUtil.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/InitUtil.java
@@ -47,8 +47,7 @@
plcParameterObject.addPlcParameter(plcParameterInfo);
}
// byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
- byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
- plcParameterObject.setPlcParameterList(getplcvlues);
+
return plcParameterObject;
} catch (IOException e) {
@@ -94,12 +93,7 @@
} catch (IOException e) {
e.printStackTrace();
}
- //Boolean[] values1 = { false, true, true, true, false, false, true, false,
- // false, true ,true };
- // List<Boolean> getplcvlues = new ArrayList<>(Arrays.asList(values1));
-
-// List<Boolean> getplcvlues = S7control.getinstance().ReadBits(plcBitObject.getPlcAddressBegin(), plcBitObject.getPlcAddressLength());
-// plcBitObject.setPlcBitList(getplcvlues);
+
return plcBitObject;
}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
index b488fed..6e6ef8a 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutoMes.java
@@ -50,32 +50,35 @@
String jsonFilePath = PLCAutoMes.class.getResource("/JsonFile/PlcMes.json").getPath();
String jsonFilePath2 = PLCAutoMes.class.getResource("/JsonFile/PlcRead.json").getPath();
- String jsonFilePath3 = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
- System.out.println(jsonFilePath);
+ // String jsonFilePath3 = PLCAutoMes.class.getResource("/JsonFile/Plcframe.json").getPath();
+ // System.out.println(jsonFilePath);
// 璋冪敤initword鏂规硶
PlcParameterObject PlcMesObject= initUtil.initword(jsonFilePath);
// 璋冪敤initbit鏂规硶
- PlcParameterObject PlcReadObject= initUtil.initword(jsonFilePath2);
- // 璋冪敤initbit鏂规硶
- PlcParameterObject PlcframeObject= initUtil.initword(jsonFilePath3);
- readAndUpdateWordValues(PlcframeObject);
- readAndUpdateWordValues(PlcMesObject);
+ PlcParameterObject PlcReadObject= initUtil.initword(jsonFilePath2);
+ // // 璋冪敤initbit鏂规硶
+ // PlcParameterObject PlcframeObject= initUtil.initword(jsonFilePath3);
readAndUpdateWordValues(PlcReadObject);
+ readAndUpdateWordValues(PlcMesObject);
+ // readAndUpdateWordValues(PlcframeObject);
+
+
// readAndUpdateWordValues(plcStateObject);
int index = PlcMesObject.getPlcParameter("AddStart").getAddressIndex();
- System.out.println(index);
+ //System.out.println(index);
PlcMesObject.getPlcParameter("AddStart").getAddress(index);
- System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index));
+ //System.out.println(PlcMesObject.getPlcParameter("AddStart").getAddress(index));
List<String> addresses = new ArrayList<>();
- addresses.add("FeedCarStatus");
- addresses.add("OutRequest");
- System.out.println(PlcReadObject.getPlcParameterValues(addresses));
+ addresses.add("FeedID");
+ addresses.add("AddStart");
+ //System.out.println(addresses);
+ //System.out.println(PlcMesObject.getPlcParameterValues(addresses));
List<String> addresses2 = new ArrayList<>();
- addresses2.add("conveyorVelocity(AutoSLOW)");
- addresses2.add("D01.SRdec");
+ addresses2.add("FeedID");
+ addresses2.add("FeedCarStatus");
System.out.println(PlcReadObject.getPlcParameterValues(addresses2));
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
index 1717468..ada22ca 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
@@ -1,19 +1,10 @@
package com.example.springboot.component;
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
+import java.time.LocalDateTime;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianService;
-
-import cn.hutool.json.JSONArray;
-import cn.hutool.json.JSONObject;
-
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.SpianMapper;
@@ -26,7 +17,6 @@
private JdbcConnections jdbcConnections;
private SpianMapper spianMapper;
private SpianService spianService;
-
int aaa;
@Override
@@ -35,24 +25,16 @@
while (this != null) {
try {
- Thread.sleep(50);
+ Thread.sleep(100);
} catch (InterruptedException e) {
// \\ TODO Auto-generated catch block
e.printStackTrace();
}
+
// if (S7control.getinstance().CheckConnected() == false) {
spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
-
- String str = "";
- BufferedReader bufferedReader = null;
- FileInputStream fileInputStream;
-
-
-
-
-
// 鏍规嵁鐜荤拑id鑾峰彇璁㈠崟鍙�,鍗曠嫭鏁版嵁婧�
// try {
// north_glass_buffer1 glass = jdbcConnections.selectGlass(112);
@@ -61,27 +43,38 @@
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
-
+
// 鍑虹墖浠诲姟////////////////////////////////
List<Short> outlist = S7control.getinstance().ReadWord("DB106.20", 1); // 鍑虹墖杞︾姸鎬�
List<Short> outlist1 = S7control.getinstance().ReadWord("DB105.18", 1); // 鍑虹墖浠诲姟鏄惁鍚姩
+
+ boolean Plcout = spianService.listbool("DB106.64"); // 鍑虹墖璇锋眰瀛�
+ boolean Plcout2 = spianService.listbool("DB105.18"); // 鍑虹墖鍚姩
+ if (Plcout == false&&Plcout2==true) {
+ S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
+ System.out.println("鍏抽棴鍑虹墖鍚姩" + LocalDateTime.now());// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负0
+ }
+ boolean Plcadd = spianService.listbool("DB106.24"); // 杩涚墖璇锋眰瀛�
+ boolean Plcadd2 = spianService.listbool("DB105.16"); // 杩涚墖鍚姩
+ if (Plcadd == false&&Plcadd2==true) {
+ S7control.getinstance().WriteWord("DB105.16", (short) 0);//杩涚墖浠诲姟鍚姩鏀逛负0
+ System.out.println("鍏抽棴杩涚墖鍚姩" + LocalDateTime.now());// 杩涚墖浠诲姟鍙戦�佸瓧鏀逛负0
+ }
+
+
+
// StringBuilder writedstrIdOut = new StringBuilder();
// 鑾峰彇宸蹭笅鍙戠殑鍑虹墖id
byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14);
String writedstrIdOut = new String(writedglassidbytesOut);
- boolean outstate = false;// 鍑虹墖杞︾┖闂插垽鏂�
- boolean outstate1 = false;// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔�
- if (outlist != null && outlist1 != null) {
-
- outstate = outlist.contains((short) 0);// 鍑虹墖杞︾┖闂插垽鏂� 褰撳嚭鐗囪溅绌洪棽鏃朵负true
- outstate1 = outlist1.contains((short) 1);// 鍑虹墖杞︿换鍔℃槸鍚﹀惎鍔� 褰撳嚭鐗囪溅浠诲姟鍚姩鏃朵负true
-
+
+ if (Plcout == true) {
// 鍒ゆ柇褰撳墠鏄惁鏈夋湭鎵ц鐨勪换鍔�
- int outnum = spianMapper.SelectOutSliceshu();
- int cageoutsum = spianMapper.Selectcageout(3);
+ int outnum = spianMapper.SelectOutSliceshu();//鏄惁鏈夋鍦ㄥ嚭鐗囩殑浠诲姟
+ int cageoutsum = spianMapper.Selectcageout(3);//绗煎瓙鍐呮槸鍚﹁繕鏈夊湪鍑虹墖鐨勭幓鐠�
// 褰撴病鏈変换鍔℃墽琛屽苟涓斿嚭鐗囪溅绌洪棽鏃�
- if (outnum == 0 && outstate == true && Plchome.isAllowQueue == true && cageoutsum == 0) {
+ if (outnum == 0 && Plchome.isAllowQueue == true && cageoutsum == 0) {
// 鍒ゆ柇閾濇鍑虹墖闃熷垪琛ㄦ槸鍚︽湁寰呭嚭鐗囩殑鐜荤拑
String outglassid = spianMapper.SelectOutSlice();
// 褰撴湁寰呭嚭鐗囩殑鐜荤拑鏃�
@@ -92,18 +85,13 @@
if (glassdisabled == 0) {
spianService.selectout2(outglassid);
Plchome.isQueueWarning = false;
- outstate = false;
} else { // 绂佺敤鏇存敼鐘舵�佸脊鍑烘彁绀�
Plchome.isQueueWarning = true;
}
}
}
- if (outstate == true) {// 褰撳嚭鐗囪溅绌洪棽鏃�,涓斿嚭鐗囧惎鍔ㄤ负1鏃讹紝浠诲姟鍚姩鏀逛负0
- if (outstate1 == true) {
- S7control.getinstance().WriteWord("DB105.18", (short) 0);// 鍑虹墖浠诲姟鍚姩鏀逛负0
- }
- }
+
}
///////////// 杩涚墖浠诲姟
@@ -113,28 +101,46 @@
boolean B01backs = spianService.listbool("DB106.60");// b01姹囨姤
boolean B02backs = spianService.listbool("DB106.62");// b02姹囨姤
-
StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1鐨勭幓鐠僫d
StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02鐨勭幓鐠僫d
// 褰撹繘鐗囧皬杞﹀畬鎴愪换鍔℃椂
if (B01backs == true) {
- // 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
- // spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
- // S7control.getinstance().WriteWord("DB106.60", (short) 0);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负0
- boolean yingda = spianService.listbool("DB106.60");// b01姹囨姤
- System.out.println("姹囨姤鏃禕01|绗�" + aaa + "娆�" + B01glassid + "搴旂瓟" + yingda);
- aaa += 1;
+ // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+ int HB = spianMapper.SelectHB(B01glassid.toString());
+ if (HB > 0) {
+ // 褰揃01灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬� 涓�1
+ S7control.getinstance().WriteWord("DB105.48", (short) 1);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
+ boolean yingda = spianService.listbool("DB105.48");// b01姹囨姤
+ if (yingda == true) {
+ spianService.overtask(B01glassid.toString());// 瀹屾垚浠诲姟
+ }
+ System.out.println("姹囨姤鏃禕01|绗�" + aaa + "娆�" + B01glassid + "搴旂瓟" + yingda);
+ aaa += 1;
+ }
+
+ }else{
+ S7control.getinstance().WriteWord("DB105.48", (short) 0);// 鎭㈠B01灏忚溅搴旂瓟鏀逛负1
}
// 褰撳嚭鐗囧皬杞﹀畬鎴愪换鍔℃椂
if (B02backs == true) {
- // 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
- // spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
- // S7control.getinstance().WriteWord("DB106.62", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
+ // 鍒ゆ柇鏄惁姹囨姤姝g‘鐨刬d
+ int HB = spianMapper.SelectHB(B02glassid.toString());
System.out.println("姹囨姤鏃禕02|" + B02glassid);
- boolean yingda1 = spianService.listbool("DB106.62");// b02姹囨姤
- System.out.println("姹囨姤鏃禕02|绗�" + aaa + "娆�" + B02glassid + "搴旂瓟" + yingda1);
+ if (HB > 0) {
+ // 褰揃02灏忚溅姹囨姤瀹屾垚鏃舵洿鏀圭幓鐠冪姸鎬佷负0
+
+ S7control.getinstance().WriteWord("DB105.50", (short) 1);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负1
+ System.out.println("姹囨姤鏃禕02ID|" + B02glassid);
+ boolean yingda = spianService.listbool("DB105.50");// b02姹囨姤
+ if (yingda == true) {
+ spianService.overtask(B02glassid.toString());// 瀹屾垚浠诲姟
+ }
+ System.out.println("姹囨姤鏃禕02|绗�" + aaa + "娆�" + B02glassid + "搴旂瓟" + yingda);
+ }
+ }else{
+ S7control.getinstance().WriteWord("DB105.50", (short) 0);// 鎭㈠B02灏忚溅搴旂瓟鏀逛负0
}
@@ -160,6 +166,7 @@
}
}
+
if (queueid2 != null) {
// 鍐欏叆D02鐨勬暟鎹埌涓婄墖闃熷垪琛�
if (glass2 == null) {
@@ -173,8 +180,6 @@
}
}
-
-
// 鏌ヨ鏁版嵁搴�
// 鎺ㄩ�佸埌鍓嶇
diff --git a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
index 4461da2..0048cb7 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -17,11 +17,11 @@
//
System.out.println("鍚姩瀹屾垚");
- new PlcHold().start();
- // new PLCAutoMes();
- new PLCAutomaticParameterSettingReview2();
+ // new PlcHold().start();
+ new PLCAutoMes().start();
+ // new PLCAutomaticParameterSettingReview2().start();
- // new Plchome().start();
+ //new Plchome().start();
// new PlcLayout().start();
// new Plcalarm().start();
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
index 8808874..76b6fae 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
@@ -122,14 +122,15 @@
*/
public void setPlcParameterList(byte[] plcValueArray) {
if (plcParameterList != null) {
+
for (PlcParameterInfo plcParameterInfo : plcParameterList) {
+
byte[] valueList = new byte[plcParameterInfo.getAddressLength()];
// System.out.println(plcParameterInfo.getAddressLength());
for (int i = 0; i < plcParameterInfo.getAddressLength(); i++) {
Array.setByte(valueList, i, plcValueArray[plcParameterInfo.getAddressIndex() + i]);
-
}
if (plcParameterInfo.getAddressLength()==2) {
diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java b/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
index 74c092d..2988da2 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/service/SpianService.java
@@ -117,6 +117,11 @@
int qidong2 = 0;
if (qidong == true) {
qidong2 = 1;
+ }else{
+ while (qidong) {
+ S7control.getinstance().WriteWord("DB105.16", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+ qidong = listbool("DB105.16");
+ }
}
spianMapper.Inserttask(0, 0, 1000, ids, glassid.toString(), prctier,qidong2);// 鏂板浠诲姟
System.out.println("杩涚墖浠诲姟|" + datas);
@@ -193,6 +198,11 @@
int qidong2 = 0;
if (qidong == true) {
qidong2 = 1;
+ }else{
+ while (qidong) {
+ S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+ qidong = listbool("DB105.18");
+ }
}
spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, state, qidong2);// 鏂板浠诲姟
outmesid(glassid, "DB105.34");// 娲惧彂鍑虹墖ID
@@ -221,6 +231,11 @@
int qidong2 = 0;
if (qidong == true) {
qidong2 = 1;
+ }else{
+ while (qidong) {
+ S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+ qidong = listbool("DB105.18");
+ }
}
spianMapper.Inserttask(1, 0, cageout.getId(), 1000, glassid, 1, qidong2);// 鏂板浠诲姟
return (200);// 缁撴潫
@@ -259,6 +274,11 @@
int qidong2 = 0;
if (qidong == true) {
qidong2 = 1;
+ }else{
+ while (qidong) {
+ S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+ qidong = listbool("DB105.18");
+ }
}
spianMapper.Inserttask(2, 0, cageout.getId(), ids, glassids, 2, qidong2);// 鏂板璋冨害浠诲姟
@@ -291,6 +311,11 @@
int qidong2 = 2;
if (qidong == true) {
qidong2 = 1;
+ }else{
+ while (qidong) {
+ S7control.getinstance().WriteWord("DB105.18", (short) 1);// 鍑虹墖浠诲姟鍙戦�佸瓧鏀逛负1
+ qidong = listbool("DB105.18");
+ }
}
spianMapper.Inserttask(2, 0, cageout.getId() + 1, ids, glassids, 2, qidong2);// 鏂板璋冨害浠诲姟
spianMapper.UpdateDBCage(ids, cage, cell, 2);// 灏嗗師鏍煎瓙鏁版嵁鏇存柊鍒版柊鏍煎瓙閲�
diff --git a/springboot-vue3/JsonFile/PlcMes.json b/springboot-vue3/src/main/resources/JsonFile/PlcMes.json
similarity index 97%
rename from springboot-vue3/JsonFile/PlcMes.json
rename to springboot-vue3/src/main/resources/JsonFile/PlcMes.json
index 53ccdef..25a48d6 100644
--- a/springboot-vue3/JsonFile/PlcMes.json
+++ b/springboot-vue3/src/main/resources/JsonFile/PlcMes.json
@@ -83,20 +83,20 @@
{
"codeId": "ReleaseID",
"addressIndex":"34",
- "addressLenght":"16",
+ "addressLenght":"14",
"ratio":"1",
"unit":"mm/S"
},
{
"codeId": "B01report",
- "addressIndex":"50",
+ "addressIndex":"48",
"addressLenght":"2",
"ratio":"1",
"unit":"mm/S"
},
{
"codeId": "B02report",
- "addressIndex":"52",
+ "addressIndex":"50",
"addressLenght":"2",
"ratio":"1",
"unit":"m/min"
diff --git a/springboot-vue3/JsonFile/PlcRead.json b/springboot-vue3/src/main/resources/JsonFile/PlcRead.json
similarity index 98%
rename from springboot-vue3/JsonFile/PlcRead.json
rename to springboot-vue3/src/main/resources/JsonFile/PlcRead.json
index 6bcfbe9..f3ebb33 100644
--- a/springboot-vue3/JsonFile/PlcRead.json
+++ b/springboot-vue3/src/main/resources/JsonFile/PlcRead.json
@@ -1,5 +1,5 @@
{
- "plcAddressBegin": "DB106.0.0",
+ "plcAddressBegin": "DB106.0",
"plcAddressLenght": "66",
"dataType": "word",
"parameteInfor": [{
diff --git a/springboot-vue3/JsonFile/Plcframe.json b/springboot-vue3/src/main/resources/JsonFile/Plcframe.json
similarity index 100%
rename from springboot-vue3/JsonFile/Plcframe.json
rename to springboot-vue3/src/main/resources/JsonFile/Plcframe.json
--
Gitblit v1.8.0