Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
# Conflicts:
# springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
199个文件已修改
2个文件已添加
1个文件已删除
| | |
| | | [ |
| | | { |
| | | "name": "A01手动格子", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "A01定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | }, |
| | | { |
| | | "name": "A01当前格子", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | [ |
| | | { |
| | | "name": "A02手动格子", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "A02定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | }, |
| | | { |
| | | "name": "A02当前格子", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | [ |
| | | { |
| | | "name": "B01手动格子", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "B01定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | }, |
| | | { |
| | | "name": "B01当前格子", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | [ |
| | | { |
| | | "name": "B02手动格子", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "B02定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | }, |
| | | { |
| | | "name": "B02当前格子", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | |
| | | [ |
| | | { |
| | | "name": "A01实时位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 4, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | [ |
| | | { |
| | | "name": "A02实时位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 5, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | [ |
| | | { |
| | | "name": "B01实时位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 6, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | [ |
| | | { |
| | | "name": "B02实时位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 7, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | [ |
| | | { |
| | | "name": "手动位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | }, |
| | | { |
| | | "name": "A01翻转实时位置", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | |
| | | [ |
| | | { |
| | | "name": "手动位置", |
| | | "value": 33, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | |
| | | }, |
| | | { |
| | | "name": "定位速度", |
| | | "value": 11, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | }, |
| | | { |
| | | "name": "A02翻转实时位置", |
| | | "value": 22, |
| | | "value": 0, |
| | | "sending": 0, |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | |
| | | { |
| | | "para": [ |
| | | [ |
| | | { |
| | | "name": "D01-D06 conveyor Velocity(Auto FAST)", |
| | | "value": 123, |
| | |
| | | "type": "1", |
| | | "page": "1" |
| | | } |
| | | ], |
| | | "address": [ |
| | | { |
| | | "name": "DB100.0", |
| | | "count": 72 |
| | | }, |
| | | { |
| | | "name": "DB101.0", |
| | | "count": 22 |
| | | }, |
| | | { |
| | | "name": "DB102.0", |
| | | "count": 33 |
| | | } |
| | | ] |
| | | } |
| | |
| | | [ |
| | | |
| | | [ |
| | | { |
| | | "name": "A01 所在格子", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "value": 1 |
| | | "value":0 |
| | | |
| | | }, |
| | | { |
| | | "name": "数量", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "进片ID", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "长度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "高度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "取片格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "存片格子", |
| | | "read": 22, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | "value":0 |
| | | }, |
| | | { |
| | | "button": { |
| | |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "半自动启动", |
| | | "name": "A01半自动启动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "取片ID", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "button": { |
| | |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "半自动启动", |
| | | "name": "A02半自动启动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | |
| | | [ |
| | | { |
| | | "name": "A01翻转实时位置", |
| | |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | ],[ |
| | | { |
| | | "name": "A02翻转实时位置", |
| | | "read": 33, |
| | |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | ], [ |
| | | { |
| | | "name": "B01 所在格子", |
| | | "read": 33, |
| | |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | } ,{ |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | |
| | | } |
| | | } |
| | | ], |
| | | |
| | | [ |
| | | { |
| | | "name": "B02 所在格子", |
| | |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | |
| | | } |
| | | }, |
| | | { |
| | | } ,{ |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | |
| | | ] |
| | | |
| | | |
| | | ] |
| | | |
| | |
| | | "address": [ |
| | | { |
| | | "name": "DB102.0.0", |
| | | "count": 58 |
| | | "count": 64 |
| | | } |
| | | ] |
| | | } |
| | |
| | | path: '/Electrical/Positioning2', |
| | | component: () => import('../views/Electrical/Positioning2') |
| | | }, |
| | | { |
| | | path: '/Electrical/ManualonePosition', |
| | | component: () => import('../views/Electrical/ManualonePosition') |
| | | }, |
| | | { |
| | | path: '/Electrical/ManualonePosition2', |
| | | component: () => import('../views/Electrical/ManualonePosition2') |
| | | }, |
| | | { |
| | | path: '/Electrical/AutomaticParameterSetting', |
| | | component: () => import('../views/Electrical/AutomaticParameterSetting') |
| | | }, |
| | | { |
| | | path: '/Electrical/ManualJog', |
| | | component: () => import('../views/Electrical/ManualJog') |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | }); |
| | | |
| | | // 路由控制守卫,解决需要登录才可以访问的页面 |
| | | |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | // 如果访问的是登录或注册页面直接放行 |
| | | if (to.path === '/login' || to.path === '/register') return next(); |
| | |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | console.log(obj); |
| | | const handleMouseMove = throttle(function (event) { |
| | | |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | |
| | | jsonData2[2][0]['value'] = dache[0][0]; |
| | | } |
| | | } |
| | | }, 50); |
| | | }, 200); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '回零') {
|
| | |
|
| | | const data2 = [];
|
| | | const resetButtonValues = this.jsonData.map(item => {
|
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '回零');
|
| | | return buttonItem ? buttonItem.button.value : null;
|
| | | }).filter(value => value !== null);
|
| | |
|
| | | // 将得到的值添加到 data 数组中
|
| | | data2.push(...resetButtonValues);
|
| | | data2.unshift([], [], [], []);
|
| | | const jsonObject2 = { data2 };
|
| | |
|
| | | // 提交数据到后端
|
| | | const jsonString2 = JSON.stringify(jsonObject2);
|
| | | console.log('所有Type为0的value:', jsonString2);
|
| | | socket?.send(jsonString2);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | }, |
| | | |
| | |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | console.log(obj) |
| | | // console.log(obj)
|
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | |
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('ServoManual')
|
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Servo Manual')
|
| | | }}</router-link>
|
| | | </el-breadcrumb>
|
| | |
|
| | |
| | |
|
| | | <el-form label-width="100px" style="display: flex; flex-wrap: wrap;" :model="messagepack.data">
|
| | | <div id="btn_div">
|
| | | <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">{{ $t('Distribute parameters')
|
| | | }}</el-button>
|
| | | <!-- <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">{{ $t('Distribute parameters')
|
| | | }}</el-button> -->
|
| | |
|
| | | </div>
|
| | | <div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
|
| | | <div class="kuai_div" v-for="(item, index) in jsonData" :key="index">
|
| | | <el-input style="width: 280px; border:none;" class="in_mc" v-model="item.name" readonly></el-input>
|
| | |
|
| | | <span style="margin-right: 5px; width: 50px;">{{ item.value }}</span>
|
| | | <span style="margin-right: 5px; font-size: 14px;color: red;">|</span>
|
| | | <input type="number" style="width: 43px; margin-right: 5px; margin-top: 5px; font-size: 16px;">
|
| | | <!-- <span style="margin-right: 5px; width: 50px;">{{ item.value }}</span> -->
|
| | | <!-- <span style="margin-right: 5px; font-size: 14px;color: red;">|</span> -->
|
| | | <el-input v-model="item.value" type="number"
|
| | | style="width: 143px; margin-right: 5px; margin-top: 5px; font-size: 16px;border:none" class="input-box"
|
| | | @keyup.enter.native="send"></el-input>
|
| | | <span style="margin-right: 5px; width: 50px;">{{ item.unit }}</span>
|
| | |
|
| | | </div>
|
| | |
| | | let socket;
|
| | | import LanguageMixin from '../../lang/LanguageMixin'
|
| | | import data from '../../configuration/Parameter'
|
| | | import { throttle } from 'lodash';
|
| | | export default {
|
| | | name: "Parameter",
|
| | | mixins: [LanguageMixin],
|
| | | data () {
|
| | | return {
|
| | | jsonData: data,
|
| | | |
| | | dialogVisible: true,
|
| | | password: '',
|
| | | activeButton: '',
|
| | | record: {
|
| | | params: [100, 200, 10, 10, 10, 10],
|
| | | xyData: [
|
| | |
|
| | | ],
|
| | | canshu: []
|
| | | },
|
| | | messagepack: {
|
| | | data: { taskname: "" }
|
| | | },
|
| | |
| | | this.initWebSocket();
|
| | | this.isButtonDisabled = true;
|
| | |
|
| | |
|
| | | },
|
| | | methods: {
|
| | | showdata () {
|
| | | |
| | |
|
| | | },
|
| | |
|
| | |
|
| | | setActiveButton (buttonName) {
|
| | |
| | | }
|
| | |
|
| | | let obj = JSON.parse(msg.data);
|
| | |
|
| | |
|
| | | // console.log(obj);
|
| | | const jsonData2=this.jsonData;
|
| | | // console.log(jsonData2);
|
| | | const handleMouseMove = throttle(function (event) {
|
| | | const inputBox = document.querySelectorAll('.input-box');
|
| | | const target = event.target;
|
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
|
| | | if (obj.params && obj.state) {
|
| | |
|
| | |
|
| | | this.record.params[0] = obj.params[0];
|
| | | this.record.state = obj.state[0];
|
| | | if (obj.state && obj.state.length > 0) {
|
| | | let isButtonDisabled = this.record.state.includes(1);
|
| | | this.isButtonDisabled = isButtonDisabled;
|
| | |
|
| | | // console.log( Array.isArray(jsonData2));
|
| | |
|
| | |
|
| | | this.record.xyData = this.jsonData.para;
|
| | |
|
| | | for (let a = 0; a < this.record.xyData.length; a++) {
|
| | | this.record.xyData[a].value = this.record.params[0][a];
|
| | |
|
| | | // 将 obj 中的 params 值更新到 jsonData 中的 value 中
|
| | | for (let i = 0; i < obj.params[0].length; i++) {
|
| | | jsonData2[i].value = obj.params[0][i];
|
| | | }
|
| | |
|
| | | this.record.xyData = this.jsonData.para.filter(item => {
|
| | | return item.state != 0;
|
| | | }
|
| | |
|
| | | );
|
| | | const language = this.$i18n.locale;
|
| | | if (language === 'en-US') {
|
| | | this.replaceChineseWithEnglish();
|
| | | } else {
|
| | | this.localizedRoles = [...this.record.xyData];
|
| | | |
| | | |
| | | }
|
| | | }
|
| | | // this.$forceUpdate();
|
| | | // this.replaceChineseWithEnglish();
|
| | | }
|
| | | this.$forceUpdate();
|
| | | this.replaceChineseWithEnglish();
|
| | | }, 200);
|
| | |
|
| | | document.addEventListener('mouseover', handleMouseMove);
|
| | | |
| | | };
|
| | |
|
| | | // 关闭事件
|
| | |
| | | }
|
| | | },
|
| | | send () {
|
| | | this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value2)); // 转换为整数数组
|
| | | //console.log(this.messagepack);
|
| | | this.messagepack.data = this.jsonData.map((item) => parseInt(item.value)); // 转换为整数数组
|
| | | console.log(this.messagepack);
|
| | | socket?.send(JSON.stringify(this.messagepack));
|
| | | },
|
| | | handleChange (index, value) {
|
| | |
| | | //语言转换
|
| | | replaceChineseWithEnglish () {
|
| | | const translation = this.$t('langparameter');
|
| | | this.record.xyData = this.record.xyData.map(item => { return { name: translation[item.name] || item.name, value: item.value, unit: item.unit }; });
|
| | | this.jsonData.para = this.jsonData.para.map(item => { return { name: translation[item.name] || item.name, value: item.value, unit: item.unit }; });
|
| | | //console.log(translation);
|
| | | },
|
| | | }
|
| | |
| | | border: 1px solid black;
|
| | | border: none;
|
| | | }
|
| | | .special-class{
|
| | |
|
| | | .special-class {}
|
| | |
|
| | | }
|
| | |
|
| | | .in_mc {
|
| | |
|
| | |
| | | const parms = obj.params; |
| | | const fanzhuan = obj.fanzhuan; |
| | | const xiaoche = obj.xiaoche; |
| | | |
| | | console.log('parms:', parms); |
| | | console.log('fanzhuan:', fanzhuan); |
| | | console.log('xiaoche:', xiaoche); |
| | | console.log(obj); |
| | | // console.log('parms:', parms); |
| | | // console.log('fanzhuan:', fanzhuan); |
| | | // console.log('xiaoche:', xiaoche); |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ServoManual') }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="40"> |
| | | <el-col :span="6" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:260px;"> |
| | | <el-col :span="6" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" style="margin-bottom: -20px;"> |
| | | <el-card class="json-block" style="width:260px;margin-bottom: 2px;"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button">{{ item.title.name }}</span> |
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <el-button v-if="item.button" :name="item.button.name" v-model="item.button.value" class="action-button" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name)" |
| | | :class="{ 'green-button': item.button.value === 0 && item.button.name !== '清除ID', 'red-button': item.button.value === 1 && item.button.name !== '清除ID' }">{{ |
| | | item.button.name }}</el-button> |
| | | :class="{ 'green-button': item.button.value === 0 && item.button.name !== '清除ID','red-button': item.button.value === 2 && item.button.name !== '清除ID' ,'yellow-button': item.button.value === 1 && item.button.name !== '清除ID' }">{{ item.button.name }}</el-button> |
| | | </div> |
| | | </div> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | |
| | | <span class="name" style="width:150px;">{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" readonly="readonly" style="width:150px;" |
| | | class="input-box"></el-input> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" readonly="readonly" style="width:400px;" class="input-box"></el-input> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | import data from '../../configuration/parameter2' |
| | | let socket; |
| | | export default { |
| | | destroyed() { |
| | | socket.close(); |
| | | }, |
| | | name: "Parameter2", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | |
| | | }); |
| | | |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | |
| | | const jsonObject = { data: values }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | window.location.reload(); |
| | | } |
| | | }, |
| | | initWebSocket () { |
| | |
| | | const parms = obj.params; |
| | | // const xiaoche = obj.params[3]; |
| | | |
| | | console.log(parms); |
| | | |
| | | // console.log(parms); |
| | | //清除id |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | //ID |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | //手动状态 |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | //扫描枪扫码的ID |
| | | jsonData2.forEach((item) => { |
| | | item.forEach((subItem) => { |
| | | if (subItem.read === 66) { |
| | |
| | | }); |
| | | |
| | | |
| | | |
| | | //A01当前格子 |
| | | let lastParmsArray = parms[parms.length - 1]; |
| | | |
| | | let lastParmsIndex = 0; |
| | |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | |
| | | } |
| | | }, |
| | | send () { |
| | |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | |
| | | .red-button { |
| | | background-color: red; |
| | | } |
| | | .yellow-button{ |
| | | background-color: blue; |
| | | } |
| | | |
| | | </style> |
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style="width:250px;">{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class="input-box"></el-input> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class="input-box" @keyup.enter.native="submitDataToBackend" ></el-input> |
| | | |
| | | |
| | | |
| | | <el-button |
| | | <!-- <el-button |
| | | v-if="item.type === '0' && item.name !== '格子间距' && item.name !== '出片接片地址' && item.name !== '存片接片地址'" |
| | | class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | class="input-box" @click="submitDataToBackend();">取地址</el-button> --> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style="width:250px;">{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class="input-box"></el-input> |
| | | <el-button v-if="item.type === '0'" class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class="input-box" @keyup.enter.native="submitDataToBackend"></el-input> |
| | | <!-- <el-button v-if="item.type === '0'" class="input-box" @click="submitDataToBackend();">取地址</el-button> --> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ServoManual') |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Servo Manual') |
| | | }}</router-link> |
| | | |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="26"> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:auto;"> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" style="margin-bottom: -20px;"> |
| | | <el-card class="json-block" style="width:auto;margin-bottom: 10px;"> |
| | | <el-row> |
| | | <el-col v-for="(item, itemIndex) in dataGroup" :key="itemIndex" :span="12"> |
| | | <div class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style='width:230px;'>{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class='input-box' |
| | | :class="{ 'special-class': groupIndex === 0, 'special-class2': groupIndex === 1 }" |
| | | v-show="groupIndex !== 0 && groupIndex !== 1"></el-input> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input> |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <el-button v-if="item.button" :name="item.button.name" v-model="item.button.value" |
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1 }" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ |
| | | item.button.name }}</el-button> |
| | | <el-button v-if="item.button" :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | |
| | | </div> |
| | | </div> |
| | |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/ServoManualone' |
| | | import { throttle } from 'lodash'; |
| | | |
| | | let socket; |
| | | export default { |
| | | name: "ServoManualone", |
| | | mixins: [LanguageMixin], |
| | | |
| | | data () { |
| | | return { |
| | | jsonData: data, |
| | |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | |
| | | methods: { |
| | | |
| | | |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | |
| | | |
| | | // 将其他按钮的值设为0 |
| | | // dataGroup.forEach((item, index) => { |
| | | // if (index !== itemIndex && item.button) { |
| | | // this.$set(item.button, 'value', 0); |
| | | // } |
| | | // }); |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === '半自动启动') { |
| | | if (currentButtonName === 'A01半自动启动') { |
| | | const data = []; |
| | | |
| | | for (let i = 0; i < 2; i++) { |
| | | for (let i = 0; i < 1; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | |
| | | |
| | | data.push(values); |
| | | } |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '复位') { |
| | | if (currentButtonName === 'A02半自动启动') { |
| | | const data2 = []; |
| | | |
| | | for (let i = 1; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | const values2 = inputData.map(item => item.value); |
| | | |
| | | data2.push(values2); |
| | | |
| | | } |
| | | data2.unshift([]); |
| | | const jsonObject = { data:data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '复位') { |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '复位'); |
| | |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | const jsonObject2 = { data2 }; |
| | | data2.push(resetButtonValues.flat()); |
| | | |
| | | // 在 data2 数组前面添加两个空数组 |
| | | data2.unshift([], []); |
| | | |
| | | // 创建 jsonObject2 对象,并添加 data2 属性 |
| | | const jsonObject2 = { data: data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有Type为0的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | |
| | | |
| | | window.location.reload(); |
| | | } |
| | | |
| | | if (currentButtonName === '回零') { |
| | | const data3 = []; |
| | | const resetButtonValues3 = this.jsonData.map(item => { |
| | | const buttonItem3 = item.find(subItem => subItem.button && subItem.button.name === '回零'); |
| | | return buttonItem3 ? buttonItem3.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data3.push(resetButtonValues3.flat()); |
| | | |
| | | // 在 data3 数组前面添加两个空数组 |
| | | data3.unshift([], [], []); |
| | | |
| | | // 创建 jsonObject2 对象,并添加 data3 属性 |
| | | const jsonObject3 = { data: data3 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString3 = JSON.stringify(jsonObject3); |
| | | console.log('回零:', jsonString3); |
| | | socket?.send(jsonString3); |
| | | window.location.reload(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | if (currentButtonName === 'A01半自动') { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | |
| | | } |
| | | } |
| | | |
| | | for (let i = 0; i < obj.weihuiling[0].length; i++) { |
| | | const weihuilingValue = obj.weihuiling[0][i]; |
| | | |
| | | // 查找jsonData2中带有"button"的对象,并且name等于"故障" |
| | | for (let j = 0; j < jsonData2.length; j++) { |
| | | const section = jsonData2[j]; |
| | | |
| | | for (let k = 0; k < section.length; k++) { |
| | | const item = section[k]; |
| | | |
| | | if (item.button && item.button.name === "未回零") { |
| | | // 更新value属性 |
| | | item.button.value = weihuilingValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | }, 200); |
| | | }, 500); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 2px; |
| | | /* 调整每个项目之间的间距 */ |
| | | margin-bottom: 2px; /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | |
| | | .error-button { |
| | | background-color: red; |
| | | } |
| | | |
| | | |
| | | </style> |
| | |
| | | this.record.params[0] = obj.sig[0];
|
| | |
|
| | | this.record.xyData = this.jsonData.sign;
|
| | |
|
| | | console.log(this.jsonData.sign)
|
| | | for (let a = 0; a < this.record.xyData.length; a++) {
|
| | | this.record.xyData[a].value = this.record.params[0][a];
|
| | |
|
New file |
| | |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | | import org.apache.commons.io.FileUtils;
|
| | |
|
| | | import java.io.*;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class PLCManualJog extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | |
|
| | | public static String readFileToString(String filePath) throws IOException {
|
| | | File file = new File(filePath);
|
| | | return FileUtils.readFileToString(file, "UTF-8");
|
| | | }
|
| | |
|
| | | public void readValue() {
|
| | | String str = "";
|
| | | BufferedReader bufferedReader = null;
|
| | | FileInputStream fileInputStream;
|
| | | try {
|
| | | // 从文件中读取字节数据存入 fileInputStream
|
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
|
| | | // 读取 fileInputStream 中字节并将其解码为字符
|
| | | 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;
|
| | | }
|
| | |
|
| | | // 将str字符串格式转为json
|
| | | 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) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // System.out.println(stt);
|
| | | List<Boolean> arraylist = S7control.getinstance().ReadBits("DB101.0.0", 16);
|
| | | List<Boolean> arraylist2 = S7control.getinstance().ReadBits("DB101.2.6", 8);
|
| | | List<Boolean> arraylist3 = S7control.getinstance().ReadBits("DB101.5.2", 2);
|
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true, true, true, false, false,
|
| | | // true, false };
|
| | | // List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | | // Boolean[] values2 = { false, true, true, true, false, false, true, false };
|
| | | // List<Boolean> arraylist2 = new ArrayList<>(Arrays.asList(values2));
|
| | | // Boolean[] values3 = { false, false };
|
| | | // List<Boolean> arraylist3 = new ArrayList<>(Arrays.asList(values3));
|
| | |
|
| | | arraylist.addAll(arraylist2);
|
| | | arraylist.addAll(arraylist3);
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | short[] params = new short[arraylist.size()];
|
| | | for (int i = 0; i < arraylist.size(); i++) {
|
| | | boolean value = arraylist.get(i);
|
| | | params[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | jsonObject.append("params", params);
|
| | |
|
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | | if (sendwServer != null) {
|
| | | sendwServer.sendMessage(jsonObject.toString());
|
| | | }
|
| | |
|
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | |
|
| | | if (webSocketServer != null) {
|
| | | String addressList1 = "DB101.0.0";
|
| | | String addressList2 = "DB101.2.6";
|
| | | String addressList3 = "DB101.5.2";
|
| | |
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | | 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 {
|
| | | // 使用正则表达式清除非数字字符
|
| | | String cleanedPart = part.replaceAll("[^0-9-]", "");
|
| | | Integer value = Integer.parseInt(cleanedPart.trim());
|
| | | messageValues.add(value);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为整数类型,则忽略该部分
|
| | | // e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | // 将消息值转换为布尔列表
|
| | | List<Boolean> messageBooleans = new ArrayList<>();
|
| | | for (Integer value : messageValues) {
|
| | | messageBooleans.add(value == 1 ? true : false);
|
| | | }
|
| | | // System.out.println(messageBooleans);
|
| | | List<Boolean> bolList = new ArrayList<>();
|
| | | List<Boolean> bolList2 = new ArrayList<>();
|
| | | List<Boolean> bolList3 = new ArrayList<>();
|
| | |
|
| | | for (int i = 0; i < 16 && i < messageBooleans.size(); i++) {
|
| | | bolList.add(messageBooleans.get(i));
|
| | | }
|
| | |
|
| | | for (int i = 16; i < 24 && i < messageBooleans.size(); i++) {
|
| | | bolList2.add(messageBooleans.get(i));
|
| | | }
|
| | |
|
| | | for (int i = 24; i < 26 && i < messageBooleans.size(); i++) {
|
| | | bolList3.add(messageBooleans.get(i));
|
| | | }
|
| | |
|
| | | // System.out.println(bolList);
|
| | | // System.out.println(bolList2);
|
| | | // System.out.println(bolList3);
|
| | | if (!bolList.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(addressList1, bolList);
|
| | | System.out.println("messageValue:" + bolList + " written to PLC at address " + addressList1);
|
| | | }
|
| | | if (!bolList2.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(addressList2, bolList2);
|
| | | System.out.println("messageValue:" + bolList2 + " written to PLC at address " + addressList2);
|
| | | }
|
| | | if (!bolList3.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(addressList3, bolList3);
|
| | | System.out.println("messageValue:" + bolList3 + " written to PLC at address " + addressList3);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | // 判断进片请求 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 获取prc进片请求数据 |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 获取进片车状态 |
| | | List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.16", 1);// 获取进片车任务是否启动 |
| | | |
| | | |
| | | boolean B01backs =spianService.listbool("DB106.60");// b01汇报 |
| | | boolean B02backs = spianService.listbool("DB106.62");// b02汇报 |
| | | StringBuilder B01glassid=spianService.queGlassid("DB106.DBB26");//BO1的玻璃id |
| | | StringBuilder B02glassid=spianService.queGlassid("DB106.DBB26");//B02的玻璃id |
| | | StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1的玻璃id |
| | | StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02的玻璃id |
| | | //当进片小车完成任务时 |
| | | if(B01backs==true){ |
| | | //当B01小车汇报完成时更改玻璃状态为1 |
| | | spianMapper.UpdateCageOver(B01glassid.toString(),1);//更改笼子表进片状态 |
| | | spianMapper.Updatetask(1,0);//更改进片任务状态为1 |
| | | spianMapper.overqueue(B01glassid.toString(),0);//更改上片任务表的状态为0 |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 1);//应答B01小车收到 |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);//进片任务启动改为0 |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 0);//恢复B01小车应答 |
| | | S7control.getinstance().WriteWord("DB106.60", (short) 0);// 恢复B01小车应答改为0 |
| | | S7control.getinstance().WriteWord("DB105.48", (short) 1);//汇报B01小车收到 |
| | | } |
| | | |
| | | //当出片小车完成任务时 |
| | | if(B02backs==true){ |
| | | //当B02小车汇报完成时更改玻璃状态为0 |
| | | spianMapper.UpdateCageOver(B02glassid.toString(),0);//更改笼子表出片状态 |
| | | spianMapper.UpdatetaskOut(B02glassid.toString()); // 完成上一次出片或者调度任务 |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 1);//应答B02小车收到 |
| | | }else{ |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 0);//恢复B02小车应答 |
| | | S7control.getinstance().WriteWord("DB105.50", (short) 0);// 恢复B02小车应答改为0 |
| | | // S7control.getinstance().WriteWord("DB105.50", (short) 1);//汇报B02小车收到 |
| | | } |
| | | |
| | | |
| | | |
| | | // 获取DO1数据 |
| | | StringBuilder queueid1 = spianService.queGlassid("DB106.DBB26"); |
| | | StringBuilder queueid1 = spianService.queGlassid("DB103.44", 14); |
| | | // 获取DO2数据 |
| | | StringBuilder queueid2 = spianService.queGlassid("DB103.DBB78"); |
| | | System.out.println("D01"+queueid1); |
| | | System.out.println("D02"+queueid2); |
| | | int questate = spianMapper.Selectqueuestate();//判断扫码位是否有玻璃已确认 |
| | | StringBuilder queueid2 = spianService.queGlassid("DB103.58", 14); |
| | | System.out.println("D01|" + queueid1); |
| | | System.out.println("D02|" + queueid2); |
| | | int questate = spianMapper.Selectquecount(queueid1.toString());// 判断扫码位是否有玻璃已确认 |
| | | // queueid1.toString().isEmpty() |
| | | north_glass_buffer1 glass1 = spianMapper.selectGlass(queueid1.toString());//D01的玻璃信息 |
| | | north_glass_buffer1 glass2 = spianMapper.selectGlass(queueid2.toString());//D02玻璃信息 |
| | | double quewitdh=0; |
| | | double quewitdh2=0; |
| | | //当扫码位玻璃id为空时 宽度为0 |
| | | if(glass1==null){ |
| | | quewitdh=0; |
| | | queueid1=new StringBuilder(""); |
| | | }else{ |
| | | quewitdh=glass1.getglasslengthmm(); |
| | | } |
| | | if(glass2==null){ |
| | | quewitdh2=0; |
| | | queueid2=new StringBuilder(""); |
| | | }else{ |
| | | quewitdh2=glass2.getglasslengthmm(); |
| | | } |
| | | |
| | | |
| | | if (queueid1!=null&& questate == 0) { |
| | | // 写入D01的数据到上片队列表 |
| | | spianMapper.insertqueue(queueid1.toString(), 1, quewitdh); |
| | | if (glass1 == null) { //当没有值时传空 |
| | | spianMapper.Updatequeue(null,null,null,null, 0, null, null, null, null, 1); |
| | | } else { |
| | | spianMapper.overqueue2(queueid2.toString(), 0, 1);// 更改扫码位任务表的状态为0 |
| | | spianMapper.Updatequeue(queueid1.toString(),glass1.getordernumber(),glass1.getlistnumber(),glass1.getboxnumber(),0,glass1.getglasslengthmm().toString(),glass1.getglassheightmm().toString(),glass1.getglasslength().toString(),glass1.getglassheight().toString(),1); |
| | | } |
| | | |
| | | } |
| | | if (queueid2!=null) { |
| | | // 写入D02的数据到上片队列表 |
| | | spianMapper.insertqueue(queueid2.toString(), 2, quewitdh2); |
| | | spianMapper.overqueue2(queueid2.toString(),0,1);//更改上片任务表的状态为0 |
| | | if(glass2==null){ |
| | | spianMapper.Updatequeue(null,null,null,null, 0, null, null, null, null, 2); |
| | | }else{ |
| | | spianMapper.Updatequeue(queueid1.toString(),glass2.getordernumber(),glass2.getlistnumber(),glass2.getboxnumber(),0,glass2.getglasslengthmm().toString(),glass2.getglassheightmm().toString(),glass2.getglasslength().toString(),glass2.getglassheight().toString(),2); |
| | | |
| | | S7control.getinstance().WriteWord("DB105.16", (short) 0);//关闭任务启动 |
| | | } |
| | | |
| | | } |
| | | |
| | | // 出片任务//////////////////////////////// |
| | |
| | | // 获取已下发的出片id |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte("DB105.30", 14); |
| | | String writedstrIdOut = new String(writedglassidbytesOut); |
| | | |
| | | |
| | | boolean outstate = false;// 出片车空闲判断 |
| | | boolean outstate1 = false;// 出片车任务是否启动 |
| | |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | |
| | | // 获取json中的值 |
| | | JSONArray address = jsonObject.getJSONArray("ServoManualone"); |
| | | JSONArray address = jsonObject.getJSONArray("ManualonePosition"); |
| | | for (int i = 0; i < address.size(); i++) { |
| | | JSONObject ress = (JSONObject) address.get(i); |
| | | |
| | |
| | | List<Short> arraylist7 = S7control.getinstance().ReadWord("DB103.48", 1); |
| | | List<Short> arraylist8 = S7control.getinstance().ReadWord("DB103.50", 1); |
| | | List<String> addresses9 = new ArrayList<>(); |
| | | addresses9.add("DB104.24"); |
| | | addresses9.add("DB104.26"); |
| | | addresses9.add("DB104.20"); |
| | | addresses9.add("DB104.22"); |
| | | addresses9.add("DB104.28"); |
| | | addresses9.add("DB104.30"); |
| | | List<Short> arraylist9 = S7control.getinstance().readWords(addresses9); |
| | | addresses9.add("DB104.1.2"); |
| | | addresses9.add("DB104.1.3"); |
| | | addresses9.add("DB104.1.6"); |
| | | addresses9.add("DB104.1.7"); |
| | | // addresses9.add("DB104.28"); |
| | | // addresses9.add("DB104.30"); |
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9); |
| | | short[] params2 = new short[arraylist9.size()]; |
| | | for (int i = 0; i < arraylist9.size(); i++) { |
| | | boolean value = arraylist9.get(i); |
| | | params2[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | // List<Short> arraylist9 = S7control.getinstance().readWords(addresses9); |
| | | arraylist5.addAll(arraylist6); |
| | | arraylist5.addAll(arraylist7); |
| | | arraylist5.addAll(arraylist8); |
| | |
| | | jsonObject.append("zuhe3", arraylist3); |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("shishi1", arraylist5); |
| | | jsonObject.append("guzhang", arraylist9); |
| | | jsonObject.append("guzhang", params2); |
| | | // jsonObject.append("weihuiling", arraylist8); |
| | | |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition"); |
New file |
| | |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | | import org.apache.commons.io.FileUtils;
|
| | |
|
| | | import java.io.*;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class PlcManualonePosition2 extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | |
|
| | | public static String readFileToString(String filePath) throws IOException {
|
| | | File file = new File(filePath);
|
| | | return FileUtils.readFileToString(file, "UTF-8");
|
| | | }
|
| | |
|
| | | public void readValue() {
|
| | | String str = "";
|
| | | BufferedReader bufferedReader = null;
|
| | | FileInputStream fileInputStream;
|
| | | try {
|
| | | // 从文件中读取字节数据存入 fileInputStream
|
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
|
| | | // 读取 fileInputStream 中字节并将其解码为字符
|
| | | 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;
|
| | | }
|
| | |
|
| | | // 将str字符串格式转为json
|
| | | JSONObject jsonObject = new JSONObject(str);
|
| | |
|
| | | // 获取json中的值
|
| | | JSONArray address = jsonObject.getJSONArray("ServoManualone");
|
| | | 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) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | List<String> addresses = new ArrayList<>();
|
| | | addresses.add("DB100.16");
|
| | | addresses.add("DB100.116");
|
| | | addresses.add("DB103.20");
|
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses);
|
| | | // System.out.println(arraylist);
|
| | |
|
| | | List<String> addresses2 = new ArrayList<>();
|
| | | addresses2.add("DB100.192");
|
| | | addresses2.add("DB100.118");
|
| | | addresses2.add("DB103.22");
|
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
|
| | |
|
| | | List<String> addresses9 = new ArrayList<>();
|
| | |
|
| | |
|
| | |
|
| | | addresses9.add("DB104.1.2");
|
| | | addresses9.add("DB104.1.3");
|
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
|
| | | short[] params2 = new short[arraylist9.size()];
|
| | | for (int i = 0; i < arraylist9.size(); i++) {
|
| | | boolean value = arraylist9.get(i);
|
| | | params2[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | // System.out.println(arraylist);
|
| | | jsonObject.append("zuhe1", arraylist);
|
| | | jsonObject.append("zuhe2", arraylist2);
|
| | | jsonObject.append("guzhang", params2);
|
| | | // jsonObject.append("weihuiling", arraylist8);
|
| | |
|
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | if (sendwServer != null) {
|
| | | sendwServer.sendMessage(jsonObject.toString());
|
| | | }
|
| | |
|
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | | List<String> waddresses1 = new ArrayList<>();
|
| | | waddresses1.add("DB100.108");
|
| | | waddresses1.add("DB100.20");
|
| | | waddresses1.add("DB103.52");
|
| | |
|
| | | List<String> waddresses2 = new ArrayList<>();
|
| | | waddresses2.add("DB100.110");
|
| | | waddresses2.add("DB100.176");
|
| | | waddresses2.add("DB103.54");
|
| | |
|
| | | // 故障地址
|
| | | List<String> waddresses3 = new ArrayList<>();
|
| | | waddresses3.add("DB103.242");
|
| | | waddresses3.add("DB103.248");
|
| | |
|
| | | // 复位地址
|
| | | List<String> waddresses4 = new ArrayList<>();
|
| | | waddresses4.add("DB101.3.6");
|
| | | waddresses4.add("DB101.4.1");
|
| | |
|
| | | // 回零地址
|
| | | List<String> waddresses5 = new ArrayList<>();
|
| | | waddresses5.add("DB101.3.7");
|
| | | waddresses5.add("DB101.4.2");
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | |
|
| | | // A01下发
|
| | | if (messageArray.getJSONArray(0).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(0);
|
| | | List<Short> sValue = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses1, sValue);
|
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1);
|
| | | }
|
| | | }
|
| | |
|
| | | // A02下发
|
| | | if (messageArray.getJSONArray(1).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(1);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue2.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses2, sValue2);
|
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入故障地址
|
| | | if (messageArray.getJSONArray(2).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(2);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue2.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses3, sValue2);
|
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses3);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入复位地址
|
| | | if (messageArray.getJSONArray(3).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(3);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | List<Boolean> messageBooleans = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | // 将消息值转换为布尔列表
|
| | | for (short values : sValue2) {
|
| | | messageBooleans.add(values == 1 ? true : false);
|
| | | }
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!messageBooleans.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(waddresses4, messageBooleans);
|
| | | System.out.println("Values " + messageBooleans + " written to PLC at address " + waddresses4);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入回零地址
|
| | | if (messageArray.getJSONArray(4).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(4);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | List<Boolean> messageBooleans = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | // 将消息值转换为布尔列表
|
| | | for (short values : sValue2) {
|
| | | messageBooleans.add(values == 1 ? true : false);
|
| | | }
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!messageBooleans.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(waddresses5, messageBooleans);
|
| | | System.out.println("Values " + messageBooleans + " written to PLC at address " + waddresses5);
|
| | | }
|
| | | }
|
| | |
|
| | | // 清空消息列表
|
| | | webSocketServer.clearMessages();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | this.readValue(); |
| | | String PlcAddress = this.name; |
| | | Integer Plccount = this.count; |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | // System.out.println(stt); |
| | | // List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12); |
| | | // List<Short> state = S7control.getinstance().ReadWord("DB103.0", 10); |
| | | Short[] values1 = { 1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 }; |
| | | List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 72); |
| | | List<Short> state = S7control.getinstance().ReadWord("DB103.0", 10); |
| | | // Short[] values1 = { 1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 ,1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | |
| | | Short[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| | | List<Short> state = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| | | // List<Short> state = new ArrayList<>(Arrays.asList(values2)); |
| | | |
| | | // Boolean[] values = { false, true, true, true, true, true, true, true, true, |
| | | // true, true, true, true, true, true, true, true, true, true, true, true, true, |
| | |
| | | } |
| | | |
| | | // 将消息值写入 PLC |
| | | // S7control.getinstance().WriteWord(addressList, messageValues); |
| | | S7control.getinstance().WriteWord(addressList, messageValues); |
| | | System.out.println("messageValues:" + messageValues); |
| | | System.out.println("addressList:" + addressList); |
| | | // 清空消息列表 |
| | |
| | | // Integer Plccount = this.count; |
| | | |
| | | // System.out.println(stt); |
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.0"); |
| | | addresses.add("DB100.2"); |
| | | addresses.add("DB100.4"); |
| | | addresses.add("DB100.6"); |
| | | addresses.add("DB100.26"); |
| | | addresses.add("DB100.28"); |
| | | addresses.add("DB100.30"); |
| | | addresses.add("DB100.32"); |
| | | addresses.add("DB100.34"); |
| | | addresses.add("DB100.36"); |
| | | addresses.add("DB100.38"); |
| | | addresses.add("DB100.40"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | |
| | | List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
| | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | if (webSocketServer != null) { |
| | | List<String> messages = webSocketServer.getMessages(); |
| | | String addressList1 = "DB100.0"; |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.0"); |
| | | waddresses1.add("DB100.2"); |
| | | waddresses1.add("DB100.4"); |
| | | waddresses1.add("DB100.6"); |
| | | waddresses1.add("DB100.26"); |
| | | waddresses1.add("DB100.28"); |
| | | waddresses1.add("DB100.30"); |
| | | waddresses1.add("DB100.32"); |
| | | waddresses1.add("DB100.34"); |
| | | waddresses1.add("DB100.36"); |
| | | waddresses1.add("DB100.38"); |
| | | waddresses1.add("DB100.40"); |
| | | |
| | | String addressList2 = "DB100.8"; |
| | | String addressList3 = "DB100.12"; |
| | | |
| | |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList1, Arrays.asList(sValue)); |
| | | S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList3); |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList2); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue)); |
| | | S7control.getinstance().WriteWord(addressList3, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList2); |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList3); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | |
| | | |
| | | // 写入第三个地址 |
| | | if (!mergedList.isEmpty()) { |
| | | S7control.getinstance().WriteWord(addressList3, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList1); |
| | | S7control.getinstance().WriteWord(waddresses1, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + waddresses1); |
| | | } |
| | | |
| | | // 清空消息列表 |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | List<String> addressList1 = new ArrayList<>(); |
| | | addressList1.add("DB103.32~45"); |
| | | addressList1.add("DB103.46~59"); |
| | | addressList1.add("DB103.60~73"); |
| | | addressList1.add("DB103.74~101"); |
| | | addressList1.add("DB103.102~115"); |
| | | addressList1.add("DB103.116~143"); |
| | | addressList1.add("DB103.144~157"); |
| | | addressList1.add("DB103.158~171"); |
| | | addressList1.add("DB103.172~185"); |
| | | addressList1.add("DB103.200~213"); |
| | | addressList1.add("DB103.228~241"); |
| | | List<Boolean> paramlist = S7control.getinstance().readBits(addressList1); |
| | | // addressList1.add("DB103.32~45"); |
| | | // addressList1.add("DB103.46~59"); |
| | | // addressList1.add("DB103.60~73"); |
| | | // addressList1.add("DB103.74~101"); |
| | | // addressList1.add("DB103.102~115"); |
| | | // addressList1.add("DB103.116~143"); |
| | | // addressList1.add("DB103.144~157"); |
| | | // addressList1.add("DB103.158~171"); |
| | | // addressList1.add("DB103.172~185"); |
| | | // addressList1.add("DB103.200~213"); |
| | | // addressList1.add("DB103.228~241"); |
| | | addressList1.add("DB103.44");//D01 |
| | | addressList1.add("DB103.58");//D02 |
| | | addressList1.add("DB103.72");//D03 |
| | | addressList1.add("DB103.86");//D04 |
| | | addressList1.add("DB103.100");//D05 |
| | | addressList1.add("DB103.114");//D06 |
| | | addressList1.add("DB103.128");//A01 |
| | | addressList1.add("DB103.156");//A01 2 |
| | | addressList1.add("DB103.142");//A02 |
| | | addressList1.add("DB103.212");//B01 |
| | | addressList1.add("DB103.184");//B02 |
| | | |
| | | |
| | | List<String> paramlist = S7control.getinstance().readStrings(addressList1); |
| | | |
| | | |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB103.0"); |
| | |
| | | addresses.add("DB103.6"); |
| | | List<Short> data = S7control.getinstance().readWords(addresses); |
| | | |
| | | |
| | | |
| | | List<Boolean> data2 = S7control.getinstance().ReadBits("DB101.9.2", 10); |
| | | List<String> addressList3 = new ArrayList<>(); |
| | | addressList3.add("DB103.6"); |
| | | List<Boolean> data3 = S7control.getinstance().readBits(addressList3); |
| | | addressList3.add("DB106.64"); |
| | | List<String> data3 = S7control.getinstance().readStrings(addressList3); |
| | | |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses.add("DB106.0"); |
| | | addresses.add("DB106.12"); |
| | | addresses.add("DB106.40"); |
| | | addresses.add("DB106.50"); |
| | | addresses4.add("DB103.52"); |
| | | addresses4.add("DB103.54"); |
| | | addresses4.add("DB103.56"); |
| | | addresses4.add("DB103.60"); |
| | | |
| | | List<Short> data4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | |
| | | // Boolean[] values = { false, true, true, true, true, true, true, true, true, |
| | | // true}; |
| | |
| | | // Short[] values4 = { 2,2,3,4}; |
| | | // List<Short> data4 = new ArrayList<>(Arrays.asList(values4)); |
| | | |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | short[] params = new short[paramlist.size()]; |
| | | for (int i = 0; i < paramlist.size(); i++) { |
| | | boolean value = paramlist.get(i); |
| | | short[] params = new short[data2.size()]; |
| | | for (int i = 0; i < data2.size(); i++) { |
| | | boolean value = data2.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | jsonObject.append("params", params); |
| | | jsonObject.append("params", paramlist); |
| | | jsonObject.append("params", data); |
| | | jsonObject.append("params", data2); |
| | | jsonObject.append("params", data3); |
| | | jsonObject.append("params", data4); |
| | | |
| | | |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter2"); |
| | | if (sendwServer != null) { |
| | | sendwServer.sendMessage(jsonObject.toString()); |
| | |
| | |
|
| | | // System.out.println(stt);
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 23);
|
| | |
|
| | | // System.out.println(arraylist);
|
| | | // Short[] 存片 = { 1 };
|
| | | // List<Short> 存片1 = new ArrayList<>(Arrays.asList(存片));
|
| | | // Short[] 接片 = { 1 };
|
| | | // List<Short> 接片1 = new ArrayList<>(Arrays.asList(接片));
|
| | | // Short[] 间距 = { 1 };
|
| | | // List<Short> 间距1 = new ArrayList<>(Arrays.asList(间距));
|
| | | // Short[] values1 = {1,1,1, 1,2, 3, 4, 5, 6, 7, 8, 9, 10,11,
|
| | | // 12,13,14,15,16,17,18,19,20 };
|
| | | // Short[] values1 = {1,1,1, 1,2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12,13,14,15,16,17,18,19,20 };
|
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | |
|
| | | jsonObject.append("params", arraylist);
|
| | |
|
| | |
|
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Positioning1");
|
| | | if (sendwServer != null) {
|
| | |
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | String addressList3 = "DB100.12";
|
| | | String addressList3 = "DB100.42";
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | // 写入第yi个地址
|
| | | if (!mergedList.isEmpty()) {
|
| | | // S7control.getinstance().WriteWord(addressList3, mergedList);
|
| | | S7control.getinstance().WriteWord(addressList3, mergedList);
|
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList3);
|
| | | }
|
| | |
|
| | |
| | | webSocketServer.clearMessages();
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | return FileUtils.readFileToString(file, "UTF-8"); |
| | | } |
| | | |
| | | public void readValue() { |
| | | String str = ""; |
| | | BufferedReader bufferedReader = null; |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json"); |
| | | // 读取 fileInputStream 中字节并将其解码为字符 |
| | | 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; |
| | | |
| | | |
| | | |
| | | public void insertDataToList(List<Short> list, String rangeAddress, int insertIndex) { |
| | | if (list.size() >= insertIndex + 14) { |
| | | List<Short> rangeData = new ArrayList<>(); |
| | | byte[] byteData = S7control.getinstance().ReadByte(rangeAddress, 14); |
| | | if (byteData != null && byteData.length == 14) { |
| | | for (byte b : byteData) { |
| | | rangeData.add((short) b); |
| | | } |
| | | } else { |
| | | // 读取数据失败,添加默认值 |
| | | for (int i = 0; i < 14; i++) { |
| | | rangeData.add((short) -1); |
| | | } |
| | | } |
| | | |
| | | // 将str字符串格式转为json |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | |
| | | // 获取json中的值 |
| | | JSONArray address = jsonObject.getJSONArray("ServoManualone"); |
| | | 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(); |
| | | list.addAll(insertIndex, rangeData); |
| | | } |
| | | } |
| | | |
| | |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB103.25"); |
| | | addresses.add("DB100.144"); |
| | | |
| | | // addresses.add("DB100.148-161"); |
| | | addresses.add("DB100.184"); |
| | | addresses.add("DB100.186"); |
| | | addresses.add("DB100.180"); |
| | | addresses.add("DB100.182"); |
| | | |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // System.out.println(arraylist); |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("DB103.26"); |
| | | addresses2.add("DB100.188"); |
| | | addresses2.add("DB100.190"); |
| | | addresses2.add("DB100.146"); |
| | | // addresses2.add("DB100.162-175"); |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | |
| | | List<String> addresses3 = new ArrayList<>(); |
| | | addresses3.add("DB103.42"); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB103.46"); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord("DB103.27", 2); |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord("DB103.29", 2); |
| | | List<String> addresses7 = new ArrayList<>(); |
| | | addresses7.add("DB104.24"); |
| | | addresses7.add("DB104.26"); |
| | | addresses7.add("DB104.20"); |
| | | addresses7.add("DB104.22"); |
| | | addresses7.add("DB104.28"); |
| | | addresses7.add("DB104.30"); |
| | | List<Short> arraylist7 = S7control.getinstance().readWords(addresses7); |
| | | // List<String> addresses = new ArrayList<>(); |
| | | // addresses.add("DB103.25"); |
| | | // addresses.add("DB100.144"); |
| | | // |
| | | // addresses.add("DB100.184"); |
| | | // addresses.add("DB100.186"); |
| | | // addresses.add("DB100.180"); |
| | | // addresses.add("DB100.182"); |
| | | // |
| | | // List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // |
| | | //// String rangeAddress = "DB100.148-161"; |
| | | // String rangeAddress = "DB100.148"; |
| | | // int insertIndex = 2; |
| | | // insertDataToList(arraylist, rangeAddress, insertIndex); |
| | | // |
| | | // |
| | | // List<String> addresses2 = new ArrayList<>(); |
| | | // addresses2.add("DB103.26"); |
| | | // addresses2.add("DB100.188"); |
| | | // addresses2.add("DB100.190"); |
| | | // addresses2.add("DB100.146"); |
| | | //// addresses2.add("DB100.162-175"); |
| | | // List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | //// String rangeAddress2 = "DB100.148-161"; |
| | | // String rangeAddress2 = "DB100.162"; |
| | | // int insertIndex2 = 4; |
| | | // insertDataToList(arraylist2, rangeAddress2, insertIndex2); |
| | | //// System.out.println(arraylist2); |
| | | // List<String> addresses3 = new ArrayList<>(); |
| | | // addresses3.add("DB103.42"); |
| | | // List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | // |
| | | // List<String> addresses4 = new ArrayList<>(); |
| | | // addresses4.add("DB103.46"); |
| | | // List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | // |
| | | // List<Short> arraylist5 = S7control.getinstance().ReadWord("DB103.27", 2); |
| | | // List<Short> arraylist6 = S7control.getinstance().ReadWord("DB103.29", 2); |
| | | // List<String> addresses7 = new ArrayList<>(); |
| | | // addresses7.add("DB104.1.4"); |
| | | // addresses7.add("DB104.1.5"); |
| | | // addresses7.add("DB104.1.2"); |
| | | // addresses7.add("DB104.1.3"); |
| | | // addresses7.add("DB104.1.6"); |
| | | // addresses7.add("DB104.1.7"); |
| | | // List<Boolean> arraylist7 = S7control.getinstance().readBits(addresses7); |
| | | // |
| | | // |
| | | // short[] params2 = new short[arraylist7.size()]; |
| | | // for (int i = 0; i < arraylist7.size(); i++) { |
| | | // boolean value = arraylist7.get(i); |
| | | // params2[i] = value ? (short) 1 : (short) 0; |
| | | // } |
| | | // |
| | | // List<String> addresses8 = new ArrayList<>(); |
| | | // addresses8.add("DB103.26"); |
| | | // addresses8.add("DB103.26"); |
| | | // addresses8.add("DB103.26"); |
| | | // addresses8.add("DB103.26"); |
| | | // List<Short> arraylist8 = S7control.getinstance().readWords(addresses8); |
| | | // addresses8.add("DB101.3.7"); |
| | | // addresses8.add("DB101.4.2"); |
| | | // addresses8.add("DB101.4.5"); |
| | | // addresses8.add("DB101.4.7"); |
| | | // List<Boolean> arraylist8 = S7control.getinstance().readBits(addresses8); |
| | | // short[] params = new short[arraylist8.size()]; |
| | | // for (int i = 0; i < arraylist8.size(); i++) { |
| | | // boolean value = arraylist8.get(i); |
| | | // params[i] = value ? (short) 1 : (short) 0; |
| | | // } |
| | | |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7}; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] values2 = { 1, 2, 3, 4, 5}; |
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | |
| | | // Short[] values3 = {1}; |
| | | // List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3)); |
| | | // Short[] values4 = {2}; |
| | | // List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4)); |
| | | // Short[] values5 = {3,3}; |
| | | // List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5)); |
| | | // Short[] values6 = { 4,4}; |
| | | // List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6)); |
| | | // Short[] values7 = { 1,1,1,1,1,1}; |
| | | // List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7)); |
| | | // Short[] values8 = { 1,1,1,1,1,1}; |
| | | // List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8)); |
| | | // System.out.println(arraylist); |
| | | Short[] values1 = { 1, 2, 3, 4, 5, 6, 7}; |
| | | List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | Short[] values2 = { 1, 2, 3, 4, 5}; |
| | | List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | |
| | | Short[] values3 = {1}; |
| | | List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3)); |
| | | Short[] values4 = {2}; |
| | | List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4)); |
| | | Short[] values5 = {3,3}; |
| | | List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5)); |
| | | Short[] values6 = { 4,4}; |
| | | List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6)); |
| | | Short[] values7 = { 1,1,1,1,1,1}; |
| | | List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7)); |
| | | Short[] values8 = { 1,1,1,1,1,1}; |
| | | List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8)); |
| | | |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | jsonObject.append("zuhe1", arraylist); |
| | |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("zuhe5", arraylist5); |
| | | jsonObject.append("zuhe6", arraylist6); |
| | | jsonObject.append("guzhang", arraylist7); |
| | | // jsonObject.append("weihuiling", arraylist8); |
| | | // jsonObject.append("guzhang", params2); |
| | | // jsonObject.append("weihuiling", params); |
| | | |
| | | |
| | | |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ServoManualone"); |
| | | if (sendwServer != null) { |
| | |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB103.25"); |
| | | waddresses1.add("DB100.144"); |
| | | // waddresses1.add("DB100.148-161"); |
| | | waddresses1.add("DB100.148-161"); |
| | | waddresses1.add("DB100.184"); |
| | | waddresses1.add("DB100.186"); |
| | | waddresses1.add("DB100.180"); |
| | |
| | | waddresses2.add("DB100.188"); |
| | | waddresses2.add("DB100.190"); |
| | | waddresses2.add("DB100.146"); |
| | | // waddresses2.add("DB100.162-175"); |
| | | waddresses2.add("DB100.162-175"); |
| | | |
| | | List<String> waddresses3 = new ArrayList<>(); |
| | | waddresses3.add("DB101.4.0"); |
| | | waddresses3.add("DB101.4.3"); |
| | | waddresses3.add("DB101.3.6"); |
| | | waddresses3.add("DB101.4.1"); |
| | | waddresses3.add("DB101.4.4"); |
| | | waddresses3.add("DB101.4.6"); |
| | | |
| | | |
| | | List<String> waddresses4 = new ArrayList<>(); |
| | | waddresses4.add("DB101.3.7"); |
| | | waddresses4.add("DB101.4.2"); |
| | | waddresses4.add("DB101.4.5"); |
| | | waddresses4.add("DB101.4.7"); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | |
| | | |
| | | |
| | | // 写入第一个地址 |
| | | if (messageArray.getJSONArray(0).size() > 0) { |
| | |
| | | } |
| | | |
| | | if (messageArray.getJSONArray(1).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(1); |
| | | JSONArray jsonArray2 = messageArray.getJSONArray(1); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | for (int i = 0; i < jsonArray2.size(); i++) { |
| | | Object value = jsonArray2.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (messageArray.getJSONArray(2).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(2); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray3.size(); i++) { |
| | | Object value = jsonArray3.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue3.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue3.isEmpty()) { |
| | | S7control.getinstance().WriteBit(waddresses3, sValue3); |
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + waddresses3); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (messageArray.getJSONArray(3).size() > 0) { |
| | | JSONArray jsonArray4 = messageArray.getJSONArray(3); |
| | | List<Boolean> sValue4 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray4.size(); i++) { |
| | | Object value = jsonArray4.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue4.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue4.isEmpty()) { |
| | | S7control.getinstance().WriteBit(waddresses4, sValue4); |
| | | System.out.println("Values " + sValue4 + " written to PLC at address " + waddresses4); |
| | | } |
| | | } |
| | | |
| | | // 清空消息列表 |
| | | webSocketServer.clearMessages(); |
| | | } |
| | |
| | | }
|
| | |
|
| | | // 调用方法,进行赋值
|
| | | this.readValue();
|
| | | String PlcAddress = this.name;
|
| | | Integer Plccount = this.count;
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | | // System.out.println(PlcAddress);
|
| | |
|
| | | // List<Boolean> paramlist = S7control.getinstance().ReadBits("DB2.0.0", 26);
|
| | | Boolean[] values = { false, true, true, true, true, true, true, true, true,
|
| | | true, true, true, true, true, true, true, true, true, true, true, true, true, true,
|
| | | true, false, true };
|
| | | List<Boolean> paramlist = new ArrayList<>(Arrays.asList(values));
|
| | | List<Boolean> paramlist = S7control.getinstance().ReadBits("DB2.0.0", 26);
|
| | | // Boolean[] values = { false, true, true, true, true, true, true, true, true,
|
| | | // true, true, true, true, true, true, true, true, true, true, true, true, true, true,
|
| | | // true, false, true };
|
| | | // List<Boolean> paramlist = new ArrayList<>(Arrays.asList(values));
|
| | |
|
| | | if (paramlist != null) {
|
| | |
|
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | this.readValue(); |
| | | String PlcAddress = this.name; |
| | | Integer Plccount = this.count; |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | // 根据地址读取PCL数据 |
| | | // List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71); |
| | | // List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); |
| | | // System.out.println(plclist); |
| | | // Boolean[] values = { false, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | this.readValue(); |
| | | String PlcAddress = this.name; |
| | | Integer Plccount = this.count; |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | // System.out.println(PlcAddress); |
| | | |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); |
| | | // List<Boolean> plclist2 = S7control.getinstance().ReadBits("DB102.5.5", 13); |
| | | // List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 64); |
| | | |
| | | // Boolean[] values = { true, true, true, true, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | this.readValue(); |
| | | String PlcAddress = this.name; |
| | | Integer Plccount = this.count; |
| | | // 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)); |
| | | List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 44); |
| | | // 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<>(); |
| | |
| | | package com.example.springboot.component; |
| | | |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import com.google.common.primitives.Bytes; |
| | | |
| | | public class S7control { |
| | | |
| | |
| | | * @param address 地址 |
| | | * @param datas word的值 |
| | | */ |
| | | public void WriteWord(List<String> address, List<Short> datas) { |
| | | if (s7PLC == null) |
| | | return; |
| | | |
| | | for (int i = 0; i < address.size(); i++) { |
| | | String addr = address.get(i); |
| | | short data = datas.get(i); |
| | | |
| | | if (addr.contains("-")) { |
| | | // 处理范围地址 |
| | | String[] range = addr.split("-"); |
| | | if (range.length == 2) { |
| | | String startAddr = range[0].trim(); |
| | | String endAddr = range[1].trim(); |
| | | |
| | | int startIndex = Integer.parseInt(startAddr.substring(startAddr.indexOf('.') + 1)); |
| | | int endIndex = Integer.parseInt(endAddr.substring(endAddr.indexOf('.') + 1)); |
| | | |
| | | for (int j = startIndex; j <= endIndex; j++) { |
| | | String currentAddress = startAddr.substring(0, startAddr.indexOf('.') + 1) + j; |
| | | s7PLC.writeInt16(currentAddress, data); // 将数据写入当前地址 |
| | | } |
| | | } |
| | | } else { |
| | | // 处理单个地址 |
| | | s7PLC.writeInt16(addr, data); // 将数据写入单个地址 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | return s7PLC.readInt16(address); |
| | | } |
| | | |
| | | public List<Short> readWords(List<String> addresses) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<Short> data = new ArrayList<>(); |
| | | |
| | | for (String address : addresses) { |
| | | if (address.contains("-")) { |
| | | String[] range = address.split("-"); |
| | | String startAddress = range[0]; |
| | | String endAddress = range[1]; |
| | | |
| | | if (startAddress.equals(endAddress)) { |
| | | // 单个地址 |
| | | Short value = s7PLC.readInt16(startAddress); |
| | | data.add(value); |
| | | } else { |
| | | // 范围地址 |
| | | int startIndex = getIndexFromAddress(startAddress); |
| | | int endIndex = getIndexFromAddress(endAddress); |
| | | |
| | | for (int i = startIndex; i <= endIndex; i++) { |
| | | String currentAddress = getAddressFromIndex(i); |
| | | Short value = s7PLC.readInt16(currentAddress); |
| | | data.add(value); |
| | | } |
| | | } |
| | | } else { |
| | | // 单个地址 |
| | | Short value = s7PLC.readInt16(address); |
| | | data.add(value); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | private int getIndexFromAddress(String address) { |
| | | |
| | |
| | | public byte[] ReadByte(String address, int count) { |
| | | if (s7PLC==null) |
| | | return null; |
| | | |
| | | // List<String> addresslist = GetAddressList(address, count, 16); |
| | | return s7PLC.readByte(address,count); |
| | | } |
| | |
| | | } |
| | | |
| | | public List<Boolean> readBits(List<String> addressList) { |
| | | if (s7PLC == null) |
| | | if (s7PLC == null || addressList.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | List<Boolean> result = new ArrayList<>(); |
| | | List<Boolean> values = new ArrayList<>(); |
| | | for (String address : addressList) { |
| | | boolean value = s7PLC.readBoolean(address); |
| | | values.add(value); |
| | | } |
| | | |
| | | return values; |
| | | } |
| | | |
| | | |
| | | public List<String> readStrings(List<String> addressList) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<String> result = new ArrayList<>(); |
| | | |
| | | for (String address : addressList) { |
| | | if (address.contains("~")) { |
| | | String[] range = address.split("~"); |
| | | String startAddress = range[0]; |
| | | String endAddress = range[1]; |
| | | byte[] bytes = s7PLC.readByte(address, 14); |
| | | |
| | | int startIndex = extractAddressNumber(startAddress); |
| | | int endIndex = extractAddressNumber(endAddress); |
| | | |
| | | String prefix = startAddress.substring(0, startAddress.indexOf(".") + 1); |
| | | |
| | | for (int i = startIndex; i <= endIndex; i++) { |
| | | String newAddress = prefix + i; |
| | | result.add(s7PLC.readBoolean(newAddress)); |
| | | } |
| | | } else { |
| | | result.add(s7PLC.readBoolean(address)); |
| | | if (bytes != null) { |
| | | String str = new String(bytes, StandardCharsets.US_ASCII); |
| | | result.add(str); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public void WriteWord(List<String> address, List<Short> datas) { |
| | | if (s7PLC == null) |
| | | return; |
| | | |
| | | for (int i = 0; i < address.size(); i++) { |
| | | String addr = address.get(i); |
| | | short data = datas.get(i); |
| | | |
| | | if (addr.contains("-")) { |
| | | outmesid(String.valueOf(data),addr); // 单独处理带破折号的地址 |
| | | } else { |
| | | s7PLC.writeInt16(addr, data); // 将数据写入单个地址 |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void outmesid(String data, String addr) { |
| | | System.out.println("outmesid: " + data); |
| | | List<Byte> glassidlist = new ArrayList<>(); |
| | | String[] parts = addr.split("-"); |
| | | if (parts.length == 2) { |
| | | addr = parts[0]; // 只保留 "-" 前面的部分 |
| | | } |
| | | for (char iditem : data.toCharArray()) { |
| | | glassidlist.add(Byte.valueOf(String.valueOf(iditem))); |
| | | } |
| | | byte[] bytes = Bytes.toArray(glassidlist); |
| | | S7control.getinstance().WriteByte(addr, bytes); |
| | | } |
| | | |
| | | |
| | | public List<Short> readWords(List<String> addresses) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<Short> data = new ArrayList<>(); |
| | | |
| | | for (String address : addresses) { |
| | | |
| | | // 单个地址 |
| | | Short value = s7PLC.readInt16(address); |
| | | data.add(value); |
| | | |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | private int extractAddressNumber(String address) { |
| | | String numberStr = address.replaceAll("\\D+", ""); // 使用正则表达式提取数字部分 |
| | | return Integer.parseInt(numberStr); |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.example.springboot.component.PLCAutomaticParameterSetting; |
| | | import com.example.springboot.component.PLCManualJog; |
| | | import com.example.springboot.component.PlcHold; |
| | | import com.example.springboot.component.PlcManualonePosition; |
| | | import com.example.springboot.component.PlcManualonePosition2; |
| | | import com.example.springboot.component.PlcParameter; |
| | | import com.example.springboot.component.Plcaction; |
| | | import com.example.springboot.component.Plchome; |
| | |
| | | import com.example.springboot.component.PlcParameter2; |
| | | import com.example.springboot.component.PlcParameter1; |
| | | import com.example.springboot.component.PlcServoManualone; |
| | | import com.example.springboot.component.PLCAutomaticParameterSetting; |
| | | import com.example.springboot.component.PlcManualonePosition; |
| | | import com.example.springboot.component.PlcManualonePosition2; |
| | | import com.example.springboot.component.PLCManualJog; |
| | | |
| | | @Component |
| | | @Order(1) |
| | |
| | | // |
| | | System.out.println("启动完成"); |
| | | |
| | | // new PlcHold().start(); |
| | | new PlcHold().start(); |
| | | |
| | | // new Plcaction().start(); |
| | | new Plcaction().start(); |
| | | // |
| | | new Plchome().start(); |
| | | // // |
| | | // new PlcParameter().start(); |
| | | // |
| | | new PlcParameter().start(); |
| | | // |
| | | // new Plcalarm().start(); |
| | | // |
| | | // new Plcsign().start(); |
| | | new Plcsign().start(); |
| | | // |
| | | // new Plcstate().start(); |
| | | // new PlcPositioning1().start(); |
| | | // new PlcPositioning2().start(); |
| | | // new PlcParameter2().start(); |
| | | // new PlcParameter1().start(); |
| | | // new PLCAutomaticParameterSetting().start(); |
| | | // new PlcServoManualone().start(); |
| | | // new PLCManualJog().start(); |
| | | // new PlcManualonePosition().start(); |
| | | // new PlcManualonePosition2().start(); |
| | | new Plcstate().start(); |
| | | new PlcPositioning1().start(); |
| | | new PlcPositioning2().start(); |
| | | new PlcParameter2().start(); |
| | | new PlcParameter1().start(); |
| | | new PLCAutomaticParameterSetting().start(); |
| | | |
| | | new PlcManualonePosition().start(); |
| | | new PlcManualonePosition2().start(); |
| | | new PlcServoManualone().start(); |
| | | new PLCManualJog().start(); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | //获取玻璃信息 |
| | | @Select("select ordernumber as ordernumber,glasslength_mm as glasslengthmm,barcode from north_glass_buffer1 where barcode=#{glassid}") |
| | | @Select("select ordernumber ,glasslength_mm as glasslengthmm,glassheight_mm as glassheightmm,barcode,listnumber,boxnumber,glasslength,glassheight from north_glass_buffer1 where barcode=#{glassid}") |
| | | north_glass_buffer1 selectGlass(String glassid); |
| | | |
| | | //出片任务查询 |
| | |
| | | //判断有几块玻璃还在出片中 |
| | | @Select("SELECT COUNT(*) FROM `storage_cage` where state=3;") |
| | | Integer Selectoutstate(); |
| | | //获取进片队列id |
| | | @Insert("update queue set glassid=#{glassid},width=#{width} where type=#{type};") |
| | | void insertqueue(String glassid,int type,double width); |
| | | //判断队列表是否有该玻璃 |
| | | @Select("select COUNT(*) from queue where glassid=#{glassid};") |
| | | int Selectquecount(String glassid); |
| | | //更新进片队列 |
| | | @Update("update queue set glassid=#{glassid},orderid=#{orderid},listid=#{listid},boxid=#{boxid},state=#{state},glasswidthmm=#{glasswidthmm},glassheightmm=#{glassheightmm},glasswidth=#{glasswidth},glassheight=#{glassheight} where type=#{type};") |
| | | void Updatequeue(String glassid,String orderid,String listid,String boxid,int state,String glasswidth,String glassheight,String glasswidthmm,String glassheightmm,int type); |
| | | //完成进片队列任务 |
| | | @Update("update queue set state=#{state} where glassid=#{glassid};") |
| | | void overqueue(String glassid,int state); |
| | |
| | | // List<Out_slice> resultlist = new ArrayList<Out_slice>(); |
| | | // HashMap map = new HashMap<>(); |
| | | // // HashMap<String,List<Out_slice>> map=new HashMap<String,List<Out_slice>>(); |
| | | // for (Out_slice out_slice : out_slices) { |
| | | // String key_ = out_slice.getState() + "-"; |
| | | // for (Out_slice Out_slice.java : out_slices) { |
| | | // String key_ = Out_slice.java.getState() + "-"; |
| | | // if (map.get(key_) == null) { |
| | | // List<Out_slice> lists = new ArrayList<Out_slice>(); |
| | | // lists.add(out_slice); |
| | | // lists.add(Out_slice.java); |
| | | // map.put(key_, lists); |
| | | // } else { |
| | | // List<Out_slice> lists = (List<Out_slice>) map.get(key_); |
| | | // lists.add(out_slice); |
| | | // lists.add(Out_slice.java); |
| | | // map.put(key_, lists); |
| | | // } |
| | | // } |
| | |
| | | // public static List<Out_slice> Orderbyresult(List<Out_slice> out_slices, int orders) { |
| | | // // orders 排序模式 |
| | | // List<Out_slice> list = new ArrayList<Out_slice>(); |
| | | // for (Out_slice out_slice : out_slices) { |
| | | // for (Out_slice Out_slice.java : out_slices) { |
| | | // if (list.isEmpty()) { |
| | | // list.add(out_slice); |
| | | // list.add(Out_slice.java); |
| | | // } else { |
| | | // for (int i = 0; i < list.size(); i++) { |
| | | // Out_slice out_slice2 = list.get(i); |
| | | // if (out_slice.getID() > out_slice2.getID()) { |
| | | // if (Out_slice.java.getID() > out_slice2.getID()) { |
| | | // continue; |
| | | // } else { |
| | | // list.add(i, out_slice2); |
| | |
| | | |
| | | // public static void f() { |
| | | // HashMap map = new HashMap<>(); |
| | | // for (Out_slice out_slice : listoutslice) { |
| | | // String key_ = out_slice.getState() + "-"; |
| | | // for (Out_slice Out_slice.java : listoutslice) { |
| | | // String key_ = Out_slice.java.getState() + "-"; |
| | | // if (map.get(key_) == null) { |
| | | // List<Out_slice> lists = new ArrayList<Out_slice>(); |
| | | // lists.add(out_slice); |
| | | // lists.add(Out_slice.java); |
| | | // map.put(key_, lists); |
| | | // } else { |
| | | // List<Out_slice> lists = (List<Out_slice>) map.get(key_); |
| | | // lists.add(out_slice); |
| | | // lists.add(Out_slice.java); |
| | | // map.put(key_, lists); |
| | | // } |
| | | // } |
| | |
| | | S7control.getinstance().WriteByte(address, bytes);// 派发出片id |
| | | } |
| | | //获取地址内的玻璃id转字符串 |
| | | public StringBuilder queGlassid(String address) { |
| | | public StringBuilder queGlassid(String address,int count) { |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, 14); |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, count); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |