Browse Source

添加开始/结束接口

feature/debug
zhangjiming 5 months ago
parent
commit
3b4fdddcb3
  1. 48
      src/services/globalCmd/cmdTypes.ts
  2. 42
      src/services/globalCmd/globalCmd.ts
  3. 20
      src/views/SprayView.vue

48
src/services/globalCmd/cmdTypes.ts

@ -1,29 +1,29 @@
export type OperationCmd =
| "moveMotorToPosition" // 移动电机
export type OperationCmd = "moveMotorToPosition"; // 移动电机
export type ControlType = {
valveType: string,
isOpen: Boolean
}
valveType: string;
isOpen: Boolean;
};
export type SyringeType = {
rotationSpeed: string | number,
direction: string | number,
time: string | number,
}
rotationSpeed: string | number;
direction: string | number;
time: string | number;
};
type PositionType = {
x:string | number
y:string | number
}
type PositionListType = [PositionType]
export type workType = {
direction: string
space: string | number
nitrogenFlowVelocity : string | number
nitrogenAirPressure : string | number
matrixFlowVelocity : string | number
voltage : string | number
height : string | number
movementSpeed : string | number
position: PositionListType
}
x: number;
y: number;
};
type PositionListType = PositionType[];
export type WorkType = {
direction: 1 | 2;
space: number;
nitrogenFlowVelocity: number;
nitrogenAirPressure: number;
matrixFlowVelocity: number;
voltage: number;
needPower?: boolean;
height: number;
movementSpeed: number;
position: PositionListType;
};

42
src/services/globalCmd/globalCmd.ts

@ -1,48 +1,62 @@
import httpRequest, { type BaseResponse } from "../httpRequest";
import { addTxnRecord } from "../txn";
import type { OperationCmd, ControlType, SyringeType, workType } from "./cmdTypes";
import type { OperationCmd, ControlType, SyringeType, WorkType } from "./cmdTypes";
//移动电机
export function moveMotorToPosition(params: { commandName: string; params: Record<string, any> }) {
const commandId = addTxnRecord({ ...params, category: "debug" });
return httpRequest<BaseResponse<string>>({ url: "api/cmd/moveMotorToPosition", params: { ...params, commandId }, method: "POST" });
return httpRequest<BaseResponse<string>>({
url: "/api/cmd/moveMotorToPosition",
params: { ...params, commandId },
method: "POST",
});
}
//切换清洗管路
export function switchThreeWayValve(params: { type: string }) {
const commandId = addTxnRecord({ ...params, category: "debug" });
return httpRequest<BaseResponse<string>>({ url: "/cmd/switchThreeWayValve", params: { ...params, commandId }, method: "POST" });
return httpRequest<BaseResponse<string>>({
url: "/api/cmd/switchThreeWayValve",
params: { ...params, commandId },
method: "POST",
});
}
//氮气三路
export function controlValve(params:ControlType) {
export function controlValve(params: ControlType) {
const commandId = addTxnRecord({ ...params, category: "debug" });
return httpRequest<BaseResponse<string>>({ url: "/cmd/controlValve", params: { ...params, commandId }, method: "POST" });
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/controlValve", params: { ...params, commandId }, method: "POST" });
}
//电压控制 开启
export function turnOnHighVoltage(params:{voltage: string | number}) {
export function turnOnHighVoltage(params: { voltage: string | number }) {
const commandId = addTxnRecord({ ...params, category: "debug" });
return httpRequest<BaseResponse<string>>({ url: "/cmd/turnOnHighVoltage", params: { ...params, commandId }, method: "POST" });
return httpRequest<BaseResponse<string>>({
url: "/api/cmd/turnOnHighVoltage",
params: { ...params, commandId },
method: "POST",
});
}
//电压控制 关闭
export function turnOffHighVoltage() {
return httpRequest<BaseResponse<string>>({ url: "/cmd/turnOffHighVoltage", params: {}, method: "POST" });
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/turnOffHighVoltage", params: {}, method: "POST" });
}
//注射泵开启
export function turnOnSyringePump(params:SyringeType) {
return httpRequest<BaseResponse<string>>({ url: "/cmd/turnOnSyringePump", params: {...params}, method: "POST" });
export function turnOnSyringePump(params: SyringeType) {
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/turnOnSyringePump", params: { ...params }, method: "POST" });
}
//注射泵关闭
export function turnOffSyringePump() {
return httpRequest<BaseResponse<string>>({ url: "/cmd/turnOffSyringePump", params: {}, method: "POST" });
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/turnOffSyringePump", params: {}, method: "POST" });
}
//开始喷涂
export function startWork(params:workType) {
return httpRequest<BaseResponse<string>>({ url: "/cmd/startWork", params, method: "POST" });
export function startWork(params: WorkType) {
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/startWork", params, method: "POST" });
}
export function stopWork() {
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/stopWork", method: "POST" });
}

20
src/views/SprayView.vue

@ -120,6 +120,9 @@ import route_h from "@/assets/route_horizontal.png";
import route_h2 from "@/assets/route_horizontal2.png";
import Spray, { type GridArea } from "@/components/Spray.vue";
import { reactive, ref } from "vue";
import { startWork, stopWork } from "@/services/globalCmd/globalCmd";
import type { WorkType } from "@/services/globalCmd/cmdTypes";
import { ElMessage } from "element-plus";
type DTO = {
direction: 1 | 2;
@ -136,7 +139,7 @@ type DTO = {
y: number;
}>;
};
const dto = reactive<DTO>({
const dto = reactive<WorkType>({
direction: 1,
space: 20,
nitrogenFlowVelocity: 20,
@ -171,11 +174,22 @@ function startSpray() {
];
const params = dto.needPower ? dto : { ...dto, voltage: 0 };
console.log(params);
//
startWork(dto).then(res => {
if (res.success) {
} else {
ElMessage.error(res.msg);
}
});
}
function stopSpray() {
//
stopWork().then(res => {
if (res.success) {
} else {
ElMessage.error(res.msg);
}
});
}
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save