From 892b13a55e27a950993f3d0fafb997be5360177d Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 11 八月 2020 14:25:38 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/DevpThread.java | 84 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/DevpThread.java b/src/main/java/com/zy/core/thread/DevpThread.java
index 030e98b..03f028f 100644
--- a/src/main/java/com/zy/core/thread/DevpThread.java
+++ b/src/main/java/com/zy/core/thread/DevpThread.java
@@ -1,8 +1,9 @@
package com.zy.core.thread;
-import com.zy.common.HslCommunication.Core.Types.OperateResult;
-import com.zy.common.HslCommunication.Profinet.Siemens.SiemensPLCS;
-import com.zy.common.HslCommunication.Profinet.Siemens.SiemensS7Net;
+import HslCommunication.Core.Types.OperateResult;
+import HslCommunication.Core.Types.OperateResultExOne;
+import HslCommunication.Profinet.Siemens.SiemensPLCS;
+import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.MessageQueue;
@@ -37,9 +38,27 @@
public void run() {
while (true) {
try {
+ int step = 1;
Task task = MessageQueue.poll(SlaveType.Devp, slave.getId());
if (task != null) {
- System.out.println("浠诲姟"+task.getId());
+ step = task.getStep();
+ }
+ switch (step) {
+ // 璇绘暟鎹�
+ case 1:
+ readWorkNo(); // 璇诲彇宸ヤ綔鍙�
+ readStaDest(); // 璇诲彇鐩爣绔�
+ readStatus(); // 璇诲彇鐘舵��
+ readError(); // 璇诲彇寮傚父淇℃伅
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ default:
+ break;
}
Thread.sleep(3000);
} catch (Exception e) {
@@ -53,6 +72,8 @@
public boolean connect() {
boolean result = false;
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
+ siemensS7Net.setRack((byte) 0);
+ siemensS7Net.setSlot((byte) 1);
OperateResult connect = siemensS7Net.ConnectServer();
if(connect.IsSuccess){
result = true;
@@ -64,6 +85,61 @@
return result;
}
+ /**
+ * 璇诲彇宸ヤ綔鍙�
+ */
+ private void readWorkNo(){
+ OperateResultExOne<int[]> read = siemensS7Net.ReadInt32("DB100", (short) 8);
+ if (read.IsSuccess) {
+ int staNo1 = read.Content[0];
+ int staNo2 = read.Content[1];
+ int staNo3 = read.Content[2];
+ int staNo4 = read.Content[3];
+ int staNo5 = read.Content[4];
+ int staNo6 = read.Content[5];
+ int staNo7 = read.Content[6];
+ int staNo8 = read.Content[7];
+ }
+ }
+
+ /**
+ * 璇诲彇鐩爣绔�
+ */
+ private void readStaDest(){
+ OperateResultExOne<byte[]> read = siemensS7Net.Read("DB101", (short) 8);
+ if (read.IsSuccess) {
+ int staNo1 = siemensS7Net.getByteTransform().TransInt32(read.Content, 0);
+ int staNo2 = siemensS7Net.getByteTransform().TransInt32(read.Content, 4);
+ int staNo3 = siemensS7Net.getByteTransform().TransInt32(read.Content, 8);
+ int staNo4 = siemensS7Net.getByteTransform().TransInt32(read.Content, 12);
+ int staNo5 = siemensS7Net.getByteTransform().TransInt32(read.Content, 16);
+ int staNo6 = siemensS7Net.getByteTransform().TransInt32(read.Content, 20);
+ int staNo7 = siemensS7Net.getByteTransform().TransInt32(read.Content, 24);
+ int staNo8 = siemensS7Net.getByteTransform().TransInt32(read.Content, 28);
+
+ }
+ }
+
+ /**
+ * 璇诲彇鐘舵��
+ */
+ private void readStatus(){
+
+ }
+
+ /**
+ * 璇诲彇寮傚父淇℃伅
+ */
+ private void readError(){
+
+ }
+
+ private void writeWorkNo(){
+
+
+
+ }
+
@Override
public void close() {
--
Gitblit v1.9.1