Commit ee9a8ec3 authored by wanghao's avatar wanghao

1 设置 直接 发下料指令

2 增加 接受 标定的 udp 消息的方法,
parent ae08d61e
...@@ -96,6 +96,14 @@ public class TStoreyInfoController extends BaseController ...@@ -96,6 +96,14 @@ public class TStoreyInfoController extends BaseController
return tStoreyInfoService.handleBlanking(command); 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: ...@@ -26,7 +26,7 @@ spring:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: dev active: test
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:
......
...@@ -97,10 +97,54 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -97,10 +97,54 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
// 记录最后活动时间 // 记录最后活动时间
lastActivityTime = System.currentTimeMillis(); lastActivityTime = System.currentTimeMillis();
// 判断消息类型并进行相应处理
if (correctMessage.startsWith("calibration")) {
// 处理校准消息
handleCalibrationMessage(ctx, packet, correctMessage);
} else {
// 处理普通状态消息(原有逻辑)
handleNormalMessage(ctx, packet, correctMessage);
}
// // 解析消息
// 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);
// 出现异常时发送故障状态
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.RobotArmStatus status =
RobotArmMessageParser.parseMessage(correctMessage); RobotArmMessageParser.parseMessage(message);
if (status != null) { if (status != null) {
// 处理状态消息 // 处理状态消息
...@@ -111,20 +155,28 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP ...@@ -111,20 +155,28 @@ public class NettyUdpServerHandler extends SimpleChannelInboundHandler<DatagramP
handleFullyIdleState(); 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); byte[] responseBytes = response.getBytes(StandardCharsets.UTF_8);
ctx.writeAndFlush(new DatagramPacket( ctx.writeAndFlush(new DatagramPacket(
io.netty.buffer.Unpooled.copiedBuffer(responseBytes), io.netty.buffer.Unpooled.copiedBuffer(responseBytes),
packet.sender())); packet.sender()));
} catch (Exception e) { // TODO: 添加具体的校准业务逻辑
log.error("处理UDP消息异常", e); // 例如:更新校准状态、保存校准数据、通知前端等
// 出现异常时发送故障状态
sendStatusToWebSocket("error");
}
} }
/** /**
* 仅处理已完成的指令 * 仅处理已完成的指令
*/ */
......
...@@ -60,6 +60,8 @@ public interface ITStoreyInfoService ...@@ -60,6 +60,8 @@ public interface ITStoreyInfoService
public AjaxResult handleBlanking(String command); public AjaxResult handleBlanking(String command);
public AjaxResult handleDirectBlanking(String command);
/** /**
* 新增老化层信息 * 新增老化层信息
* *
......
...@@ -548,6 +548,18 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -548,6 +548,18 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 批量处理
* @param command c
* @return r
*/
@Override
public AjaxResult handleDirectBlanking(String command) {
// 发送UDP指令
robotArmCommandService.sendCommand(command);
return AjaxResult.success();
}
/** /**
* 发送下料指令 * 发送下料指令
* @return r * @return r
......
...@@ -90,6 +90,13 @@ export function blanking(command) { ...@@ -90,6 +90,13 @@ export function blanking(command) {
}) })
} }
export function directBlanking(command) {
return request({
url: '/storey/handleDirectBlanking/' + command,
method: 'get'
})
}
export function batchReadingCabinetStatus(fEquipmentCode) { export function batchReadingCabinetStatus(fEquipmentCode) {
return request({ return request({
url: '/storey/batchReadingCabinetStatus/' + fEquipmentCode, url: '/storey/batchReadingCabinetStatus/' + fEquipmentCode,
......
...@@ -128,13 +128,11 @@ ...@@ -128,13 +128,11 @@
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete"
@click="handlePowerOn(scope.row)" @click="handlePowerOn(scope.row)"
>上电</el-button> >上电</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete"
@click="handlePowerOutage(scope.row)" @click="handlePowerOutage(scope.row)"
>断电</el-button> >断电</el-button>
...@@ -147,9 +145,13 @@ ...@@ -147,9 +145,13 @@
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete"
@click="handleBlanking(scope.row)" @click="handleBlanking(scope.row)"
>下料</el-button> >生成下料命令</el-button>
<el-button
size="mini"
type="text"
@click="handleDirectBlanking(scope.row)"
>直接下料</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -211,9 +213,11 @@ ...@@ -211,9 +213,11 @@
</template> </template>
<script> <script>
import { listStorey, getStorey, delStorey, addStorey, updateStorey, import {
exportStorey,PowerOn,PowerOutage , listStorey, getStorey, delStorey, addStorey, updateStorey,
feeding, blanking} from "@/api/storey/storey"; exportStorey, PowerOn, PowerOutage,
feeding, blanking, directBlanking
} from "@/api/storey/storey";
import {sendHomeCommand, sendStopCommand} from "@/api/robotArm/robotArmCommand"; import {sendHomeCommand, sendStopCommand} from "@/api/robotArm/robotArmCommand";
export default { export default {
...@@ -391,6 +395,21 @@ export default { ...@@ -391,6 +395,21 @@ export default {
this.msgSuccess("上电成功"); this.msgSuccess("上电成功");
}).catch(() => {}); }).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) { handleBlanking(row) {
const fIp = row.fIp; 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