From bae1ed5e1b1770a224cc9cc0bdd2aec6cd633ed7 Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期一, 19 八月 2024 15:01:23 +0800
Subject: [PATCH] #
---
app/src/main/java/com/example/agvcontroller/MainActivity.java | 52 +++++
app/src/main/res/layout/activity_main.xml | 439 +++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 439 insertions(+), 52 deletions(-)
diff --git a/app/src/main/java/com/example/agvcontroller/MainActivity.java b/app/src/main/java/com/example/agvcontroller/MainActivity.java
index d655f7c..f9ffbe3 100644
--- a/app/src/main/java/com/example/agvcontroller/MainActivity.java
+++ b/app/src/main/java/com/example/agvcontroller/MainActivity.java
@@ -16,6 +16,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
+import android.widget.RelativeLayout;
import com.example.agvcontroller.action.ForwardBackAction;
import com.example.agvcontroller.action.HandInAction;
@@ -50,8 +51,16 @@
private Button goForwardBtn; // 鍓嶈繘
private Button goBackwardBtn; // 鍚庨��
private Button modelSwitchBtn; // 杩涘叆銆侀��鍑� 鎵嬪姩
+
+ private Button bodySwitchBtn; // 搴曠洏/璐у弶鍒囨崲
private Socket socket;
private String AgvNo = "12";
+ private RelativeLayout layout_bottom;
+ private RelativeLayout layout_top;
+ private RelativeLayout layout_single;
+ private RelativeLayout layout_reset;
+
+
SocketManager socketManager;
private int autoVal = 1;
@@ -128,6 +137,13 @@
rotatopnLeftBtn = findViewById(R.id.btn_rotatopn_left);
rotatopnRightBtn = findViewById(R.id.btn_rotatopn_right);
modelSwitchBtn = findViewById(R.id.btn_model_switch);
+
+ bodySwitchBtn = findViewById(R.id.btn_body_switch);
+
+ layout_bottom = findViewById(R.id.layout_bottom);
+ layout_top = findViewById(R.id.layout_top);
+ layout_single = findViewById(R.id.layout_single);
+ layout_reset = findViewById(R.id.layout_reset);
Intent intent = getIntent();
clientId = intent.getStringExtra("message");
@@ -261,6 +277,42 @@
}
}
+ private boolean isVisble = true;
+
+ // 璐у弶绛夋寜閽�
+ public void switchover(View view) {
+ if (isVisble) {
+ layout_bottom.setVisibility(View.GONE);
+ layout_top.setVisibility(View.VISIBLE);
+ bodySwitchBtn.setText("璐у弶");
+ } else {
+ layout_bottom.setVisibility(View.VISIBLE);
+ layout_top.setVisibility(View.GONE);
+ bodySwitchBtn.setText("搴曠洏");
+ }
+ isVisble = !isVisble;
+
+ layout_single.setVisibility(View.GONE);
+ layout_reset.setVisibility(View.GONE);
+
+ }
+
+ // 鍗曡酱浣胯兘鎸夐挳
+ public void switchSingle(View view) {
+ layout_bottom.setVisibility(View.GONE);
+ layout_top.setVisibility(View.GONE);
+ layout_single.setVisibility(View.VISIBLE);
+ layout_reset.setVisibility(View.GONE);
+ }
+
+ // 澶嶄綅鎸夐挳
+ public void switchRest(View view) {
+ layout_bottom.setVisibility(View.GONE);
+ layout_top.setVisibility(View.GONE);
+ layout_single.setVisibility(View.GONE);
+ layout_reset.setVisibility(View.VISIBLE);
+ }
+
@Override
protected void onDestroy() {
super.onDestroy();
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 09d3d11..35a1f3b 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -13,7 +13,11 @@
android:layout_height="0dp"
android:layout_weight="4">
</LinearLayout>
+
+ <!-- **************** 搴曠洏 **************** -->
<RelativeLayout
+ android:id="@+id/layout_bottom"
+ android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6">
@@ -54,22 +58,6 @@
android:minWidth="10dp"
android:backgroundTint="#2196F3" />
-<!-- <com.google.android.material.button.MaterialButton-->
-<!-- android:id="@+id/btn_up"-->
-<!-- android:layout_width="wrap_content"-->
-<!-- android:layout_height="wrap_content"-->
-<!-- android:text="涓婂崌"-->
-<!-- android:layout_marginRight="20sp"-->
-<!-- android:layout_centerVertical="true"-->
-<!-- android:layout_alignParentRight="true"-->
-<!-- app:cornerRadius="5dp"-->
-<!-- android:paddingLeft="10dp"-->
-<!-- android:paddingRight="10dp"-->
-<!-- android:minWidth="10dp"-->
-<!-- android:layout_alignLeft="@+id/btn_rotatopn_left"-->
-<!-- android:layout_alignBottom="@+id/btn_go_backward"-->
-<!-- android:backgroundTint="#2196F3" />-->
-
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_rotatopn_left"
android:layout_width="wrap_content"
@@ -98,45 +86,389 @@
android:minWidth="10dp"
android:backgroundTint="#2196F3" />
-<!-- <com.google.android.material.button.MaterialButton-->
-<!-- android:id="@+id/btn_extend_fork"-->
-<!-- android:layout_width="wrap_content"-->
-<!-- android:layout_height="wrap_content"-->
-<!-- android:text="浼稿弶"-->
-<!-- android:layout_marginLeft="20sp"-->
-<!-- android:layout_centerVertical="true"-->
-<!-- android:layout_alignParentLeft="true"-->
-<!-- app:cornerRadius="5dp"-->
-<!-- android:paddingLeft="10dp"-->
-<!-- android:paddingRight="10dp"-->
-<!-- android:minWidth="10dp"-->
-<!-- android:layout_alignLeft="@+id/btn_rotatopn_left"-->
-<!-- android:layout_alignBottom="@+id/btn_go_forward"-->
-<!-- android:backgroundTint="#2196F3" />-->
+ </RelativeLayout>
-<!-- <com.google.android.material.button.MaterialButton-->
-<!-- android:id="@+id/btn_collect_fork"-->
-<!-- android:layout_width="wrap_content"-->
-<!-- android:layout_height="wrap_content"-->
-<!-- android:text="鏀跺弶"-->
-<!-- android:layout_marginLeft="20sp"-->
-<!-- android:layout_centerVertical="true"-->
-<!-- android:layout_alignParentLeft="true"-->
-<!-- app:cornerRadius="5dp"-->
-<!-- android:paddingLeft="10dp"-->
-<!-- android:paddingRight="10dp"-->
-<!-- android:minWidth="10dp"-->
-<!-- android:layout_alignLeft="@+id/btn_rotatopn_right"-->
-<!-- android:layout_alignBottom="@+id/btn_go_backward"-->
-<!-- android:backgroundTint="#2196F3" />-->
+ <!-- **************** 璐у弶 **************** -->
+ <RelativeLayout
+ android:id="@+id/layout_top"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="6"
+ android:visibility="visible">
+
+ <Button
+ android:id="@+id/btn_stop2"
+ android:layout_width="100sp"
+ android:layout_height="100sp"
+ android:layout_centerInParent="true"
+ android:layout_margin="30sp"
+ android:backgroundTint="#F62727"
+ android:text="STOP"
+ android:textSize="18sp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_extend_fork"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="10sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="浼稿弶"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_collect_fork"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:layout_marginBottom="10sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鏀跺弶"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_rise"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_front_paddle_extend"
+ android:layout_alignBottom="@+id/btn_turn_left"
+ android:layout_centerVertical="true"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="涓婂崌"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_drop"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_front_paddle_extend"
+ android:layout_alignBottom="@+id/btn_collect_fork"
+ android:layout_marginTop="-24dp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="涓嬮檷"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_turn_right"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@+id/btn_collect_fork"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:layout_marginRight="20sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鍙虫棆"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_turn_left"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@+id/btn_stop2"
+ android:layout_alignParentRight="true"
+ android:layout_marginTop="70dp"
+ android:layout_marginRight="20sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="宸︽棆"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_back_paddle_extend"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignBottom="@+id/btn_extend_fork"
+ android:layout_marginRight="20sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鍚庢嫧鏉嗕几鍑�"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_back_paddle_collect"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignBottom="@+id/btn_front_paddle_collect"
+ android:layout_marginRight="20sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鍚庢嫧鏉嗘敹璧�"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_front_paddle_extend"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignBottom="@+id/btn_extend_fork"
+ android:layout_marginRight="20sp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鍓嶆嫧鏉嗕几鍑�"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_front_paddle_collect"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignTop="@+id/btn_stop2"
+ android:layout_alignParentLeft="true"
+ android:layout_marginTop="-24dp"
+ android:backgroundTint="#2196F3"
+ android:minWidth="10dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="鍓嶆嫧鏉嗘敹璧�"
+
+ app:cornerRadius="5dp" />
+
</RelativeLayout>
-<!-- <LinearLayout-->
-<!-- android:layout_width="match_parent"-->
-<!-- android:layout_height="0dp"-->
-<!-- android:layout_weight="6">-->
-<!-- -->
-<!-- </LinearLayout>-->
+
+ <!-- **************** 鍗曡酱 **************** -->
+ <RelativeLayout
+ android:id="@+id/layout_single"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="6"
+ android:visibility="gone">
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_marginTop="10sp"
+ android:layout_marginLeft="20sp"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 1"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_single_5"
+ android:layout_marginTop="10sp"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 2"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="20sp"
+ android:layout_marginTop="10sp"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 3"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_4"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_single_1"
+ android:layout_alignBottom="@+id/btn_single_5"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 4"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_5"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 5"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_6"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_single_3"
+ android:layout_alignBottom="@+id/btn_single_5"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 6"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_7"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_single_1"
+ android:layout_alignBottom="@+id/btn_single_8"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 7"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_8"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="20sp"
+ android:layout_alignLeft="@+id/btn_single_5"
+ android:layout_marginTop="10sp"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 8"
+ app:cornerRadius="5dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_single_9"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/btn_single_3"
+ android:layout_alignBottom="@+id/btn_single_8"
+ android:backgroundTint="#2196F3"
+ android:text="杞� - 9"
+ app:cornerRadius="5dp" />
+
+ </RelativeLayout>
+
+ <!-- **************** 澶嶄綅 **************** -->
+ <RelativeLayout
+ android:id="@+id/layout_reset"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="6"
+ android:visibility="gone">
+
+ <Button
+ android:id="@+id/btn_stop3"
+ android:layout_width="100sp"
+ android:layout_height="100sp"
+ android:layout_centerInParent="true"
+ android:layout_margin="30sp"
+ android:backgroundTint="#F62727"
+ android:text="STOP"
+ android:textSize="18sp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_camera_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鐩告満澶嶄綅"
+ android:layout_marginLeft="20sp"
+ android:layout_marginTop="20sp"
+ android:layout_alignParentLeft="true"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_load_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="娓呴櫎璺緞"
+ android:layout_marginLeft="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignParentLeft="true"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_fork_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="璐у弶褰掗浂"
+ android:layout_marginLeft="20sp"
+ android:layout_marginBottom="20sp"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_gyro_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="闄�铻轰华澶嶄綅"
+ android:layout_marginRight="20sp"
+ android:layout_marginTop="20sp"
+ android:layout_alignParentRight="true"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_lift_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍗囬檷褰掗浂"
+ android:layout_marginRight="20sp"
+ android:layout_centerVertical="true"
+ android:layout_alignParentRight="true"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/btn_all_reset"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鏁存満澶嶄綅"
+ android:layout_marginRight="20sp"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="20sp"
+ app:cornerRadius="5dp"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:minWidth="10dp"
+ android:backgroundTint="#2196F3" />
+
+ </RelativeLayout>
+
+ <!-- **************** 搴曢儴 **************** -->
<LinearLayout
android:background="#334455"
android:layout_width="match_parent"
@@ -179,6 +511,7 @@
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:minWidth="10dp"
+ android:onClick="switchSingle"
android:textSize="10sp"
android:backgroundTint="#2196F3" />
</LinearLayout>
@@ -199,6 +532,7 @@
android:paddingRight="10dp"
android:minWidth="10dp"
android:textSize="10sp"
+ android:onClick="switchover"
android:backgroundTint="#2196F3" />
</LinearLayout>
@@ -218,6 +552,7 @@
android:paddingRight="10dp"
android:minWidth="10dp"
android:textSize="10sp"
+ android:onClick="switchRest"
android:backgroundTint="#2196F3" />
</LinearLayout>
--
Gitblit v1.9.1