Commit ee9a8ec3 authored by wanghao's avatar wanghao

1 设置 直接 发下料指令

2 增加 接受 标定的 udp 消息的方法,
parent ae08d61e
......@@ -96,6 +96,14 @@ public class TStoreyInfoController extends BaseController
return tStoreyInfoService.handleBlanking(command);
}
/**
* 处理直接消 blanking
*/
@GetMapping(value = "/handleDirectBlanking/{command}")
public AjaxResult handleDirectBlanking(@PathVariable("command") String command) {
return tStoreyInfoService.handleDirectBlanking(command);
}
/**
* 批量读取老化柜状态
*/
......
......@@ -26,7 +26,7 @@ spring:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: dev
active: test
# 文件上传
servlet:
multipart:
......
......@@ -97,26 +97,33 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
// 记录最后活动时间
lastActivityTime = System.currentTimeMillis();
// 解析消息
RobotArmMessageParser.RobotArmStatus status =
RobotArmMessageParser.parseMessage(correctMessage);
if (status != null) {
// 处理状态消息
processStatusMessage(status);
// 检查是否为完全空闲状态
if (status.isFullyIdle()) {
handleFullyIdleState();
}
// 判断消息类型并进行相应处理
if (correctMessage.startsWith("calibration")) {
// 处理校准消息
handleCalibrationMessage(ctx, packet, correctMessage);
} else {
// 处理普通状态消息(原有逻辑)
handleNormalMessage(ctx, packet, correctMessage);
}
// 回复客户端
byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
ctx.writeAndFlush(new DatagramPacket(
io.netty.buffer.Unpooled.copiedBuffer(responseBytes),
packet.sender()));
// // 解析消息
// RobotArmMessageParser.RobotArmStatus status =
// RobotArmMessageParser.parseMessage(correctMessage);
//
// if (status != null) {
// // 处理状态消息
// processStatusMessage(status);
//
// // 检查是否为完全空闲状态
// if (status.isFullyIdle()) {
// handleFullyIdleState();
// }
// }
//
// // 回复客户端
// byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
// ctx.writeAndFlush(new DatagramPacket(
// io.netty.buffer.Unpooled.copiedBuffer(responseBytes),
// packet.sender()));
} catch (Exception e) {
log.error("处理UDP消息异常", e);
......@@ -124,7 +131,52 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
sendStatusToWebSocket("error");
}
}
/**
* 处理普通状态消息(原有逻辑)
*/
private void handleNormalMessage(ChannelHandlerContext ctx, DatagramPacket packet, String message) {
// 回复客户端
String response = "服务器已收到UDP消息:" + message;
byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
ctx.writeAndFlush(new DatagramPacket(
io.netty.buffer.Unpooled.copiedBuffer(responseBytes),
packet.sender()));
// 解析消息
RobotArmMessageParser.RobotArmStatus status =
RobotArmMessageParser.parseMessage(message);
if (status != null) {
// 处理状态消息
processStatusMessage(status);
// 检查是否为完全空闲状态
if (status.isFullyIdle()) {
handleFullyIdleState();
}
}
}
/**
* 处理校准消息
*/
private void handleCalibrationMessage(ChannelHandlerContext ctx, DatagramPacket packet, String message) {
// TODO: 实现校准消息的具体处理逻辑
log.info("收到校准消息: {}", message);
// 示例:解析校准数据
// String calibrationData = message.substring("calibration".length()).trim();
// 示例:回复校准确认
String response = "校准消息已接收";
byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
ctx.writeAndFlush(new DatagramPacket(
io.netty.buffer.Unpooled.copiedBuffer(responseBytes),
packet.sender()));
// TODO: 添加具体的校准业务逻辑
// 例如:更新校准状态、保存校准数据、通知前端等
}
/**
* 仅处理已完成的指令
*/
......
......@@ -60,6 +60,8 @@ public interface ITStoreyInfoService
public AjaxResult handleBlanking(String command);
public AjaxResult handleDirectBlanking(String command);
/**
* 新增老化层信息
*
......
......@@ -548,6 +548,18 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return AjaxResult.success();
}
/**
* 批量处理
* @param command c
* @return r
*/
@Override
public AjaxResult handleDirectBlanking(String command) {
// 发送UDP指令
robotArmCommandService.sendCommand(command);
return AjaxResult.success();
}
/**
* 发送下料指令
* @return r
......
......@@ -90,6 +90,13 @@ export function blanking(command) {
})
}
export function directBlanking(command) {
return request({
url: '/storey/handleDirectBlanking/' + command,
method: 'get'
})
}
export function batchReadingCabinetStatus(fEquipmentCode) {
return request({
url: '/storey/batchReadingCabinetStatus/' + fEquipmentCode,
......
......@@ -128,13 +128,11 @@
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handlePowerOn(scope.row)"
>上电</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handlePowerOutage(scope.row)"
>断电</el-button>
......@@ -147,9 +145,13 @@
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleBlanking(scope.row)"
>下料</el-button>
>生成下料命令</el-button>
<el-button
size="mini"
type="text"
@click="handleDirectBlanking(scope.row)"
>直接下料</el-button>
</template>
</el-table-column>
</el-table>
......@@ -211,9 +213,11 @@
</template>
<script>
import { listStorey, getStorey, delStorey, addStorey, updateStorey,
exportStorey,PowerOn,PowerOutage ,
feeding, blanking} from "@/api/storey/storey";
import {
listStorey, getStorey, delStorey, addStorey, updateStorey,
exportStorey, PowerOn, PowerOutage,
feeding, blanking, directBlanking
} from "@/api/storey/storey";
import {sendHomeCommand, sendStopCommand} from "@/api/robotArm/robotArmCommand";
export default {
......@@ -391,6 +395,21 @@ export default {
this.msgSuccess("上电成功");
}).catch(() => {});
},
// 直接下料
handleDirectBlanking(row){
const fIp = row.fIp;
this.$confirm('是否确认给设备IP为"' + fIp + '"的设备下料?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return directBlanking(row.blankingCommand);
}).then(() => {
this.getList();
this.msgSuccess("下料成功");
}).catch(() => {});
},
// 下料
handleBlanking(row) {
const fIp = row.fIp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment