From 9020f58f9c945d8a99493eb4da2253b6937909fe Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期五, 08 九月 2023 16:57:38 +0800
Subject: [PATCH] Merge branch 'master' of ssh://10.153.19.150:29418/CanadaMes
---
/dev/null | 148 -------------------------------------------------
1 files changed, 0 insertions(+), 148 deletions(-)
diff --git a/CanadaMes-ui/src/layout/index.vue b/CanadaMes-ui/src/layout/index.vue
deleted file mode 100644
index 23af1e7..0000000
--- a/CanadaMes-ui/src/layout/index.vue
+++ /dev/null
@@ -1,305 +0,0 @@
-<template>
- <el-container style="flex: 1;">
- <div style="width: 200px;background-color: #222f3e" :style="{width: isCollapse?'70px':'250px'}">
- <el-aside :width="isCollapse?'70px':'250px'">
- <el-col :gutter="20">
- <el-row :span="4">
- <div class="logo" @click="goToHome">
- <div class="sys-name" v-show="!isCollapse">{{ $t('northglassMESsystem') }}</div>
- </div>
- </el-row>
- <el-row :span="20">
- <el-menu :default-active="activePath" class="el-menu-vertical-demo"
- background-color="#222f3e" text-color="#fff" active-text-color="#ffd04b"
- :collapse="isCollapse" :unique-opened="true"
- :collapse-transition="false" :router="true">
- <el-menu-item index="/" @click="goToHome">
- <template slot="title">
- <!--鍥炬爣-->
- <i class="el-icon-menu"></i>
- <!--鏂囨湰-->
- <span>{{ $t('home') }}</span>
- </template>
- </el-menu-item>
- <!--涓�绾ц彍鍗�-->
- <el-submenu :index="item.id.toString()" v-for="item in menuList" :key="item.id">
- <!--涓�绾ц彍鍗曟ā鏉垮尯鍩�-->
- <template slot="title">
- <!--鍥炬爣-->
- <i :class="item.icon"></i>
- <!--鏂囨湰-->
- <span>{{ item.name }}</span>
- </template>
- <!--浜岀骇鑿滃崟-->
-
- <el-menu-item :index="'/'+menu.router"
- v-for="menu in item.menuLists" :key="menu.id"
- @click="addTag(menu.router)">
- <template slot="title">
- <!--鍥炬爣-->
- <i :class="menu.icon"></i>
- <!--鏂囨湰-->
- <span>{{ menu.name }}</span>
- </template>
- </el-menu-item>
- </el-submenu>
- </el-menu>
- </el-row>
- </el-col>
- </el-aside>
- </div>
- <el-container>
- <el-header class="header-container">
-
- <el-menu :default-active="activePath1" class="el-menu-demo" mode="horizontal"
- background-color="#576574" text-color="#fff" active-text-color="#ffd04b">
- <div class="header-left">
- <el-button :icon="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'" @click="toggleCollapse" style="height:30px;"></el-button>
- </div>
- <div class="tagContainer" style="display: flex;">
- <tag v-for="(tag, index) in tags" :key="index" :tag="tag" @removeTag="removeTag(index)" @switchTag="switchTag(index)"></tag>
-</div>
- <template>
- <el-submenu index="1" class="custom-submenu" >
- <template slot="title">
- <el-avatar src="../assets/emi.png" style="width:20px;height:20px;margin-top:30px;background-color: white;"></el-avatar>
- </template>
- <el-menu-item index="1-1" @click="logout">{{ $t('exit') }}</el-menu-item>
- <el-menu-item index="1-2" @click="showChangePasswordDialog">{{ $t('changePassword') }}</el-menu-item>
- </el-submenu>
- </template>
- <template>
- <el-dialog title="淇敼瀵嗙爜" :visible.sync="dialogVisible" width="30%">
- <el-form ref="form" :model="formData" label-width="100px">
- <el-form-item label="鏃у瘑鐮�">
- <el-input v-model="formData.oldPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="鏂板瘑鐮�">
- <el-input v-model="formData.newPassword" type="password" show-password></el-input>
- </el-form-item>
- <el-form-item label="纭鏂板瘑鐮�">
- <el-input v-model="formData.confirmPassword" type="password" show-password></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">鍙栨秷</el-button>
- <el-button type="primary" @click="savePassword">淇濆瓨</el-button>
- </div>
- </el-dialog>
- </template>
- </el-menu>
- </el-header>
- <el-main>
- <keep-alive>
- <router-view/>
- </keep-alive>
- </el-main>
- </el-container>
- </el-container>
-</template>
-
-<script>
-import { selectList } from '../api/menuList'
-import { changePassword } from '../api/user'
-import { removeToken } from "../utils/auth";
-import LanguageMixin from '../lang/LanguageMixin'
-import { mapState, mapMutations } from 'vuex';
-import Tag from '../layout/tag.vue';
-import store from '../store';
-
-export default {
- name: "Layout",
- store,
- mixins: [LanguageMixin],
- data() {
- return {
- activeTag: '', // 褰撳墠婵�娲荤殑鏍囩
- dialogVisible: false,
- formData: {
- oldPassword: '',
- newPassword: '',
- confirmPassword: ''
- },
- menuList: [],
- isCollapse: false,
- activePath: '',
- activePath1: '',
- menuListForm: {
- pageSize: 1,
- pageNum: -1
- }
- }
- },
- components: {
- Tag
- },
- created() {
- selectList(this.menuListForm).then(res => {
- this.menuList = res.data
-
- const language = this.$i18n.locale;
- if (language === 'en-US') {
- this.replaceChineseWithEnglish(this.menuList);
- }
- // 璁板綍涓婁竴娆℃縺娲荤殑鑿滃崟
- this.activePath = window.sessionStorage.getItem('activePath')
- });
- },
- computed: {
- ...mapState('tags', ['tags'])
- },
- methods: {
-
- logout: function () {
- removeToken()
- this.$router.push('/login')
- },
- goToHome() {
- this.$router.push('/home');
- },
- ...mapMutations('tags', ['addTag', 'removeTag', 'switchTag']),
- addTag(router) {
- let submenuItem;
- const menuItem = this.menuList.find(item => item.menuLists.some(menu => menu.router === router));
- if (menuItem) {
- submenuItem = menuItem.menuLists.find(menu => menu.router === router);
- }
- if (submenuItem) {
- const tag = submenuItem.router;
- this.$store.commit('tags/addTag', tag);
- }
-},
-
-
- removeTag(index) {
- this.$store.commit('tags/removeTag', index); // 浠� Vuex Store 涓Щ闄ゆ爣绛�
- },
- showChangePasswordDialog() {
- this.dialogVisible = true;
- },
- savePassword() {
- const { oldPassword, newPassword, confirmPassword } = this.formData;
-
- if (newPassword !== confirmPassword) {
- this.$message.error('鏂板瘑鐮佷笌纭瀵嗙爜涓嶄竴鑷�');
- return;
- }
- changePassword({oldPassword, newPassword}).then(res => {
- console.log(res.data);
- this.$message.success('瀵嗙爜淇敼鎴愬姛');
- removeToken()
- this.$router.push('/login')
- }).catch(() => {
-
- });
-
- this.dialogVisible = false;
- },
- toggleCollapse: function () {
- this.isCollapse = !this.isCollapse;
- },
- replaceChineseWithEnglish(menuData) {
- // 瀹氫箟涓嫳鏂囧鐓у叧绯诲璞�
- const translation = {
- '鐢ㄦ埛绠$悊': 'UserManagement',
- '鐢ㄦ埛鍒楄〃': 'UserList',
- '璁惧绠$悊': 'DeviceManagement',
- '鎶ヨ淇℃伅': 'AlarmInformation',
- '鍙傛暟涓嬪彂': 'ParameterSetting',
- '寮�鍏虫帶鍒�': 'SwitchControl',
- 'I/O鐘舵��': 'I/O Status',
- '鏉冮檺绠$悊': 'PermissionManagement',
- '鏉冮檺鍒楄〃': 'PermissionList',
- '瑙掕壊绠$悊': 'RoleManagement',
- '瑙掕壊鍒楄〃': 'RoleList',
- '鐢垫皵绠$悊': 'Electrical management'
- // 鏍规嵁瀹為檯闇�姹傜户缁坊鍔犲鐓у叧绯�
- };
-
- menuData.forEach(menu => {
- menu.name = translation[menu.name] || menu.name;
- menu.menuLists && menu.menuLists.forEach(subMenu => {
- subMenu.name = translation[subMenu.name] || subMenu.name;
- });
- });
- }
- },
- watch: {
- '$route'(to) {
- // 鍒囨崲璺敱鏃舵洿鏂版縺娲荤殑鏍囩
- const tag = this.menuList.some(item => item.menuLists.some(menu => '/' + menu.router === to.path));
- if (tag) {
- this.activeTag = tag;
- }
- }
- }
-}
-</script>
-
-<style scoped lang="less">
-
-.el-menu--horizontal > .el-submenu .el-submenu__title {
- height: 45px !important;
-}
-.custom-submenu {
-
-
- height: 90px !important;
-}
-
-
-.header-container {
-
- height: 30px !important; /* 璁剧疆杈冨皬鐨勯珮搴� */
-}
-
-
-
-.header-left {
- margin-right: auto;
-width:30px;
-
-}
-.el-aside {
- height: 100vh;
- background-color: #222f3e;
- line-height: 200px;
-}
-
-.el-menu-vertical-demo:not(.el-menu--collapse) {
- width: 200px;
- min-height: 400px;
-}
-
-.el-menu-demo {
- display: flex;
- width: 100%;
- height: 100%;
- justify-content: flex-end;
- align-items: center;
-
-}
-
-.el-menu-vertical-demo {
- border: 0;
-}
-
-.logo {
- background-color: #222f3e;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 60px;
-
- .sys-name {
- font-size: 20px;
- color: #ffffff;
- margin-left: 10px;
- }
-}
-
-.el-header {
-
- background-color: #576574;
-}
-</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/layout/tag.vue b/CanadaMes-ui/src/layout/tag.vue
deleted file mode 100644
index 01a1b7d..0000000
--- a/CanadaMes-ui/src/layout/tag.vue
+++ /dev/null
@@ -1,70 +0,0 @@
-<template>
- <keep-alive>
- <div
- class="tag"
- :class="{ active: isActive }"
- @click="switchTag(tag)">
- <span>{{ tag }}</span>
- <i class="el-icon-close" @click.stop="removeTag(tag)"></i>
- </div>
- </keep-alive>
-</template>
-
-<script>
-export default {
- props: {
- tag: {
- type: String,
- required: true
- },
- activeTag: {
- type: String,
- required: true
- }
- },
- computed: {
- isActive() {
- return this.tag === this.activeTag;
- },
- tagData() {
- return this.$store.getters.getTagData(this.tag);
- }
- },
- methods: {
- removeTag(tag) {
- this.$emit('removeTag', tag);
- },
- switchTag(tag) {
- this.$emit('switchTag', tag);
- this.$router.push('/' + tag); // 鍒囨崲鍒版寚瀹氳矾鐢�
-}
-
- }
-}
-</script>
-
-<style scoped>
-.tag {
- display: inline-block;
- margin-right: 10px;
- padding: 4px 10px;
- border-radius: 4px;
- background-color: #f0f0f0;
- cursor: pointer;
-}
-
-.tag.active {
- background-color: #409eff;
- color: #fff;
-}
-
-.tag span {
- margin-right: 5px;
-}
-
-.tag i {
- margin-left: 5px;
- font-size: 12px;
- cursor: pointer;
-}
-</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter.vue b/CanadaMes-ui/src/views/Electrical/Parameter.vue
deleted file mode 100644
index ed3cb31..0000000
--- a/CanadaMes-ui/src/views/Electrical/Parameter.vue
+++ /dev/null
@@ -1,159 +0,0 @@
-<template>
- <div class="app">
- <!--闈㈠寘灞戝鑸尯鍩�-->
- <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
- <router-link to="/home" tag="el-button" type="text">{{ $t('langHome') }}</router-link>
- <el-button type="text">{{ $t('Distribute') }}</el-button>
- <router-link to="/Electrical/Parameter" tag="el-button" type="text">Parameter</router-link>
- <router-link to="/Electrical/Action" tag="el-button" type="text">Action</router-link>
- <router-link to="/Electrical/Sign" tag="el-button" type="text">Sign</router-link>
- <router-link to="/Electrical/State" tag="el-button" type="text">State</router-link>
- <router-link to="/Electrical/alarm" tag="el-button" type="text">Alarm</router-link>
- </el-breadcrumb>
- <div>Parameter</div>
-
- <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="messagepack.data">
- <div id="btn_div">
- <el-button type="primary" @click="send()">{{ $t('Distribute') }}</el-button>
- </div>
- <div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
- <el-input style="width: 280px;" class="in_mc" v-model="item.name" readonly></el-input>
- <el-input v-model.number="item.value" style="width: 80px;"
- @input="handleChange(index, $event.target.value)"></el-input>
- </div>
- </el-form>
- </div>
-</template>
-
-<script>
-
-import LanguageMixin from '../../lang/LanguageMixin'
-let socket;
-
-export default {
- name: "Parameter",
- mixins: [LanguageMixin],
- data () {
- return {
- record: {
- params: [100, 200, 10, 10, 10, 10],
- xyData: [
- { name: "conveyor Velocity(Auto FAST)", value: 0 },
- { name: "conveyor Velocity(Auto SLOW)", value: 0 },
- { name: "conveyor Velocity(Manual)", value: 0 },
- { name: "A01 A02 TURN JOG Velocity", value: 0 },
- { name: "A01 A02 TRAVEL JOG Velocity", value: 0 },
- { name: "B01 B02 TRAVEL JOG Velocity", value: 0 },
- { name: "A01 A02 TURN POS Velocity AUTO", value: 0 },
- { name: "A01 A02 TURN POS Velocity manual", value: 0 },
- { name: "A01 A02 TRAVEL POS Velocity AUTO", value: 0 },
- { name: "A01 A02 TRAVEL POS Velocity manual", value: 0 },
- { name: "B01 B02 TRAVEL POS Velocity AUTO", value: 0 },
- { name: "B01 B02 TRAVEL POS Velocity manual", value: 0 }
- ],
- canshu: []
- },
- messagepack: {
- data: { taskname: "" }
- },
- queryInfo: {
- data: "1",
- pageSize: 10
- }
- };
- },
- created () {
- this.initWebSocket();
- },
- methods: {
- initWebSocket () {
- let viewname = "Parameter";
-
- if (typeof WebSocket === "undefined") {
- console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
- } else {
- let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
-
- if (socket != null) {
- socket.close();
- socket = null;
- }
-
- // 寮�鍚竴涓獁ebsocket鏈嶅姟
- socket = new WebSocket(socketUrl);
-
- // 鎵撳紑浜嬩欢
- socket.onopen = function () {
- console.log("websocket宸叉墦寮�");
- };
-
- // 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
-
- let obj = JSON.parse(msg.data);
- this.record.params[0] = obj.params[0];
-
- for (let a = 0; a <= this.record.params[0].length - 1; a++) {
- if (!this.record.xyData[a]) {
- this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
- } else {
- this.record.xyData[a].value = this.record.params[0][a];
- }
- }
-
- console.log(this.record.xyData);
- this.$forceUpdate();
- };
-
- // 鍏抽棴浜嬩欢
- socket.onclose = function () {
- console.log("websocket宸插叧闂�");
- };
-
- // 鍙戠敓閿欒浜嬩欢
- socket.onerror = function () {
- console.log("websocket鍙戠敓浜嗛敊璇�");
- };
- }
- },
- send () {
- this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
- console.log(this.messagepack);
- socket?.send(JSON.stringify(this.messagepack));
- },
- handleChange (index, value) {
- this.record.xyData[index].value = value;
- }
- }
-};
-</script>
-
-<style>
-.kuai_div {
- width: 30%;
- margin-bottom: 15px;
-}
-
-.el-input {
- border: none;
-}
-
-.el-input__inner {
- border: 1px solid black;
-}
-
-.in_mc .el-input__inner {
- border: none;
-}
-
-#btn_div {
- width: 100%;
-}
-
-#btn_div .el-button {
- float: right;
-}
-</style>
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
deleted file mode 100644
index 601fd7e..0000000
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.example.springboot.component;
-
-import cn.hutool.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PlcParameter extends Thread {
- private static final int SEND_INTERVAL = 10000;
- private static final int WRITE_INTERVAL = 100;
-
- @Override
-
- public void run() {
- try {
- // 鍙戦�佷竴娆℃秷鎭�
- sendMessages();
-
- // 寤惰繜涓�娈垫椂闂�
- Thread.sleep(SEND_INTERVAL);
-
- while (true) {
- // 鍐欏叆PLC
- writeToPlc();
- Thread.sleep(WRITE_INTERVAL);
-
- // 鍙戦�佹秷鎭�
- sendMessages();
- Thread.sleep(SEND_INTERVAL);
- }
-
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- private void sendMessages() {
- WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
- if (sendwServer != null) {
- List<Short> paramlist = S7control.getinstance().ReadWord("DB100.DBW", 12);
- JSONObject jsonObject = new JSONObject();
-// new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}
- jsonObject.append("params", new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0});
- sendwServer.sendMessage(jsonObject.toString());
- }
- }
-
- private void writeToPlc() {
- WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter");
- if (webSocketServer != null) {
- List<String> messages = webSocketServer.getMessages();
-
- String addressList = "DB100.DBW0";
-
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
- String lastMessage = messages.get(messages.size() - 1);
- System.out.println("messages锛�" + messages);
- String[] parts = lastMessage.split(",");
- List<Short> messageValues = new ArrayList<>();
- for (String part : parts) {
- try {
- // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
- String cleanedPart = part.replaceAll("[^0-9-]", "");
- short value = Short.parseShort(cleanedPart.trim());
- messageValues.add(value);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
- e.printStackTrace();
- }
- }
-
- // 灏嗘秷鎭�煎啓鍏� PLC
- S7control.getinstance().WriteWord(addressList, messageValues);
- System.out.println("messageValues锛�" + messageValues);
- System.out.println("addressList锛�" + addressList);
- // 娓呯┖娑堟伅鍒楄〃
- webSocketServer.clearMessages();
- }
- }
- }
-}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
deleted file mode 100644
index bcd2cf9..0000000
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.example.springboot.component;
-
-import cn.hutool.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-
-public class Plcaction extends Thread {
- private static final long SEND_INTERVAL = 2000; // 鍙戦�佹秷鎭殑鏃堕棿闂撮殧
- private static final long WRITE_INTERVAL = 100; // 鍐欏叆PLC鐨勬椂闂撮棿闅�
-
- @Override
- public void run() {
- try {
- // 鍙戦�佷竴娆℃秷鎭�
- sendMessages();
-
- // 寤惰繜涓�娈垫椂闂�
- Thread.sleep(SEND_INTERVAL);
-
- while (true) {
- // 鍐欏叆PLC
- writeToPlc();
- Thread.sleep(WRITE_INTERVAL);
-
- // 鍙戦�佹秷鎭�
- sendMessages();
- Thread.sleep(SEND_INTERVAL);
- }
-
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- private void sendMessages() {
- WebSocketServer sendwServer = WebSocketServer.sessionMap.get("action");
- if (sendwServer != null) {
-
- List<Boolean> paramlist = S7control.getinstance().ReadBits("DB100.DBW", 12);
- // new short[]{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
- // 1, 0}
- JSONObject jsonObject = new JSONObject();
- jsonObject.append("params",
- new short[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 });
-
- sendwServer.sendMessage(jsonObject.toString());
- }
-
- }
-
- private void writeToPlc() {
- WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("action");
- if (webSocketServer != null) {
- List<String> messages = webSocketServer.getMessages();
-
- String addressList = "DB100.DBW0";
-
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
- String lastMessage = messages.get(messages.size() - 1);
- System.out.println("messages锛�" + messages);
- String[] parts = lastMessage.split(",");
- List<Integer> messageValues = new ArrayList<>();
- for (String part : parts) {
- try {
- // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
- String cleanedPart = part.replaceAll("[^0-9-]", "");
- Integer value = Integer.parseInt(cleanedPart.trim());
- messageValues.add(value);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓烘暣鏁扮被鍨嬶紝鍒欏拷鐣ヨ閮ㄥ垎
- e.printStackTrace();
- }
- }
-
-
- // 灏嗘秷鎭�艰浆鎹负甯冨皵鍒楄〃
- List<Boolean> messageBooleans = new ArrayList<>();
- for (Integer value : messageValues) {
- messageBooleans.add(value == 0 ? true : false);
- }
-
- // 灏嗗竷灏斿垪琛ㄥ啓鍏� PLC
- S7control.getinstance().WriteBit(addressList, messageBooleans);
- System.out.println("messageValues锛�" + messageBooleans);
- System.out.println("addressList锛�" + addressList);
-
- // 娓呯┖娑堟伅鍒楄〃
- webSocketServer.clearMessages();
- }
- }
- }
-
- private List<Boolean> paramList() {
- // 鑾峰彇鍙傛暟鍒楄〃鐨勯�昏緫
-
- return new ArrayList<>(); // 鍋囪杩斿洖绌哄垪琛�
- }
-}
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
deleted file mode 100644
index 469665f..0000000
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.example.springboot.component;
-
-import cn.hutool.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.example.springboot.mapper.AlarmMapper;
-
-public class Plcalarm extends Thread {
- private AlarmMapper alarmMapper;
-
- @Override
- public void run() {
- while (this != null) {
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- List<Short> paramlist = S7control.getinstance().ReadWord("DB100.DBW", 12);
-
- // JSONObject jsonObject = new JSONObject();
- // // jsonObject.append("params", paramlist);
- // jsonObject.append("params", new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- // 11, });
- // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter");
- // if (sendwServer != null) {
- // sendwServer.sendMessage(jsonObject.toString());
- // }
-
- JSONObject jsonObject = new JSONObject();
-
- jsonObject.append("arm",
- new short[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
- 1, 0, 1, 0, 1, 0, 1, 0, 1, });
- WebSocketServer sendwServer = WebSocketServer.sessionMap.get("alarm");
- if (sendwServer != null) {
- sendwServer.sendMessage(jsonObject.toString());
- }
-
- Short[] shuzu1 = {
- 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
- 1, 0, 1, 0, 1, 0, 1, 0, 1,
- };
-
- String[] shuzu = {
- "D01 VFD error",
- "D02 VFD error",
- "D03 VFD error",
- "D04 VFD error",
- "D05 VFD error",
- "D06 VFD error",
- "B01 VFD error",
- "B02 VFD error",
- "A01 VFD error",
- "A02 VFD error",
- "A01 servo turn error",
- "A02 servo turn error",
- "A01 servo travel error",
- "A02 servo travel error",
- "B01 servo travel error",
- "B02 servo travel error",
- "D01 DEC error",
- "D01 pos error",
- "D02 DEC error",
- "D02 pos error",
- "D03 DEC error",
- "D03 pos error",
- "D04 DEC error",
- "D04 pos error",
- "D05 DEC error",
- "D05 pos error",
- "D06 DEC error",
- "D06 pos error",
- "A01 DEC error",
- "A01 pos error",
- "A02 DEC error",
- "A02 pos error",
- "B01 IN DEC error",
- "B01 IN pos error",
- "B01 OUT DEC error",
- "B01 OUT pos error",
- "B02 IN DEC error",
- "B02 IN pos error",
- "B02 OUT DEC error",
- "B02 OUT pos error",
- };
- alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class);
- for (short i = 0; i < shuzu1.length; i++) {
- short result = alarmMapper.selectnullti(shuzu[i]);
- if (shuzu1[i] == 1 && result == 0) {
- // alarmMapper.Insertalarm(shuzu[i]);
- } else if (shuzu1[i] == 0 && result > 0) {
- alarmMapper.updatealarm(shuzu[i]);
- }
- }
-
- // 鍐�
- WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter");
- if (webSocketServer != null) {
- List<String> messages = webSocketServer.getMessages();
-
- String addressList = "DB100.DBW0";
- // addressList.add("DB100.DBW0");
- // addressList.add("DB100.DBW2");
- // addressList.add("DB100.DBW4");
- // addressList.add("DB100.DBW6");
- // addressList.add("DB100.DBW8");
- // addressList.add("DB100.DBW10");
- // addressList.add("DB100.DBW12");
- // addressList.add("DB100.DBW14");
- // addressList.add("DB100.DBW16");
- // addressList.add("DB100.DBW18");
- // addressList.add("DB100.DBW20");
- // addressList.add("DB100.DBW22");
-
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
- String lastMessage = messages.get(messages.size() - 1);
- System.out.println("messages锛�" + messages);
- String[] parts = lastMessage.split(",");
- List<Short> messageValues = new ArrayList<>();
- for (String part : parts) {
- try {
- // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
- String cleanedPart = part.replaceAll("[^0-9-]", "");
- short value = Short.parseShort(cleanedPart.trim());
- messageValues.add(value);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
-
- e.printStackTrace();
- }
- }
-
- // 灏嗘秷鎭�煎啓鍏� PLC
- // S7control.getinstance().WriteWord(addressList, messageValues);
- System.out.println("messageValues锛�" + messageValues);
- System.out.println("addressList锛�" + addressList);
- // 娓呯┖娑堟伅鍒楄〃
- webSocketServer.clearMessages();
- }
- }
- }
- }
-}
--
Gitblit v1.8.0