getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.example.roughapp2_0bbwiredrpm.models.BspIV.IV_struct_define getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_IV_struct_define_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_IV_struct_define_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\014bsp_IV.proto\"\364\002\n\020IV_struct_define\022\r\n\005P" +
+ "ress\030\001 \001(\005\022\017\n\007RunMode\030\002 \001(\005\022\030\n\020LeftCompe" +
+ "nsation\030\003 \001(\005\022\031\n\021RightCompensation\030\004 \001(\005" +
+ "\022\024\n\014CurrentAngle\030\005 \001(\005\022\026\n\016RobotMoveSpeed" +
+ "\030\006 \001(\001\022\023\n\013SystemError\030\007 \001(\005\022\026\n\016Left_Moto" +
+ "r_Err\030\010 \001(\005\022\027\n\017Right_Motor_Err\030\t \001(\005\022\027\n\017" +
+ "Left_Motor_Temp\030\n \001(\005\022\030\n\020Right_Motor_Tem" +
+ "p\030\013 \001(\005\022\021\n\tIsWorking\030\014 \001(\005\022\021\n\tTimeStamp\030" +
+ "\r \001(\003\022\024\n\014RobotRestart\030\016 \001(\005\022\024\n\014CurrentSp" +
+ "eed\030\017 \001(\001\022\022\n\nSBUS_State\030\020 \001(\005B,\n(com.exa" +
+ "mple.roughapp2_0bbwiredrpm.modelsP\000b\006pro" +
+ "to3"
+ };
+ descriptor = com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ });
+ internal_static_IV_struct_define_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_IV_struct_define_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_IV_struct_define_descriptor,
+ new java.lang.String[] { "Press", "RunMode", "LeftCompensation", "RightCompensation", "CurrentAngle", "RobotMoveSpeed", "SystemError", "LeftMotorErr", "RightMotorErr", "LeftMotorTemp", "RightMotorTemp", "IsWorking", "TimeStamp", "RobotRestart", "CurrentSpeed", "SBUSState", });
+ descriptor.resolveAllFeaturesImmutable();
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/BspPV.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/BspPV.java
new file mode 100644
index 0000000..ec6a4ef
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/BspPV.java
@@ -0,0 +1,1608 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// NO CHECKED-IN PROTOBUF GENCODE
+// source: bsp_PV.proto
+// Protobuf Java Version: 4.27.2
+
+package com.example.roughapp2_0bbwiredrpm.models;
+
+public final class BspPV {
+ private BspPV() {}
+ static {
+ com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
+ com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
+ /* major= */ 4,
+ /* minor= */ 27,
+ /* patch= */ 2,
+ /* suffix= */ "",
+ BspPV.class.getName());
+ }
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistryLite registry) {
+ }
+
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ registerAllExtensions(
+ (com.google.protobuf.ExtensionRegistryLite) registry);
+ }
+ public interface PV_struct_defineOrBuilder extends
+ // @@protoc_insertion_point(interface_extends:PV_struct_define)
+ com.google.protobuf.MessageOrBuilder {
+
+ /**
+ *
+ * 拉毛项目
+ *
+ *
+ * int32 RobotSpeed = 1;
+ * @return The robotSpeed.
+ */
+ int getRobotSpeed();
+
+ /**
+ *
+ * 1 手动无校准作业 2 手动水平作业 3 手动竖直向左作业 4 手动竖直向右作业 5 自动水平作业 6 自动竖直向左作业 7 自动竖直向右作业;
+ *
+ *
+ * int32 RunMode = 2;
+ * @return The runMode.
+ */
+ int getRunMode();
+
+ /**
+ *
+ * 0-100cm
+ *
+ *
+ * int32 LaneChangeDistance = 3;
+ * @return The laneChangeDistance.
+ */
+ int getLaneChangeDistance();
+
+ /**
+ *
+ * 水平方向 作业长度0-200m0-200m
+ *
+ *
+ * double HorizontalDistanceMeters = 4;
+ * @return The horizontalDistanceMeters.
+ */
+ double getHorizontalDistanceMeters();
+
+ /**
+ *
+ * 竖直方向 作业宽度度0-200m
+ *
+ *
+ * double VerticalDistanceMeters = 5;
+ * @return The verticalDistanceMeters.
+ */
+ double getVerticalDistanceMeters();
+
+ /**
+ *
+ * 下压到某个值之后,停止运动
+ *
+ *
+ * int32 PressSet = 6;
+ * @return The pressSet.
+ */
+ int getPressSet();
+
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 LeftCompensation = 7;
+ * @return The leftCompensation.
+ */
+ int getLeftCompensation();
+
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 RightCompensation = 8;
+ * @return The rightCompensation.
+ */
+ int getRightCompensation();
+
+ /**
+ * double Vertical_Calibration = 9;
+ * @return The verticalCalibration.
+ */
+ double getVerticalCalibration();
+
+ /**
+ *
+ * 是否接收到IV restart flag
+ *
+ *
+ * int32 RobotRestartAccepted = 10;
+ * @return The robotRestartAccepted.
+ */
+ int getRobotRestartAccepted();
+
+ /**
+ *
+ *
+ *
+ * int64 TimeStamp = 11;
+ * @return The timeStamp.
+ */
+ long getTimeStamp();
+
+ /**
+ *
+ * RPM
+ *
+ *
+ * int32 DmkSpeed = 12;
+ * @return The dmkSpeed.
+ */
+ int getDmkSpeed();
+
+ /**
+ *
+ * 1正向 2反向
+ *
+ *
+ * int32 ToolRotationDirection = 13;
+ * @return The toolRotationDirection.
+ */
+ int getToolRotationDirection();
+ }
+ /**
+ * Protobuf type {@code PV_struct_define}
+ */
+ public static final class PV_struct_define extends
+ com.google.protobuf.GeneratedMessage implements
+ // @@protoc_insertion_point(message_implements:PV_struct_define)
+ PV_struct_defineOrBuilder {
+ private static final long serialVersionUID = 0L;
+ static {
+ com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(
+ com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC,
+ /* major= */ 4,
+ /* minor= */ 27,
+ /* patch= */ 2,
+ /* suffix= */ "",
+ PV_struct_define.class.getName());
+ }
+ // Use PV_struct_define.newBuilder() to construct.
+ private PV_struct_define(com.google.protobuf.GeneratedMessage.Builder> builder) {
+ super(builder);
+ }
+ private PV_struct_define() {
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.internal_static_PV_struct_define_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.internal_static_PV_struct_define_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.class, com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.Builder.class);
+ }
+
+ public static final int ROBOTSPEED_FIELD_NUMBER = 1;
+ private int robotSpeed_ = 0;
+ /**
+ *
+ * 拉毛项目
+ *
+ *
+ * int32 RobotSpeed = 1;
+ * @return The robotSpeed.
+ */
+ @java.lang.Override
+ public int getRobotSpeed() {
+ return robotSpeed_;
+ }
+
+ public static final int RUNMODE_FIELD_NUMBER = 2;
+ private int runMode_ = 0;
+ /**
+ *
+ * 1 手动无校准作业 2 手动水平作业 3 手动竖直向左作业 4 手动竖直向右作业 5 自动水平作业 6 自动竖直向左作业 7 自动竖直向右作业;
+ *
+ *
+ * int32 RunMode = 2;
+ * @return The runMode.
+ */
+ @java.lang.Override
+ public int getRunMode() {
+ return runMode_;
+ }
+
+ public static final int LANECHANGEDISTANCE_FIELD_NUMBER = 3;
+ private int laneChangeDistance_ = 0;
+ /**
+ *
+ * 0-100cm
+ *
+ *
+ * int32 LaneChangeDistance = 3;
+ * @return The laneChangeDistance.
+ */
+ @java.lang.Override
+ public int getLaneChangeDistance() {
+ return laneChangeDistance_;
+ }
+
+ public static final int HORIZONTALDISTANCEMETERS_FIELD_NUMBER = 4;
+ private double horizontalDistanceMeters_ = 0D;
+ /**
+ *
+ * 水平方向 作业长度0-200m0-200m
+ *
+ *
+ * double HorizontalDistanceMeters = 4;
+ * @return The horizontalDistanceMeters.
+ */
+ @java.lang.Override
+ public double getHorizontalDistanceMeters() {
+ return horizontalDistanceMeters_;
+ }
+
+ public static final int VERTICALDISTANCEMETERS_FIELD_NUMBER = 5;
+ private double verticalDistanceMeters_ = 0D;
+ /**
+ *
+ * 竖直方向 作业宽度度0-200m
+ *
+ *
+ * double VerticalDistanceMeters = 5;
+ * @return The verticalDistanceMeters.
+ */
+ @java.lang.Override
+ public double getVerticalDistanceMeters() {
+ return verticalDistanceMeters_;
+ }
+
+ public static final int PRESSSET_FIELD_NUMBER = 6;
+ private int pressSet_ = 0;
+ /**
+ *
+ * 下压到某个值之后,停止运动
+ *
+ *
+ * int32 PressSet = 6;
+ * @return The pressSet.
+ */
+ @java.lang.Override
+ public int getPressSet() {
+ return pressSet_;
+ }
+
+ public static final int LEFTCOMPENSATION_FIELD_NUMBER = 7;
+ private int leftCompensation_ = 0;
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 LeftCompensation = 7;
+ * @return The leftCompensation.
+ */
+ @java.lang.Override
+ public int getLeftCompensation() {
+ return leftCompensation_;
+ }
+
+ public static final int RIGHTCOMPENSATION_FIELD_NUMBER = 8;
+ private int rightCompensation_ = 0;
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 RightCompensation = 8;
+ * @return The rightCompensation.
+ */
+ @java.lang.Override
+ public int getRightCompensation() {
+ return rightCompensation_;
+ }
+
+ public static final int VERTICAL_CALIBRATION_FIELD_NUMBER = 9;
+ private double verticalCalibration_ = 0D;
+ /**
+ * double Vertical_Calibration = 9;
+ * @return The verticalCalibration.
+ */
+ @java.lang.Override
+ public double getVerticalCalibration() {
+ return verticalCalibration_;
+ }
+
+ public static final int ROBOTRESTARTACCEPTED_FIELD_NUMBER = 10;
+ private int robotRestartAccepted_ = 0;
+ /**
+ *
+ * 是否接收到IV restart flag
+ *
+ *
+ * int32 RobotRestartAccepted = 10;
+ * @return The robotRestartAccepted.
+ */
+ @java.lang.Override
+ public int getRobotRestartAccepted() {
+ return robotRestartAccepted_;
+ }
+
+ public static final int TIMESTAMP_FIELD_NUMBER = 11;
+ private long timeStamp_ = 0L;
+ /**
+ *
+ *
+ *
+ * int64 TimeStamp = 11;
+ * @return The timeStamp.
+ */
+ @java.lang.Override
+ public long getTimeStamp() {
+ return timeStamp_;
+ }
+
+ public static final int DMKSPEED_FIELD_NUMBER = 12;
+ private int dmkSpeed_ = 0;
+ /**
+ *
+ * RPM
+ *
+ *
+ * int32 DmkSpeed = 12;
+ * @return The dmkSpeed.
+ */
+ @java.lang.Override
+ public int getDmkSpeed() {
+ return dmkSpeed_;
+ }
+
+ public static final int TOOLROTATIONDIRECTION_FIELD_NUMBER = 13;
+ private int toolRotationDirection_ = 0;
+ /**
+ *
+ * 1正向 2反向
+ *
+ *
+ * int32 ToolRotationDirection = 13;
+ * @return The toolRotationDirection.
+ */
+ @java.lang.Override
+ public int getToolRotationDirection() {
+ return toolRotationDirection_;
+ }
+
+ private byte memoizedIsInitialized = -1;
+ @java.lang.Override
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized == 1) return true;
+ if (isInitialized == 0) return false;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ @java.lang.Override
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ if (robotSpeed_ != 0) {
+ output.writeInt32(1, robotSpeed_);
+ }
+ if (runMode_ != 0) {
+ output.writeInt32(2, runMode_);
+ }
+ if (laneChangeDistance_ != 0) {
+ output.writeInt32(3, laneChangeDistance_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(horizontalDistanceMeters_) != 0) {
+ output.writeDouble(4, horizontalDistanceMeters_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(verticalDistanceMeters_) != 0) {
+ output.writeDouble(5, verticalDistanceMeters_);
+ }
+ if (pressSet_ != 0) {
+ output.writeInt32(6, pressSet_);
+ }
+ if (leftCompensation_ != 0) {
+ output.writeInt32(7, leftCompensation_);
+ }
+ if (rightCompensation_ != 0) {
+ output.writeInt32(8, rightCompensation_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(verticalCalibration_) != 0) {
+ output.writeDouble(9, verticalCalibration_);
+ }
+ if (robotRestartAccepted_ != 0) {
+ output.writeInt32(10, robotRestartAccepted_);
+ }
+ if (timeStamp_ != 0L) {
+ output.writeInt64(11, timeStamp_);
+ }
+ if (dmkSpeed_ != 0) {
+ output.writeInt32(12, dmkSpeed_);
+ }
+ if (toolRotationDirection_ != 0) {
+ output.writeInt32(13, toolRotationDirection_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ @java.lang.Override
+ public int getSerializedSize() {
+ int size = memoizedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (robotSpeed_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(1, robotSpeed_);
+ }
+ if (runMode_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(2, runMode_);
+ }
+ if (laneChangeDistance_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(3, laneChangeDistance_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(horizontalDistanceMeters_) != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeDoubleSize(4, horizontalDistanceMeters_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(verticalDistanceMeters_) != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeDoubleSize(5, verticalDistanceMeters_);
+ }
+ if (pressSet_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(6, pressSet_);
+ }
+ if (leftCompensation_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(7, leftCompensation_);
+ }
+ if (rightCompensation_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(8, rightCompensation_);
+ }
+ if (java.lang.Double.doubleToRawLongBits(verticalCalibration_) != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeDoubleSize(9, verticalCalibration_);
+ }
+ if (robotRestartAccepted_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(10, robotRestartAccepted_);
+ }
+ if (timeStamp_ != 0L) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt64Size(11, timeStamp_);
+ }
+ if (dmkSpeed_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(12, dmkSpeed_);
+ }
+ if (toolRotationDirection_ != 0) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(13, toolRotationDirection_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ public boolean equals(final java.lang.Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define)) {
+ return super.equals(obj);
+ }
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define other = (com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define) obj;
+
+ if (getRobotSpeed()
+ != other.getRobotSpeed()) return false;
+ if (getRunMode()
+ != other.getRunMode()) return false;
+ if (getLaneChangeDistance()
+ != other.getLaneChangeDistance()) return false;
+ if (java.lang.Double.doubleToLongBits(getHorizontalDistanceMeters())
+ != java.lang.Double.doubleToLongBits(
+ other.getHorizontalDistanceMeters())) return false;
+ if (java.lang.Double.doubleToLongBits(getVerticalDistanceMeters())
+ != java.lang.Double.doubleToLongBits(
+ other.getVerticalDistanceMeters())) return false;
+ if (getPressSet()
+ != other.getPressSet()) return false;
+ if (getLeftCompensation()
+ != other.getLeftCompensation()) return false;
+ if (getRightCompensation()
+ != other.getRightCompensation()) return false;
+ if (java.lang.Double.doubleToLongBits(getVerticalCalibration())
+ != java.lang.Double.doubleToLongBits(
+ other.getVerticalCalibration())) return false;
+ if (getRobotRestartAccepted()
+ != other.getRobotRestartAccepted()) return false;
+ if (getTimeStamp()
+ != other.getTimeStamp()) return false;
+ if (getDmkSpeed()
+ != other.getDmkSpeed()) return false;
+ if (getToolRotationDirection()
+ != other.getToolRotationDirection()) return false;
+ if (!getUnknownFields().equals(other.getUnknownFields())) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ public int hashCode() {
+ if (memoizedHashCode != 0) {
+ return memoizedHashCode;
+ }
+ int hash = 41;
+ hash = (19 * hash) + getDescriptor().hashCode();
+ hash = (37 * hash) + ROBOTSPEED_FIELD_NUMBER;
+ hash = (53 * hash) + getRobotSpeed();
+ hash = (37 * hash) + RUNMODE_FIELD_NUMBER;
+ hash = (53 * hash) + getRunMode();
+ hash = (37 * hash) + LANECHANGEDISTANCE_FIELD_NUMBER;
+ hash = (53 * hash) + getLaneChangeDistance();
+ hash = (37 * hash) + HORIZONTALDISTANCEMETERS_FIELD_NUMBER;
+ hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
+ java.lang.Double.doubleToLongBits(getHorizontalDistanceMeters()));
+ hash = (37 * hash) + VERTICALDISTANCEMETERS_FIELD_NUMBER;
+ hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
+ java.lang.Double.doubleToLongBits(getVerticalDistanceMeters()));
+ hash = (37 * hash) + PRESSSET_FIELD_NUMBER;
+ hash = (53 * hash) + getPressSet();
+ hash = (37 * hash) + LEFTCOMPENSATION_FIELD_NUMBER;
+ hash = (53 * hash) + getLeftCompensation();
+ hash = (37 * hash) + RIGHTCOMPENSATION_FIELD_NUMBER;
+ hash = (53 * hash) + getRightCompensation();
+ hash = (37 * hash) + VERTICAL_CALIBRATION_FIELD_NUMBER;
+ hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
+ java.lang.Double.doubleToLongBits(getVerticalCalibration()));
+ hash = (37 * hash) + ROBOTRESTARTACCEPTED_FIELD_NUMBER;
+ hash = (53 * hash) + getRobotRestartAccepted();
+ hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER;
+ hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
+ getTimeStamp());
+ hash = (37 * hash) + DMKSPEED_FIELD_NUMBER;
+ hash = (53 * hash) + getDmkSpeed();
+ hash = (37 * hash) + TOOLROTATIONDIRECTION_FIELD_NUMBER;
+ hash = (53 * hash) + getToolRotationDirection();
+ hash = (29 * hash) + getUnknownFields().hashCode();
+ memoizedHashCode = hash;
+ return hash;
+ }
+
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ java.nio.ByteBuffer data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ java.nio.ByteBuffer data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return PARSER.parseFrom(data, extensionRegistry);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseDelimitedWithIOException(PARSER, input);
+ }
+
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseWithIOException(PARSER, input);
+ }
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return com.google.protobuf.GeneratedMessage
+ .parseWithIOException(PARSER, input, extensionRegistry);
+ }
+
+ @java.lang.Override
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder() {
+ return DEFAULT_INSTANCE.toBuilder();
+ }
+ public static Builder newBuilder(com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define prototype) {
+ return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+ }
+ @java.lang.Override
+ public Builder toBuilder() {
+ return this == DEFAULT_INSTANCE
+ ? new Builder() : new Builder().mergeFrom(this);
+ }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ /**
+ * Protobuf type {@code PV_struct_define}
+ */
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder implements
+ // @@protoc_insertion_point(builder_implements:PV_struct_define)
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_defineOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.internal_static_PV_struct_define_descriptor;
+ }
+
+ @java.lang.Override
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.internal_static_PV_struct_define_fieldAccessorTable
+ .ensureFieldAccessorsInitialized(
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.class, com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.Builder.class);
+ }
+
+ // Construct using com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.newBuilder()
+ private Builder() {
+
+ }
+
+ private Builder(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ super(parent);
+
+ }
+ @java.lang.Override
+ public Builder clear() {
+ super.clear();
+ bitField0_ = 0;
+ robotSpeed_ = 0;
+ runMode_ = 0;
+ laneChangeDistance_ = 0;
+ horizontalDistanceMeters_ = 0D;
+ verticalDistanceMeters_ = 0D;
+ pressSet_ = 0;
+ leftCompensation_ = 0;
+ rightCompensation_ = 0;
+ verticalCalibration_ = 0D;
+ robotRestartAccepted_ = 0;
+ timeStamp_ = 0L;
+ dmkSpeed_ = 0;
+ toolRotationDirection_ = 0;
+ return this;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.internal_static_PV_struct_define_descriptor;
+ }
+
+ @java.lang.Override
+ public com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define getDefaultInstanceForType() {
+ return com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.getDefaultInstance();
+ }
+
+ @java.lang.Override
+ public com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define build() {
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ @java.lang.Override
+ public com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define buildPartial() {
+ com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define result = new com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define(this);
+ if (bitField0_ != 0) { buildPartial0(result); }
+ onBuilt();
+ return result;
+ }
+
+ private void buildPartial0(com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define result) {
+ int from_bitField0_ = bitField0_;
+ if (((from_bitField0_ & 0x00000001) != 0)) {
+ result.robotSpeed_ = robotSpeed_;
+ }
+ if (((from_bitField0_ & 0x00000002) != 0)) {
+ result.runMode_ = runMode_;
+ }
+ if (((from_bitField0_ & 0x00000004) != 0)) {
+ result.laneChangeDistance_ = laneChangeDistance_;
+ }
+ if (((from_bitField0_ & 0x00000008) != 0)) {
+ result.horizontalDistanceMeters_ = horizontalDistanceMeters_;
+ }
+ if (((from_bitField0_ & 0x00000010) != 0)) {
+ result.verticalDistanceMeters_ = verticalDistanceMeters_;
+ }
+ if (((from_bitField0_ & 0x00000020) != 0)) {
+ result.pressSet_ = pressSet_;
+ }
+ if (((from_bitField0_ & 0x00000040) != 0)) {
+ result.leftCompensation_ = leftCompensation_;
+ }
+ if (((from_bitField0_ & 0x00000080) != 0)) {
+ result.rightCompensation_ = rightCompensation_;
+ }
+ if (((from_bitField0_ & 0x00000100) != 0)) {
+ result.verticalCalibration_ = verticalCalibration_;
+ }
+ if (((from_bitField0_ & 0x00000200) != 0)) {
+ result.robotRestartAccepted_ = robotRestartAccepted_;
+ }
+ if (((from_bitField0_ & 0x00000400) != 0)) {
+ result.timeStamp_ = timeStamp_;
+ }
+ if (((from_bitField0_ & 0x00000800) != 0)) {
+ result.dmkSpeed_ = dmkSpeed_;
+ }
+ if (((from_bitField0_ & 0x00001000) != 0)) {
+ result.toolRotationDirection_ = toolRotationDirection_;
+ }
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define) {
+ return mergeFrom((com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define other) {
+ if (other == com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define.getDefaultInstance()) return this;
+ if (other.getRobotSpeed() != 0) {
+ setRobotSpeed(other.getRobotSpeed());
+ }
+ if (other.getRunMode() != 0) {
+ setRunMode(other.getRunMode());
+ }
+ if (other.getLaneChangeDistance() != 0) {
+ setLaneChangeDistance(other.getLaneChangeDistance());
+ }
+ if (other.getHorizontalDistanceMeters() != 0D) {
+ setHorizontalDistanceMeters(other.getHorizontalDistanceMeters());
+ }
+ if (other.getVerticalDistanceMeters() != 0D) {
+ setVerticalDistanceMeters(other.getVerticalDistanceMeters());
+ }
+ if (other.getPressSet() != 0) {
+ setPressSet(other.getPressSet());
+ }
+ if (other.getLeftCompensation() != 0) {
+ setLeftCompensation(other.getLeftCompensation());
+ }
+ if (other.getRightCompensation() != 0) {
+ setRightCompensation(other.getRightCompensation());
+ }
+ if (other.getVerticalCalibration() != 0D) {
+ setVerticalCalibration(other.getVerticalCalibration());
+ }
+ if (other.getRobotRestartAccepted() != 0) {
+ setRobotRestartAccepted(other.getRobotRestartAccepted());
+ }
+ if (other.getTimeStamp() != 0L) {
+ setTimeStamp(other.getTimeStamp());
+ }
+ if (other.getDmkSpeed() != 0) {
+ setDmkSpeed(other.getDmkSpeed());
+ }
+ if (other.getToolRotationDirection() != 0) {
+ setToolRotationDirection(other.getToolRotationDirection());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ onChanged();
+ return this;
+ }
+
+ @java.lang.Override
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ @java.lang.Override
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ if (extensionRegistry == null) {
+ throw new java.lang.NullPointerException();
+ }
+ try {
+ boolean done = false;
+ while (!done) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ done = true;
+ break;
+ case 8: {
+ robotSpeed_ = input.readInt32();
+ bitField0_ |= 0x00000001;
+ break;
+ } // case 8
+ case 16: {
+ runMode_ = input.readInt32();
+ bitField0_ |= 0x00000002;
+ break;
+ } // case 16
+ case 24: {
+ laneChangeDistance_ = input.readInt32();
+ bitField0_ |= 0x00000004;
+ break;
+ } // case 24
+ case 33: {
+ horizontalDistanceMeters_ = input.readDouble();
+ bitField0_ |= 0x00000008;
+ break;
+ } // case 33
+ case 41: {
+ verticalDistanceMeters_ = input.readDouble();
+ bitField0_ |= 0x00000010;
+ break;
+ } // case 41
+ case 48: {
+ pressSet_ = input.readInt32();
+ bitField0_ |= 0x00000020;
+ break;
+ } // case 48
+ case 56: {
+ leftCompensation_ = input.readInt32();
+ bitField0_ |= 0x00000040;
+ break;
+ } // case 56
+ case 64: {
+ rightCompensation_ = input.readInt32();
+ bitField0_ |= 0x00000080;
+ break;
+ } // case 64
+ case 73: {
+ verticalCalibration_ = input.readDouble();
+ bitField0_ |= 0x00000100;
+ break;
+ } // case 73
+ case 80: {
+ robotRestartAccepted_ = input.readInt32();
+ bitField0_ |= 0x00000200;
+ break;
+ } // case 80
+ case 88: {
+ timeStamp_ = input.readInt64();
+ bitField0_ |= 0x00000400;
+ break;
+ } // case 88
+ case 96: {
+ dmkSpeed_ = input.readInt32();
+ bitField0_ |= 0x00000800;
+ break;
+ } // case 96
+ case 104: {
+ toolRotationDirection_ = input.readInt32();
+ bitField0_ |= 0x00001000;
+ break;
+ } // case 104
+ default: {
+ if (!super.parseUnknownField(input, extensionRegistry, tag)) {
+ done = true; // was an endgroup tag
+ }
+ break;
+ } // default:
+ } // switch (tag)
+ } // while (!done)
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ } finally {
+ onChanged();
+ } // finally
+ return this;
+ }
+ private int bitField0_;
+
+ private int robotSpeed_ ;
+ /**
+ *
+ * 拉毛项目
+ *
+ *
+ * int32 RobotSpeed = 1;
+ * @return The robotSpeed.
+ */
+ @java.lang.Override
+ public int getRobotSpeed() {
+ return robotSpeed_;
+ }
+ /**
+ *
+ * 拉毛项目
+ *
+ *
+ * int32 RobotSpeed = 1;
+ * @param value The robotSpeed to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRobotSpeed(int value) {
+
+ robotSpeed_ = value;
+ bitField0_ |= 0x00000001;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 拉毛项目
+ *
+ *
+ * int32 RobotSpeed = 1;
+ * @return This builder for chaining.
+ */
+ public Builder clearRobotSpeed() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ robotSpeed_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int runMode_ ;
+ /**
+ *
+ * 1 手动无校准作业 2 手动水平作业 3 手动竖直向左作业 4 手动竖直向右作业 5 自动水平作业 6 自动竖直向左作业 7 自动竖直向右作业;
+ *
+ *
+ * int32 RunMode = 2;
+ * @return The runMode.
+ */
+ @java.lang.Override
+ public int getRunMode() {
+ return runMode_;
+ }
+ /**
+ *
+ * 1 手动无校准作业 2 手动水平作业 3 手动竖直向左作业 4 手动竖直向右作业 5 自动水平作业 6 自动竖直向左作业 7 自动竖直向右作业;
+ *
+ *
+ * int32 RunMode = 2;
+ * @param value The runMode to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRunMode(int value) {
+
+ runMode_ = value;
+ bitField0_ |= 0x00000002;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 1 手动无校准作业 2 手动水平作业 3 手动竖直向左作业 4 手动竖直向右作业 5 自动水平作业 6 自动竖直向左作业 7 自动竖直向右作业;
+ *
+ *
+ * int32 RunMode = 2;
+ * @return This builder for chaining.
+ */
+ public Builder clearRunMode() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ runMode_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int laneChangeDistance_ ;
+ /**
+ *
+ * 0-100cm
+ *
+ *
+ * int32 LaneChangeDistance = 3;
+ * @return The laneChangeDistance.
+ */
+ @java.lang.Override
+ public int getLaneChangeDistance() {
+ return laneChangeDistance_;
+ }
+ /**
+ *
+ * 0-100cm
+ *
+ *
+ * int32 LaneChangeDistance = 3;
+ * @param value The laneChangeDistance to set.
+ * @return This builder for chaining.
+ */
+ public Builder setLaneChangeDistance(int value) {
+
+ laneChangeDistance_ = value;
+ bitField0_ |= 0x00000004;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 0-100cm
+ *
+ *
+ * int32 LaneChangeDistance = 3;
+ * @return This builder for chaining.
+ */
+ public Builder clearLaneChangeDistance() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ laneChangeDistance_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private double horizontalDistanceMeters_ ;
+ /**
+ *
+ * 水平方向 作业长度0-200m0-200m
+ *
+ *
+ * double HorizontalDistanceMeters = 4;
+ * @return The horizontalDistanceMeters.
+ */
+ @java.lang.Override
+ public double getHorizontalDistanceMeters() {
+ return horizontalDistanceMeters_;
+ }
+ /**
+ *
+ * 水平方向 作业长度0-200m0-200m
+ *
+ *
+ * double HorizontalDistanceMeters = 4;
+ * @param value The horizontalDistanceMeters to set.
+ * @return This builder for chaining.
+ */
+ public Builder setHorizontalDistanceMeters(double value) {
+
+ horizontalDistanceMeters_ = value;
+ bitField0_ |= 0x00000008;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 水平方向 作业长度0-200m0-200m
+ *
+ *
+ * double HorizontalDistanceMeters = 4;
+ * @return This builder for chaining.
+ */
+ public Builder clearHorizontalDistanceMeters() {
+ bitField0_ = (bitField0_ & ~0x00000008);
+ horizontalDistanceMeters_ = 0D;
+ onChanged();
+ return this;
+ }
+
+ private double verticalDistanceMeters_ ;
+ /**
+ *
+ * 竖直方向 作业宽度度0-200m
+ *
+ *
+ * double VerticalDistanceMeters = 5;
+ * @return The verticalDistanceMeters.
+ */
+ @java.lang.Override
+ public double getVerticalDistanceMeters() {
+ return verticalDistanceMeters_;
+ }
+ /**
+ *
+ * 竖直方向 作业宽度度0-200m
+ *
+ *
+ * double VerticalDistanceMeters = 5;
+ * @param value The verticalDistanceMeters to set.
+ * @return This builder for chaining.
+ */
+ public Builder setVerticalDistanceMeters(double value) {
+
+ verticalDistanceMeters_ = value;
+ bitField0_ |= 0x00000010;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 竖直方向 作业宽度度0-200m
+ *
+ *
+ * double VerticalDistanceMeters = 5;
+ * @return This builder for chaining.
+ */
+ public Builder clearVerticalDistanceMeters() {
+ bitField0_ = (bitField0_ & ~0x00000010);
+ verticalDistanceMeters_ = 0D;
+ onChanged();
+ return this;
+ }
+
+ private int pressSet_ ;
+ /**
+ *
+ * 下压到某个值之后,停止运动
+ *
+ *
+ * int32 PressSet = 6;
+ * @return The pressSet.
+ */
+ @java.lang.Override
+ public int getPressSet() {
+ return pressSet_;
+ }
+ /**
+ *
+ * 下压到某个值之后,停止运动
+ *
+ *
+ * int32 PressSet = 6;
+ * @param value The pressSet to set.
+ * @return This builder for chaining.
+ */
+ public Builder setPressSet(int value) {
+
+ pressSet_ = value;
+ bitField0_ |= 0x00000020;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 下压到某个值之后,停止运动
+ *
+ *
+ * int32 PressSet = 6;
+ * @return This builder for chaining.
+ */
+ public Builder clearPressSet() {
+ bitField0_ = (bitField0_ & ~0x00000020);
+ pressSet_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int leftCompensation_ ;
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 LeftCompensation = 7;
+ * @return The leftCompensation.
+ */
+ @java.lang.Override
+ public int getLeftCompensation() {
+ return leftCompensation_;
+ }
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 LeftCompensation = 7;
+ * @param value The leftCompensation to set.
+ * @return This builder for chaining.
+ */
+ public Builder setLeftCompensation(int value) {
+
+ leftCompensation_ = value;
+ bitField0_ |= 0x00000040;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 LeftCompensation = 7;
+ * @return This builder for chaining.
+ */
+ public Builder clearLeftCompensation() {
+ bitField0_ = (bitField0_ & ~0x00000040);
+ leftCompensation_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int rightCompensation_ ;
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 RightCompensation = 8;
+ * @return The rightCompensation.
+ */
+ @java.lang.Override
+ public int getRightCompensation() {
+ return rightCompensation_;
+ }
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 RightCompensation = 8;
+ * @param value The rightCompensation to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRightCompensation(int value) {
+
+ rightCompensation_ = value;
+ bitField0_ |= 0x00000080;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 0.01°
+ *
+ *
+ * int32 RightCompensation = 8;
+ * @return This builder for chaining.
+ */
+ public Builder clearRightCompensation() {
+ bitField0_ = (bitField0_ & ~0x00000080);
+ rightCompensation_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private double verticalCalibration_ ;
+ /**
+ * double Vertical_Calibration = 9;
+ * @return The verticalCalibration.
+ */
+ @java.lang.Override
+ public double getVerticalCalibration() {
+ return verticalCalibration_;
+ }
+ /**
+ * double Vertical_Calibration = 9;
+ * @param value The verticalCalibration to set.
+ * @return This builder for chaining.
+ */
+ public Builder setVerticalCalibration(double value) {
+
+ verticalCalibration_ = value;
+ bitField0_ |= 0x00000100;
+ onChanged();
+ return this;
+ }
+ /**
+ * double Vertical_Calibration = 9;
+ * @return This builder for chaining.
+ */
+ public Builder clearVerticalCalibration() {
+ bitField0_ = (bitField0_ & ~0x00000100);
+ verticalCalibration_ = 0D;
+ onChanged();
+ return this;
+ }
+
+ private int robotRestartAccepted_ ;
+ /**
+ *
+ * 是否接收到IV restart flag
+ *
+ *
+ * int32 RobotRestartAccepted = 10;
+ * @return The robotRestartAccepted.
+ */
+ @java.lang.Override
+ public int getRobotRestartAccepted() {
+ return robotRestartAccepted_;
+ }
+ /**
+ *
+ * 是否接收到IV restart flag
+ *
+ *
+ * int32 RobotRestartAccepted = 10;
+ * @param value The robotRestartAccepted to set.
+ * @return This builder for chaining.
+ */
+ public Builder setRobotRestartAccepted(int value) {
+
+ robotRestartAccepted_ = value;
+ bitField0_ |= 0x00000200;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 是否接收到IV restart flag
+ *
+ *
+ * int32 RobotRestartAccepted = 10;
+ * @return This builder for chaining.
+ */
+ public Builder clearRobotRestartAccepted() {
+ bitField0_ = (bitField0_ & ~0x00000200);
+ robotRestartAccepted_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private long timeStamp_ ;
+ /**
+ *
+ *
+ *
+ * int64 TimeStamp = 11;
+ * @return The timeStamp.
+ */
+ @java.lang.Override
+ public long getTimeStamp() {
+ return timeStamp_;
+ }
+ /**
+ *
+ *
+ *
+ * int64 TimeStamp = 11;
+ * @param value The timeStamp to set.
+ * @return This builder for chaining.
+ */
+ public Builder setTimeStamp(long value) {
+
+ timeStamp_ = value;
+ bitField0_ |= 0x00000400;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ *
+ *
+ * int64 TimeStamp = 11;
+ * @return This builder for chaining.
+ */
+ public Builder clearTimeStamp() {
+ bitField0_ = (bitField0_ & ~0x00000400);
+ timeStamp_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ private int dmkSpeed_ ;
+ /**
+ *
+ * RPM
+ *
+ *
+ * int32 DmkSpeed = 12;
+ * @return The dmkSpeed.
+ */
+ @java.lang.Override
+ public int getDmkSpeed() {
+ return dmkSpeed_;
+ }
+ /**
+ *
+ * RPM
+ *
+ *
+ * int32 DmkSpeed = 12;
+ * @param value The dmkSpeed to set.
+ * @return This builder for chaining.
+ */
+ public Builder setDmkSpeed(int value) {
+
+ dmkSpeed_ = value;
+ bitField0_ |= 0x00000800;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * RPM
+ *
+ *
+ * int32 DmkSpeed = 12;
+ * @return This builder for chaining.
+ */
+ public Builder clearDmkSpeed() {
+ bitField0_ = (bitField0_ & ~0x00000800);
+ dmkSpeed_ = 0;
+ onChanged();
+ return this;
+ }
+
+ private int toolRotationDirection_ ;
+ /**
+ *
+ * 1正向 2反向
+ *
+ *
+ * int32 ToolRotationDirection = 13;
+ * @return The toolRotationDirection.
+ */
+ @java.lang.Override
+ public int getToolRotationDirection() {
+ return toolRotationDirection_;
+ }
+ /**
+ *
+ * 1正向 2反向
+ *
+ *
+ * int32 ToolRotationDirection = 13;
+ * @param value The toolRotationDirection to set.
+ * @return This builder for chaining.
+ */
+ public Builder setToolRotationDirection(int value) {
+
+ toolRotationDirection_ = value;
+ bitField0_ |= 0x00001000;
+ onChanged();
+ return this;
+ }
+ /**
+ *
+ * 1正向 2反向
+ *
+ *
+ * int32 ToolRotationDirection = 13;
+ * @return This builder for chaining.
+ */
+ public Builder clearToolRotationDirection() {
+ bitField0_ = (bitField0_ & ~0x00001000);
+ toolRotationDirection_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:PV_struct_define)
+ }
+
+ // @@protoc_insertion_point(class_scope:PV_struct_define)
+ private static final com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define DEFAULT_INSTANCE;
+ static {
+ DEFAULT_INSTANCE = new com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define();
+ }
+
+ public static com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define getDefaultInstance() {
+ return DEFAULT_INSTANCE;
+ }
+
+ private static final com.google.protobuf.Parser
+ PARSER = new com.google.protobuf.AbstractParser() {
+ @java.lang.Override
+ public PV_struct_define parsePartialFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ Builder builder = newBuilder();
+ try {
+ builder.mergeFrom(input, extensionRegistry);
+ } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+ throw e.setUnfinishedMessage(builder.buildPartial());
+ } catch (com.google.protobuf.UninitializedMessageException e) {
+ throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
+ } catch (java.io.IOException e) {
+ throw new com.google.protobuf.InvalidProtocolBufferException(e)
+ .setUnfinishedMessage(builder.buildPartial());
+ }
+ return builder.buildPartial();
+ }
+ };
+
+ public static com.google.protobuf.Parser parser() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.google.protobuf.Parser getParserForType() {
+ return PARSER;
+ }
+
+ @java.lang.Override
+ public com.example.roughapp2_0bbwiredrpm.models.BspPV.PV_struct_define getDefaultInstanceForType() {
+ return DEFAULT_INSTANCE;
+ }
+
+ }
+
+ private static final com.google.protobuf.Descriptors.Descriptor
+ internal_static_PV_struct_define_descriptor;
+ private static final
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_PV_struct_define_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\014bsp_PV.proto\"\334\002\n\020PV_struct_define\022\022\n\nR" +
+ "obotSpeed\030\001 \001(\005\022\017\n\007RunMode\030\002 \001(\005\022\032\n\022Lane" +
+ "ChangeDistance\030\003 \001(\005\022 \n\030HorizontalDistan" +
+ "ceMeters\030\004 \001(\001\022\036\n\026VerticalDistanceMeters" +
+ "\030\005 \001(\001\022\020\n\010PressSet\030\006 \001(\005\022\030\n\020LeftCompensa" +
+ "tion\030\007 \001(\005\022\031\n\021RightCompensation\030\010 \001(\005\022\034\n" +
+ "\024Vertical_Calibration\030\t \001(\001\022\034\n\024RobotRest" +
+ "artAccepted\030\n \001(\005\022\021\n\tTimeStamp\030\013 \001(\003\022\020\n\010" +
+ "DmkSpeed\030\014 \001(\005\022\035\n\025ToolRotationDirection\030" +
+ "\r \001(\005B,\n(com.example.roughapp2_0bbwiredr" +
+ "pm.modelsP\000b\006proto3"
+ };
+ descriptor = com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ });
+ internal_static_PV_struct_define_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_PV_struct_define_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_PV_struct_define_descriptor,
+ new java.lang.String[] { "RobotSpeed", "RunMode", "LaneChangeDistance", "HorizontalDistanceMeters", "VerticalDistanceMeters", "PressSet", "LeftCompensation", "RightCompensation", "VerticalCalibration", "RobotRestartAccepted", "TimeStamp", "DmkSpeed", "ToolRotationDirection", });
+ descriptor.resolveAllFeaturesImmutable();
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayIV.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayIV.java
new file mode 100644
index 0000000..913da4e
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayIV.java
@@ -0,0 +1,50 @@
+package com.example.roughapp2_0bbwiredrpm.models;
+
+import androidx.databinding.BaseObservable;
+
+public class DisplayIV extends BaseObservable {
+ private double leftCompensation;
+ private double rightCompensation;
+ private double currentAngle;
+
+ public double getLeftCompensation() {
+ return leftCompensation;
+ }
+
+ public void setLeftCompensation(double leftCompensation) {
+ this.leftCompensation = leftCompensation;
+ }
+
+ public double getRightCompensation() {
+ return rightCompensation;
+ }
+
+ public void setRightCompensation(double rightCompensation) {
+ this.rightCompensation = rightCompensation;
+ }
+
+ public double getCurrentAngle() {
+ return currentAngle;
+ }
+
+ public void setCurrentAngle(double currentAngle) {
+ this.currentAngle = currentAngle;
+ }
+
+ public double getRobotMoveSpeed() {
+ return robotMoveSpeed;
+ }
+
+ public void setRobotMoveSpeed(double robotMoveSpeed) {
+ this.robotMoveSpeed = robotMoveSpeed;
+ }
+
+ private double robotMoveSpeed;
+
+ public DisplayIV(double leftCompensation, double rightCompensation, double currentAngle, double robotMoveSpeed) {
+ this.leftCompensation = leftCompensation;
+ this.rightCompensation = rightCompensation;
+ this.currentAngle = currentAngle;
+ this.robotMoveSpeed = robotMoveSpeed;
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayPV.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayPV.java
new file mode 100644
index 0000000..ed20ba5
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/DisplayPV.java
@@ -0,0 +1,90 @@
+package com.example.roughapp2_0bbwiredrpm.models;
+
+import androidx.databinding.BaseObservable;
+
+public class DisplayPV extends BaseObservable {
+
+ private int id;
+
+ private int laneChangeDistance;
+ private double horizontalDistance;
+ private double verticalDistance;
+ private double verticalAdjust;
+ private double leftCompensation;
+ private double rightCompensation;
+ private int pressSet;
+
+ public DisplayPV(int id, int laneChangeDistance, double horizontalDistance, double verticalDistance, double verticalAdjust, double leftCompensation, double rightCompensation ,int pressSet) {
+ this.id = id;
+ this.laneChangeDistance=laneChangeDistance;
+ this.horizontalDistance = horizontalDistance;
+ this.verticalDistance = verticalDistance;
+ this.verticalAdjust=verticalAdjust;
+ this.leftCompensation = leftCompensation;
+ this.rightCompensation=rightCompensation;
+ this.pressSet=pressSet;
+
+ }
+
+
+ public int getId() { return id; }
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+
+ public int getLaneChangeDistance() {
+ return laneChangeDistance;
+ }
+ public void setLaneChangeDistance(int laneChangeDistance) { this.laneChangeDistance = laneChangeDistance;}
+
+ public double getHorizontalDistance() {
+ return horizontalDistance;
+ }
+ public void setHorizontalDistance(double horizontalDistance) { this.horizontalDistance = horizontalDistance;}
+
+ public double getVerticalDistance() {
+ return verticalDistance;
+ }
+ public void setVerticalDistance(double verticalDistance) {
+ this.verticalDistance = verticalDistance;
+ }
+
+ public double getVerticalAdjust(){
+ return verticalAdjust;
+ }
+ public void setVerticalAdjust(double verticalAdjust) {
+ this.verticalAdjust = verticalAdjust;
+ }
+
+
+ public double getLeftCompensation() {
+ return leftCompensation;
+ }
+ public void setLeftCompensation(double leftCompensation) {
+ this.leftCompensation = leftCompensation;
+ }
+
+ public double getRightCompensation() {
+ return rightCompensation;
+ }
+ public void setRightCompensation(double rightCompensation) {
+ this.rightCompensation = rightCompensation;
+ }
+
+ public int getPressSet() {
+ return pressSet;
+ }
+ public void setPressSet(int pressSet) {
+ this.pressSet = pressSet;
+ }
+
+
+
+
+
+
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ErrorModel.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ErrorModel.java
new file mode 100644
index 0000000..51e5dd0
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ErrorModel.java
@@ -0,0 +1,44 @@
+package com.example.roughapp2_0bbwiredrpm.models;
+
+public class ErrorModel {
+
+ public ErrorModel(long timeID, String errorInfo) {
+ this.timeID = timeID;
+ this.errorInfo = errorInfo;
+ }
+ private long timeID;
+
+
+ public void setDateTimeBJ(String dateTimeUTC) {
+ this.dateTimeBJ = dateTimeUTC;
+ }
+
+ private String errorInfo;
+
+ public String getDateTimeBJ() {
+ return dateTimeBJ;
+ }
+
+ private String dateTimeBJ;
+
+
+ @Override
+ public String toString() {
+ return String.valueOf(dateTimeBJ + errorInfo);
+ }
+ public void setTimeID(long timeID) {
+ this.timeID = timeID;
+ }
+
+ public void setErrorInfo(String errorInfo) {
+ this.errorInfo = errorInfo;
+ }
+
+ public long getTimeID() {
+ return timeID;
+ }
+
+ public String getErrorInfo() {
+ return errorInfo;
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ScrollBottomScrollView.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ScrollBottomScrollView.java
new file mode 100644
index 0000000..d052dc7
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/models/ScrollBottomScrollView.java
@@ -0,0 +1,43 @@
+package com.example.roughapp2_0bbwiredrpm.models;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.ScrollView;
+
+public class ScrollBottomScrollView extends ScrollView {
+
+ private OnScrollBottomListener listener;
+ private int calCount;
+
+ public interface OnScrollBottomListener {
+ void scrollToBottom();
+ }
+
+ public void onScrollViewScrollToBottom(OnScrollBottomListener l) {
+ listener = l;
+ }
+
+ public void unRegisterOnScrollViewScrollToBottom() {
+ listener = null;
+ }
+
+ public ScrollBottomScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+ View view = this.getChildAt(0);
+ if (this.getHeight() + this.getScrollY() == view.getHeight()) {
+ calCount++;
+ if (calCount == 1) {
+ if (listener != null) {
+ listener.scrollToBottom();
+ }
+ }
+ } else {
+ calCount = 0;
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CCITT_CRC16.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CCITT_CRC16.java
new file mode 100644
index 0000000..bac3c7a
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CCITT_CRC16.java
@@ -0,0 +1,55 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+//用来校验有线的subs通道数据
+public class CCITT_CRC16 {
+
+
+ /**
+ * 计算XMODEM-CRC16校验值(符合XMODEM协议标准)
+ * @param data 待校验的字节数组
+ * @return 包含2个字节的CRC16校验结果数组(高位在前,低位在后)
+ */
+ public static byte[] calculateXModemCRC16(byte[] data) {
+ // 1. 参数合法性校验,避免空指针和空数组异常
+ if (data == null || data.length == 0) {
+ return new byte[]{0x00, 0x00}; // 空数据返回0值数组
+ }
+
+ // 2. XMODEM-CRC16 核心参数
+ int crc = 0x0000; // 初始值为0(区别于CCITT的0xFFFF)
+ final int POLYNOMIAL = 0x1021; // 固定多项式0x1021
+
+ // 3. 逐字节处理输入数据
+ for (byte b : data) {
+ // 将字节转为无符号整数(解决Java byte有符号的问题)
+ int byteValue = b & 0xFF;
+ // 先异或当前字节到CRC的高8位
+ crc ^= (byteValue << 8);
+
+ // 逐位处理8个比特
+ for (int i = 0; i < 8; i++) {
+ // 判断最高位是否为1
+ if ((crc & 0x8000) != 0) {
+ // 左移1位后异或多项式
+ crc = (crc << 1) ^ POLYNOMIAL;
+ } else {
+ // 仅左移1位
+ crc = crc << 1;
+ }
+ // 保留低16位,防止整数溢出
+ crc &= 0xFFFF;
+ }
+ }
+
+ // 4. 将16位CRC结果拆分为2字节数组(高位在前,符合XMODEM标准)
+ byte[] crcResult = new byte[2];
+ crcResult[0] = (byte)(crc & 0xFF); // 低8位
+ crcResult[1] = (byte)((crc >> 8) & 0xFF); // 高8位
+
+ return crcResult;
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CommunicationMethond.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CommunicationMethond.java
new file mode 100644
index 0000000..d135ebe
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CommunicationMethond.java
@@ -0,0 +1,6 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+public enum CommunicationMethond {
+ Wireless, Wired
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ConvertHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ConvertHelper.java
new file mode 100644
index 0000000..44107ee
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ConvertHelper.java
@@ -0,0 +1,26 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.widget.EditText;
+import android.widget.TextView;
+
+public class ConvertHelper {
+
+ public static int convertEditTextToInt(TextView editText) {
+ // 获取 EditText 中的文本
+ String input = editText.getText().toString().trim();
+ try {
+ // 尝试将字符串转换为整数
+ return Integer.parseInt(input);
+ } catch (NumberFormatException e) {
+ // 输入不是有效的整数格式,返回 -1 表示转换失败
+ return -1;
+ }
+ }
+
+ public static boolean isEditTextNullOrEmpty(EditText editText) {
+
+ String str = String.valueOf(editText.getText());
+
+ return str == null || str.isEmpty();
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CustomProber.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CustomProber.java
new file mode 100644
index 0000000..16ecb0e
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/CustomProber.java
@@ -0,0 +1,22 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import com.hoho.android.usbserial.driver.FtdiSerialDriver;
+import com.hoho.android.usbserial.driver.ProbeTable;
+import com.hoho.android.usbserial.driver.UsbSerialProber;
+
+/**
+ * add devices here, that are not known to DefaultProber
+ *
+ * if the App should auto start for these devices, also
+ * add IDs to app/src/main/res/xml/device_filter.xml
+ */
+public class CustomProber {
+
+ public static UsbSerialProber getCustomProber() {
+ ProbeTable customTable = new ProbeTable();
+ customTable.addProduct(0x1234, 0x0001, FtdiSerialDriver.class); // e.g. device with custom VID+PID
+ customTable.addProduct(0x1234, 0x0002, FtdiSerialDriver.class); // e.g. device with custom VID+PID
+ return new UsbSerialProber(customTable);
+ }
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DataExchangeHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DataExchangeHelper.java
new file mode 100644
index 0000000..1400114
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DataExchangeHelper.java
@@ -0,0 +1,155 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+import com.example.roughapp2_0bbwiredrpm.models.BspIV;
+import com.example.roughapp2_0bbwiredrpm.models.BspPV;
+import com.google.protobuf.InvalidProtocolBufferException;
+
+public class DataExchangeHelper {
+
+
+
+
+
+
+ public static int[] decodedCH = new int[17];
+ static double slope = 1000.0 / (1950 - 1500);
+
+ public static int[] getdecodedCH(byte[] receivedData) {
+ for (int i = 0; i < 16; i++) {
+ decodedCH[i] = ((receivedData[8 + i * 2] & 0xFF) | (receivedData[9 + i * 2] & 0xFF) << 8);
+ }
+
+ for (int i = 0; i < 16; i++) {
+ decodedCH[i] = (int) Math.round(slope * (decodedCH[i] - 1500));
+ }
+ return decodedCH;
+ }
+
+
+ public static byte[] getSendPVBytes(BspPV.PV_struct_define _toSendPV) {
+ byte[] byteArray = _toSendPV.toByteArray();
+ byte[] sendbyteArray = new byte[byteArray.length + 4];
+ byte[] sendbyteArray3 = new byte[byteArray.length + 6];
+ if (byteArray.length != 0) {
+ System.arraycopy(byteArray, 0, sendbyteArray, 4, byteArray.length);
+ }
+ sendbyteArray[0] = (byte) 0x55;
+ sendbyteArray[1] = (byte) 0x55;
+ sendbyteArray[2] = (byte) 0x01;
+ sendbyteArray[3] = (byte) 0x01;
+ byte[] byteArray2 = ModbusCRC.calculateCRC(sendbyteArray);
+ System.arraycopy(sendbyteArray, 0, sendbyteArray3, 0, sendbyteArray.length);
+ System.arraycopy(byteArray2, 0, sendbyteArray3, sendbyteArray3.length - 2, 2);
+ return sendbyteArray3;
+ }
+
+ public static BspIV.IV_struct_define getIVByBytes(byte[] data) {
+ byte[] crcbytes = new byte[data.length - 2];
+ System.arraycopy(data, 0, crcbytes, 0, data.length - 2);
+ byte[] crc = ModbusCRC.calculateCRC(crcbytes);
+ // status(bytesToHex(data));
+ if (data[data.length - 2] == (byte) (crc[1] & 0xff) && data[data.length - 1] == (byte) (crc[0] & 0xff)) {
+ if ((data[0] == 0x55) && (data[1] == 0x55)) {
+ byte[] bytes = new byte[data.length - 4];
+ System.arraycopy(data, 2, bytes, 0, data.length - 4);
+ try {
+ BspIV.IV_struct_define _toReceiveIV = BspIV.IV_struct_define.parseFrom(bytes);
+ return _toReceiveIV;
+ } catch (InvalidProtocolBufferException ex) {
+ return null;
+ }
+ }
+ return null;
+ }
+ return null;
+ }
+
+ public static BspIV.IV_struct_define getIVByModbus() {
+
+ try {
+ //定义100 是IV的数据开头数组个数 建立多少个字节数组
+ byte[] bytes = new byte[ModbusRtuSlaveService.holdingRegisters[100]];
+ int modifyHoldingRegisterNum = (bytes.length + 1) / 2;
+ for (int i = 0; i < modifyHoldingRegisterNum; i++) {
+ bytes[2 * i] = (byte) (ModbusRtuSlaveService.holdingRegisters[101 + i] >> 8);
+ if (2 * i + 1 > bytes.length - 1) {
+ break;
+ }
+
+ bytes[2 * i + 1] = (byte) (ModbusRtuSlaveService.holdingRegisters[101 + i] & 0xff);
+ }
+
+ BspIV.IV_struct_define _toReceiveIV = BspIV.IV_struct_define.parseFrom(bytes);
+ return _toReceiveIV;
+ } catch (InvalidProtocolBufferException ex) {
+ return null;
+ }
+ }
+
+ //_toSendPV 换算成bytes
+ public static void setModbusPVValues(BspPV.PV_struct_define _toSendPV) {
+
+ byte[] byteArray = _toSendPV.toByteArray();
+ byte[] bytesToSend;
+ int modifyHoldingRegisterNum = (byteArray.length + 1) / 2;
+
+ if (byteArray.length != 0) {
+ if (byteArray.length % 2 != 0) {
+ bytesToSend = new byte[byteArray.length + 1];
+ bytesToSend[bytesToSend.length - 1] = 0;
+
+ } else {
+ bytesToSend = new byte[byteArray.length];
+ }
+ System.arraycopy(byteArray, 0, bytesToSend, 0, byteArray.length);
+
+ ModbusRtuSlaveService.holdingRegisters[18] = (short) byteArray.length;
+ //将数据转为小端发送
+ for (int i = 0; i < modifyHoldingRegisterNum; i++) {
+
+
+ ModbusRtuSlaveService.holdingRegisters[19 + i] = (short) (
+ ((bytesToSend[2 * i + 1] & 0xFF) << 8) | // 高位字节
+ bytesToSend[2 * i] & 0xFF); // 低位字节
+
+ // (short) ((bytesToSend[2 * i + 1]) << 8 | ((short)bytesToSend[2 * i]));
+ }
+
+ }
+ }
+
+
+ /**
+ * 判断字符串是否是数字
+ */
+ public static boolean isNumber(String value) {
+ return isInteger(value) || isDouble(value);
+ }
+
+ /**
+ * 判断字符串是否是整数
+ */
+ public static boolean isInteger(String value) {
+ try {
+ Integer.parseInt(value);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ /**
+ * 判断字符串是否是浮点数
+ */
+ public static boolean isDouble(String value) {
+ try {
+ Double.parseDouble(value);
+ if (value.contains("."))
+ return true;
+ return false;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DecimalDigitsInputFilter.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DecimalDigitsInputFilter.java
new file mode 100644
index 0000000..1f797ac
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/DecimalDigitsInputFilter.java
@@ -0,0 +1,71 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.text.InputFilter;
+import android.text.Spanned;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/*
+ 自定义 InputFilter 类,用于限制输入格式
+ 支持整数、负数和最多一位小数的输入
+ 使用方法:editText.setFilters(new InputFilter[]{new DecimalDigitsInputFilter()});
+*/
+public class DecimalDigitsInputFilter implements InputFilter {
+ // 最终验证的正则表达式
+ private final Pattern mFinalPattern;
+ // 中间状态允许的正则表达式
+ private final Pattern mIntermediatePattern;
+
+ public DecimalDigitsInputFilter() {
+ // 最终验证:必须是完整的数字格式
+ mFinalPattern = Pattern.compile("^-?(0|[1-9]\\d*)(\\.\\d)?$");
+
+ // 中间状态:允许临时的不完整格式(如 "-"、"0."、"-2.")
+ mIntermediatePattern = Pattern.compile("^-?(0|[1-9]\\d*)?(\\.)?$");
+ }
+
+ @Override
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
+ // 处理删除操作
+ if (end - start == 0) {
+ return null;
+ }
+
+ // 拼接新的输入内容
+ String newText = dest.toString().substring(0, dstart) +
+ source.toString().substring(start, end) +
+ dest.toString().substring(dend);
+
+ // 允许空字符串或单独的负号
+ if (newText.isEmpty() || newText.equals("-")) {
+ return null;
+ }
+
+ // 防止前导零(除非是 0 或 0.x)
+ if (newText.startsWith("0") && newText.length() > 1 &&
+ !newText.startsWith("0.") && !newText.equals("0")) {
+ return "";
+ }
+
+ // 防止多个负号
+ if (newText.indexOf('-') > 0) {
+ return "";
+ }
+
+ // 防止多个小数点
+ if (newText.indexOf('.') != newText.lastIndexOf('.')) {
+ return "";
+ }
+
+ // 检查是否匹配最终模式或中间模式
+ Matcher finalMatcher = mFinalPattern.matcher(newText);
+ Matcher intermediateMatcher = mIntermediatePattern.matcher(newText);
+
+ if (finalMatcher.matches() || intermediateMatcher.matches()) {
+ return null; // 匹配成功,允许输入
+ }
+
+ return ""; // 匹配失败,阻止输入
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ErrorDeocdeHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ErrorDeocdeHelper.java
new file mode 100644
index 0000000..ffe4ba1
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ErrorDeocdeHelper.java
@@ -0,0 +1,59 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import com.example.roughapp2_0bbwiredrpm.models.BspError;
+
+public class ErrorDeocdeHelper {
+
+ //private static Map flagMap = new HashMap<>();
+
+// public static void AddMap(String errorName, Integer bitPosition)
+// {
+// flagMap.put(errorName,bitPosition);
+// }
+ private static String ErrorResult;
+ private static String addErrorResult;
+ public static String ErrorDeocde(int data)
+ {
+ ErrorResult="";
+
+ // 循环遍历 Map
+ for (BspError.ComError err : BspError.ComError.values()) {
+
+ int bitPosiiton = err.ordinal();
+// if (err.toString().equals("UNRECOGNIZED")) continue;
+// if (err.toString().equals("TL720D"))
+// addErrorResult = " 作业模式已切换至手动";
+// else
+// addErrorResult = " ";
+//
+// if (err.toString().equals("MK32_InitialState"))
+// addErrorResult = " 遥控器按键未复位";
+// else
+// addErrorResult = " ";
+
+
+ // 使用左移操作生成要检查的标志位
+ int bitToCheck = 1 << bitPosiiton;
+
+ // 判断该位置是否有对应的标志位
+ if ((data & bitToCheck) != 0)
+ {
+
+ // ErrorResult += String.valueOf(bitPosiiton);
+
+ if (err.toString().equals("Remote_Button_Reset_State"))
+ {
+ ErrorResult = "未复位" ;
+ }
+// else
+// {
+// ErrorResult += err.toString()+addErrorResult+"\t";
+// }
+ }
+ }
+ return ErrorResult;
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/LogUtil.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/LogUtil.java
new file mode 100644
index 0000000..c0a817c
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/LogUtil.java
@@ -0,0 +1,39 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.util.Log;
+
+public class LogUtil {
+ private String TAG;
+ private boolean isRelease = false;
+ private boolean isDebug;
+
+ public LogUtil(Class c, boolean isDebug) {
+ this.TAG = c.getName();
+ this.isDebug = isDebug;
+ }
+
+ public void d(String msg) {
+ if (!isRelease && isDebug) {
+ Log.d(TAG, "--------->" + msg);
+ }
+ }
+
+ public void i(String msg) {
+ if (!isRelease && isDebug) {
+ Log.i(TAG, "--------->" + msg);
+ }
+ }
+
+ public void w(String msg) {
+ if (!isRelease && isDebug) {
+ Log.w(TAG, "--------->" + msg);
+ }
+ }
+
+ public void e(String msg) {
+ if (!isRelease && isDebug) {
+ Log.e(TAG, "--------->" + msg);
+ }
+ }
+}
+
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusCRC.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusCRC.java
new file mode 100644
index 0000000..c542627
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusCRC.java
@@ -0,0 +1,72 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+public class ModbusCRC {
+
+// /**
+// * 一个字节包含位的数量 8
+// */
+// private static final int BITS_OF_BYTE = 8;
+// /**
+// * 多项式
+// */
+// private static final int POLYNOMIAL = 0xA001;
+// /**
+// * 初始值
+// */
+// private static final int INITIAL_VALUE = 0xFFFF;
+//
+// /**
+// * CRC16 编码
+// *
+// * @param bytes 编码内容
+// * @return 编码结果
+// */
+// public static int crc16(byte[] bytes) {
+// int res = INITIAL_VALUE;
+// for (int data : bytes) {
+// res = res ^ data;
+// for (int i = 0; i < BITS_OF_BYTE; i++) {
+// res = (res & 0x0001) == 1 ? (res >> 1) ^ POLYNOMIAL : res >> 1;
+// }
+// }
+// return revert(res);
+// }
+//
+// /**
+// * 翻转16位的高八位和低八位字节
+// *
+// * @param src 翻转数字
+// * @return 翻转结果
+// */
+// private static int revert(int src) {
+// int lowByte = (src & 0xFF00) >> 8;
+// int highByte = (src & 0x00FF) << 8;
+// return lowByte | highByte;
+// }
+
+
+ /**
+ * 计算 Modbus CRC 校验值
+ * @param data 要计算校验值的字节数组
+ * @return CRC 校验值,以 2 字节的数组形式返回
+ */
+ public static byte[] calculateCRC(byte[] data) {
+ int crc = 0xFFFF;
+ for (byte b : data) {
+ crc ^= (b & 0xFF);
+ for (int i = 0; i < 8; i++) {
+ if ((crc & 0x0001) != 0) {
+ crc >>= 1;
+ crc ^= 0xA001;
+ } else {
+ crc >>= 1;
+ }
+ }
+ }
+ // 将 CRC 结果拆分为两个字节
+ byte[] crcBytes = new byte[2];
+ crcBytes[0] = (byte) (crc & 0xFF);
+ crcBytes[1] = (byte) ((crc >> 8) & 0xFF);
+ return crcBytes;
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusRtuSlaveService.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusRtuSlaveService.java
new file mode 100644
index 0000000..f16b963
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ModbusRtuSlaveService.java
@@ -0,0 +1,508 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.util.Log;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class ModbusRtuSlaveService {
+ public static void ModbusRtuSlaveServiceIntialize(USBSerialPortHelper serialPortHelper) {
+ _serialPortHelper = serialPortHelper;
+ initializeData();
+
+ }
+
+ public static final String TAG = "ModbusRtuSlave";
+ public static final int slaveId = 0x40;
+ public static Thread readThread;
+ public final AtomicBoolean shouldRead = new AtomicBoolean(false);
+ public static USBSerialPortHelper _serialPortHelper;
+
+ // Modbus 数据存储
+ public static final boolean[] coils = new boolean[65536];
+ public static final boolean[] discreteInputs = new boolean[65536];
+
+ public static final short[] holdingRegisters_temp = new short[65536];
+ public static final short[] holdingRegisters = new short[65536];
+ public static final short[] inputRegisters = new short[65536];
+
+ // 数据更新监听器
+ public DataUpdateListener dataUpdateListener;
+
+ public interface DataUpdateListener {
+ void onCoilUpdated(int address, boolean value);
+
+ void onRegisterUpdated(int address, short value);
+
+ void onError(String errorMessage);
+ }
+
+ public static void initializeData() {
+ // 初始化示例数据
+ Arrays.fill(holdingRegisters, (short) 0);
+ Arrays.fill(inputRegisters, (short) 0);
+ Arrays.fill(coils, false);
+ Arrays.fill(discreteInputs, false);
+
+ // 设置一些默认值 可以处理一些默认值 后面
+
+
+ }
+
+
+ public final byte[] buffer = new byte[256];
+
+ //处理Modbus数据,这个可以在数据接收后调用 返回调用的功能码
+ public static int processModbusRequest(byte[] request, int length) {
+ if (length < 4) {
+ Log.w(TAG, "Request too short: " + length + " bytes");
+ return 0;
+ }
+
+ // 提取从站地址
+ byte receivedSlaveId = request[0];
+ if (receivedSlaveId != slaveId && receivedSlaveId != 0) {
+ Log.d(TAG, "Request not for this slave. Target: " + receivedSlaveId + ", Our ID: " + slaveId);
+ return 0;
+ }
+
+ Log.d(TAG, "Processing request for slave: " + receivedSlaveId);
+
+ // 验证CRC
+ if (!validateCrc(request, length)) {
+ Log.w(TAG, "CRC validation failed");
+ return 0;
+ }
+
+ // 处理Modbus请求
+ byte[] response = handleModbusFrame(request, length);
+ if (response != null && response.length > 0) {
+ try {
+ sendResponse(response);
+ return request[1];//返回功能码
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ public static byte[] handleModbusFrame(byte[] frame, int length) {
+ if (length < 4) return null;
+
+ byte functionCode = frame[1];
+ byte[] response;// null;
+
+ Log.d(TAG, "Handling function code: 0x" + String.format("%02X", functionCode));
+
+ try {
+ switch (functionCode) {
+ case 0x01: // Read Coils
+ response = handleReadCoils(frame, length);
+ break;
+ case 0x02: // Read Discrete Inputs
+ response = handleReadDiscreteInputs(frame, length);
+ break;
+ case 0x03: // Read Holding Registers
+ response = handleReadHoldingRegisters(frame, length);
+ break;
+ case 0x04: // Read Input Registers
+ response = handleReadInputRegisters(frame, length);
+ break;
+ case 0x05: // Write Single Coil
+ response = handleWriteSingleCoil(frame, length);
+ break;
+ case 0x06: // Write Single Register
+ response = handleWriteSingleRegister(frame, length);
+ break;
+ case 0x0F: // Write Multiple Coils
+ response = handleWriteMultipleCoils(frame, length);
+ break;
+ case 0x10: // Write Multiple Registers
+ response = handleWriteMultipleRegisters(frame, length);
+ break;
+ default:
+ Log.w(TAG, "Unsupported function code: 0x" + String.format("%02X", functionCode));
+ response = createExceptionResponse(functionCode, (byte) 0x01); // Illegal function
+ break;
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Error handling Modbus request: " + e.getMessage());
+ response = createExceptionResponse(functionCode, (byte) 0x04); // Slave device failure
+ }
+
+ return response;
+ }
+
+ public static byte[] handleWriteMultipleRegisters(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+ int byteCount = request[6] & 0xFF;
+
+ Log.d(TAG, "Write Multiple Registers - Start: " + startAddress + ", Quantity: " + quantity);
+
+ if (quantity < 1 || quantity > 123) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ if (startAddress + quantity > holdingRegisters.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+
+ if (byteCount != quantity * 2) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ // 解析并写入寄存器数据
+ for (int i = 0; i < quantity; i++) {
+ int dataIndex = 7 + i * 2;
+ short value = (short) (((request[dataIndex] & 0xFF) << 8) | (request[dataIndex + 1] & 0xFF));
+
+ int registerAddress = startAddress + i;
+ holdingRegisters[registerAddress] = value;
+
+ }
+
+ byte[] response = createWriteMultipleResponse(request[1], startAddress, quantity);
+ Log.d(TAG, "Wrote " + quantity + " registers from address " + startAddress);
+ return response;
+ }
+
+ public static byte[] handleWriteMultipleCoils(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+ int byteCount = request[6] & 0xFF;
+
+ Log.d(TAG, "Write Multiple Coils - Start: " + startAddress + ", Quantity: " + quantity);
+
+ if (quantity < 1 || quantity > 1968) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ if (startAddress + quantity > coils.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+
+ int expectedByteCount = (quantity + 7) / 8;
+ if (byteCount != expectedByteCount) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ // 解析并写入线圈数据
+ for (int i = 0; i < quantity; i++) {
+ int byteIndex = 7 + (i / 8);
+ int bitIndex = i % 8;
+ boolean value = ((request[byteIndex] >> bitIndex) & 0x01) == 0x01;
+
+ int coilAddress = startAddress + i;
+ coils[coilAddress] = value;
+
+ }
+
+ byte[] response = createWriteMultipleResponse(request[1], startAddress, quantity);
+ Log.d(TAG, "Wrote " + quantity + " coils from address " + startAddress);
+ return response;
+ }
+
+ public static byte[] createWriteMultipleResponse(byte functionCode, int startAddress, int quantity) {
+ byte[] response = new byte[8];
+
+ response[0] = (byte) slaveId;
+ response[1] = functionCode;
+ response[2] = (byte) (startAddress >> 8);
+ response[3] = (byte) (startAddress & 0xFF);
+ response[4] = (byte) (quantity >> 8);
+ response[5] = (byte) (quantity & 0xFF);
+
+ addCrc(response);
+ return response;
+ }
+
+ public static byte[] createExceptionResponse(byte functionCode, byte exceptionCode) {
+ byte[] response = new byte[5];
+ response[0] = (byte) slaveId;
+ response[1] = (byte) (functionCode | 0x80);
+ response[2] = exceptionCode;
+ addCrc(response);
+
+ Log.w(TAG, "Exception response - Function: 0x" + String.format("%02X", functionCode) +
+ ", Code: " + exceptionCode);
+ return response;
+ }
+
+ public static byte[] handleReadDiscreteInputs(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+
+ Log.d(TAG, "Read Discrete Inputs - Start: " + startAddress + ", Quantity: " + quantity);
+
+ if (quantity < 1 || quantity > 2000) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ if (startAddress + quantity > discreteInputs.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+
+ // 读离散输入响应结构:
+// [slaveId] + [function] + [byteCount] + [data] + [CRC]
+// 1字节 + 1字节 + 1字节 + N字节 + 2字节
+
+
+ int byteCount = (quantity + 7) / 8;
+ byte[] response = new byte[3 + byteCount + 2];
+ response[0] = (byte) slaveId;
+ response[1] = request[1];
+ response[2] = (byte) byteCount;
+
+ for (int i = 0; i < quantity; i++) {
+ if (discreteInputs[startAddress + i]) {
+ response[3 + i / 8] |= (1 << (i % 8));
+ }
+ }
+
+ addCrc(response);
+ Log.d(TAG, "Read " + quantity + " discrete inputs from address " + startAddress);
+ return response;
+ }
+
+ public static byte[] handleReadInputRegisters(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+
+ Log.d(TAG, "Read Input Registers - Start: " + startAddress + ", Quantity: " + quantity);
+
+ if (quantity < 1 || quantity > 125) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ if (startAddress + quantity > inputRegisters.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+// 读输入寄存器响应结构:
+// [slaveId] + [function] + [byteCount] + [data] + [CRC]
+// 1字节 + 1字节 + 1字节 + (quantity × 2) + 2字节
+
+ byte[] response = new byte[3 + quantity * 2 + 2];
+ response[0] = (byte) slaveId;
+ response[1] = request[1];
+ response[2] = (byte) (quantity * 2);
+
+ for (int i = 0; i < quantity; i++) {
+ short value = inputRegisters[startAddress + i];
+ response[3 + i * 2] = (byte) (value >> 8);
+ response[3 + i * 2 + 1] = (byte) value;
+ }
+
+ addCrc(response);
+ Log.d(TAG, "Read " + quantity + " input registers from address " + startAddress);
+ return response;
+ }
+
+ public static byte[] handleReadHoldingRegisters(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+
+ Log.d(TAG, "Read Holding Registers - Start: " + startAddress + ", Quantity: " + quantity);
+
+ // 验证参数
+ if (quantity < 1 || quantity > 125) {
+ Log.w(TAG, "Invalid quantity: " + quantity);
+ return createExceptionResponse(request[1], (byte) 0x03); // Illegal data value
+ }
+
+ if (startAddress + quantity > holdingRegisters.length) {
+ Log.w(TAG, "Address out of range: " + startAddress);
+ return createExceptionResponse(request[1], (byte) 0x02); // Illegal data address
+ }
+
+ // 读保持寄存器响应数据结构:
+// [slaveId] + [function] + [byteCount] + [data] + [CRC]
+// 1字节 + 1字节 + 1字节 + (quantity × 2) + 2字节
+ byte[] response = new byte[1 + 1 + 1 + quantity * 2 + 2]; // slaveId + function + byteCount + data + CRC
+ response[0] = (byte) slaveId;
+ response[1] = request[1]; // Function code
+ response[2] = (byte) (quantity * 2); // Byte count
+
+ // 填充寄存器数据
+ for (int i = 0; i < quantity; i++) {
+ short value = holdingRegisters[startAddress + i];
+ response[3 + i * 2] = (byte) (value >> 8);
+ response[3 + i * 2 + 1] = (byte) value;
+ }
+
+ // 添加CRC
+ addCrc(response);
+
+ Log.d(TAG, "Read " + quantity + " holding registers from address " + startAddress);
+ return response;
+ }
+
+ public static byte[] handleWriteSingleRegister(byte[] request, int length) {
+ int address = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ short value = (short) (((request[4] & 0xFF) << 8) | (request[5] & 0xFF));
+
+ Log.d(TAG, "Write Single Register - Address: " + address + ", Value: " + value);
+
+ if (address >= holdingRegisters.length) {
+ Log.w(TAG, "Register address out of range: " + address);
+ return createExceptionResponse(request[1], (byte) 0x02); // Illegal data address
+ }
+
+ // 更新寄存器值
+ holdingRegisters[address] = value;
+
+
+ // 写单个寄存器响应结构:
+// [slaveId] + [function] + [address] + [value] + [CRC]
+// 1字节 + 1字节 + 2字节 + 2字节 + 2字节
+ byte[] response = new byte[8];
+ System.arraycopy(request, 0, response, 0, 6);
+ response[0] = (byte) slaveId;
+ addCrc(response);
+
+
+ Log.d(TAG, "Register " + address + " updated to: " + value);
+ return response;
+ }
+
+ public static byte[] handleReadCoils(byte[] request, int length) {
+ int startAddress = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ int quantity = ((request[4] & 0xFF) << 8) | (request[5] & 0xFF);
+
+ Log.d(TAG, "Read Coils - Start: " + startAddress + ", Quantity: " + quantity);
+
+ if (quantity < 1 || quantity > 2000) {
+ return createExceptionResponse(request[1], (byte) 0x03);
+ }
+
+ if (startAddress + quantity > coils.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+
+ // 读线圈响应结构:
+// [slaveId] + [function] + [byteCount] + [data] + [CRC]
+// 1字节 + 1字节 + 1字节 + N字节 + 2字节
+
+// 数据字节数计算:N = ceil(quantity / 8)
+// int byteCount = (quantity + 7) / 8; // 向上取整
+// int totalBytes = 1 + 1 + 1 + byteCount + 2; // 5 + byteCount
+
+
+ int byteCount = (quantity + 7) / 8;
+ byte[] response = new byte[3 + byteCount + 2]; // slaveId + function + byteCount + data + CRC
+ response[0] = (byte) slaveId;
+ response[1] = request[1];
+ response[2] = (byte) byteCount;
+
+ // 打包线圈状态到字节
+ for (int i = 0; i < quantity; i++) {
+ if (coils[startAddress + i]) {
+ response[3 + i / 8] |= (1 << (i % 8));
+ }
+ }
+
+ addCrc(response);
+ return response;
+ }
+
+ public static byte[] handleWriteSingleCoil(byte[] request, int length) {
+ int address = ((request[2] & 0xFF) << 8) | (request[3] & 0xFF);
+ boolean value = (request[4] & 0xFF) == 0xFF;
+
+ Log.d(TAG, "Write Single Coil - Address: " + address + ", Value: " + value);
+
+ if (address >= coils.length) {
+ return createExceptionResponse(request[1], (byte) 0x02);
+ }
+
+ coils[address] = value;
+
+
+// 写单个线圈响应结构:
+// [slaveId] + [function] + [address] + [value] + [CRC]
+// 1字节 + 1字节 + 2字节 + 2字节 + 2字节 固定 8 字节 byte[] response = new byte[1 + 1 + 2 + 2 + 2]; //
+
+ byte[] response = new byte[8];
+ System.arraycopy(request, 0, response, 0, 6);
+ response[0] = (byte) slaveId;
+ addCrc(response);
+
+ Log.d(TAG, "Coil " + address + " updated to: " + value);
+ return response;
+ }
+
+ public static boolean validateCrc(byte[] data, int length) {
+ if (length < 2) return false;
+
+ int calculatedCrc = calculateCrc(data, 0, length - 2);
+ int receivedCrc = (data[length - 1] & 0xFF) << 8 | (data[length - 2] & 0xFF);
+
+ boolean valid = calculatedCrc == receivedCrc;
+ if (!valid) {
+ Log.w(TAG, "CRC mismatch - Calculated: " + calculatedCrc + ", Received: " + receivedCrc);
+ }
+
+ return valid;
+ }
+
+ public static void addCrc(byte[] data) {
+ int crc = calculateCrc(data, 0, data.length - 2);
+ data[data.length - 2] = (byte) (crc & 0xFF);
+ data[data.length - 1] = (byte) ((crc >> 8) & 0xFF);
+ }
+
+ public static int calculateCrc(byte[] data, int start, int length) {
+ int crc = 0xFFFF;
+ for (int i = start; i < start + length; i++) {
+ crc ^= (data[i] & 0xFF);
+ for (int j = 0; j < 8; j++) {
+ if ((crc & 0x0001) != 0) {
+ crc >>= 1;
+ crc ^= 0xA001;
+ } else {
+ crc >>= 1;
+ }
+ }
+ }
+ return crc;
+ }
+
+ public static void sendResponse(byte[] response) {
+ if (_serialPortHelper == null) {
+ return;
+ }
+ _serialPortHelper.SendData(response);
+ Log.d(TAG, "Sent response: " + response.length + " bytes");
+ }
+
+ // 公共API方法
+ public static void updateHoldingRegister(int address, short value) {
+ if (address >= 0 && address < holdingRegisters.length) {
+ holdingRegisters[address] = value;
+ }
+ }
+
+ public static short getHoldingRegister(int address) {
+ if (address >= 0 && address < holdingRegisters.length) {
+ return holdingRegisters[address];
+ }
+ return 0;
+ }
+
+ public static void updateCoil(int address, boolean state) {
+ if (address >= 0 && address < coils.length) {
+ coils[address] = state;
+
+ }
+ }
+
+ public static boolean getCoil(int address) {
+ if (address >= 0 && address < coils.length) {
+ return coils[address];
+ }
+ return false;
+ }
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/MyDataHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/MyDataHelper.java
new file mode 100644
index 0000000..2a1242e
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/MyDataHelper.java
@@ -0,0 +1,210 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.annotation.SuppressLint;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.SQLException;
+import android.database.sqlite.SQLiteDatabase;//具体进行数据库、数据表的一个操作
+import android.database.sqlite.SQLiteOpenHelper;//用来创建数据库和对数据库进行版本管理
+import android.util.Log;
+
+import androidx.annotation.Nullable;
+
+import com.example.roughapp2_0bbwiredrpm.models.DisplayPV;
+import com.example.roughapp2_0bbwiredrpm.models.ErrorModel;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Date;
+import java.util.TimeZone;
+
+public class MyDataHelper extends SQLiteOpenHelper {
+ public static final String COLUMN_ID = "id";
+ public static final String TABLE_NAME_ROUGH = "rough";
+
+ public static final String COLUMN_PRESS_SET = "pressSet";//Maintv_PressTo32 压力设定
+
+ public static final String COLUMN_HORIZONTAL_DISTANCE = "horizontalDistance";/*横向距离*/
+ public static final String COLUMN_VERTICAL_DISTANCE = "verticalDistance"; /*纵向距离*/
+ public static final String COLUMN_LEFT_COMPENSATION = "leftCompensation"; /*左补偿*/
+ public static final String COLUMN_RIGHT_COMPENSATION = "rightCompensation"; /*右补偿*/
+ public static final String COLUMN_VERTICAL_ADJUST = "verticalAdjust";//Maintv_VerticalAdjustTo32 竖直微调
+ public static final String COLUMN_LANE_CHANGE_DISTANCE = "laneChangeDistance";//换道距离
+ public static final String Error_TABLE_NAME_ROUGH = "error";
+ public static final String Error_COLUMN_TimeStamp = "timeID";
+ public static final String Error_COLUMN_ERROR_INFO = "errorInfo";
+
+ List robotErrorList = new ArrayList<>() ;
+
+ public MyDataHelper(@Nullable Context context) {
+ super(context, "bingbot.db", null, 22);
+ }
+
+ @SuppressLint("SQLiteString")
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+
+ String sql = "CREATE TABLE " + TABLE_NAME_ROUGH + " (" +
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ COLUMN_LEFT_COMPENSATION + " DOUBLE, " +
+ COLUMN_RIGHT_COMPENSATION + " DOUBLE, " +
+ COLUMN_HORIZONTAL_DISTANCE + " DOUBLE, " +
+ COLUMN_VERTICAL_DISTANCE + " DOUBLE, " +
+ COLUMN_VERTICAL_ADJUST + " DOUBLE, " +
+ COLUMN_PRESS_SET + " INTEGER, " +
+ COLUMN_LANE_CHANGE_DISTANCE + " INTEGER);" ;
+ db.execSQL(sql); //执行sql语句 拉毛表
+
+
+ // (int id, int leftCompSelect, int rightCompSelect, int speedSelect, int laneChangeSelect, int endForceValue)
+
+ sql = "CREATE TABLE " + Error_TABLE_NAME_ROUGH + "(" + Error_COLUMN_TimeStamp + " INTEGER PRIMARY KEY ," +
+ Error_COLUMN_ERROR_INFO + " STRING " + ")";
+ db.execSQL(sql);
+
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_ROUGH);
+ db.execSQL("DROP TABLE IF EXISTS " + Error_TABLE_NAME_ROUGH);
+ onCreate(db);
+ }
+
+ //增 删 改 查
+ public String addOrUpdateDisplayDataRough(DisplayPV pv) {
+ ContentValues cv = new ContentValues(); //键值对的类
+ cv.put(COLUMN_ID, pv.getId());
+ cv.put(COLUMN_LANE_CHANGE_DISTANCE, pv.getLaneChangeDistance());
+ cv.put(COLUMN_HORIZONTAL_DISTANCE, pv.getHorizontalDistance());
+ cv.put(COLUMN_VERTICAL_DISTANCE, pv.getVerticalDistance());
+ cv.put(COLUMN_VERTICAL_ADJUST, pv.getVerticalAdjust());
+
+ cv.put(COLUMN_LEFT_COMPENSATION, pv.getLeftCompensation());
+ cv.put(COLUMN_RIGHT_COMPENSATION, pv.getRightCompensation());
+ cv.put(COLUMN_PRESS_SET, pv.getPressSet());
+
+
+
+ SQLiteDatabase sqliteDatabase = this.getWritableDatabase();//获取数据库实例以实现增上查改等,如果没有就新建 并把sqliteDatabase作为参数传给oncreate方法
+ long insert = sqliteDatabase.insertWithOnConflict(TABLE_NAME_ROUGH, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
+ sqliteDatabase.close();
+ if (insert == -1) {
+ return "failed";
+ }
+ return "success";
+ }
+
+
+
+ public void IntializeDataBaseRough() {
+
+ for (int i = 1; i < 6; i++) {
+ List list = getDisplayDataRough(i); //从数据库中读
+ if (list.size() == 0) {
+ DisplayPV pv = new DisplayPV(i, 0, 0, 0, 0, 0, 0,0);
+ addOrUpdateDisplayDataRough(pv);//一行一行添加
+ }
+ }
+ }
+
+ public List getDisplayDataRough(int id) { //初始化
+ List list = new ArrayList<>();
+ String sql = "SELECT * FROM " + TABLE_NAME_ROUGH + " WHERE " + COLUMN_ID + " = " + String.valueOf(id);
+ SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();//获取可写数据库实例
+ Cursor cursor = sqLiteDatabase.rawQuery(sql, null); //按id查询
+
+ int idIndex = cursor.getColumnIndex(COLUMN_ID);
+ int _laneChangeDistanceIndex = cursor.getColumnIndex(COLUMN_LANE_CHANGE_DISTANCE);
+ int _verticalAdjustIndex = cursor.getColumnIndex(COLUMN_VERTICAL_ADJUST);
+ int _pressSetIndex = cursor.getColumnIndex(COLUMN_PRESS_SET);
+ int _leftCompensationIndex=cursor.getColumnIndex(COLUMN_LEFT_COMPENSATION);
+ int _rightCompensationIndex=cursor.getColumnIndex(COLUMN_RIGHT_COMPENSATION);
+ int _horizontalDistanceIndex=cursor.getColumnIndex(COLUMN_HORIZONTAL_DISTANCE);
+ int _verticalDistanceIndex=cursor.getColumnIndex(COLUMN_VERTICAL_DISTANCE);
+
+ while (cursor.moveToNext()) {
+
+ DisplayPV pv = new DisplayPV(cursor.getInt(idIndex), cursor.getInt(_laneChangeDistanceIndex),
+ cursor.getDouble(_horizontalDistanceIndex), cursor.getDouble(_verticalDistanceIndex), cursor.getDouble(_verticalAdjustIndex),cursor.getDouble(_leftCompensationIndex), cursor.getDouble(_rightCompensationIndex),
+ cursor.getInt(_pressSetIndex)
+ );
+
+ list.add(pv);
+ }
+ cursor.close();
+ sqLiteDatabase.close();
+ return list;
+
+ }
+ public String AddOrUpdateErrorModelRough(ErrorModel em) {
+ ContentValues cv = new ContentValues();
+ cv.put(Error_COLUMN_TimeStamp, em.getTimeID());
+ cv.put(Error_COLUMN_ERROR_INFO, em.getErrorInfo());
+
+
+ SQLiteDatabase sqliteDatabase = this.getWritableDatabase();
+ long insert = sqliteDatabase.insertWithOnConflict(Error_TABLE_NAME_ROUGH, null, cv, SQLiteDatabase.CONFLICT_REPLACE);
+
+ if (insert == -1) {
+ // 插入失败,按时间戳删除最早的100行
+ try {
+ // 开始事务
+ sqliteDatabase.beginTransaction();
+
+ String deleteQuery = "DELETE FROM error WHERE timeID IN (SELECT timeID FROM error ORDER BY timeID ASC LIMIT 100)";
+ sqliteDatabase.execSQL(deleteQuery);
+ // 标记事务成功
+ sqliteDatabase.setTransactionSuccessful();
+
+ Log.d("DB_OPERATION", "插入失败,已按时间戳删除最早的100行数据");
+ } catch (SQLException e) {
+ Log.e("DB_ERROR", "删除时发生错误: " + e.getMessage());
+ } finally {
+ // 结束事务(若setTransactionSuccessful()被调用则提交,否则回滚)
+ sqliteDatabase.endTransaction();
+ }
+ sqliteDatabase.close();
+ return "failed";
+ }
+ sqliteDatabase.close();
+ return "success";
+ }
+
+ public List GetAllErrorModels() {
+ List list = new ArrayList<>();
+
+ String sql = "SELECT * FROM " + Error_TABLE_NAME_ROUGH;
+ SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
+ Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
+
+
+
+ int _time_id_Index = cursor.getColumnIndex(Error_COLUMN_TimeStamp);
+ int _error_Index = cursor.getColumnIndex(Error_COLUMN_ERROR_INFO);
+
+ while (cursor.moveToNext()) {
+
+ ErrorModel em = new ErrorModel(cursor.getLong(_time_id_Index),cursor.getString(_error_Index));
+
+ Date date = new Date(em.getTimeID()); // 将时间戳转换为Date对象
+ // 创建SimpleDateFormat实例,并设置时区为UTC
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); // 设置为UTC时区
+ // 格式化日期
+ String utcTime = sdf.format(date);
+ // System.out.println("UTC时间: " + utcTime);
+ em.setDateTimeBJ(utcTime);
+
+ list.add(em);
+ }
+ cursor.close();
+ sqLiteDatabase.close();
+ return list;
+
+ }
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PVModify.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PVModify.java
new file mode 100644
index 0000000..c7d7ef3
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PVModify.java
@@ -0,0 +1,104 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+public class PVModify {
+
+ public static void HandlePVDataRough(com.example.roughapp2_0bbwiredrpm.MainActivity roughActivity) {
+
+
+ String ChangeLaneDistanceStr = roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.getText().toString();
+ String PressStr = roughActivity.mainBinding.roughEditPressTo32.getText().toString();
+ String VeticalAdjustStr = roughActivity.mainBinding.roughEditVerticalAdjustTo32.getText().toString();
+ String DMKSpeedStr = roughActivity.mainBinding.DMKSpeedTo32.getText().toString();
+
+ //前端转速
+ try{
+ if (DMKSpeedStr.isEmpty()) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setDmkSpeed(0).build();
+ } else {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder()
+ .setDmkSpeed((Integer.parseInt(String.valueOf(roughActivity.mainBinding.DMKSpeedTo32.getText())))).build();
+ }
+ } catch (Exception e) {
+ //
+ }
+
+ //换道距离
+ try{
+ if (ChangeLaneDistanceStr.isEmpty()) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setLaneChangeDistance(1).build();
+ } else {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder()
+ .setLaneChangeDistance((Integer.parseInt(String.valueOf(roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.getText())))).build();
+ }
+ } catch (Exception e) {
+ //
+ }
+
+
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setVerticalDistanceMeters(Double.parseDouble(roughActivity.VerticalDistance)).build(); //作业长度
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setHorizontalDistanceMeters(Double.parseDouble(roughActivity.HorizontalDistance)).build(); //作业宽度
+
+ try {
+ //压力设定
+ if (PressStr.isEmpty()) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setPressSet(1).build();
+ } else {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder()
+ .setPressSet((Integer.parseInt(String.valueOf(roughActivity.mainBinding.roughEditPressTo32.getText())))).build();
+ }
+
+ } catch (Exception e) {
+
+ }
+
+ //竖直微调--小数 *10
+ try {
+
+ if (VeticalAdjustStr.isEmpty()) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setVerticalCalibration(0).build();
+ } else {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder()
+ .setVerticalCalibration((Double.parseDouble(String.valueOf(roughActivity.mainBinding.roughEditVerticalAdjustTo32.getText())) * 100)).build();
+
+ }
+
+ } catch (Exception e) {
+
+ }
+
+ //自动手动模式发送
+ if (roughActivity.rough_Manual_Mode_Call_Value.equals("未启用")) //手动模式未启用
+ {
+ //发送自动模式值
+ if (roughActivity.rough_Auto_Mode_Call_Value.equals("水平")) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRunMode(5).build();
+ }
+
+ }
+ else if (roughActivity.rough_Auto_Mode_Call_Value.equals("未启用")) //自动模式未启用
+ {
+ //发送手动模式值
+ if (roughActivity.rough_Manual_Mode_Call_Value.equals("无")) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRunMode(1).build();
+ } else if (roughActivity.rough_Manual_Mode_Call_Value.equals("水平")) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRunMode(2).build();
+ } else if (roughActivity.rough_Manual_Mode_Call_Value.equals("竖直向左")) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRunMode(3).build();
+ } else if (roughActivity.rough_Manual_Mode_Call_Value.equals("竖直向右")) {
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRunMode(4).build();
+ }
+ }
+ //前端转向设置
+ String toolRotationDirectionDAta =roughActivity.mainBinding.mainViewToolRotationDirectionTxView.getText().toString();
+ switch (toolRotationDirectionDAta) {
+
+ case "正向":
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setToolRotationDirection(1).build();
+ break;
+ case "反向":
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setToolRotationDirection(2).build();
+ break;
+ }
+
+ }
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PopupHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PopupHelper.java
new file mode 100644
index 0000000..1c47d6c
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/PopupHelper.java
@@ -0,0 +1,505 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.app.Dialog;
+import android.text.InputFilter;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.example.roughapp2_0bbwiredrpm.MainActivity;
+import com.example.roughapp2_0bbwiredrpm.R;
+import com.example.roughapp2_0bbwiredrpm.models.DisplayPV;
+import com.example.roughapp2_0bbwiredrpm.models.ErrorModel;
+import com.example.roughapp2_0bbwiredrpm.models.ScrollBottomScrollView;
+
+import java.util.List;
+
+public class PopupHelper {
+
+ String result="1";
+
+ private final MainActivity mainActivity;
+
+ public PopupHelper(MainActivity mainActivity)
+ {
+ this.mainActivity = mainActivity;
+ }
+
+ //拉毛手动模式弹窗
+ public void Rough_ManualModePopup(View.OnClickListener context) { //手动模式弹窗
+ Dialog dialog = new Dialog(mainActivity);
+
+ dialog.setContentView(R.layout.rough_manualmodepopup); // 设置自定义布局
+ dialog.setCancelable(true); // 设置点击外部是否关闭弹窗
+
+ // 获取布局中的视图
+ Button cancelButton = dialog.findViewById(R.id.manualModeCancel_Rough);
+ Button confirmButton = dialog.findViewById(R.id.manualModeApply_Rough);
+
+ //获取按钮组
+ RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.manualModeSelectorGroup_Rough);
+
+ //4种模式
+ radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
+ if (radioButton!=null)
+ {
+ mainActivity.rough_Manual_Mode_Call_Value = radioButton.getText().toString();
+ }
+ }
+ });
+
+ //下次进来保证是选中状态或者未选中
+ String ii= mainActivity.mainBinding.roughManualModeDisplay.getText().toString();
+ switch (ii)
+ {
+ case "无": { radioGroup.check(R.id.rb_one_rough);
+ break;
+ }
+ case "水平": { radioGroup.check(R.id.rb_two_rough);
+ break;
+ }
+ case "竖直向左": { radioGroup.check(R.id.rb_three_rough);
+ break;
+ }
+ case "竖直向右": { radioGroup.check(R.id.rb_four_rough);
+ break;
+ }
+ default:
+ radioGroup.clearCheck();
+ break;
+
+ }
+
+ // 设置确定按钮点击事件
+ confirmButton.setOnClickListener(v -> { //手动模式弹窗确认
+ if (radioGroup.getCheckedRadioButtonId() != -1) { //有按钮选中时按确定 更新值
+ mainActivity.mainBinding.roughManualModeDisplay.setText(mainActivity.rough_Manual_Mode_Call_Value);
+ //失能自动模式
+ mainActivity.rough_Auto_Mode_Call_Value="未启用";
+ mainActivity.mainBinding.roughAutoModeDisplay.setText("未启用");
+ Toast.makeText(mainActivity, "设置成功", Toast.LENGTH_SHORT).show();
+ }
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+ // 设置取消按钮点击事件
+ cancelButton.setOnClickListener(v -> {
+ Toast.makeText(mainActivity, "点击了取消", Toast.LENGTH_SHORT).show();
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+
+ // 显示弹窗
+ dialog.show();
+
+ }
+
+ public void AutomaticModeSetPopUp(View.OnClickListener context) {
+
+
+
+ Dialog dialog = new Dialog(mainActivity);
+
+ dialog.setContentView(R.layout.rough_automodepopup); // 设置自定义布局
+ dialog.setCancelable(true); // 设置点击外部是否关闭弹窗
+
+ // 获取布局中的视图
+ Button cancelButton = dialog.findViewById(R.id.autoModeCancel_Rough);
+ Button confirmButton = dialog.findViewById(R.id.autoModeApply_Rough);
+
+ EditText HorizontalDistance_Edit=dialog.findViewById(R.id.HorizontalDistance_input);
+ EditText VerticalDistance_Edit=dialog.findViewById(R.id.VerticalDistance_input);
+
+ HorizontalDistance_Edit.setFilters(new InputFilter[]{new DecimalDigitsInputFilter()}); //editext 一位小数限制
+ VerticalDistance_Edit.setFilters(new InputFilter[]{new DecimalDigitsInputFilter()}); //editext 一位小数限制
+
+ /*进入显示文本*/
+ HorizontalDistance_Edit.setText(mainActivity.HorizontalDistance);
+ VerticalDistance_Edit.setText(mainActivity.VerticalDistance);
+
+
+
+ // 设置单选按钮点击事件
+ RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.autoModeSelectorGroup_Rough);
+
+ radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
+ if(radioButton!=null){
+ mainActivity.rough_Auto_Mode_Call_Value = radioButton.getText().toString();
+ }
+
+ }
+ });
+
+ String ii= mainActivity.mainBinding.roughAutoModeDisplay.getText().toString();
+ switch (ii)
+ {
+
+ case "水平": { radioGroup.check(R.id.rb_autoHorizontal);
+ break;
+ }
+ default:
+ radioGroup.clearCheck();//清除选中,此时触发radioGroup事件,自动模式值被改为未启用
+ break;
+
+ }
+ // 设置确定按钮点击事件
+ confirmButton.setOnClickListener(v -> {
+
+ if (radioGroup.getCheckedRadioButtonId() != -1) { //有按钮选中时按确定 更新值
+ mainActivity.mainBinding.roughAutoModeDisplay.setText(mainActivity.rough_Auto_Mode_Call_Value);
+ //失能手动模式
+ mainActivity.rough_Manual_Mode_Call_Value="未启用";
+ mainActivity.mainBinding.roughManualModeDisplay.setText("未启用");
+ Toast.makeText(mainActivity, "设置成功", Toast.LENGTH_SHORT).show();
+ }
+
+ //检查作业宽度 长度 范围
+ double value1=0; double value2=0;
+ try {
+ value1=Double.parseDouble(String.valueOf(HorizontalDistance_Edit.getText()));
+ value2=Double.parseDouble(String.valueOf(VerticalDistance_Edit.getText()));
+ }
+ catch(Exception e)
+ {
+ Toast.makeText(mainActivity, "输入不能为空", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if(value1>=0 && value1<=50)
+ {
+ mainActivity.HorizontalDistance=String.valueOf(value1);
+
+ }else{
+ Toast.makeText(mainActivity, "请输入0-50的数字", Toast.LENGTH_SHORT).show();
+ HorizontalDistance_Edit.setText("0.0");
+ return;
+ }
+ if(value2>=0 && value2<=50)
+ {
+ mainActivity.VerticalDistance=String.valueOf(value2);
+
+ }else{
+ Toast.makeText(mainActivity, "请输入0-50的数字", Toast.LENGTH_SHORT).show();
+ VerticalDistance_Edit.setText("0.0");
+ return;
+ }
+
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+
+ // 设置取消按钮点击事件
+ cancelButton.setOnClickListener(v -> {
+ Toast.makeText(mainActivity, "点击了取消", Toast.LENGTH_SHORT).show();
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+
+ /*显示弹窗*/
+ dialog.show();
+ }
+
+ /*前端旋转方向*/
+ public void ToolRotationDirectionPopUp(View.OnClickListener context) {
+
+
+ Dialog dialog = new Dialog(mainActivity);
+
+ dialog.setContentView(R.layout.toolrotationdirectionpopup); // 设置自定义布局
+ dialog.setCancelable(true); // 设置点击外部是否关闭弹窗
+
+ // 获取布局中的视图
+ Button confirmButton = dialog.findViewById(R.id.Apply);
+ Button cancelButton = dialog.findViewById(R.id.Cancel);
+
+
+
+ // 设置取消按钮点击事件
+ cancelButton.setOnClickListener(v -> {
+ Toast.makeText(mainActivity, "点击了取消", Toast.LENGTH_SHORT).show();
+
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+ RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.toolRotationDirectionSelectorGroup);
+
+ radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+
+ RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
+ if (radioButton!=null)
+ {
+ mainActivity._Tool_Rotation_Direction_Value = radioButton.getText().toString();
+ }
+ }
+ });
+ //下次进来保证是选中状态或者未选中
+ String ii= mainActivity.mainBinding.mainViewToolRotationDirectionTxView.getText().toString();
+ switch (ii)
+ {
+
+ case "正向": { radioGroup.check(R.id.rb_DirPos);
+ break;
+ }
+ case "反向": { radioGroup.check(R.id.rb_DirNag);
+ break;
+ }
+
+ }
+ // 设置确定按钮点击事件
+ confirmButton.setOnClickListener(v -> {
+
+ mainActivity.mainBinding.mainViewToolRotationDirectionTxView.setText(mainActivity._Tool_Rotation_Direction_Value);
+ Toast.makeText(mainActivity, "设置成功", Toast.LENGTH_SHORT).show();
+ dialog.dismiss(); // 关闭弹窗
+ });
+ dialog.show(); // 显示弹窗
+
+ }
+
+ public void ParametersCallPopup_Rough(View.OnClickListener context,MyDataHelper myDataHelper) {
+ Dialog dialog = new Dialog(mainActivity);
+ dialog.setContentView(R.layout.parameters_call_rough); // 设置自定义布局
+ dialog.setCancelable(true); // 设置点击外部是否关闭弹窗
+
+ // 获取布局中的视图
+ Button exitButton = dialog.findViewById(R.id.parametersExitRough);
+ Button confirmButton = dialog.findViewById(R.id.parametersApplyRough);
+ Button saveButton=dialog.findViewById(R.id.parametersSavebtnRough);
+ Button clearButton=dialog.findViewById(R.id.parametersClearBtnRough);
+ RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.parameters_call_group_rough);
+
+ Integer ii= ConvertHelper.convertEditTextToInt(mainActivity.mainBinding.roughTvParameterCallTo32);
+
+ switch (ii)
+ {
+ case 1: { radioGroup.check(R.id.rb_paraOneRough);
+ break;
+ }
+ case 2: { radioGroup.check(R.id.rb_paraTwoRough);
+ break;
+ }
+ case 3: { radioGroup.check(R.id.rb_paraThreeRough);
+ break;
+ }
+ case 4: { radioGroup.check(R.id.rb_paraFourRough);
+ break;
+ }
+ case 5: { radioGroup.check(R.id.rb_paraFiveRough);
+ break;
+ }
+ default:
+ radioGroup.clearCheck();
+ break;
+ }
+
+ dialog.show(); // 显示弹窗
+
+ radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ try {
+ RadioButton radioButton = (RadioButton) group.findViewById(checkedId);
+ result = radioButton.getText().toString();
+
+ } catch (Exception e) {
+ //**/
+ }
+ }
+ });
+
+ //保存按钮 获取界面参数 存入数据库
+ saveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ int selectedId = radioGroup.getCheckedRadioButtonId();
+ if (selectedId == -1) {
+ Toast.makeText(mainActivity, "未选中参数,无法保存", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ //获取界面参数以写进数据库
+ int paraIndex = Integer.parseInt(mainActivity.mainBinding.roughTvParameterCallTo32.getText().toString());
+ int laneChangeDistance = Integer.parseInt(mainActivity.mainBinding.roughEditLaneChangeDistanceTo32.getText().toString());
+ double verticalAdjust = Double.parseDouble(mainActivity.mainBinding.roughEditVerticalAdjustTo32.getText().toString());
+ double horizontalDistance = Double.parseDouble(mainActivity.HorizontalDistance);
+ double verticalDistance = Double.parseDouble(mainActivity.VerticalDistance);
+ double leftCompensation=Double.parseDouble(mainActivity.mainBinding.roughTvLCompensationFrom32.getText().toString());
+ double rightCompensation=Double.parseDouble(mainActivity.mainBinding.roughTvRCopmpensationFrom32.getText().toString());
+ int pressSet=Integer.parseInt(mainActivity.mainBinding.roughEditPressTo32.getText().toString());
+ //把界面中的值放进PV类的变量中
+ DisplayPV displayPV = new DisplayPV(paraIndex, laneChangeDistance,horizontalDistance,verticalDistance,verticalAdjust ,leftCompensation,rightCompensation, pressSet );
+ myDataHelper.addOrUpdateDisplayDataRough(displayPV); //创建数据库的实例在这里 PV传进去保存到数据库
+ Toast.makeText(dialog.getContext(), "保存成功", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ //清除按钮 界面显示设为默认值 并存入数据库
+ clearButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+
+ int selectedId = radioGroup.getCheckedRadioButtonId();
+ if (selectedId == -1) {
+ Toast.makeText(mainActivity, "未选中参数,无法清除", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ mainActivity.mainBinding.roughEditLaneChangeDistanceTo32.setText(String.valueOf(1));
+ mainActivity.mainBinding.roughEditVerticalAdjustTo32.setText(String.valueOf(0));
+ mainActivity.mainBinding.roughEditPressTo32.setText(String.valueOf(0));
+ mainActivity.mainBinding.roughTvLCompensationFrom32.setText(String.valueOf(0));
+ mainActivity.mainBinding.roughTvRCopmpensationFrom32.setText(String.valueOf(0));
+ mainActivity.HorizontalDistance=String.valueOf(0);
+ mainActivity.VerticalDistance=String.valueOf(0);
+ //获取界面参数以写进数据库
+ int paraIndex = Integer.parseInt(mainActivity.mainBinding.roughTvParameterCallTo32.getText().toString());
+ int laneChangeDistance = Integer.parseInt(mainActivity.mainBinding.roughEditLaneChangeDistanceTo32.getText().toString());
+ double verticalAdjust = Double.parseDouble(mainActivity.mainBinding.roughEditVerticalAdjustTo32.getText().toString());
+ double horizontalDistance = Double.parseDouble(mainActivity.HorizontalDistance);
+ double verticalDistance = Double.parseDouble(mainActivity.VerticalDistance);
+ double leftCompensation=Double.parseDouble(mainActivity.mainBinding.roughTvLCompensationFrom32.getText().toString());
+ double rightCompensation=Double.parseDouble(mainActivity.mainBinding.roughTvRCopmpensationFrom32.getText().toString());
+ int pressSet=Integer.parseInt(mainActivity.mainBinding.roughEditPressTo32.getText().toString());
+
+ //把界面中的值放进PV类的变量中
+ DisplayPV displayPV = new DisplayPV(paraIndex, laneChangeDistance,horizontalDistance,verticalDistance,verticalAdjust ,leftCompensation,rightCompensation, pressSet );
+ myDataHelper.addOrUpdateDisplayDataRough(displayPV); //创建数据库的实例在这里 PV传进去保存到数据库
+ Toast.makeText(dialog.getContext(), "清除成功", Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ // 使用按钮 点击事件 //把主界面 调用值显示 改了 并从数据库中读赋值给界面
+ confirmButton.setOnClickListener(v -> {
+
+ /*未选中时设为无*/
+ int selectedId = radioGroup.getCheckedRadioButtonId();
+ if (selectedId == -1) {
+ Toast.makeText(mainActivity, "未使用预设参数", Toast.LENGTH_SHORT).show();
+ mainActivity.mainBinding.roughTvParameterCallTo32.setText("无");
+ return;
+ }
+ mainActivity.rough_parameters_Call_Value = result;
+ mainActivity.mainBinding.roughTvParameterCallTo32.setText(mainActivity.rough_parameters_Call_Value);//把主界面 调用值显示 改了
+
+ //读取数据
+ int paraIndex = Integer.parseInt(mainActivity.rough_parameters_Call_Value);
+ List pvList = mainActivity.myDataHelper.getDisplayDataRough(paraIndex);//从数据库中读,,并对其他控件进行赋值
+
+ mainActivity.mainBinding.roughEditLaneChangeDistanceTo32.setText(String.valueOf(pvList.get(0).getLaneChangeDistance()));
+ mainActivity.mainBinding.roughEditVerticalAdjustTo32.setText(String.valueOf(pvList.get(0).getVerticalAdjust()));
+ mainActivity.HorizontalDistance=String.valueOf(pvList.get(0).getHorizontalDistance());
+ mainActivity.VerticalDistance=String.valueOf(pvList.get(0).getVerticalDistance());
+ mainActivity.mainBinding.roughTvLCompensationFrom32.setText(String.valueOf(pvList.get(0).getLeftCompensation()));
+ mainActivity.mainBinding.roughTvRCopmpensationFrom32.setText(String.valueOf(pvList.get(0).getRightCompensation()));
+ mainActivity.mainBinding.roughEditPressTo32.setText(String.valueOf(pvList.get(0).getPressSet()));
+ //读取数据库,并对其他控件进行赋值
+ Toast.makeText(dialog.getContext(), "调用成功", Toast.LENGTH_SHORT).show();
+
+
+ });
+
+
+
+ // 退出按钮点击事件
+ exitButton.setOnClickListener(v -> {
+ Toast.makeText(dialog.getContext(), "点击了退出", Toast.LENGTH_SHORT).show();
+ dialog.dismiss(); // 关闭弹窗
+ });
+
+ }
+
+ public void RobotErrorListPopUp(View.OnClickListener context) {
+ Dialog dialog = new Dialog(mainActivity);
+ dialog.setContentView(R.layout.log_item_rough); // 设置自定义布局
+ dialog.setCancelable(true); // 设置点击外部是否关闭弹窗
+
+ TextView LogText = dialog.findViewById(R.id.popUpErrorLogTextView);
+ ScrollBottomScrollView LogScrollView = dialog.findViewById(R.id.popUpErrorLogScrollview);
+ List list = mainActivity.myDataHelper.GetAllErrorModels();
+ LogText.setMovementMethod(ScrollingMovementMethod.getInstance());
+
+ final int[] firstDisplay = {1};
+ final int[] display = {2};
+ final int[] displayOver = {0};
+ int displayNum = 25;
+ LogScrollView.post(new Runnable() {
+ @Override
+ public void run() {
+ if(firstDisplay[0] == 1){
+ //滑动顶部
+ LogScrollView.fullScroll(ScrollView.FOCUS_UP);
+ firstDisplay[0] = 0;
+ }
+ }
+ });
+
+ LogScrollView.onScrollViewScrollToBottom(new ScrollBottomScrollView.OnScrollBottomListener() {
+ @Override
+ public void scrollToBottom() {
+ //请求数据
+ if (!list.isEmpty()) {
+ if(list.size()>displayNum * display[0]) {
+ for(int i = list.size() - displayNum * (display[0]-1); i-- > list.size() - displayNum * display[0];){
+ ErrorModel item = list.get(i);
+ String RobotErrorLog = item.getDateTimeBJ() + item.getErrorInfo() +"\n";
+ LogText.append(RobotErrorLog);
+ }
+ display[0] ++;
+ }
+ else{
+ if(displayOver[0]==0){
+ for(int i = list.size() - displayNum * (display[0]-1); i-- > 0;){
+ ErrorModel item = list.get(i);
+ String RobotErrorLog = item.getDateTimeBJ() + item.getErrorInfo() +"\n";
+ LogText.append(RobotErrorLog);
+ displayOver[0]=1;
+ }
+ }
+ }
+ }
+ }});
+
+ if (!list.isEmpty()) {
+
+ if(list.size() > displayNum) {
+
+ for(int i = list.size(); i-- > list.size() - displayNum;){
+ ErrorModel item = list.get(i);
+ String RobotErrorLog = item.getDateTimeBJ() + item.getErrorInfo() +"\n";
+ LogText.append(RobotErrorLog);
+ }
+ }
+ else{
+ for(int i = list.size(); i-- > 0;){
+ ErrorModel item = list.get(i);
+ String RobotErrorLog = item.getDateTimeBJ() + item.getErrorInfo() +"\n";
+ LogText.append(RobotErrorLog);
+ }
+ }
+
+ }
+// String list3 = mainActivity.myDataHelper.DeleteAllErrorModels();
+
+ dialog.show(); // 显示弹窗
+ }
+
+
+
+
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ReceiivedIVHandler.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ReceiivedIVHandler.java
new file mode 100644
index 0000000..7fbd570
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ReceiivedIVHandler.java
@@ -0,0 +1,254 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import static com.example.roughapp2_0bbwiredrpm.MainActivity.AndroidMCUCommunicationMethod;
+import static com.example.roughapp2_0bbwiredrpm.services.ErrorDeocdeHelper.ErrorDeocde;
+
+import android.annotation.SuppressLint;
+
+import com.example.roughapp2_0bbwiredrpm.R;
+import com.example.roughapp2_0bbwiredrpm.models.BspIV;
+import com.example.roughapp2_0bbwiredrpm.models.ErrorModel;
+import com.google.protobuf.InvalidProtocolBufferException;
+
+import java.util.Objects;
+
+public class ReceiivedIVHandler {
+ static String errorLastPaint = "";
+ static String errorLastRough = "";
+ static int Rough_485Flag = 0; //屏蔽有线485错误
+
+
+
+
+
+ public static BspIV.IV_struct_define _toReceiveIV = BspIV.IV_struct_define.newBuilder().build();//上一次有效数据
+ public static BspIV.IV_struct_define _toReceiveIV_Temp = BspIV.IV_struct_define.newBuilder().build();//最新数据
+
+
+
+ public static void HandleData(com.example.roughapp2_0bbwiredrpm.MainActivity mainActivity, byte[] data) {
+ try {
+
+ byte[] crcbytes = new byte[data.length - 2];
+ System.arraycopy(data, 0, crcbytes, 0, data.length - 2);
+ byte[] crc = ModbusCRC.calculateCRC(crcbytes);
+ // status(bytesToHex(data));
+
+ if (data[data.length - 2] == (byte) (crc[1] & 0xff) && data[data.length - 1] == (byte) (crc[0] & 0xff)) {
+
+ if ((data[0] == 0x55) && (data[1] == 0x55)) {
+
+ byte[] bytes = new byte[data.length - 4];
+ System.arraycopy(data, 2, bytes, 0, data.length - 4);
+ try {
+ _toReceiveIV_Temp = BspIV.IV_struct_define.parseFrom(bytes);//单片机新数据到来
+ HandleIVRough(mainActivity, _toReceiveIV_Temp);
+ } catch (InvalidProtocolBufferException ex) {
+ }
+ } else {
+
+ }
+ } else {
+ //status("crc failed");
+ }
+
+ } catch (Exception e) {
+
+ }
+ }
+
+
+
+
+
+ @SuppressLint("DefaultLocale")
+ public static void HandleIVRough(com.example.roughapp2_0bbwiredrpm.MainActivity roughActivity, BspIV.IV_struct_define _toReceiveIV_Temp) {
+ try {
+
+ if (_toReceiveIV_Temp != null) {
+ //若单片机重启,则变量时间戳重置
+ if (_toReceiveIV_Temp.getRobotRestart() == 1) {
+ _toReceiveIV = _toReceiveIV.toBuilder().setTimeStamp(0).build();
+ //告知单片机接收到
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRobotRestartAccepted(1).build();
+ return;
+ }
+ roughActivity._toSendPV = roughActivity._toSendPV.toBuilder().setRobotRestartAccepted(0).build();
+
+ //新数据的时间大于上次时间 将新数据赋值给上次数据
+ if (_toReceiveIV_Temp.getTimeStamp() >= _toReceiveIV.getTimeStamp()) {
+ _toReceiveIV = _toReceiveIV_Temp;
+ }
+ }
+
+ if (_toReceiveIV != null) {
+
+ roughActivity.runOnUiThread(() -> {
+ roughActivity.mainBinding.roughTvSpeedFrom32.setText(String.format("%.1f", _toReceiveIV.getRobotMoveSpeed()));
+ roughActivity.mainBinding.roughTvCurrentSpeedFrom32.setText(String.format("%.1f", _toReceiveIV.getCurrentSpeed()));
+ roughActivity.mainBinding.roughTvLCompensationFrom32.setText(String.valueOf((double) _toReceiveIV.getLeftCompensation() / 100));
+ roughActivity.mainBinding.roughTvRCopmpensationFrom32.setText(String.valueOf((double) _toReceiveIV.getRightCompensation() / 100));
+ roughActivity.mainBinding.roughTvPressFrom32.setText(String.valueOf(_toReceiveIV.getPress()));
+ roughActivity.mainBinding.roughTvAngleFrom32.setText(String.valueOf((double) _toReceiveIV.getCurrentAngle() / 100));
+ if (_toReceiveIV.getSBUSState() == 0) {
+ roughActivity.mainBinding.roughTvSignal.setText("断开");
+ } else if (_toReceiveIV.getSBUSState() == 1) {
+ roughActivity.mainBinding.roughTvSignal.setText("已连接");
+ }
+
+ /******************************硬件错误*****************************/
+ int errorInt = _toReceiveIV.getSystemError();//硬件错误
+ String errorString2 = ErrorDeocde(errorInt); //未复位 null
+ String errorString = " # " + unsignedIntToBinaryWithSeparator(errorInt);
+ errorString += " " + toHex4Digits(_toReceiveIV.getLeftMotorErr());
+ errorString += " " + toHex4Digits(_toReceiveIV.getRightMotorErr());
+
+ if ( AndroidMCUCommunicationMethod == CommunicationMethond.Wireless &&errorInt==64
+ &&_toReceiveIV.getLeftMotorErr() == 0 && _toReceiveIV.getRightMotorErr() == 0)
+ {
+ //Rough_485Flag=1;
+// errorLastRough = errorString;
+ roughActivity.mainBinding.mainViewErrMessageTxView.setText("无");
+ roughActivity.mainBinding.messageRounded.setBackgroundResource(R.drawable.orange_rounded_rectangle);
+ }
+
+ if (errorInt != 0 || _toReceiveIV.getLeftMotorErr() != 0 || _toReceiveIV.getRightMotorErr() != 0) {
+ if (!Objects.equals(errorLastRough, errorString)) { /*错误变了才显示*/
+ ErrorModel em = new ErrorModel(System.currentTimeMillis(), errorString);
+
+ roughActivity.myDataHelper.AddOrUpdateErrorModelRough(em);
+
+ if (Objects.equals(errorString2, "未复位")) {
+ roughActivity.mainBinding.messageRounded.setBackgroundResource(R.drawable.message_rounded_rectangle_red);
+ roughActivity.mainBinding.mainViewErrMessageTxView.setText(String.valueOf(errorString2));
+ }
+ else
+ {
+// if(Rough_485Flag==1)
+// {
+// return;
+// }
+ roughActivity.mainBinding.mainViewErrMessageTxView.setText("有");
+ roughActivity.mainBinding.messageRounded.setBackgroundResource(R.drawable.message_rounded_rectangle_red);
+ }
+
+ errorLastRough = errorString;//错误码的二进制位
+ }
+
+ }
+ else { //无错误
+ errorLastRough = errorString;//错误码的二进制位
+ roughActivity.mainBinding.mainViewErrMessageTxView.setText("无");
+ roughActivity.mainBinding.messageRounded.setBackgroundResource(R.drawable.orange_rounded_rectangle);
+
+ }
+ if (_toReceiveIV.getIsWorking() == 1) {
+
+ roughActivity.mainBinding.roughRightSend.setEnabled(false);
+ roughActivity.mainBinding.roughRightSend.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughSetManualModeBtn.setEnabled(false);
+ roughActivity.mainBinding.roughSetManualModeBtn.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughSetAutoModeBtn.setEnabled(false);
+ roughActivity.mainBinding.roughSetAutoModeBtn.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.setEnabled(false);
+ roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughEditVerticalAdjustTo32.setEnabled(false);
+ roughActivity.mainBinding.roughEditVerticalAdjustTo32.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughEditPressTo32.setEnabled(false);
+ roughActivity.mainBinding.roughEditPressTo32.setAlpha(0.5f);
+
+ roughActivity.mainBinding.roughSetCallParametersBtn.setEnabled(false);
+ roughActivity.mainBinding.roughSetCallParametersBtn.setAlpha(0.5f);
+
+ roughActivity.mainBinding.DMKSpeedTo32.setEnabled(false);
+ roughActivity.mainBinding.DMKSpeedTo32.setAlpha(0.5f);
+
+
+ }
+ else {
+
+ roughActivity.mainBinding.roughRightSend.setEnabled(true);
+ roughActivity.mainBinding.roughRightSend.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughSetManualModeBtn.setEnabled(true);
+ roughActivity.mainBinding.roughSetManualModeBtn.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughSetAutoModeBtn.setEnabled(true);
+ roughActivity.mainBinding.roughSetAutoModeBtn.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.setEnabled(true);
+ roughActivity.mainBinding.roughEditLaneChangeDistanceTo32.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughEditVerticalAdjustTo32.setEnabled(true);
+ roughActivity.mainBinding.roughEditVerticalAdjustTo32.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughEditPressTo32.setEnabled(true);
+ roughActivity.mainBinding.roughEditPressTo32.setAlpha(1.0f);
+
+ roughActivity.mainBinding.roughSetCallParametersBtn.setEnabled(true);
+ roughActivity.mainBinding.roughSetCallParametersBtn.setAlpha(1.0f);
+
+ roughActivity.mainBinding.DMKSpeedTo32.setEnabled(true);
+ roughActivity.mainBinding.DMKSpeedTo32.setAlpha(1.0f);
+
+
+
+ }
+
+ });
+
+
+ } else { //_toReceiveIV == null
+ }
+
+ } catch (Exception ex) {
+ }
+
+
+ } //函数头结尾
+
+ /*
+ 逐位检查并构建二进制字符串
+ */
+ String unsignedIntToBinary(int value) {
+ StringBuilder sb = new StringBuilder(32);
+ for (int i = 7; i >= 0; i--) {
+ sb.append((value & (1 << i)) == 0 ? '0' : '1');
+ }
+ return sb.toString();
+ }
+
+ /*
+ 逐位检查并构建二进制字符串 每4位添加一个分隔符
+ */
+ static String unsignedIntToBinaryWithSeparator(int value) {
+ StringBuilder sb = new StringBuilder(35);
+ for (int i = 11; i >= 0; i--) {
+ sb.append((value & (1 << i)) == 0 ? '0' : '1');
+ if (i % 4 == 0 && i != 0) {
+ sb.append(' '); // 每4位添加一个分隔符
+ }
+ }
+ return sb.toString();
+ }
+
+ static String toHex4Digits(int value) {
+ char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+ int low16Bits = value & 0xFFFF;
+
+ char[] result = new char[4];
+ result[0] = hexChars[(low16Bits >> 12) & 0xF];
+ result[1] = hexChars[(low16Bits >> 8) & 0xF];
+ result[2] = hexChars[(low16Bits >> 4) & 0xF];
+ result[3] = hexChars[low16Bits & 0xF];
+
+ return new String(result);
+ }
+
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/RobotDataHanlder.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/RobotDataHanlder.java
new file mode 100644
index 0000000..8c786bf
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/RobotDataHanlder.java
@@ -0,0 +1,64 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+import com.example.roughapp2_0bbwiredrpm.models.BspIV;
+import com.example.roughapp2_0bbwiredrpm.models.BspPV;
+import com.google.protobuf.InvalidProtocolBufferException;
+
+public class RobotDataHanlder {
+
+
+ public static void test()
+ {
+ //byte[] data=hexToByteArray("080110830118313A04B1CBBACF");
+ byte[] data=hexToByteArray("100A180A28013A32B1CBBACF00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
+
+
+
+ }
+ public static void DeoodeDataFromRobot(byte[] data)
+ {
+ try
+ {
+ if(data[0]==0x55&&data[1]==0x55)
+ {
+ if (data[2]==0x01)
+ {
+ BspIV.IV_struct_define iv = BspIV.IV_struct_define.parseFrom(data);
+ }else if(data[2]==0x02)
+ {
+ BspPV.PV_struct_define pv = BspPV.PV_struct_define.parseFrom(data);
+ }
+ }
+ } catch (InvalidProtocolBufferException e)
+ {
+
+ }
+
+
+ }
+
+ public static byte[] hexToByteArray(String inHex){
+ int hexlen = inHex.length();
+ byte[] result;
+ if (hexlen % 2 == 1){
+ //奇数
+ hexlen++;
+ result = new byte[(hexlen/2)];
+ inHex="0"+inHex;
+ }else {
+ //偶数
+ result = new byte[(hexlen/2)];
+ }
+ int j=0;
+ for (int i = 0; i < hexlen; i+=2){
+ result[j]=hexToByte(inHex.substring(i,i+2));
+ j++;
+ }
+ return result;
+ }
+ public static byte hexToByte(String inHex){
+ return (byte)Integer.parseInt(inHex,16);
+ }
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/UDPHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/UDPHelper.java
new file mode 100644
index 0000000..9e1876b
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/UDPHelper.java
@@ -0,0 +1,98 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.util.logging.Handler;
+
+
+public class UDPHelper {
+
+
+ private static com.example.roughapp2_0bbwiredrpm.MainActivity MainActivity;
+ private static Thread receiveThread;
+ private static boolean running = false;
+ private static DatagramSocket sendSocket;
+ private static DatagramSocket receiveSocket;
+ private static Handler handler;// = new Handler(Looper.getMainLooper());
+ private static String target_ip;
+ private static int target_port;
+ private static int listening_port;
+
+ public static void Intialize(com.example.roughapp2_0bbwiredrpm.MainActivity mainActivity, String targetip, int targetPort, int listentingPort) {
+ try {
+ MainActivity = mainActivity;
+ target_ip = targetip;
+ target_port = targetPort;
+ listening_port = listentingPort;
+ sendSocket = new DatagramSocket(10000);
+ //sendSocket.setBroadcast(true);
+
+ running = true;
+ receiveSocket = new DatagramSocket(listening_port);
+ receiveSocket.setBroadcast(true);
+ running = true;
+
+
+ receiveThread = new Thread(() -> {
+ byte[] buffer = new byte[1024];
+ DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
+
+ while (running) {
+ try {
+ receiveSocket.receive(packet);
+ byte[] receivedArray = new byte[packet.getLength()];
+ System.arraycopy( packet.getData(), 0, receivedArray, 0, receivedArray.length);
+
+ ReceiivedIVHandler.HandleData(mainActivity,receivedArray);
+
+ } catch (IOException e) {
+ if (running) {
+
+ }
+ }
+ }
+ });
+ receiveThread.start();
+ } catch (IOException e) {
+ // tvOutput.setText("Socket error: " + e.getMessage());
+ }
+ }
+
+ public static void SendData(byte[] buffer) {
+ MainActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+
+ new Thread(() ->
+ {
+ DatagramSocket socket = null;
+ try {
+ InetAddress address = InetAddress.getByName(target_ip);
+ DatagramPacket packet = new DatagramPacket(buffer, buffer.length, address, target_port);
+ sendSocket.send(packet);
+ } catch (Exception e)
+ {
+
+
+ }
+ }).start();
+ }});
+
+
+ }
+
+ public static void Destroy() {
+ running = false;
+ if (receiveSocket != null && !receiveSocket.isClosed()) {
+ receiveSocket.close();
+ }
+ if (sendSocket != null && !sendSocket.isClosed()) {
+ sendSocket.close();
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/USBSerialPortHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/USBSerialPortHelper.java
new file mode 100644
index 0000000..f9fa112
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/USBSerialPortHelper.java
@@ -0,0 +1,333 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.hardware.usb.UsbDevice;
+import android.hardware.usb.UsbDeviceConnection;
+import android.hardware.usb.UsbManager;
+import android.os.Build;
+import android.os.CountDownTimer;
+import android.os.Handler;
+import android.os.Looper;
+
+import androidx.core.content.ContextCompat;
+
+import com.example.roughapp2_0bbwiredrpm.BuildConfig;
+import com.example.roughapp2_0bbwiredrpm.models.BspIV;
+import com.hoho.android.usbserial.driver.UsbSerialDriver;
+import com.hoho.android.usbserial.driver.UsbSerialPort;
+import com.hoho.android.usbserial.driver.UsbSerialProber;
+import com.hoho.android.usbserial.util.SerialInputOutputManager;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class USBSerialPortHelper implements SerialInputOutputManager.Listener {
+ public USBSerialPortHelper(com.example.roughapp2_0bbwiredrpm.MainActivity mainActivity, int baudRate) {
+ this.MainActivity = mainActivity;
+ this.baudRate=baudRate;
+ }
+ private com.example.roughapp2_0bbwiredrpm.MainActivity MainActivity;
+ private enum UsbPermission {Unknown, Requested, Granted, Denied}
+ private final String INTENT_ACTION_GRANT_USB = BuildConfig.APPLICATION_ID + ".GRANT_USB";
+ private int deviceId = 60000;
+ private int deviceId_test = 60000;
+ private int portNum;
+ private final int WRITE_WAIT_MILLIS = 120;
+ private final int READ_WAIT_MILLIS = 120;
+ private String PortNameContians = "SILICON";/**/
+ // private static String PortNameContians="FTD";
+ //private int baudRate = 115200;
+ private int baudRate = 115200;
+ private boolean withIoManager = true;
+
+ private BroadcastReceiver broadcastReceiver;
+ private Handler mainLooper;
+
+ private SerialInputOutputManager usbIoManager;
+ private UsbSerialPort usbSerialPort;
+ private UsbPermission usbPermission = UsbPermission.Unknown;
+ private boolean connected = false;
+
+ public void intialize() {
+
+ broadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (INTENT_ACTION_GRANT_USB.equals(intent.getAction())) {
+ usbPermission = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false) ? UsbPermission.Granted : UsbPermission.Denied;
+ connect();
+ }
+ }
+ };
+ mainLooper = new Handler(Looper.getMainLooper());
+ _receiveBufferlist = new ArrayList();
+ }
+ @Override
+ public void onNewData(byte[] data) {
+ status("new data");
+ mainLooper.post(() -> {
+ receive(data);
+ // receive data
+ });
+ }
+
+ @Override
+ public void onRunError(Exception e) {
+ mainLooper.post(() -> {
+ status("connection lost: " + e.getMessage());
+ disconnect();
+ });
+ }
+ public void connect() {
+
+ UsbDevice device = null;
+ UsbManager usbManager = (UsbManager) MainActivity.getSystemService(Context.USB_SERVICE);
+ for (UsbDevice v : usbManager.getDeviceList().values()) {
+ // status(v.getManufacturerName().toUpperCase());
+
+ if (v.getVendorId() == 6790||v.getVendorId() == 1027) {
+ device = v;
+ break;
+ }
+// if (v.getManufacturerName().toUpperCase().contains(PortNameContians)) {
+// device = v;
+// break;
+// }
+ }
+
+ if (device == null) {
+ // _serialPortSwitch.setChecked(false);
+
+ status("找不到设备");
+ return;
+ }
+ UsbSerialDriver driver = UsbSerialProber.getDefaultProber().probeDevice(device);
+ if (driver == null) {
+ driver = CustomProber.getCustomProber().probeDevice(device);
+ }
+ if (driver == null) {
+ // _serialPortSwitch.setChecked(false);
+ status("无驱动");
+ return;
+ }
+ if (driver.getPorts().size() < portNum) //就是0 cp2102 或者同一个驱动,第一个
+ {
+ status("connection failed: not enough ports at device");
+ status("找不到设备");
+ return;
+ }
+ usbSerialPort = driver.getPorts().get(portNum);
+
+ UsbDeviceConnection usbConnection = usbManager.openDevice(driver.getDevice());
+ if (usbConnection == null && usbPermission == UsbPermission.Unknown && !usbManager.hasPermission(driver.getDevice())) {
+ usbPermission = UsbPermission.Requested;
+ int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0;
+ Intent intent = new Intent(INTENT_ACTION_GRANT_USB);
+ intent.setPackage(MainActivity.getPackageName());
+ PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(MainActivity, 0, intent, flags);
+ usbManager.requestPermission(driver.getDevice(), usbPermissionIntent);
+ return;
+ }
+ if (usbConnection == null) {
+ if (!usbManager.hasPermission(driver.getDevice())) {
+ status("connection failed: permission denied");
+ } else {
+ status("connection failed: open failed");
+ }
+ return;
+ }
+
+ try {
+ usbSerialPort.open(usbConnection);
+ try {
+ usbSerialPort.setParameters(baudRate, 8, 1, UsbSerialPort.PARITY_NONE);
+ status("connected: ");
+
+ } catch (UnsupportedOperationException e) {
+ status("unsupport setparameters");
+ }
+ if (withIoManager) {
+ usbIoManager = new SerialInputOutputManager(usbSerialPort, this);
+ usbIoManager.setReadBufferSize(40960);
+ usbIoManager.setReadTimeout(READ_WAIT_MILLIS);
+ usbIoManager.start();
+ }
+ connected = true;
+ } catch (Exception e) {
+ status("connection failed: " + e.getMessage());
+ disconnect();
+ }
+ }
+
+ private void disconnect() {
+ connected = false;
+
+ if (usbIoManager != null) {
+ usbIoManager.setListener(null);
+ usbIoManager.stop();
+ }
+ usbIoManager = null;
+ try {
+ usbSerialPort.close();
+ } catch (IOException ignored) {
+
+ }
+ usbSerialPort = null;
+ }
+
+ List _receiveBufferlist;
+
+ private static byte[] listTobyte(List list) {
+ if (list == null || list.size() < 0) return null;
+ byte[] bytes = new byte[list.size()];
+ int i = 0;
+ Iterator iterator = list.iterator();
+ while (iterator.hasNext()) {
+ bytes[i] = iterator.next();
+ i++;
+ }
+ return bytes;
+ }
+ boolean StartCountDown = false;
+ private void receive(byte[] data) {
+
+ // status("read data");
+ for (int i = 0; i < data.length; i++) {
+ _receiveBufferlist.add(data[i]);
+ }
+
+ //decodeRceive(data);
+ if (StartCountDown == false)//从收到第一个数据开始计时
+ {
+ StartCountDown = true;
+ new CountDownTimer(4, 2) {
+ public void onTick(long millisUntilFinished) {
+
+ }
+ public void onFinish() {
+
+ status("read finished");
+ decodeRceive(listTobyte(_receiveBufferlist));
+ _receiveBufferlist.clear();
+ StartCountDown = false;
+ }
+ }.start();
+ }
+ }
+
+ void status(String str) {
+// SpannableStringBuilder spn = new SpannableStringBuilder(str+'\r'+'\n');
+//
+// // spn.append(getTime());
+//
+// spn.setSpan(new ForegroundColorSpan(MainActivity.getResources().getColor(R.color.colorAccent)), 0, spn.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+// receiveText.append(spn);
+ // mainBinding.roll.fullScroll(ScrollView.FOCUS_DOWN);
+
+
+ // MainActivity.mainBinding.message.setText(str);
+ }
+
+ int Index = 0;
+
+
+ private void decodeRceive(byte[] data) { //USB串口接收
+
+ try {
+
+ MainActivity.USBSerialPortReceivedTimeCounter = 0;//计算时间 归零
+
+
+ for (int i = 0; i < 18; i++)
+ {
+ ModbusRtuSlaveService.holdingRegisters[i] = ModbusRtuSlaveService.holdingRegisters_temp[i];
+ }
+
+ //单片机请求读取PV
+ if (ModbusRtuSlaveService.processModbusRequest(data, data.length) == 0x03) {
+ Index++;
+ //Index=128;
+ //由于 System.currentTimeMillis() 会随着时间累加,所以不存在
+ MainActivity._toSendPV = MainActivity._toSendPV.toBuilder()
+ .setTimeStamp(System.currentTimeMillis())
+ .build();
+ DataExchangeHelper.setModbusPVValues(MainActivity._toSendPV); //设置PV
+ } else if (ModbusRtuSlaveService.processModbusRequest(data, data.length) == 0x10) {
+ BspIV.IV_struct_define iv = DataExchangeHelper.getIVByModbus(); //收到单片机的IV.
+
+ //TODO
+ ReceiivedIVHandler.HandleIVRough(MainActivity, iv);
+
+
+ }
+
+
+ }
+ catch (Exception e) {
+ int a =100;
+
+ }
+ }
+
+ public static String bytesToHex(byte[] bytes) {
+ StringBuilder result = new StringBuilder();
+ for (byte b : bytes) {
+ result.append(String.format("%02X ", b & 0xFF));
+ }
+ return result.toString();
+ }
+
+ public void onStart() {
+
+ ContextCompat.registerReceiver(MainActivity, broadcastReceiver, new IntentFilter(INTENT_ACTION_GRANT_USB), ContextCompat.RECEIVER_NOT_EXPORTED);
+ status("onStart");
+
+ }
+
+ public void onStop() {
+ MainActivity.unregisterReceiver(broadcastReceiver);
+ status("onStop");
+ }
+
+
+ public void onResume() {
+
+ if (!connected && (usbPermission == UsbPermission.Unknown || usbPermission == UsbPermission.Granted)) {
+ mainLooper.post(this::connect);
+
+ }
+ }
+
+
+ public void onPause() {
+ if (connected) {
+ status("串口断开");
+ // _serialPortSwitch.setChecked(false);
+ disconnect();
+ }
+ }
+
+ public void SendData(byte[] data) {
+ if (connected) {
+ try {
+ usbSerialPort.write(data, WRITE_WAIT_MILLIS);
+ } catch (IOException e) {
+ status("Send Failed");
+ connected = false;
+ }
+ } else {
+ status("usb serialport disconnected");
+
+ }
+
+
+ }
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/VideoPlayerHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/VideoPlayerHelper.java
new file mode 100644
index 0000000..4c301e2
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/VideoPlayerHelper.java
@@ -0,0 +1,27 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+
+import cn.nodemedia.NodePlayer;
+import cn.nodemedia.NodePlayerView;
+
+public class VideoPlayerHelper {
+
+
+
+ public static void startVedio(NodePlayerView nodePlayerView, NodePlayer nodePlayer,String address ){
+
+
+ nodePlayerView.setRenderType(NodePlayerView.RenderType.SURFACEVIEW);//设置渲染器类型
+ nodePlayerView.setUIViewContentMode(NodePlayerView.UIViewContentMode.ScaleToFill);//设置视频画面缩放模式
+ //nodePlayer=new NodePlayer(this);
+ nodePlayer.setPlayerView(nodePlayerView);//设置播放视图
+ //设置RTSP流使用的传输协议,支持的模式有:
+ nodePlayer.setRtspTransport(NodePlayer.RTSP_TRANSPORT_TCP);//设置传输
+ nodePlayer.setInputUrl(address);
+ nodePlayer.setVideoEnable(true);//设置视频启用
+ nodePlayer.setBufferTime(100);//设置缓冲时间
+ nodePlayer.setMaxBufferTime(200);//设置最大缓冲时间
+ nodePlayer.start();
+ }
+}
+
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ttySerialPortHelper.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ttySerialPortHelper.java
new file mode 100644
index 0000000..5ecc57a
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/services/ttySerialPortHelper.java
@@ -0,0 +1,117 @@
+package com.example.roughapp2_0bbwiredrpm.services;
+
+import android.util.Log;
+
+import android_serialport_api.SerialPortFinder;
+import tp.xmaihh.serialport.SerialHelper;
+import tp.xmaihh.serialport.bean.ComBean;
+
+public class ttySerialPortHelper {
+ public static com.example.roughapp2_0bbwiredrpm.MainActivity MainActivity;
+ private static final String TAG = "ttySerialPortHelper";
+ private static SerialHelper serialHelper;
+ private static SerialPortFinder serialPortFinder;
+ public static boolean IsAllButtonSendBack = false;
+
+ final String[] ports = serialPortFinder.getAllDevicesPath();
+ final String[] botes = new String[]{"0", "50", "75", "110", "134", "150", "200", "300", "600", "1200", "1800", "2400", "4800", "9600", "19200", "38400", "57600", "115200", "230400", "460800", "500000", "576000", "921600", "1000000", "1152000", "1500000", "2000000", "2500000", "3000000", "3500000", "4000000", "CUSTOM"};
+ final String[] databits = new String[]{"8", "7", "6", "5"};
+ final String[] paritys = new String[]{"NONE", "ODD", "EVEN", "SPACE", "MARK"};
+ final String[] stopbits = new String[]{"1", "2"};
+ final String[] flowcons = new String[]{"NONE", "RTS/CTS", "XON/XOFF"};
+
+ public static int[] decodedCH = new int[17];
+
+ public static void Open() {
+
+ try {
+ // serialPortFinder = new SerialPortFinder();
+ serialHelper = new SerialHelper("dev/ttyHS0", 115200)//MK32
+ // serialHelper = new SerialHelper("/dev/ttyHS3", 115200) //UR7
+ {
+ @Override
+ protected void onDataReceived(ComBean comBean) {
+
+ MainActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // 更新 UI 的代码
+ byte[] receivedData = comBean.bRec;
+ if (MainActivity.AndroidMCUCommunicationMethod == CommunicationMethond.Wireless)
+ {
+ //解析单片机传来的数据
+ //TODO
+ ReceiivedIVHandler.HandleData(MainActivity, receivedData);
+ return;
+ }
+ //有按钮数据传输
+ if (receivedData.length <= 2) {
+ return;
+ }
+ if (receivedData[0] != 0x55 || receivedData[1] != 0x66 || receivedData.length != 42) {
+ return;
+ }
+ byte[] crcbytes = new byte[receivedData.length - 2];
+ System.arraycopy(receivedData, 0, crcbytes, 0, receivedData.length - 2);
+ byte[] crc = CCITT_CRC16.calculateXModemCRC16(crcbytes);
+ if (receivedData[receivedData.length - 2] == (byte) (crc[0] & 0xff) && receivedData[receivedData.length - 1] == (byte) (crc[1] & 0xff)) {
+ if ((receivedData[0] == 0x55) && (receivedData[1] == 0x66)) {
+ IsAllButtonSendBack = true;
+ int[] decodedCH = DataExchangeHelper.getdecodedCH(receivedData);
+ //0 代表index,和sbus里面的数据其实不同,这里用作接收一次,添加一个
+ ModbusRtuSlaveService.holdingRegisters_temp[0] += 1;
+ for (int i = 0; i < decodedCH.length; i++) {
+ ModbusRtuSlaveService.holdingRegisters_temp[i + 1] = (short) decodedCH[i];
+ }
+ ModbusRtuSlaveService.holdingRegisters_temp[17]=1;
+ }
+ }else
+ {
+ ModbusRtuSlaveService.holdingRegisters_temp[17]=0;
+ }
+
+
+// IsAllButtonSendBack = true;
+// int[] decodedCH = DataExchangeHelper.getdecodedCH(receivedData);
+// //0 代表index,和sbus里面的数据其实不同,这里用作接收一次,添加一个
+// ModbusRtuSlaveService.holdingRegisters[0] += 1;
+// for (int i = 0; i < decodedCH.length; i++) {
+// ModbusRtuSlaveService.holdingRegisters[i + 1] = (short) decodedCH[i];
+// }
+
+
+ }
+ });
+ }
+ };
+ serialHelper.open();
+ } catch (Exception exception) {
+ Log.d(TAG, "Data Received");
+ }
+
+ }
+
+
+ public static void SendData(byte[] data) {
+
+ serialHelper.send(data); // 发送byte[]
+ }
+
+ public static byte[] getAllChData_4Hz = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x02, (byte) (0xB5 & 0xff), (byte) (0xC0 & 0xff)};
+ public static byte[] getAllChData_5Hz = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x03, (byte) (0x94 & 0xff), (byte) (0xD0 & 0xff)};
+ public static byte[] getAllChData_10Hz = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x04, (byte) (0x73 & 0xff), (byte) (0xA0 & 0xff)};
+ public static byte[] getAllChData_20Hz = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x05, (byte) (0x52 & 0xff), (byte) (0xb0 & 0xff)};
+ public static byte[] getAllChData_50Hz = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x06, (byte) (0x31 & 0xff), (byte) (0x80 & 0xff)};
+
+
+ public static byte[] stopgetAllChData = new byte[]{0x55, 0x66, 0x01, 0x01, 0x00, 0x00, 0x00, 0x42, 0x00, (byte) (0xf7 & 0xff), (byte) (0xe0 & 0xff)};
+
+ public static void sendTxt(String sTxt) {
+ serialHelper.sendTxt(sTxt); // 发送byte[]
+ }
+ public static void onDestroy() {
+
+ serialHelper.close();
+ }
+
+}
diff --git a/app/src/main/java/com/example/roughapp2_0bbwiredrpm/viewmodels/MainViewModel.java b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/viewmodels/MainViewModel.java
new file mode 100644
index 0000000..3c69824
--- /dev/null
+++ b/app/src/main/java/com/example/roughapp2_0bbwiredrpm/viewmodels/MainViewModel.java
@@ -0,0 +1,11 @@
+package com.example.roughapp2_0bbwiredrpm.viewmodels;
+
+import androidx.lifecycle.ViewModel;
+
+public class MainViewModel extends ViewModel {
+
+ public MainViewModel() {
+
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/generate_java.bat b/app/src/main/java/generate_java.bat
new file mode 100644
index 0000000..97deb24
--- /dev/null
+++ b/app/src/main/java/generate_java.bat
@@ -0,0 +1,2 @@
+ protoc --java_out . *.proto
+ pause
diff --git a/app/src/main/java/protoc.7z b/app/src/main/java/protoc.7z
new file mode 100644
index 0000000..b4ac7a1
Binary files /dev/null and b/app/src/main/java/protoc.7z differ
diff --git a/app/src/main/java/protoc.exe b/app/src/main/java/protoc.exe
new file mode 100644
index 0000000..f1ffb02
Binary files /dev/null and b/app/src/main/java/protoc.exe differ
diff --git a/app/src/main/java/protoc/protoc.exe b/app/src/main/java/protoc/protoc.exe
new file mode 100644
index 0000000..f1ffb02
Binary files /dev/null and b/app/src/main/java/protoc/protoc.exe differ
diff --git a/app/src/main/res/drawable/background.xml b/app/src/main/res/drawable/background.xml
new file mode 100644
index 0000000..9c77c74
--- /dev/null
+++ b/app/src/main/res/drawable/background.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/bgr.png b/app/src/main/res/drawable/bgr.png
new file mode 100644
index 0000000..4d6154f
Binary files /dev/null and b/app/src/main/res/drawable/bgr.png differ
diff --git a/app/src/main/res/drawable/bigackground.png b/app/src/main/res/drawable/bigackground.png
new file mode 100644
index 0000000..8466de6
Binary files /dev/null and b/app/src/main/res/drawable/bigackground.png differ
diff --git a/app/src/main/res/drawable/bigackground2.png b/app/src/main/res/drawable/bigackground2.png
new file mode 100644
index 0000000..5ac409f
Binary files /dev/null and b/app/src/main/res/drawable/bigackground2.png differ
diff --git a/app/src/main/res/drawable/blue_rounded_rectangle.xml b/app/src/main/res/drawable/blue_rounded_rectangle.xml
new file mode 100644
index 0000000..a973af9
--- /dev/null
+++ b/app/src/main/res/drawable/blue_rounded_rectangle.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/border.xml b/app/src/main/res/drawable/border.xml
new file mode 100644
index 0000000..4f76948
--- /dev/null
+++ b/app/src/main/res/drawable/border.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/borderblue.xml b/app/src/main/res/drawable/borderblue.xml
new file mode 100644
index 0000000..e4995a9
--- /dev/null
+++ b/app/src/main/res/drawable/borderblue.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/bordergreen.xml b/app/src/main/res/drawable/bordergreen.xml
new file mode 100644
index 0000000..c10e3c7
--- /dev/null
+++ b/app/src/main/res/drawable/bordergreen.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/borderlog.xml b/app/src/main/res/drawable/borderlog.xml
new file mode 100644
index 0000000..1a1b34c
--- /dev/null
+++ b/app/src/main/res/drawable/borderlog.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/borderorange.xml b/app/src/main/res/drawable/borderorange.xml
new file mode 100644
index 0000000..0b0d657
--- /dev/null
+++ b/app/src/main/res/drawable/borderorange.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/bordersubmenu.xml b/app/src/main/res/drawable/bordersubmenu.xml
new file mode 100644
index 0000000..af31d78
--- /dev/null
+++ b/app/src/main/res/drawable/bordersubmenu.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/borderwhite.xml b/app/src/main/res/drawable/borderwhite.xml
new file mode 100644
index 0000000..e013ef8
--- /dev/null
+++ b/app/src/main/res/drawable/borderwhite.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/buttonborderwhite.xml b/app/src/main/res/drawable/buttonborderwhite.xml
new file mode 100644
index 0000000..ec98fab
--- /dev/null
+++ b/app/src/main/res/drawable/buttonborderwhite.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml
new file mode 100644
index 0000000..c83a8c5
--- /dev/null
+++ b/app/src/main/res/drawable/dash_line.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/message_rounded_rectangle.xml b/app/src/main/res/drawable/message_rounded_rectangle.xml
new file mode 100644
index 0000000..785673c
--- /dev/null
+++ b/app/src/main/res/drawable/message_rounded_rectangle.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/message_rounded_rectangle_red.xml b/app/src/main/res/drawable/message_rounded_rectangle_red.xml
new file mode 100644
index 0000000..0b0063f
--- /dev/null
+++ b/app/src/main/res/drawable/message_rounded_rectangle_red.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/orange_rounded_rectangle.xml b/app/src/main/res/drawable/orange_rounded_rectangle.xml
new file mode 100644
index 0000000..6fde1b6
--- /dev/null
+++ b/app/src/main/res/drawable/orange_rounded_rectangle.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/radio_button_selected.xml b/app/src/main/res/drawable/radio_button_selected.xml
new file mode 100644
index 0000000..3232aed
--- /dev/null
+++ b/app/src/main/res/drawable/radio_button_selected.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/radio_button_textcolor.xml b/app/src/main/res/drawable/radio_button_textcolor.xml
new file mode 100644
index 0000000..04c3ced
--- /dev/null
+++ b/app/src/main/res/drawable/radio_button_textcolor.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/radio_button_unselected.xml b/app/src/main/res/drawable/radio_button_unselected.xml
new file mode 100644
index 0000000..8190483
--- /dev/null
+++ b/app/src/main/res/drawable/radio_button_unselected.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/radiobutton_background.xml b/app/src/main/res/drawable/radiobutton_background.xml
new file mode 100644
index 0000000..6eb6a48
--- /dev/null
+++ b/app/src/main/res/drawable/radiobutton_background.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/smallbackground.png b/app/src/main/res/drawable/smallbackground.png
new file mode 100644
index 0000000..1f6f84f
Binary files /dev/null and b/app/src/main/res/drawable/smallbackground.png differ
diff --git a/app/src/main/res/drawable/squrelogo.png b/app/src/main/res/drawable/squrelogo.png
new file mode 100644
index 0000000..f7cafaf
Binary files /dev/null and b/app/src/main/res/drawable/squrelogo.png differ
diff --git a/app/src/main/res/drawable/submenu.xml b/app/src/main/res/drawable/submenu.xml
new file mode 100644
index 0000000..64f9e41
--- /dev/null
+++ b/app/src/main/res/drawable/submenu.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/submenu2.png b/app/src/main/res/drawable/submenu2.png
new file mode 100644
index 0000000..ea943ed
Binary files /dev/null and b/app/src/main/res/drawable/submenu2.png differ
diff --git a/app/src/main/res/drawable/submenupng.png b/app/src/main/res/drawable/submenupng.png
new file mode 100644
index 0000000..359b006
Binary files /dev/null and b/app/src/main/res/drawable/submenupng.png differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..f1155a5
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,885 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/log_item_rough.xml b/app/src/main/res/layout/log_item_rough.xml
new file mode 100644
index 0000000..e5104ef
--- /dev/null
+++ b/app/src/main/res/layout/log_item_rough.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/parameters_call_rough.xml b/app/src/main/res/layout/parameters_call_rough.xml
new file mode 100644
index 0000000..1766868
--- /dev/null
+++ b/app/src/main/res/layout/parameters_call_rough.xml
@@ -0,0 +1,210 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/rough_automodepopup.xml b/app/src/main/res/layout/rough_automodepopup.xml
new file mode 100644
index 0000000..499bb3f
--- /dev/null
+++ b/app/src/main/res/layout/rough_automodepopup.xml
@@ -0,0 +1,269 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/rough_manualmodepopup.xml b/app/src/main/res/layout/rough_manualmodepopup.xml
new file mode 100644
index 0000000..4ef6cdf
--- /dev/null
+++ b/app/src/main/res/layout/rough_manualmodepopup.xml
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/toolrotationdirectionpopup.xml b/app/src/main/res/layout/toolrotationdirectionpopup.xml
new file mode 100644
index 0000000..7f4371e
--- /dev/null
+++ b/app/src/main/res/layout/toolrotationdirectionpopup.xml
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..6f3b755
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..6f3b755
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml
new file mode 100644
index 0000000..d5516cd
--- /dev/null
+++ b/app/src/main/res/values-night/themes.xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..5b3d18a
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,154 @@
+
+
+ #FF000000
+ #FFFFFFFF
+ #FFFFFFFF
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
+
+ #fffafa
+ #fffaf0
+ #ffebcd
+ #f8f8ff
+ #f5f5f5
+ #faebd7
+ #ffdead
+ #808080
+ #dcdcdc
+ #d3d3d3
+ #a9a9a9
+ #696969
+ #708090
+ #778899
+ #2f4f4f
+ #c0c0c0
+
+ #ff0000
+ #8b0000
+ #dc143c
+ #8b008b
+ #ff00ff
+ #ff6347
+ #f08080
+ #e9967a
+ #ffdab9
+ #dda0dd
+ #ffc0cb
+ #ffb6c1
+ #ff1493
+ #ff69b4
+ #fff0f5
+ #cd5c5c
+ #bc8f8f
+ #b22222
+ #800000
+ #f0fff0
+ #ff4500
+ #ffa500
+ #32cd32
+ #00ff00
+ #ffff00
+ #f5deb3
+ #f0e68c
+ #deb887
+ #ffe4c4
+ #ffffe0
+ #b8860b
+ #ff8c00
+ #fafad2
+ #fffacd
+ #fff8dc
+ #fff5ee
+ #ffefd5
+ #ffe4e1
+ #ffe4b5
+ #fffff0
+ #ffd700
+ #daa520
+ #ffa07a
+ #ff7f50
+ #f5fffa
+ #f5f5dc
+ #f4a460
+ #fdf5e6
+ #faf0e6
+ #fa8072
+ #d8bfd8
+ #d2b48c
+ #d2691e
+ #cd853f
+ #bdb76b
+ #eee8aa
+ #a52a2a
+ #8b4513
+ #a0522d
+ #808000
+ #7fff00
+ #adff2f
+ #008000
+ #006400
+ #556b2f
+ #6b8e23
+ #7cfc00
+ #228b22
+ #7fffd4
+ #afeeee
+ #98fb98
+ #48d1cc
+ #66cdaa
+ #00ffff
+ #00ff7f
+ #00fa9a
+ #00ced1
+ #2e8b57
+ #90ee90
+ #8fbc8f
+ #40e0d0
+ #00ffff
+ #008b8b
+ #e0ffff
+ #008080
+ #4b0082
+ #0000ff
+ #00008b
+ #0000cd
+ #191970
+ #000080
+ #4169e1
+ #f0ffff
+ #87ceeb
+ #00bfff
+ #87cefa
+ #20b2aa
+ #add8e6
+ #b0e0e6
+ #f0f8ff
+ #7b68ee
+ #6a5acd
+ #483d8b
+ #3cb371
+ #4682b4
+ #b0c4de
+ #6495ed
+ #1e90ff
+ #5f9ea0
+ #8a2be2
+ #800080
+ #e6e6fa
+ #da70d6
+ #9370db
+ #9932cc
+ #ee82ee
+ #c71585
+ #db7093
+ #9400d3
+ #ba55d3
+ #00000000
+
+ #6efe00
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..f1263e7
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,35 @@
+
+ 拉毛2.0bb
+
+ - 手动操作
+ - 竖直操作
+ - 水平操作
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+
+ 20
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
new file mode 100644
index 0000000..a645915
--- /dev/null
+++ b/app/src/main/res/values/themes.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 0000000..fa0f996
--- /dev/null
+++ b/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/check_boxs.xml b/app/src/main/res/xml/check_boxs.xml
new file mode 100644
index 0000000..df2d64a
--- /dev/null
+++ b/app/src/main/res/xml/check_boxs.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 0000000..9ee9997
--- /dev/null
+++ b/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/device_filter.xml b/app/src/main/res/xml/device_filter.xml
new file mode 100644
index 0000000..b2a252c
--- /dev/null
+++ b/app/src/main/res/xml/device_filter.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/test/java/com/example/roughapp2_0bbwiredrpm/ExampleUnitTest.java b/app/src/test/java/com/example/roughapp2_0bbwiredrpm/ExampleUnitTest.java
new file mode 100644
index 0000000..f3c4de7
--- /dev/null
+++ b/app/src/test/java/com/example/roughapp2_0bbwiredrpm/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.example.roughapp2_0bbwiredrpm;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..ea2bb78
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,4 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+id 'com.android.application' version '8.2.2' apply false
+}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..3e927b1
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,21 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..e708b1c
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..1453f7b
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Feb 05 16:42:57 CST 2025
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..4f906e0
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..5f3be1b
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,18 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ maven { url 'https://jitpack.io' }
+ }
+}
+
+rootProject.name = "RoughAPPUDPV2_0BBWiredRPM"
+include ':app'