Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
# Conflicts:
# springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
# springboot-vue3/src/main/java/com/example/springboot/entity/Out_slice.java
| | |
| | | [ |
| | | { |
| | | "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 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "数量", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "进片ID", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "长度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "高度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "取片格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "name": "存片格子", |
| | | "read": 22, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 1 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | |
| | | [ |
| | | { |
| | | "name": "A01 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address":"DB100.0", |
| | | "value":0 |
| | | |
| | | }, |
| | | { |
| | | "name": "数量", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "进片ID", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "长度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "高度", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "取片格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "存片格子", |
| | | "read": 22, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A01半自动", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A01半自动启动", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | }, |
| | | ], |
| | | [ |
| | | { |
| | | "name": "A02 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address":"DB100.1", |
| | | "count":3, |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "取片格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "存片格子", |
| | | "read": 22, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "数量", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "name": "取片ID", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | |
| | | |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A02半自动", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A02半自动启动", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | |
| | | [ |
| | | { |
| | | "name": "A01翻转实时位置", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address":"DB100.2", |
| | | "count":3, |
| | | "value":0 |
| | | }, |
| | | |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "未回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | ],[ |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | "name": "A02翻转实时位置", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address":"DB100.2", |
| | | "count":3, |
| | | "value":0 |
| | | }, |
| | | |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "未回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A01半自动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "半自动启动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "A02 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.1", |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "name": "取片格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "name": "存片格子", |
| | | "read": 22, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "name": "数量", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "name": "取片ID", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A02半自动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "半自动启动", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "A01翻转实时位置", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.2", |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "A02翻转实时位置", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.2", |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | ], [ |
| | | { |
| | | "name": "B01 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.2", |
| | | "count": 3, |
| | | "value": 0 |
| | | "address":"DB100.2", |
| | | "count":3, |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "目标格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | "value":0 |
| | | }, |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | } ,{ |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "B02 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address": "DB100.3", |
| | | "count": 3, |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "name": "目标格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value": 0 |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "未回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value": 0, |
| | | "address": "DB10.0" |
| | | } |
| | | } |
| | | ], |
| | | |
| | | [ |
| | | { |
| | | "name": "B02 所在格子", |
| | | "read": 33, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "address":"DB100.3", |
| | | "count":3, |
| | | "value":0 |
| | | }, |
| | | { |
| | | "name": "目标格子", |
| | | "read": 11, |
| | | "sending": 0, |
| | | "type": "0", |
| | | "value":0 |
| | | }, |
| | | |
| | | { |
| | | "button": { |
| | | "name": "故障", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "复位", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | |
| | | } |
| | | } ,{ |
| | | "button": { |
| | | "name": "未回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "回零", |
| | | "value":0, |
| | | "address":"DB10.0" |
| | | } |
| | | } |
| | | |
| | | ] |
| | | |
| | | |
| | | ] |
| | | ] |
| | | |
| | |
| | | "address": [ |
| | | { |
| | | "name": "DB102.0.0", |
| | | "count": 58 |
| | | "count": 64 |
| | | } |
| | | ] |
| | | } |
| | |
| | | "Normal":"Normal",
|
| | | "Entering":"Entering",
|
| | | "Outing":"Outing",
|
| | | "Suspend":"Suspend"
|
| | |
|
| | | "Suspend":"Suspend",
|
| | | "Stop":"Stop",
|
| | | "Start":"Start"
|
| | | } |
| | |
| | | "Entering":"正在进",
|
| | | "Outing":"正在出",
|
| | | "Suspend":"暂停",
|
| | | "Stop":"停止",
|
| | | "Start":"开始",
|
| | | "langparameter": {
|
| | | "conveyor Velocity(Auto FAST)": "D01-D06 皮带输送自动快速",
|
| | | "conveyor Velocity(Auto SLOW)": "D01-D06 皮带输送自动慢速",
|
| | |
| | | path: '/home', |
| | | component: () => import('../views/home') |
| | | }, |
| | | |
| | | |
| | | |
| | | |
| | | { |
| | |
| | | component: () => import('../views/device/parameter'), |
| | | |
| | | }, |
| | | |
| | | |
| | | { |
| | | path: '/device/alarm', |
| | | component: () => import('../views/device/alarm') |
| | |
| | | path: '/device/iostate', |
| | | component: () => import('../views/device/iostate') |
| | | }, |
| | | |
| | | |
| | | { |
| | | path: '/device/control', |
| | | component: () => import('../views/device/control') |
| | |
| | | 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(); |
| | | |
| | | // 获取token |
| | | const hasToken = getToken(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | 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); |
| | | }; |
| | |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | //console.log(obj) |
| | | // console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</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> |
| | | </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> |
| | | <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> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:485px;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style="width:100px;">{{ item.name }}</span> |
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0'" v-model="item.value" |
| | | class="input-box"></el-input> |
| | | </div> |
| | | </div> |
| | | <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 && item.button.state != 0" :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> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/Manualoneposition2' |
| | | import { throttle } from 'lodash'; |
| | | let socket; |
| | | export default { |
| | | name: "ManualonePosition2", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | created () { |
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | |
| | | |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === 'A01翻转启动') { |
| | | const data = []; |
| | | |
| | | for (let i = 0; i < 1; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | const values = inputData.map(item => item.value); |
| | | |
| | | data.push(values); |
| | | } |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === 'A02翻转启动') { |
| | | const data = []; |
| | | |
| | | for (let i = 1; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | const values = inputData.map(item => item.value); |
| | | data.unshift([]); |
| | | data.push(values); |
| | | } |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | 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 === '故障'); |
| | | 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('所有故障的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | |
| | | |
| | | } |
| | | |
| | | 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); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | }, |
| | | |
| | | |
| | | initWebSocket () { |
| | | |
| | | let viewname = "ManualonePosition2"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | | socket = null; |
| | | } |
| | | |
| | | // 开启一个websocket服务 |
| | | socket = new WebSocket(socketUrl); |
| | | |
| | | // 打开事件 |
| | | socket.onopen = function () { |
| | | console.log("websocket已打开"); |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 执行更新逻辑 |
| | | for (let i = 0; i < 2; i++) { |
| | | jsonData2[i].forEach((item, index) => { |
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') { |
| | | item.value = obj[`zuhe${i + 1}`][0][index]; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | jsonData2.forEach((item) => { |
| | | item.forEach((subItem) => { |
| | | if (subItem.sending === 4) { |
| | | subItem.value = obj.shishi1[0][0]; |
| | | } |
| | | if (subItem.sending === 5) { |
| | | subItem.value = obj.shishi1[0][1]; |
| | | } |
| | | if (subItem.sending === 6) { |
| | | subItem.value = obj.shishi1[0][2]; |
| | | } |
| | | if (subItem.sending === 7) { |
| | | subItem.value = obj.shishi1[0][3]; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[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 = guzhangValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | }, 200); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |
| | | console.log("websocket已关闭"); |
| | | }; |
| | | |
| | | // 发生错误事件 |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 2px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 10px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | <template>
|
| | | <div class="app">
|
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
|
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
|
| | | }}</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>
|
| | | </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>
|
| | | <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>
|
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('Positioning2')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('ManualonePosition')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('ManualonePosition2')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('AutomaticParameterSetting')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{
|
| | | $t('ManualJog')
|
| | | }}</router-link>
|
| | | </el-breadcrumb>
|
| | |
|
| | | <el-row :gutter="20">
|
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex">
|
| | | <el-card class="json-block" style="width:485px;">
|
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container">
|
| | | <div class="item-row">
|
| | | <span class="name" style="width:100px;">{{ item.name }}</span>
|
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0'" v-model="item.value"
|
| | | class="input-box"></el-input>
|
| | | </div>
|
| | | </div>
|
| | | <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 && item.button.state != 0" :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>
|
| | | </el-card>
|
| | | </el-col>
|
| | | </el-row>
|
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> -->
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import LanguageMixin from '../../lang/LanguageMixin'
|
| | | import data from '../../configuration/Manualoneposition2'
|
| | | import { throttle } from 'lodash';
|
| | | let socket;
|
| | | export default {
|
| | | name: "ManualonePosition2",
|
| | | mixins: [LanguageMixin],
|
| | | data () {
|
| | | return {
|
| | | jsonData: data // 加载整个data.json文件作为jsonData
|
| | | }
|
| | | },
|
| | | created () {
|
| | | this.initWebSocket();
|
| | | // console.log('jsonData:', this.jsonData); |
| | |
|
| | | },
|
| | | methods: {
|
| | | updateButtonValue (dataGroup, itemIndex) {
|
| | | // 将当前按钮的值设为1
|
| | |
|
| | | this.$set(dataGroup[itemIndex].button, 'value', 1);
|
| | |
|
| | |
|
| | |
|
| | | },
|
| | | submitDataToBackend (currentButtonName) {
|
| | | if (currentButtonName === 'A01翻转启动') {
|
| | | const data = [];
|
| | |
|
| | | for (let i = 0; i < 1; i++) {
|
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
|
| | | return { value: item.value };
|
| | | });
|
| | |
|
| | | const values = inputData.map(item => item.value);
|
| | |
|
| | | data.push(values);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | const jsonObject = { data };
|
| | |
|
| | | // 提交数据到后端
|
| | | const jsonString = JSON.stringify(jsonObject);
|
| | | console.log('所有Type为0的value:', jsonString);
|
| | | socket?.send(jsonString);
|
| | |
|
| | | }
|
| | |
|
| | | if (currentButtonName === 'A02翻转启动') {
|
| | | const data = [];
|
| | |
|
| | | for (let i = 1; i < 2; i++) {
|
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
|
| | | return { value: item.value };
|
| | | });
|
| | |
|
| | | const values = inputData.map(item => item.value);
|
| | | data.unshift([]);
|
| | | data.push(values);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | const jsonObject = { data };
|
| | |
|
| | | // 提交数据到后端
|
| | | 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 === '故障');
|
| | | 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('所有故障的value:', jsonString2);
|
| | | socket?.send(jsonString2);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | 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);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | 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);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | },
|
| | |
|
| | |
|
| | | initWebSocket () {
|
| | |
|
| | | let viewname = "ManualonePosition2";
|
| | |
|
| | | if (typeof WebSocket === "undefined") {
|
| | | console.log("您的浏览器不支持WebSocket");
|
| | | } else {
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | |
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | | socket = null;
|
| | | }
|
| | |
|
| | | // 开启一个websocket服务
|
| | | socket = new WebSocket(socketUrl);
|
| | |
|
| | | // 打开事件
|
| | | socket.onopen = function () {
|
| | | console.log("websocket已打开");
|
| | | };
|
| | |
|
| | | // 收到消息
|
| | | socket.onmessage = (msg) => {
|
| | | if (!msg.data) {
|
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑
|
| | | }
|
| | |
|
| | | let obj = JSON.parse(msg.data);
|
| | | // console.log(obj)
|
| | | const jsonData2 = this.jsonData;
|
| | |
|
| | | const handleMouseMove = throttle(function (event) {
|
| | | const inputBox = document.querySelectorAll('.el-card__body');
|
| | | const target = event.target;
|
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
|
| | | // 执行更新逻辑
|
| | | for (let i = 0; i < 2; i++) {
|
| | | jsonData2[i].forEach((item, index) => {
|
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') {
|
| | | item.value = obj[`zuhe${i + 1}`][0][index];
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | jsonData2.forEach((item) => {
|
| | | item.forEach((subItem) => {
|
| | | if (subItem.sending === 4) {
|
| | | subItem.value = obj.shishi1[0][0];
|
| | | }
|
| | | if (subItem.sending === 5) {
|
| | | subItem.value = obj.shishi1[0][1];
|
| | | }
|
| | | if (subItem.sending === 6) {
|
| | | subItem.value = obj.shishi1[0][2];
|
| | | }
|
| | | if (subItem.sending === 7) {
|
| | | subItem.value = obj.shishi1[0][3];
|
| | | }
|
| | | });
|
| | | });
|
| | |
|
| | | // 遍历guzhang数组
|
| | | for (let i = 0; i < obj.guzhang[0].length; i++) {
|
| | | const guzhangValue = obj.guzhang[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 = guzhangValue;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | }, 200);
|
| | |
|
| | | document.addEventListener('mouseover', handleMouseMove);
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | // 关闭事件
|
| | | socket.onclose = function () {
|
| | | console.log("websocket已关闭");
|
| | | };
|
| | |
|
| | | // 发生错误事件
|
| | | socket.onerror = function () {
|
| | | console.log("websocket发生了错误");
|
| | | };
|
| | |
|
| | | }
|
| | | },
|
| | | send () {
|
| | |
|
| | |
|
| | | socket?.send(JSON.stringify(this.messagepack));
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style scoped>
|
| | | .item-row {
|
| | | display: flex;
|
| | | align-items: center;
|
| | | margin-bottom: 2px;
|
| | | /* 调整每个项目之间的间距 */
|
| | | }
|
| | |
|
| | | .action-button {
|
| | | margin-right: 10px;
|
| | | background: #66b1ff;
|
| | | color: #FFF;
|
| | | }
|
| | |
|
| | | .blue-button {
|
| | | background-color: skyblue;
|
| | | }
|
| | | </style> |
| | |
| | | }}</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>
|
| | |
|
| | | <div>Parameter</div>
|
| | |
|
| | | <el-form label-width="100px" style="display: flex; flex-wrap: wrap;" :model="messagepack.data">
|
| | | <div id="btn_div">
|
| | | <el-button type="primary" @click="send()" 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.unit }}</span>
|
| | | <!-- <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>
|
| | | </el-form>
|
| | |
| | | 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));
|
| | | |
| | | |
| | | // 将 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;
|
| | |
|
| | | for (let a = 0; a < this.record.xyData.length; a++) {
|
| | | this.record.xyData[a].value = this.record.params[0][a];
|
| | |
|
| | | }
|
| | |
|
| | | 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);
|
| | | |
| | | };
|
| | |
|
| | | // 关闭事件
|
| | | socket.onclose = function () {
|
| | |
| | | }
|
| | | },
|
| | | 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++) { |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</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/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</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('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> |
| | | <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> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</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> |
| | | <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> |
| | | <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> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button" >{{ item.title.name }}</span> |
| | | </div> |
| | | </div> |
| | | |
| | | <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" |
| | | @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> |
| | | @click="updateButtonValue(dataGroup, itemIndex);submitDataToBackend(item.button.name)" |
| | | :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> |
| | | |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | </template> |
| | | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/parameter2' |
| | | let socket; |
| | | export default { |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/parameter2' |
| | | let socket; |
| | | export default { |
| | | destroyed() { |
| | | socket.close(); |
| | | }, |
| | | name: "Parameter2", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | data() { |
| | | return { |
| | | jsonData: data, |
| | | jsonData: data , |
| | | |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | // 将其他按钮的值全部设为0 |
| | | |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | if (currentButtonName === '清除ID') { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | // 将其他按钮的值全部设为0 |
| | | |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === '清除ID') { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | 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); |
| | | } |
| | | }, |
| | | 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 () { |
| | | |
| | | |
| | | let viewname = "Parameter2"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | let obj = JSON.parse(msg.data); |
| | | |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | // const xiaoche = obj.params[3]; |
| | | |
| | | // console.log(parms); |
| | | //清除id |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '3') { |
| | | obj.button.value = parms[0][i]; |
| | | } |
| | | } |
| | | |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | } |
| | | //ID |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '0') { |
| | | obj.value = parms[1][i]; |
| | | } |
| | | } |
| | | |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | // const xiaoche = obj.params[3]; |
| | | |
| | | } |
| | | //手动状态 |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '4') { |
| | | obj.button.value = parms[2][i]; |
| | | } |
| | | } |
| | | |
| | | console.log(parms); |
| | | |
| | | } |
| | | //扫描枪扫码的ID |
| | | jsonData2.forEach((item) => { |
| | | item.forEach((subItem) => { |
| | | if (subItem.read === 66) { |
| | | subItem.value = parms[3][0]; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '3') { |
| | | obj.button.value = parms[0][i]; |
| | | } |
| | | |
| | | |
| | | //A01当前格子 |
| | | let lastParmsArray = parms[parms.length - 1]; |
| | | |
| | | let lastParmsIndex = 0; |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | for (let j = 0; j < jsonData2[i].length; j++) { |
| | | if (jsonData2[i][j].read === 333) { |
| | | jsonData2[i][j].value = lastParmsArray[lastParmsIndex]; |
| | | lastParmsIndex++; |
| | | if (lastParmsIndex === lastParmsArray.length) { |
| | | lastParmsIndex = 0; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '0') { |
| | | obj.value = parms[1][i]; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '4') { |
| | | obj.button.value = parms[2][i]; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | jsonData2.forEach((item) => { |
| | | item.forEach((subItem) => { |
| | | if (subItem.read === 66) { |
| | | subItem.value = parms[3][0]; |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | |
| | | let lastParmsArray = parms[parms.length - 1]; |
| | | |
| | | let lastParmsIndex = 0; |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | for (let j = 0; j < jsonData2[i].length; j++) { |
| | | if (jsonData2[i][j].read === 333) { |
| | | jsonData2[i][j].value = lastParmsArray[lastParmsIndex]; |
| | | lastParmsIndex++; |
| | | if (lastParmsIndex === lastParmsArray.length) { |
| | | lastParmsIndex = 0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // console.log(jsonData2); |
| | | // console.log(jsonData2); |
| | | |
| | | |
| | | }; |
| | | |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | } |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | |
| | |
| | | background-color: green; |
| | | } |
| | | |
| | | .red-button { |
| | | .red-button{ |
| | | background-color: red; |
| | | } |
| | | </style> |
| | | .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> |
| | | |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</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/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</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('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | </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') |
| | | <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> |
| | | <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> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</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> |
| | | <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-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> |
| | | </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-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> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </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> |
| | | |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/ServoManualone' |
| | | import { throttle } from 'lodash'; |
| | | |
| | | let socket; |
| | | export default { |
| | | export default { |
| | | name: "ServoManualone", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | |
| | | data() { |
| | | return { |
| | | jsonData: data, |
| | | jsonData: data , |
| | | |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | |
| | | methods: { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | |
| | | 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 === 'A01半自动启动') { |
| | | const data = []; |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | for (let i = 0; i < 1; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | const values = inputData.map(item => item.value); |
| | | |
| | | data.push(values); |
| | | } |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === '半自动启动') { |
| | | const data = []; |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | for (let i = 0; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | } |
| | | |
| | | const values = inputData.map(item => item.value); |
| | | if (currentButtonName === 'A02半自动启动') { |
| | | const data2 = []; |
| | | |
| | | data.push(values); |
| | | } |
| | | 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); |
| | | |
| | | const jsonObject = { data }; |
| | | } |
| | | data2.unshift([]); |
| | | const jsonObject = { data:data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | } |
| | | |
| | | if (currentButtonName === '复位') { |
| | | 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); |
| | | |
| | | 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.flat()); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | const jsonObject2 = { data2 }; |
| | | // 在 data2 数组前面添加两个空数组 |
| | | data2.unshift([], []); |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有Type为0的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | // 创建 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 === 'A01半自动') { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | 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); |
| | | |
| | | if (currentButtonName === 'A02半自动') { |
| | | const elements = document.getElementsByClassName('special-class2'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | // 将得到的值添加到 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++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (currentButtonName === 'A02半自动') { |
| | | const elements = document.getElementsByClassName('special-class2'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | }, |
| | | |
| | | |
| | | initWebSocket () { |
| | | |
| | | |
| | | let viewname = "ServoManualone"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | let obj = JSON.parse(msg.data); |
| | | console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 执行更新逻辑 |
| | | for (let i = 0; i < 6; i++) { |
| | | jsonData2[i].forEach((item, index) => { |
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') { |
| | | item.value = obj[`zuhe${i + 1}`][0][index]; |
| | | } |
| | | }); |
| | | } |
| | | const handleMouseMove = throttle(function(event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 执行更新逻辑 |
| | | for (let i = 0; i < 6; i++) { |
| | | jsonData2[i].forEach((item, index) => { |
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i+1}`][0][index] !== 'undefined') { |
| | | item.value = obj[`zuhe${i+1}`][0][index]; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[0][i]; |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[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 = guzhangValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | // 查找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 = guzhangValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | 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); |
| | | }; |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | </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];
|
| | |
|
| | |
| | | <el-table-column :width="130" prop="cage" :label="$t('Cage No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="cell" :label="$t('Slot No')"></el-table-column>
|
| | | <el-table-column :width="180" prop="glassId" :label="$t('Outfeed glass barcode')"></el-table-column>
|
| | | <el-table-column :width="130" prop="orderId"
|
| | | :label="$t('Order No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="orderId" :label="$t('Order No')"></el-table-column>
|
| | | <el-table-column prop="orderId" :label="$t('List No')"></el-table-column>
|
| | | <el-table-column prop="orderId" :label="$t('Box No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="lengthWidth" :label="$t('Dim')">
|
| | |
| | | <el-table-column :width="130" prop="cage" :label="$t('Cage No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="cell" :label="$t('Slot No')"></el-table-column>
|
| | | <el-table-column :width="180" prop="glassId" :label="$t('Infeed glass barcode')"></el-table-column>
|
| | | <el-table-column :width="130" prop="orderId"
|
| | | :label="$t('Order No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="orderId" :label="$t('Order No')"></el-table-column>
|
| | | <el-table-column prop="orderId" :label="$t('List No')"></el-table-column>
|
| | | <el-table-column prop="orderId" :label="$t('Box No')"></el-table-column>
|
| | | <el-table-column :width="130" prop="lengthWidth" :label="$t('Dim')">
|
| | |
| | | <el-table-column :width="55" prop="tier" :label="$t('The Side')"></el-table-column>
|
| | | <el-table-column :width="145" prop="glassId" :label="$t('Barcode')"></el-table-column>
|
| | | <el-table-column :width="100" prop="orderId" :label="$t('Order No')"></el-table-column>
|
| | | <el-table-column :width="80" prop="listId"
|
| | | :label="$t('List No')"></el-table-column>
|
| | | <el-table-column :width="80" prop="listId" :label="$t('List No')"></el-table-column>
|
| | | <el-table-column :width="100" prop="boxId" :label="$t('Box No')"></el-table-column>
|
| | | <el-table-column :width="100" prop="state" :label="$t('State')">
|
| | | <template slot-scope='scope'>
|
| | | {{ scope.row.state==1?$t('Normal'):scope.row.state==2?$t('Entering'):scope.row.state==3?$t('Outing'):"" }}
|
| | | {{
|
| | | scope.row.state == 1 ? $t('Normal') : scope.row.state == 2 ? $t('Entering') : scope.row.state == 3 ? $t('Outing') : ""
|
| | | }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column :width="150" prop="lengthWidth" :label="$t('Dim')">
|
| | | <template slot-scope='scope'>
|
| | | {{ scope.row.glassWidthMm }}{{scope.row.glassWidthMm>0?"*":""}}{{ scope.row.glassHeightMm }}
|
| | | {{ scope.row.glassWidthMm }}{{ scope.row.glassWidthMm > 0 ? "*" : "" }}{{ scope.row.glassHeightMm }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column :width="280" :label="$t('Operate')">
|
| | | <template slot-scope='scope'>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | @click="deleteglass(scope.row.glassId, scope.row.state)">{{ $t('Delete') }}</el-button>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" :disabled="scope.row.state==1?false:true"
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | :disabled="scope.row.state == 1 ? false : true"
|
| | | @click="outglass(scope.row.glassId, scope.row.state)">{{ $t('Out') }}</el-button>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | @click="UpdateDisabled(scope.row.cage, scope.row.cell, scope.row.disabled == 0 ? 1 : 0)">
|
| | | {{ scope.row.disabled == 0 ? $t('Enable') : $t('Disable') }}</el-button>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" :disabled="scope.row.glassId!=null?true:false"
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | :disabled="scope.row.glassId != null ? true : false"
|
| | | @click="insertglass(scope.row.cage, scope.row.cell, scope.row.tier)">{{ $t('Increase')
|
| | | }}</el-button>
|
| | | </template>
|
| | |
| | | <el-form-item>
|
| | | <el-input style="width:50%;margin-left: 20%;" :placeholder="$t('Enter the glass barcode')"
|
| | | v-model="glassid2"></el-input>
|
| | | <el-button type="primary" @click="SelectGlassByGlassIDs(1)" >{{ $t('Query')
|
| | | <el-button type="primary" @click="SelectGlassByGlassIDs(1)">{{ $t('Query')
|
| | | }}</el-button>
|
| | | </el-form-item>
|
| | | <el-form-item>
|
| | | <el-input style="width:50%;margin-left: 20%;" :placeholder="$t('Enter the glass barcode')"
|
| | | v-model="glassid1"></el-input>
|
| | | <el-button type="primary" @click="SelectGlassByGlassIDs(2)" >{{ $t('Query')
|
| | | <el-button type="primary" @click="SelectGlassByGlassIDs(2)">{{ $t('Query')
|
| | | }}</el-button>
|
| | | </el-form-item>
|
| | | </div>
|
| | |
| | | </el-form-item>
|
| | | </div>
|
| | | <div style="display: flex;justify-content: space-around;">
|
| | | <el-button @click="DeleteQueueGlasss(2)" type="primary" >{{ $t('Clear Current')
|
| | | <el-button @click="DeleteQueueGlasss(2)" type="primary">{{ $t('Clear Current')
|
| | | }}</el-button>
|
| | | <el-button @click="InsertQueueGlass(2)" type="primary" :disabled="disabled">
|
| | | {{ $t('Confirm Modification') }}</el-button>
|
| | | <el-button @click="DeleteQueueGlasss(1)" type="primary" >{{ $t('Clear Current')
|
| | | <el-button @click="DeleteQueueGlasss(1)" type="primary">{{ $t('Clear Current')
|
| | | }}</el-button>
|
| | | <el-button @click="InsertQueueGlass(1)" type="primary" :disabled="disabled1">
|
| | | {{ $t('Confirm Modification') }}</el-button>
|
| | |
| | |
|
| | | <el-dialog :visible.sync="dialogFormVisible6" :title="$t('Production queue')" top="5vh">
|
| | | <el-button type="primary" @click="showform7()">{{ $t('Increase') }}</el-button>
|
| | | <el-button type="primary" @click="isAllowQueueState()">{{ this.isAllowQueue==true?$t('Stop'):$t('Start') }}</el-button>
|
| | | |
| | | <el-button type="primary" @click="isAllowQueueState()">{{ this.isAllowQueue == true ? $t('Stop') : $t('Start')
|
| | | }}</el-button>
|
| | |
|
| | | <el-table :data="this.OutSlice" :height="700" border style="width: 100%;overflow: auto;">
|
| | | <el-table-column prop="glassId" :label="$t('Barcode')"></el-table-column>
|
| | | <el-table-column prop="storageCage.orderId" :label="$t('Order No')"></el-table-column>
|
| | |
| | | OutSlice: [],
|
| | | AluminumFrame: [],
|
| | | framebarcode: "",
|
| | | isAllowQueue:true
|
| | | isAllowQueue: true
|
| | | };
|
| | | },
|
| | | created() {
|
| | |
| | | this.tasklist2 = obj.tasklist2[0];
|
| | | this.alarm = obj.alarmmg[0];
|
| | |
|
| | | this.isAllowQueue=obj.isAllowQueue;
|
| | | console.log(obj);
|
| | | this.isAllowQueue = obj.isAllowQueue;
|
| | | //出片队列
|
| | | this.OutSlice = obj.listoutslice[0];
|
| | | this.loadglassheight = obj.loadglassheight;
|
| | |
| | | SelectGlassByGlassID(this.glassid).then(res => {
|
| | | if (res.data.form != null) {
|
| | | this.form = res.data.form;
|
| | | console.log(this.form);
|
| | | this.dialogFormVisible = true;
|
| | | this.$message.success(this.$t('query was successful'));
|
| | | } else {
|
| | |
| | | showform7() {
|
| | | SelectAluminumFrameInfoById(this.framebarcode).then(res => {
|
| | | this.AluminumFrame = res.data.listAluminumFrame;
|
| | | this.AluminumFrame.sort(function (x, y) {
|
| | | if(x['storageCage']!=null&&y['storageCage']!=null){
|
| | | return y['storageCage']['tier'] - x['storageCage']['tier'];
|
| | | }
|
| | | });
|
| | | this.AluminumFrame.forEach(item => {
|
| | | if (item.storageCage != null && item.out_slice == null) {
|
| | | item.isCheck = true;
|
| | |
| | | InsertQueueGlass(parameter) {
|
| | | if (parameter == 1 && this.form5.glassId != "") {
|
| | | if (this.form5.glassId != this.form2.glassId) {
|
| | | InsertQueueGlassId(1,this.form5).then(res => {
|
| | | InsertQueueGlassId(1, this.form5).then(res => {
|
| | | if (res.data.message == 200) {
|
| | | this.form5 = {};
|
| | | this.$message.success(this.$t('Operation successful'));
|
| | |
| | | }
|
| | | } else if (parameter == 2 && this.form4.glassId != "") {
|
| | | if (this.form4.glassId != this.form3.glassId) {
|
| | | InsertQueueGlassId(2,this.form4).then(res => {
|
| | | InsertQueueGlassId(2, this.form4).then(res => {
|
| | | if (res.data.message == 200) {
|
| | | this.form4 = {};
|
| | | this.$message.success(this.$t('Operation successful'));
|
| | |
| | | arr.splice(index, 1, ...arr.splice(index + 1, 1, arr[index]));
|
| | | },
|
| | | //切换出片队列状态
|
| | | isAllowQueueState(){
|
| | | isAllowQueues(!this.isAllowQueue).then(res=>{
|
| | | isAllowQueueState() {
|
| | | isAllowQueues(!this.isAllowQueue).then(res => {
|
| | | if (res.data.message == 200) {
|
| | | this.$message.success(this.$t('Operation successful'));
|
| | | }
|
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);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | 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); |
| | | |
| | |
| | | addresses.add("DB100.20"); |
| | | addresses.add("DB103.52"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // System.out.println(arraylist); |
| | | // System.out.println(arraylist); |
| | | |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("DB100.110"); |
| | |
| | | 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<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | 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 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] fanzhuan = { 4 }; |
| | |
| | | // new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0} |
| | | |
| | | jsonObject.append("params", arraylist); |
| | | jsonObject.append("fanzhuan", fanzhuan1); |
| | | jsonObject.append("xiaoche", xiaoche1); |
| | | jsonObject.append("fanzhuan", fanzhuan1); |
| | | jsonObject.append("xiaoche", xiaoche1); |
| | | |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | if (sendwServer != null) { |
| | |
| | | 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}; |
| | | // List<Boolean> paramlist = new ArrayList<>(Arrays.asList(values)); |
| | | // Short[] values1 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| | | // List<Short> data = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] values2 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| | | // List<Short> data2 = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] values3 = { 11}; |
| | | // List<Short> data3 = new ArrayList<>(Arrays.asList(values3)); |
| | | // Short[] values4 = { 2,2,3,4}; |
| | | // List<Short> data4 = new ArrayList<>(Arrays.asList(values4)); |
| | | |
| | | // Boolean[] values = { false, true, true, true, true, true, true, true, true, |
| | | // true}; |
| | | // List<Boolean> paramlist = new ArrayList<>(Arrays.asList(values)); |
| | | // Short[] values1 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| | | // List<Short> data = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] values2 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| | | // List<Short> data2 = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] values3 = { 11}; |
| | | // List<Short> data3 = new ArrayList<>(Arrays.asList(values3)); |
| | | // 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) { |
| | |
| | | messageValues.add(value); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为整数类型,则忽略该部分 |
| | | // e.printStackTrace(); |
| | | // e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 将布尔列表写入 PLC |
| | | S7control.getinstance().WriteBit(addressList, messageBooleans); |
| | | S7control.getinstance().WriteBit(addressList, messageBooleans); |
| | | System.out.println("messageValues:" + messageBooleans); |
| | | System.out.println("addressList:" + addressList); |
| | | // 清空消息列表 |
| | |
| | | import org.apache.commons.io.FileUtils;
|
| | |
|
| | | public class PlcPositioning1 extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | | 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("Positioning1");
|
| | | for (int i = 0; i < address.size(); i++) {
|
| | | JSONObject ress = (JSONObject) address.get(i);
|
| | |
|
| | | this.name = ress.getStr("name");
|
| | | this.count = ress.getInt("count");
|
| | | System.out.println("messageValues:" + this.name);
|
| | | System.out.println("messageValues:" + this.count);
|
| | | }
|
| | |
|
| | | } catch (FileNotFoundException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | public static String readFileToString(String filePath) throws IOException {
|
| | | File file = new File(filePath);
|
| | | return FileUtils.readFileToString(file, "UTF-8");
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // System.out.println(stt);
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 23);
|
| | |
|
| | | // 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 };
|
| | | // 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) {
|
| | | sendwServer.sendMessage(jsonObject.toString());
|
| | | }
|
| | |
|
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Positioning1");
|
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | String addressList3 = "DB100.12";
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | |
|
| | | // 整合第 1 到 3 个数组并去掉 null 元素
|
| | | List<Short> mergedList = new ArrayList<>();
|
| | | for (int i = 0; i < 5; i++) {
|
| | | JSONArray sublist = messageArray.getJSONArray(i);
|
| | | for (int j = 0; j < sublist.size(); j++) {
|
| | | Object value = sublist.get(j);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short sValue = Short.parseShort(cleanedValue.trim());
|
| | | mergedList.add(sValue);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入第yi个地址
|
| | | if (!mergedList.isEmpty()) {
|
| | | // S7control.getinstance().WriteWord(addressList3, mergedList);
|
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList3);
|
| | | }
|
| | | // 将str字符串格式转为json
|
| | | JSONObject jsonObject = new JSONObject(str);
|
| | |
|
| | | // 清空消息列表
|
| | | webSocketServer.clearMessages();
|
| | | // 获取json中的值
|
| | | JSONArray address = jsonObject.getJSONArray("Positioning1");
|
| | | for (int i = 0; i < address.size(); i++) {
|
| | | JSONObject ress = (JSONObject) address.get(i);
|
| | |
|
| | | this.name = ress.getStr("name");
|
| | | this.count = ress.getInt("count");
|
| | | System.out.println("messageValues:" + this.name);
|
| | | System.out.println("messageValues:" + this.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(1000);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // 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 };
|
| | | // 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) {
|
| | | sendwServer.sendMessage(jsonObject.toString());
|
| | | }
|
| | |
|
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Positioning1");
|
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | String addressList3 = "DB100.42";
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | |
|
| | | // 整合第 1 到 3 个数组并去掉 null 元素
|
| | | List<Short> mergedList = new ArrayList<>();
|
| | | for (int i = 0; i < 5; i++) {
|
| | | JSONArray sublist = messageArray.getJSONArray(i);
|
| | | for (int j = 0; j < sublist.size(); j++) {
|
| | | Object value = sublist.get(j);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short sValue = Short.parseShort(cleanedValue.trim());
|
| | | mergedList.add(sValue);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | // 写入第yi个地址
|
| | | if (!mergedList.isEmpty()) {
|
| | | 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<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("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; |
| | | // } |
| | | |
| | | 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); |
| | | 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)); |
| | | |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB103.46"); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | 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)); |
| | | |
| | | 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> 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); |
| | | |
| | | // 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); |
| | | 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); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | |
| | | |
| | | |
| | | // 写入第一个地址 |
| | | if (messageArray.getJSONArray(0).size() > 0) { |
| | |
| | | } |
| | | } |
| | | if (!sValue.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses1, sValue); |
| | | S7control.getinstance().WriteWord(waddresses1, sValue); |
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1); |
| | | } |
| | | } |
| | | |
| | | 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 (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses2, sValue2); |
| | | S7control.getinstance().WriteWord(waddresses2, sValue2); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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(); |
| | | } |
| | |
| | | package com.example.springboot.component; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | public class Plcaction extends Thread { |
| | | String name = ""; |
| | | Integer count = 0; |
| | | |
| | | public void readValue() { |
| | | String str = ""; |
| | | BufferedReader bufferedReader = null; |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/Action.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(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 调用方法,进行赋值 |
| | | 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)); |
| | | |
| | | if (paramlist != null) { |
| | | |
| | | short[] params = new short[paramlist.size()]; |
| | | |
| | | for (int i = 0; i < paramlist.size(); i++) { |
| | | boolean value = paramlist.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.append("params", params); |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("action"); |
| | | if (sendwServer != null) { |
| | | sendwServer.sendMessage(jsonObject.toString()); |
| | | } |
| | | } |
| | | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("action"); |
| | | if (webSocketServer != null) { |
| | | |
| | | List<String> messages = webSocketServer.getMessages(); |
| | | |
| | | String addressList = "DB2.0.0"; |
| | | |
| | | 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); |
| | | } |
| | | |
| | | // 将布尔列表写入 PLC |
| | | S7control.getinstance().WriteBit(addressList, messageBooleans); |
| | | System.out.println("messageValues:" + messageBooleans); |
| | | System.out.println("addressList:" + addressList); |
| | | // 清空消息列表 |
| | | webSocketServer.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONArray;
|
| | | import cn.hutool.json.JSONObject;
|
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStreamReader;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.List;
|
| | |
|
| | | public class Plcaction extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | |
|
| | | public void readValue() {
|
| | | String str = "";
|
| | | BufferedReader bufferedReader = null;
|
| | | FileInputStream fileInputStream;
|
| | | try {
|
| | | // 从文件中读取字节数据存入 fileInputStream
|
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/Action.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(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 调用方法,进行赋值
|
| | | // 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));
|
| | |
|
| | | if (paramlist != null) {
|
| | |
|
| | | short[] params = new short[paramlist.size()];
|
| | |
|
| | | for (int i = 0; i < paramlist.size(); i++) {
|
| | | boolean value = paramlist.get(i);
|
| | | params[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | jsonObject.append("params", params);
|
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("action");
|
| | | if (sendwServer != null) {
|
| | | sendwServer.sendMessage(jsonObject.toString());
|
| | | }
|
| | | }
|
| | |
|
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("action");
|
| | | if (webSocketServer != null) {
|
| | |
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | String addressList = "DB2.0.0";
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | | // 将布尔列表写入 PLC
|
| | | S7control.getinstance().WriteBit(addressList, messageBooleans);
|
| | | System.out.println("messageValues:" + messageBooleans);
|
| | | System.out.println("addressList:" + addressList);
|
| | | // 清空消息列表
|
| | | webSocketServer.clearMessages();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | 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, |
| | | // true, false, true, false, true, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, |
| | | // false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, null, |
| | | // true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | // Boolean[] values = { true, true, true, true, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, |
| | | // false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, null, |
| | | // true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | |
| | | if (plclist != null) { |
| | | // 将获取的布尔类型转换为整数类型 |
| | |
| | | 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) |
| | |
| | | |
| | | new PlcHold().start(); |
| | | |
| | | // new Plcaction().start(); |
| | | new Plcaction().start(); |
| | | // |
| | | new Plchome().start(); |
| | | // |
| | | // new PlcParameter().start(); |
| | | |
| | | // new Plcalarm().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 PlcParameter().start(); |
| | | // |
| | | //new Plcalarm().start(); |
| | | // |
| | | new Plcsign().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(); |
| | | } |
| | | } |
| | |
| | | // 根据玻璃id查询玻璃信息 |
| | | @GetMapping("/SelectGlassByGlassID") |
| | | public Result SelectGlassByGlassID(String glassid) throws SQLException { |
| | | // north_glass_buffer1 north_glass_buffer1s = homeMapper.SelectGlassByGlassID(glassid); |
| | | Queue queue=jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdQueue(glassid, "", ""); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(glassid!=""){ |
| | |
| | | // 根据铝框id获取对应玻璃信息 |
| | | @PostMapping("/SelectAluminumFrameInfoById") |
| | | public Result SelectAluminumFrameInfoById(String FrameBarcode) throws SQLException { |
| | | List<north_glass_buffer1> listAluminumFrame = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIds("","",FrameBarcode); |
| | | List<north_glass_buffer1> listAluminumFrame = jdbcConnections.SelectGlassByGlassIdOrderIdFrameIdss(FrameBarcode); |
| | | String flip=jdbcConnections.SelectFlipByFrameBarcode(FrameBarcode); |
| | | for (north_glass_buffer1 north_glass_buffer1 : listAluminumFrame) { |
| | | north_glass_buffer1.setstorageCage(homeMapper.SelectStorageGlassById(north_glass_buffer1.getbarcode())); |
| | |
| | | return queue; |
| | | } |
| | | |
| | | |
| | | |
| | | //根据玻璃id,订单id,铝框id查询客户玻璃信息 |
| | | public List<north_glass_buffer1> SelectGlassByGlassIdOrderIdFrameIds(String glassid,String orderid,String frameid) throws SQLException { |
| | | conn = getConn(); |
| | | // north_glass_buffer1 glass=new north_glass_buffer1(); |
| | |
| | | return glass; |
| | | } |
| | | |
| | | |
| | | //根据铝框id查询客户玻璃信息 |
| | | public List<north_glass_buffer1> SelectGlassByGlassIdOrderIdFrameIdss(String frameid) throws SQLException { |
| | | conn = getConn(); |
| | | // north_glass_buffer1 glass=new north_glass_buffer1(); |
| | | List<north_glass_buffer1> glass=new ArrayList<north_glass_buffer1>(); |
| | | String sql = "select * from north_glass_buffer1 where FrameBarcode=?"; |
| | | ps = conn.prepareStatement(sql); |
| | | ps.setString(1, frameid); |
| | | rs= ps.executeQuery(); |
| | | while (rs.next()) { |
| | | north_glass_buffer1 north_glass_buffer1s=new north_glass_buffer1(); |
| | | |
| | | north_glass_buffer1s.setId(rs.getInt("Id")); |
| | | north_glass_buffer1s.setordernumber(rs.getString("ordernumber")); |
| | | north_glass_buffer1s.setlistnumber(rs.getString("listnumber")); |
| | | north_glass_buffer1s.setboxnumber(rs.getString("boxnumber")); |
| | | north_glass_buffer1s.setbarcode(rs.getString("barcode")); |
| | | north_glass_buffer1s.setglasslength(rs.getDouble("glasslength")); |
| | | north_glass_buffer1s.setglassheight(rs.getDouble("glassheight")); |
| | | north_glass_buffer1s.setglasslengthmm(rs.getDouble("glasslength_mm")); |
| | | north_glass_buffer1s.setglassheightmm(rs.getDouble("glassheight_mm")); |
| | | north_glass_buffer1s.setitemtype(rs.getString("itemtype")); |
| | | north_glass_buffer1s.setslotnumber(rs.getString("slotnumber")); |
| | | north_glass_buffer1s.setdatemodified(rs.getString("datemodified")); |
| | | north_glass_buffer1s.setdatecreated(rs.getString("datecreated")); |
| | | north_glass_buffer1s.setFrameBarcode(rs.getString("FrameBarcode")); |
| | | |
| | | |
| | | glass.add(north_glass_buffer1s); |
| | | |
| | | } |
| | | // conn.close(); |
| | | return glass; |
| | | } |
| | | |
| | | //根据铝框id查询是否翻转 |
| | | public String SelectFlipByFrameBarcode(String frameBarcode) throws SQLException { |
| | | conn = getConn(); |
| | | // north_glass_buffer1 glass=new north_glass_buffer1(); |
| | |
| | | // 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); |
| | | // } |
| | | // } |