sige 1 year ago
parent
commit
6ee3db3714
  1. 2
      pom.xml
  2. 24
      src/main/java/com/iflytop/uf/UfActuatorBase.java
  3. 22
      src/main/java/com/iflytop/uf/actuator/UfActArmHbot.java
  4. 12
      src/main/java/com/iflytop/uf/actuator/UfActPipette.java
  5. 62
      src/main/java/com/iflytop/uf/actuator/UfActStepperMotor.java
  6. 1
      src/main/java/com/iflytop/uf/connection/UfZcancmderWebsocket.java
  7. 2
      src/main/resources/static/uf/index.html
  8. 2
      src/main/resources/static/uf/js/app.40311b7f.js
  9. 1
      src/main/resources/static/uf/js/app.40311b7f.js.map
  10. 2
      src/main/resources/static/uf/js/app.842430c2.js
  11. 1
      src/main/resources/static/uf/js/app.842430c2.js.map

2
pom.xml

@ -10,7 +10,7 @@
</parent>
<groupId>com.iflytop</groupId>
<artifactId>uf</artifactId>
<version>0.0.12</version>
<version>0.0.19</version>
<name>uf</name>
<description>uf</description>
<properties>

24
src/main/java/com/iflytop/uf/UfActuatorBase.java

@ -19,6 +19,30 @@ abstract public class UfActuatorBase implements UfActuator {
}
}
// execute and wait for finish
protected String executeAndWaitForFinish( UfMdbActuatorCmd cmd ) {
var executor = UfActuatorCmdExecutor.getExecutor();
var result = executor.sendCommandToConnection(cmd);
// wait for finish
var waitCmd = new UfMdbActuatorCmd();
waitCmd.actuatorId = cmd.actuatorId;
waitCmd.cmdId = "0104";
waitCmd.cmdKey = "module_get_status";
waitCmd.cmdFlags = cmd.cmdFlags;
waitCmd.parameters = "";
waitCmd.connectionKey = cmd.connectionKey;
do {
String statusText = executor.sendCommandToConnection(waitCmd);
int status = Integer.parseInt(statusText);
if ( 0 == status ) {
break;
}
} while ( true );
return result;
}
@Override
public String execute(UfMdbActuatorCmd command) {
if ( !methodMap.containsKey(command.cmdKey) ) {

22
src/main/java/com/iflytop/uf/actuator/UfActArmHbot.java

@ -0,0 +1,22 @@
package com.iflytop.uf.actuator;
import com.iflytop.uf.UfActuatorBase;
import com.iflytop.uf.UfActuatorCommand;
import com.iflytop.uf.UfActuatorHandler;
import com.iflytop.uf.model.UfMdbActuatorCmd;
@UfActuatorHandler(name = "arm-hbot")
public class UfActArmHbot extends UfActuatorBase {
@UfActuatorCommand(name = "xymotor_move_to_zero")
public String moveToZero(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
@UfActuatorCommand(name = "xymotor_move_by")
public String moveBy(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
@UfActuatorCommand(name = "xymotor_move_to")
public String moveTo(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
}

12
src/main/java/com/iflytop/uf/actuator/UfActPipette.java

@ -0,0 +1,12 @@
package com.iflytop.uf.actuator;
import com.iflytop.uf.UfActuatorBase;
import com.iflytop.uf.UfActuatorCommand;
import com.iflytop.uf.UfActuatorHandler;
import com.iflytop.uf.model.UfMdbActuatorCmd;
@UfActuatorHandler(name = "pipette")
public class UfActPipette extends UfActuatorBase {
@UfActuatorCommand(name = "pipette_ctrl_put_tip")
public String ctrlPutTip(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
}

62
src/main/java/com/iflytop/uf/actuator/UfActStepperMotor.java

@ -1,59 +1,25 @@
package com.iflytop.uf.actuator;
import com.iflytop.uf.*;
import com.iflytop.uf.model.UfMdbActuator;
import com.iflytop.uf.model.UfMdbActuatorCmd;
@UfActuatorHandler(name = "stepper-motor")
public class UfActStepperMotor extends UfActuatorBase {
@UfActuatorCommand(name = "motor_easy_move_to_zero")
public String easyMoveToZero(UfMdbActuatorCmd cmd) {
var executor = UfActuatorCmdExecutor.getExecutor();
return this.executeAndWaitForFinish(cmd);
}
@UfActuatorCommand(name = "motor_easy_move_to")
public String easyMoveTo(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
var result = executor.sendCommandToConnection(cmd);
@UfActuatorCommand(name = "motor_easy_move_by")
public String easyMoveBy(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
// wait for finish
var waitCmd = new UfMdbActuatorCmd();
waitCmd.actuatorId = cmd.actuatorId;
waitCmd.cmdId = "0104";
waitCmd.cmdKey = "module_get_status";
waitCmd.cmdFlags = cmd.cmdFlags;
waitCmd.parameters = "";
waitCmd.connectionKey = cmd.connectionKey;
do {
String statusText = executor.sendCommandToConnection(waitCmd);
int status = Integer.parseInt(statusText);
if ( 0 == status ) {
break;
}
} while ( true );
return result;
@UfActuatorCommand(name = "motor_easy_move_to_io")
public String easyMoveToIo(UfMdbActuatorCmd cmd) {
return this.executeAndWaitForFinish(cmd);
}
//
// // cmd motor easy move to
// public void cmdMotorEasyMoveTo(UfMdbActuatorCmd command) {
// this.executeDeviceCommand(command);
// this.waitForActuatorFinish(command);
//
// var actuator = UfActiveRecord.findOne(UfMdbActuator.class, command.actuatorId);
// var encoderAvailable = actuator.getProperty("encoderAvailable");
// if ( null == encoderAvailable || !encoderAvailable.asBoolean() ) {
// return ;
// }
//
// var destValue = Integer.parseInt(command.parameters);
// var encoderValue = this.getActuatorEncoderValue(command);
// if ( Math.abs(encoderValue - destValue) > 10 ) {
// throw new RuntimeException(String.format("电机 [%s] 移动失败,目标位置:%d,当前位置:%d", actuator.name, destValue, encoderValue));
// }
// }
//
// // cmd motor read enc val
// private Integer getActuatorEncoderValue(UfMdbActuatorCmd srcCmd) {
// var command = new UfMdbActuatorCmd();
// command.actuatorId = srcCmd.actuatorId;
// command.cmdId = "0219";
// command.cmdKey = "motor_read_enc_val";
// command.cmdFlags = srcCmd.cmdFlags;
// String value = this.executeDeviceCommand(command);
// return Integer.parseInt(value);
// }
}

1
src/main/java/com/iflytop/uf/connection/UfZcancmderWebsocket.java

@ -285,6 +285,7 @@ public class UfZcancmderWebsocket extends UfConnectionBase {
Integer errorCode = message.getInt(8);
String errorMessage = switch (errorCode) {
case 3 -> "操作不支持(koperation_not_support)";
case 6 -> "超时(kovertime)";
case 11 -> "子设备超时(ksubdevice_overtime)";
case 14 -> "参数数量不匹配(kcmd_param_num_error)";
default -> "未知";

2
src/main/resources/static/uf/index.html

@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/uf/favicon.ico"><title>web</title><script defer="defer" src="/uf/js/chunk-vendors.0f638fda.js"></script><script defer="defer" src="/uf/js/app.40311b7f.js"></script><link href="/uf/css/app.5595db20.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/uf/favicon.ico"><title>web</title><script defer="defer" src="/uf/js/chunk-vendors.0f638fda.js"></script><script defer="defer" src="/uf/js/app.842430c2.js"></script><link href="/uf/css/app.5595db20.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

2
src/main/resources/static/uf/js/app.40311b7f.js
File diff suppressed because it is too large
View File

1
src/main/resources/static/uf/js/app.40311b7f.js.map
File diff suppressed because it is too large
View File

2
src/main/resources/static/uf/js/app.842430c2.js
File diff suppressed because it is too large
View File

1
src/main/resources/static/uf/js/app.842430c2.js.map
File diff suppressed because it is too large
View File

Loading…
Cancel
Save