超威fix
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -100,21 +101,22 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] arr = new int[count];
|
int[] arrAll = new int[count];
|
||||||
StringBuffer bs = new StringBuffer();
|
StringBuffer bs = new StringBuffer();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
int temp = b[i];
|
int temp = b[i];
|
||||||
if (temp < 0)
|
if (temp < 0)
|
||||||
temp += 256;
|
temp += 256;
|
||||||
arr[i] = temp;
|
arrAll[i] = temp;
|
||||||
StringBuffer bs1 = new StringBuffer("0");
|
StringBuffer bs1 = new StringBuffer("0");
|
||||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.out.println("收到请求参数:" + bs);
|
int chunkSize = 28;
|
||||||
boolean flag = false;
|
List<int[]> chunks = this.splitArray(arrAll, chunkSize);
|
||||||
log.info("接收agv上报信息:" + bs);
|
for (int i = 0; i < chunks.size(); i++) {
|
||||||
|
int[] arr = chunks.get(i);
|
||||||
if (arr[8] * 256 + arr[9] == 0x73) {
|
if (arr[8] * 256 + arr[9] == 0x73) {
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
//执行阶段
|
//执行阶段
|
||||||
@@ -195,7 +197,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
} //进入区域
|
} //进入区域
|
||||||
else if (phase == 0x50) {
|
else if (phase == 0x50) {
|
||||||
//开门
|
//开门
|
||||||
if (device!=null&&device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
if (device != null && device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||||
standardAutodoorDeviceDriver.OpenOrClose("1");
|
standardAutodoorDeviceDriver.OpenOrClose("1");
|
||||||
if (standardAutodoorDeviceDriver.getAction() == 1) {
|
if (standardAutodoorDeviceDriver.getAction() == 1) {
|
||||||
@@ -207,7 +209,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
//离开区域
|
//离开区域
|
||||||
else if (phase == 0x51) {
|
else if (phase == 0x51) {
|
||||||
//关门
|
//关门
|
||||||
if (device!=null&&device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
if (device != null && device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||||
standardAutodoorDeviceDriver.OpenOrClose("2");
|
standardAutodoorDeviceDriver.OpenOrClose("2");
|
||||||
if (standardAutodoorDeviceDriver.getAction() == 2) {
|
if (standardAutodoorDeviceDriver.getAction() == 2) {
|
||||||
@@ -216,7 +218,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
}
|
}
|
||||||
//任务删除确认
|
//任务删除确认
|
||||||
//(需要WCS反馈)
|
//(需要WCS反馈)
|
||||||
}else if (phase == 0xFF) {
|
} else if (phase == 0xFF) {
|
||||||
|
|
||||||
if (!ObjectUtil.isEmpty(inst)) {
|
if (!ObjectUtil.isEmpty(inst)) {
|
||||||
if (!ObjectUtil.isEmpty(inst)) {
|
if (!ObjectUtil.isEmpty(inst)) {
|
||||||
@@ -245,11 +247,11 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
if (!ObjectUtil.isEmpty(data)) {
|
if (!ObjectUtil.isEmpty(data)) {
|
||||||
write(data);
|
write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.info("agv上报不是0073类型动作,不处理");
|
log.info("agv上报不是0073类型动作,不处理");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("OneAgv链接异常");
|
System.out.println("OneAgv链接异常");
|
||||||
@@ -301,5 +303,22 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<int[]> splitArray(int[] array, int chunkSize) {
|
||||||
|
List<int[]> resultList = new ArrayList<>();
|
||||||
|
int length = array.length;
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i += chunkSize) {
|
||||||
|
// 计算当前子数组的大小
|
||||||
|
int currentChunkSize = Math.min(chunkSize, length - i);
|
||||||
|
|
||||||
|
// 创建并填充新的子数组
|
||||||
|
int[] chunk = new int[currentChunkSize];
|
||||||
|
System.arraycopy(array, i, chunk, 0, currentChunkSize);
|
||||||
|
resultList.add(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public abstract class AbstractTask {
|
|||||||
* @param param
|
* @param param
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public void apply(JSONObject param) throws BadRequestException {
|
public synchronized void apply(JSONObject param) throws BadRequestException {
|
||||||
// 申请任务
|
// 申请任务
|
||||||
SchBaseTask task = new SchBaseTask(); // 任务实体
|
SchBaseTask task = new SchBaseTask(); // 任务实体
|
||||||
String apply_point_code = param.getString("device_code"); // 请求点
|
String apply_point_code = param.getString("device_code"); // 请求点
|
||||||
|
|||||||
Reference in New Issue
Block a user