Commit 7d7496aa authored by wanghao's avatar wanghao

1 调试

parent afcc9713
...@@ -71,6 +71,24 @@ public class RobotArmCommandController extends BaseController ...@@ -71,6 +71,24 @@ public class RobotArmCommandController extends BaseController
return toAjax(robotArmCommandService.insertBlankingRobotArmCommand(robotArmCommand)); return toAjax(robotArmCommandService.insertBlankingRobotArmCommand(robotArmCommand));
} }
/**
* 发送归位指令
*/
@GetMapping("/sendHomeCommand")
public AjaxResult sendHomeCommand() {
robotArmCommandService.sendHomeCommand();
return AjaxResult.success("发送成功");
}
/**
* 停止当前指令
*/
@GetMapping("/sendStopCommand")
public AjaxResult sendStopCommand() {
robotArmCommandService.sendStopCommand();
return AjaxResult.success("发送成功");
}
/** /**
* 新增机械臂指令 * 新增机械臂指令
*/ */
......
...@@ -66,6 +66,10 @@ public interface IRobotArmCommandService ...@@ -66,6 +66,10 @@ public interface IRobotArmCommandService
void completeCommand(Long commandId); void completeCommand(Long commandId);
void sendHomeCommand();
void sendStopCommand();
void markCommandTimeout(Long commandId); void markCommandTimeout(Long commandId);
public void processPendingCommands(); public void processPendingCommands();
} }
...@@ -133,6 +133,30 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService ...@@ -133,6 +133,30 @@ public class RobotArmCommandServiceImpl implements IRobotArmCommandService
nettyUdpServerHandler.registerCommandExecution(address, command.getRobotArmCommandId()); nettyUdpServerHandler.registerCommandExecution(address, command.getRobotArmCommandId());
} }
/**
* 发送归位指令
*/
@Override
public void sendHomeCommand() {
// 发送UDP指令
SocketAddress address = getRobotAddress();
udpCommandSender.sendCommandWithId(
address,
"HOME"
);
}
@Override
public void sendStopCommand() {
// 发送UDP指令
SocketAddress address = getRobotAddress();
udpCommandSender.sendCommandWithId(
address,
"STOP"
);
}
@Override @Override
@Transactional @Transactional
public void completeCommand(Long commandId) { public void completeCommand(Long commandId) {
......
...@@ -35,6 +35,23 @@ export function insertBlankingRobotArmCommand(data) { ...@@ -35,6 +35,23 @@ export function insertBlankingRobotArmCommand(data) {
}) })
} }
// 发送归位指令
export function sendHomeCommand() {
return request({
url: '/robotArm/command/sendHomeCommand',
method: 'get'
})
}
// 停止当前指令
export function sendStopCommand() {
return request({
url: '/robotArm/command/sendStopCommand',
method: 'get'
})
}
// 执行上电操作 // 执行上电操作
export function powerOnCommand(commandId) { export function powerOnCommand(commandId) {
......
...@@ -107,7 +107,7 @@ export default { ...@@ -107,7 +107,7 @@ export default {
// 初始化WebSocket连接 // 初始化WebSocket连接
initWebSocket() { initWebSocket() {
// 根据当前页面协议选择ws/wss // 根据当前页面协议选择ws/wss
const backendUrl = process.env.VUE_APP_API_BASE_URL || 'http://localhost:8080'; const backendUrl = process.env.VUE_APP_API_BASE_URL || 'http://localhost:8087';
const wsUrl = backendUrl.replace('http', 'ws') + '/ws-aging-cabinet'; const wsUrl = backendUrl.replace('http', 'ws') + '/ws-aging-cabinet';
this.ws = new WebSocket(wsUrl); this.ws = new WebSocket(wsUrl);
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
<button class="add-button" @click="showAddDialog = true"> <button class="add-button" @click="showAddDialog = true">
<i class="el-icon-plus"></i> 上料 <i class="el-icon-plus"></i> 上料
</button> </button>
<button class="home-button" @click="handleHome">
<i class="el-icon-refresh"></i> 回零
</button>
<button class="stop-button" @click="handleStop">
<i class="el-icon-circle-close"></i> 停止
</button>
</div> </div>
</div> </div>
...@@ -146,7 +152,7 @@ ...@@ -146,7 +152,7 @@
<script> <script>
import {addCommand,powerOnCommand} from "@/api/robotArm/robotArmCommand" import {addCommand,powerOnCommand,sendHomeCommand,sendStopCommand} from "@/api/robotArm/robotArmCommand"
export default { export default {
name: 'RoboticArm', name: 'RoboticArm',
...@@ -202,7 +208,7 @@ export default { ...@@ -202,7 +208,7 @@ export default {
}, },
methods: { methods: {
initWebSocket() { initWebSocket() {
const backendUrl = process.env.VUE_APP_API_BASE_URL || 'http://localhost:8080'; const backendUrl = process.env.VUE_APP_API_BASE_URL || 'http://localhost:8087';
const wsUrl = backendUrl.replace('http', 'ws') + '/ws-robot-arm'; const wsUrl = backendUrl.replace('http', 'ws') + '/ws-robot-arm';
try { try {
...@@ -291,6 +297,20 @@ export default { ...@@ -291,6 +297,20 @@ export default {
this.websocket = null; this.websocket = null;
}, },
// 回零
handleHome() {
sendHomeCommand().then( response => {
this.$message.success("已发送");
})
},
// 停止
handleStop() {
sendStopCommand().then( response => {
this.$message.success("已发送");
})
},
closeDialog() { closeDialog() {
this.showAddDialog = false; this.showAddDialog = false;
}, },
...@@ -471,7 +491,59 @@ export default { ...@@ -471,7 +491,59 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
} }
/* 回零按钮样式 */
.home-button {
background: linear-gradient(to right, #67C23A, #85ce61);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
display: flex;
align-items: center;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
transition: all 0.3s;
margin-left: 10px; /* 与其他按钮保持间距 */
}
.home-button:hover {
background: linear-gradient(to right, #85ce61, #67C23A);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
.home-button i {
margin-right: 5px;
}
/* 停止按钮样式 */
.stop-button {
background: linear-gradient(to right, #F56C6C, #f78989);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
font-weight: bold;
display: flex;
align-items: center;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
transition: all 0.3s;
margin-left: 10px; /* 与其他按钮保持间距 */
}
.stop-button:hover {
background: linear-gradient(to right, #f78989, #F56C6C);
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}
.stop-button i {
margin-right: 5px;
}
.add-button { .add-button {
background: linear-gradient(to right, #409EFF, #64c8ff); background: linear-gradient(to right, #409EFF, #64c8ff);
color: white; color: white;
......
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