From 3acd15a13d9edfde79ee125af135d2a089b23872 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期四, 09 十一月 2023 15:08:26 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
---
springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java | 62 +++++++++++++++++++++++++++++--
1 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
index a539781..61c28f0 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
@@ -1,12 +1,61 @@
package com.example.springboot.component;
+import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
+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.util.ArrayList;
import java.util.List;
import java.util.Arrays;
public class Plcstate extends Thread {
+ String name = "";
+ Integer count = 0;
+
+ public void readValue() {
+ String str = "";
+ BufferedReader bufferedReader = null;
+ FileInputStream fileInputStream;
+ try {
+ // 浠庢枃浠朵腑璇诲彇瀛楄妭鏁版嵁瀛樺叆 fileInputStream
+ fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/State.json");
+ // 璇诲彇 fileInputStream 涓瓧鑺傚苟灏嗗叾瑙g爜涓哄瓧绗�
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
+ // 鎻愰珮璇诲彇鏁堢巼锛屽湪 BufferedReader 鍐呭寘瑁� InputStreamReader
+ bufferedReader = new BufferedReader(inputStreamReader);
+ String line = null;
+ // 灏� bufferedReader 鍐呭涓�琛屼竴琛岃祴鍊肩粰str
+ while ((line = bufferedReader.readLine()) != null) {
+ str += line;
+ }
+
+ // 灏唖tr瀛楃涓叉牸寮忚浆涓簀son
+ JSONObject jsonObject = new JSONObject(str);
+
+ // 鑾峰彇json涓殑鍊�
+ JSONArray address = jsonObject.getJSONArray("address");
+ for (int i = 0; i < address.size(); i++) {
+ JSONObject ress = (JSONObject) address.get(i);
+
+ this.name = ress.getStr("name");
+ this.count = ress.getInt("count");
+
+ }
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
@Override
public void run() {
while (this != null) {
@@ -16,10 +65,15 @@
e.printStackTrace();
}
- List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 10);
- // Short[] values = { 0, 1, 1, 0, 1, 0, 1, 0,
- // 1, 0, };
- // List<Short> plclist = new ArrayList<>(Arrays.asList(values));
+ this.readValue();
+ String PlcAddress = this.name;
+ Integer Plccount = this.count;
+ // System.out.println(PlcAddress);
+
+ // List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 10);
+ Short[] values = { 0, 1, 1, 0, 1, 0, 1, 0,
+ 1, 0, };
+ List<Short> plclist = new ArrayList<>(Arrays.asList(values));
if (plclist != null) {
List<String> Intlist = new ArrayList<>();
--
Gitblit v1.8.0