Sfoglia il codice sorgente

1.增加通用参数的读取

Tony 5 anni fa
parent
commit
26681c44f7
99 ha cambiato i file con 1115 aggiunte e 43 eliminazioni
  1. 10 20
      app/src/main/AndroidManifest.xml
  2. 134 0
      app/src/main/java/com/sunzee/adapter/AdvanceParameterAdapter.java
  3. 128 0
      app/src/main/java/com/sunzee/adapter/GeneralParameterAdapter.java
  4. 4 1
      app/src/main/java/com/sunzee/base/BaseApplication.java
  5. 126 0
      app/src/main/java/com/sunzee/thread/GeneralParameterTask.java
  6. 8 0
      app/src/main/java/com/sunzee/thread/GeneralParameterThreadType.java
  7. 70 0
      app/src/main/java/com/sunzee/thread/ThreadPoolGeneralParameter.java
  8. 6 1
      app/src/main/java/com/sunzee/ui/activity/AdvertisingActivity.java
  9. 141 2
      app/src/main/java/com/sunzee/ui/fragment/GeneralParameterFragment.java
  10. 175 0
      app/src/main/java/com/sunzee/utils/HexadecimalUtil.java
  11. BIN
      app/src/main/res/drawable-hdpi/back_icon.png
  12. BIN
      app/src/main/res/drawable-hdpi/data_icon.png
  13. BIN
      app/src/main/res/drawable-hdpi/debug_icon.png
  14. BIN
      app/src/main/res/drawable-hdpi/home_icon.png
  15. BIN
      app/src/main/res/drawable-hdpi/language_icon.png
  16. BIN
      app/src/main/res/drawable-hdpi/login_logo.png
  17. BIN
      app/src/main/res/drawable-hdpi/material_icon.png
  18. BIN
      app/src/main/res/drawable-hdpi/other_icon.png
  19. BIN
      app/src/main/res/drawable-hdpi/parameter1_icon.png
  20. BIN
      app/src/main/res/drawable-hdpi/parameter2_icon.png
  21. BIN
      app/src/main/res/drawable-hdpi/password_icon.png
  22. BIN
      app/src/main/res/drawable-hdpi/random.png
  23. BIN
      app/src/main/res/drawable-hdpi/shutdown.png
  24. BIN
      app/src/main/res/drawable-hdpi/time.png
  25. BIN
      app/src/main/res/drawable-hdpi/timing.png
  26. BIN
      app/src/main/res/drawable-hdpi/warring_icon.png
  27. BIN
      app/src/main/res/drawable-mdpi/back_icon.png
  28. BIN
      app/src/main/res/drawable-mdpi/data_icon.png
  29. BIN
      app/src/main/res/drawable-mdpi/debug_icon.png
  30. BIN
      app/src/main/res/drawable-mdpi/home_icon.png
  31. BIN
      app/src/main/res/drawable-mdpi/language_icon.png
  32. BIN
      app/src/main/res/drawable-mdpi/login_logo.png
  33. BIN
      app/src/main/res/drawable-mdpi/material_icon.png
  34. BIN
      app/src/main/res/drawable-mdpi/other_icon.png
  35. BIN
      app/src/main/res/drawable-mdpi/parameter1_icon.png
  36. BIN
      app/src/main/res/drawable-mdpi/parameter2_icon.png
  37. BIN
      app/src/main/res/drawable-mdpi/password_icon.png
  38. BIN
      app/src/main/res/drawable-mdpi/random.png
  39. 5 0
      app/src/main/res/drawable-mdpi/selector_manual_tv_color.xml
  40. 5 0
      app/src/main/res/drawable-mdpi/selector_orange_bg.xml
  41. BIN
      app/src/main/res/drawable-mdpi/shutdown.png
  42. BIN
      app/src/main/res/drawable-mdpi/time.png
  43. BIN
      app/src/main/res/drawable-mdpi/timing.png
  44. BIN
      app/src/main/res/drawable-mdpi/warring_icon.png
  45. BIN
      app/src/main/res/drawable-xhdpi/back_icon.png
  46. BIN
      app/src/main/res/drawable-xhdpi/data_icon.png
  47. BIN
      app/src/main/res/drawable-xhdpi/debug_icon.png
  48. BIN
      app/src/main/res/drawable-xhdpi/home_icon.png
  49. BIN
      app/src/main/res/drawable-xhdpi/language_icon.png
  50. BIN
      app/src/main/res/drawable-xhdpi/login_logo.png
  51. BIN
      app/src/main/res/drawable-xhdpi/material_icon.png
  52. BIN
      app/src/main/res/drawable-xhdpi/other_icon.png
  53. BIN
      app/src/main/res/drawable-xhdpi/parameter1_icon.png
  54. BIN
      app/src/main/res/drawable-xhdpi/parameter2_icon.png
  55. BIN
      app/src/main/res/drawable-xhdpi/password_icon.png
  56. BIN
      app/src/main/res/drawable-xhdpi/random.png
  57. BIN
      app/src/main/res/drawable-xhdpi/shutdown.png
  58. BIN
      app/src/main/res/drawable-xhdpi/time.png
  59. BIN
      app/src/main/res/drawable-xhdpi/timing.png
  60. BIN
      app/src/main/res/drawable-xhdpi/warring_icon.png
  61. BIN
      app/src/main/res/drawable-xxhdpi/back_icon.png
  62. BIN
      app/src/main/res/drawable-xxhdpi/data_icon.png
  63. BIN
      app/src/main/res/drawable-xxhdpi/debug_icon.png
  64. BIN
      app/src/main/res/drawable-xxhdpi/home_icon.png
  65. BIN
      app/src/main/res/drawable-xxhdpi/language_icon.png
  66. BIN
      app/src/main/res/drawable-xxhdpi/login_logo.png
  67. BIN
      app/src/main/res/drawable-xxhdpi/material_icon.png
  68. BIN
      app/src/main/res/drawable-xxhdpi/other_icon.png
  69. BIN
      app/src/main/res/drawable-xxhdpi/parameter1_icon.png
  70. BIN
      app/src/main/res/drawable-xxhdpi/parameter2_icon.png
  71. BIN
      app/src/main/res/drawable-xxhdpi/password_icon.png
  72. BIN
      app/src/main/res/drawable-xxhdpi/random.png
  73. BIN
      app/src/main/res/drawable-xxhdpi/shutdown.png
  74. BIN
      app/src/main/res/drawable-xxhdpi/time.png
  75. BIN
      app/src/main/res/drawable-xxhdpi/timing.png
  76. BIN
      app/src/main/res/drawable-xxhdpi/warring_icon.png
  77. BIN
      app/src/main/res/drawable-xxxhdpi/back_icon.png
  78. BIN
      app/src/main/res/drawable-xxxhdpi/data_icon.png
  79. BIN
      app/src/main/res/drawable-xxxhdpi/debug_icon.png
  80. BIN
      app/src/main/res/drawable-xxxhdpi/home_icon.png
  81. BIN
      app/src/main/res/drawable-xxxhdpi/language_icon.png
  82. BIN
      app/src/main/res/drawable-xxxhdpi/login_logo.png
  83. BIN
      app/src/main/res/drawable-xxxhdpi/material_icon.png
  84. BIN
      app/src/main/res/drawable-xxxhdpi/other_icon.png
  85. BIN
      app/src/main/res/drawable-xxxhdpi/parameter1_icon.png
  86. BIN
      app/src/main/res/drawable-xxxhdpi/parameter2_icon.png
  87. BIN
      app/src/main/res/drawable-xxxhdpi/password_icon.png
  88. BIN
      app/src/main/res/drawable-xxxhdpi/random.png
  89. BIN
      app/src/main/res/drawable-xxxhdpi/shutdown.png
  90. BIN
      app/src/main/res/drawable-xxxhdpi/time.png
  91. BIN
      app/src/main/res/drawable-xxxhdpi/timing.png
  92. BIN
      app/src/main/res/drawable-xxxhdpi/warring_icon.png
  93. 1 0
      app/src/main/res/layout/activity_login.xml
  94. 184 0
      app/src/main/res/layout/activity_testserial_port.xml
  95. 29 0
      app/src/main/res/layout/dialog_result.xml
  96. 14 8
      app/src/main/res/layout/fragment_general_parameter.xml
  97. 42 0
      app/src/main/res/layout/item_advanceparameter.xml
  98. 21 0
      app/src/main/res/layout/item_generalparameter.xml
  99. 12 11
      app/src/main/res/values/strings.xml

+ 10 - 20
app/src/main/AndroidManifest.xml

@@ -3,17 +3,14 @@
     xmlns:tools="http://schemas.android.com/tools"
     package="com.sunzee">
 
-    <uses-permission android:name="android.permission.INTERNET" />
-    <!-- iBeancon 功能所需权限 -->
+    <uses-permission android:name="android.permission.INTERNET" /> <!-- iBeancon 功能所需权限 -->
     <uses-permission android:name="android.permission.BLUETOOTH" />
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
-    <!-- 个推电子围栏功能所需权限 -->
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 个推电子围栏功能所需权限 -->
     <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
-
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission
         android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
@@ -27,13 +24,11 @@
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
         <activity
-            android:name="com.sunzee.ui.activity.MainActivity"
-            android:label="@string/app_name">
-
-        </activity>
-        <activity android:name=".ui.activity.HomeActivity">
-
-        </activity>
+            android:name=".ui.activity.MainActivity"
+            android:label="@string/app_name"></activity>
+        <activity
+            android:name=".ui.activity.HomeActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"></activity>
         <activity android:name=".ui.activity.LoginActivity" />
         <activity android:name=".ui.activity.AdvertisingActivity">
             <intent-filter>
@@ -51,11 +46,8 @@
         <service
             android:name=".service.MyIntentService"
             android:permission="android.permission.BIND_JOB_SERVICE" />
-
         <service android:name=".service.DownServer" />
-
         <service android:name=".service.MyService" />
-
         <service
             android:name="com.igexin.sdk.PushService"
             android:exported="true"
@@ -68,7 +60,6 @@
             </intent-filter>
         </service>
 
-
         <receiver android:name="com.igexin.sdk.PushReceiver">
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
@@ -80,7 +71,6 @@
                 <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
             </intent-filter>
         </receiver>
-
         <receiver android:name=".receiver.DownReceiver">
             <intent-filter>
                 <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
@@ -88,4 +78,4 @@
         </receiver>
     </application>
 
-</manifest>
+</manifest>

+ 134 - 0
app/src/main/java/com/sunzee/adapter/AdvanceParameterAdapter.java

@@ -0,0 +1,134 @@
+package com.sunzee.adapter;
+
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.wuxiaolong.androidutils.library.LogUtil;
+
+import java.util.HashMap;
+
+/**
+ * 进阶参数 AdvanceParameterAdapter
+ */
+public class AdvanceParameterAdapter extends RecyclerView.Adapter<AdvanceParameterAdapter.ViewHolder> {
+
+    private final int[] paraName;
+    //保存editText的值
+    public HashMap<Integer, String> contents = new HashMap<>();
+
+    public AdvanceParameterAdapter(int[] paraName) {
+        this.paraName = paraName;
+    }
+
+    public void setItemListener(AdvanceParameterAdapter.ItemParaClickListener listener) {
+        this.listener = listener;
+    }
+
+    private AdvanceParameterAdapter.ItemParaClickListener listener;
+
+    public void setValues(String[] values) {
+        this.values = values;
+    }
+
+    //地址具体数值
+    private String[] values;
+
+
+    @NonNull
+    @Override
+    public AdvanceParameterAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
+        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_advanceparameter, viewGroup, false);
+        return new AdvanceParameterAdapter.ViewHolder(inflate);
+
+    }
+
+    @Override
+    public void onBindViewHolder(@NonNull AdvanceParameterAdapter.ViewHolder viewHolder, final int i) {
+        viewHolder.tvName.setText(paraName[i]);
+        viewHolder.etPara.addTextChangedListener(new AdvanceParameterAdapter.MyTextChangedListener(viewHolder, contents));
+        contents.put(i, viewHolder.etPara.getText().toString().trim());
+        viewHolder.btnUpdate.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                String text = contents.get(i);
+                listener.onItemListener(v, i, text);
+            }
+        });
+        if (values != null && values.length > 0) {
+            viewHolder.etPara.setText(values[i]);
+        }
+
+    }
+
+    @Override
+    public int getItemCount() {
+        return paraName.length;
+    }
+
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+
+        TextView tvName;
+        EditText etPara;
+        Button btnUpdate;
+
+        public ViewHolder(@NonNull View itemView) {
+            super(itemView);
+            tvName = itemView.findViewById(R.id.tv_para_name);
+            etPara = itemView.findViewById(R.id.et_para);
+            btnUpdate = itemView.findViewById(R.id.btn_update_para);
+        }
+    }
+
+
+    public class MyTextChangedListener implements TextWatcher {
+
+        public AdvanceParameterAdapter.ViewHolder holder;
+        public HashMap<Integer, String> contents;
+        public String TAG = "测试";
+
+        public MyTextChangedListener(AdvanceParameterAdapter.ViewHolder holder, HashMap<Integer, String> contents) {
+            this.holder = holder;
+            this.contents = contents;
+        }
+
+        @Override
+        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+        }
+
+        @Override
+        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+        }
+
+        @Override
+        public void afterTextChanged(Editable editable) {
+            if (holder != null && contents != null) {
+                int adapterPosition = holder.getAdapterPosition();
+                LogUtil.d(TAG, "adapterPosition===================" + adapterPosition);
+                contents.put(adapterPosition, editable.toString());
+            }
+        }
+    }
+
+    /**
+     * @Description 进阶参数界面点击事件监听
+     */
+    public interface ItemParaClickListener {
+        /**
+         * @param view     控件
+         * @param position 位置
+         * @param text
+         */
+        void onItemListener(View view, int position, String text);
+    }
+}

+ 128 - 0
app/src/main/java/com/sunzee/adapter/GeneralParameterAdapter.java

@@ -0,0 +1,128 @@
+package com.sunzee.adapter;
+
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.wuxiaolong.androidutils.library.LogUtil;
+
+import java.util.HashMap;
+
+/**
+ * @author whw
+ * @time 2019/3/11
+ * @Description 通用参数recyclerview 设配器
+ */
+public class GeneralParameterAdapter extends RecyclerView.Adapter<GeneralParameterAdapter.ViewHolder> {
+    private int[] paraName;
+
+    //保存editText的值
+    public HashMap<Integer, String> contents = new HashMap<>();
+
+    public GeneralParameterAdapter(int[] paraName) {
+        this.paraName = paraName;
+    }
+
+    public void setItemListener(ItemParaClickListener listener) {
+        this.listener = listener;
+    }
+
+    private ItemParaClickListener listener;
+
+    public void setValues(String[] values) {
+        this.values = values;
+    }
+
+    //地址具体数值
+    private String[] values;
+
+
+    @NonNull
+    @Override
+    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
+        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_generalparameter, viewGroup, false);
+        return new ViewHolder(inflate);
+
+    }
+
+    @Override
+    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
+        viewHolder.cbManual.setText(paraName[i]);
+
+        viewHolder.cbManual.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                listener.onItemListener(view, i, "");
+            }
+        });
+    }
+
+    @Override
+    public int getItemCount() {
+        return paraName.length;
+    }
+
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+
+        public CheckBox cbManual;
+
+        public ViewHolder(@NonNull View itemView) {
+            super(itemView);
+            cbManual = itemView.findViewById(R.id.cb_manual);
+
+        }
+    }
+
+
+    public class MyTextChangedListener implements TextWatcher {
+
+        public ViewHolder holder;
+        public HashMap<Integer, String> contents;
+        public String TAG = "测试";
+
+        public MyTextChangedListener(ViewHolder holder, HashMap<Integer, String> contents) {
+            this.holder = holder;
+            this.contents = contents;
+        }
+
+        @Override
+        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+        }
+
+        @Override
+        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+        }
+
+        @Override
+        public void afterTextChanged(Editable editable) {
+            if (holder != null && contents != null) {
+                int adapterPosition = holder.getAdapterPosition();
+                LogUtil.d(TAG, "adapterPosition===================" + adapterPosition);
+                contents.put(adapterPosition, editable.toString());
+            }
+        }
+    }
+
+    /**
+     * @Description 通用参数界面点击事件监听
+     */
+    public interface ItemParaClickListener {
+        /**
+         * @param view     控件
+         * @param position 位置
+         * @param text
+         */
+        void onItemListener(View view, int position, String text);
+    }
+}

+ 4 - 1
app/src/main/java/com/sunzee/base/BaseApplication.java

@@ -5,6 +5,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 
+import com.hboxs.serialport.SerialPortDevice;
+import com.hboxs.serialport.SerialPortManager;
 import com.orhanobut.hawk.Hawk;
 import com.sunzee.model.Heartbeat;
 import com.sunzee.model.domain.Name;
@@ -27,7 +29,8 @@ public class BaseApplication extends Application {
         Hawk.init(this).build();
         Heartbeat.deviceId = FileUtil.getDeviceId();
         Heartbeat.managerId = (String) SharedPreferencesUtils.getParam(Name.SYSTEM_ID, "");
-
+        SerialPortDevice device = new SerialPortDevice("/dev/ttyS2", "9600");
+        SerialPortManager.getInstance().open(device);
         startMyService();
         firstHeartbeat();
     }

+ 126 - 0
app/src/main/java/com/sunzee/thread/GeneralParameterTask.java

@@ -0,0 +1,126 @@
+package com.sunzee.thread;
+
+import com.hboxs.serialport.SerialPortSendQueue;
+import com.hboxs.serialport.frame.ReadCommandFrame;
+import com.hboxs.serialport.frame.RstCommandFrame;
+import com.hboxs.serialport.frame.SetCommandFrame;
+
+/**
+ * 通用参数任务
+ */
+public class GeneralParameterTask implements Runnable {
+
+    private int type;
+    private volatile String address;
+
+    public String getAddress() {
+        return address;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    private volatile int id;
+    private volatile boolean isRun;
+    private String name;
+    private String data;
+
+    public GeneralParameterTask(int type) {
+        clearPlcQuee();
+        this.type = type;
+    }
+
+    public GeneralParameterTask(int type, String address, int id) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+        this.id = id;
+    }
+
+
+    public GeneralParameterTask(int type, String address, String data, int id, String name) {
+        clearPlcQuee();
+        this.type = type;
+        this.address = address;
+        this.data = data;
+        this.id = id;
+        this.name = name;
+    }
+
+    private void clearPlcQuee() {
+        setIsRun(true);
+        SerialPortSendQueue.clear();
+    }
+
+    public void setIsRun(boolean isRun) {
+        this.isRun = isRun;
+    }
+
+    public boolean getIsRun() {
+        return isRun;
+    }
+
+    @Override
+    public void run() {
+        switch (type) {
+            case GeneralParameterThreadType.runM17:
+                runReadM17();
+                break;
+            case GeneralParameterThreadType.rstM17:
+                runRstM17();
+                break;
+            case GeneralParameterThreadType.setM17:
+                runSetM17();
+                break;
+
+        }
+    }
+
+    private void runReadM17() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new ReadCommandFrame("M17", 2), 17,"M17");
+        }
+    }
+
+    private void runSetM17() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new SetCommandFrame("M17"), 17, "M17");
+        }
+    }
+
+    private void runRstM17() {
+        if (getIsRun()) {
+            SerialPortSendQueue.sendCommand(new RstCommandFrame("M17"), 17, "M17");
+        }
+    }
+
+    public void setAddressAndId(String address, int id) {
+        this.address = address;
+        this.id = id;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+}

+ 8 - 0
app/src/main/java/com/sunzee/thread/GeneralParameterThreadType.java

@@ -0,0 +1,8 @@
+package com.sunzee.thread;
+
+public interface GeneralParameterThreadType {
+  int runM17 = 17;
+
+    int rstM17 = 171;
+    int setM17 = 172;
+}

+ 70 - 0
app/src/main/java/com/sunzee/thread/ThreadPoolGeneralParameter.java

@@ -0,0 +1,70 @@
+package com.sunzee.thread;
+
+import android.util.Log;
+
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 通用参数线程池
+ */
+public class ThreadPoolGeneralParameter {
+    private ScheduledThreadPoolExecutor scheduled;
+
+    private ScheduledFuture<?> mScheduledFutureM17;
+    private GeneralParameterTask mTaskRunM17;
+    private GeneralParameterTask mTaskRstM17;
+    private GeneralParameterTask mTaskSetM17;
+
+    public ThreadPoolGeneralParameter() {
+        scheduled = new ScheduledThreadPoolExecutor(2);
+        //设置线程池的策略  抛弃旧的任务
+        scheduled.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
+    }
+
+    private static final String TAG = "ThreadPoolGeneralParame";
+
+    public void startALLRead() {
+        mTaskRunM17 = new GeneralParameterTask(GeneralParameterThreadType.runM17);
+
+        mScheduledFutureM17 = scheduled.scheduleAtFixedRate(mTaskRunM17, 10, 1000, TimeUnit.MILLISECONDS);
+        Log.d(TAG, "startALLRead: " + mTaskRunM17 + ":" + mScheduledFutureM17);
+    }
+
+    public void stopReadM17() {
+        stopRead(mTaskRunM17, mScheduledFutureM17);
+    }
+
+    public void stopRstM17() {
+        stopRead(mTaskRstM17, mScheduledFutureM17);
+    }
+
+    public void stopSetM17() {
+        stopRead(mTaskSetM17, mScheduledFutureM17);
+    }
+
+
+    public void startRstM17(String address) {
+        mTaskRstM17 = new GeneralParameterTask(GeneralParameterThreadType.rstM17);
+
+        mScheduledFutureM17 = scheduled.scheduleAtFixedRate(mTaskRstM17, 10, 100, TimeUnit.MILLISECONDS);
+    }
+
+
+    public void startSetM17(String address) {
+        mTaskSetM17 = new GeneralParameterTask(GeneralParameterThreadType.setM17);
+        mScheduledFutureM17 = scheduled.scheduleAtFixedRate(mTaskSetM17, 10, 100, TimeUnit.MILLISECONDS);
+    }
+
+
+    public static void stopRead(GeneralParameterTask threadTask, ScheduledFuture<?> scheduledFuture1) {
+        if (threadTask != null) {
+            threadTask.setIsRun(false);
+        }
+        if (scheduledFuture1 != null) {
+            scheduledFuture1.cancel(true);
+        }
+    }
+}

+ 6 - 1
app/src/main/java/com/sunzee/ui/activity/AdvertisingActivity.java

@@ -5,6 +5,7 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.support.annotation.Nullable;
 import android.text.format.DateFormat;
+import android.util.Log;
 import android.view.SurfaceView;
 import android.view.View;
 import android.widget.ImageView;
@@ -84,7 +85,11 @@ public class AdvertisingActivity extends MvpActivity<AdvertisingPresenter> imple
         mRlRoot = findViewById(R.id.rl_root);
         mTvTime = findViewById(R.id.tv_time1);
         mTvEquipmentNo = findViewById(R.id.tv_equipment_no1);
-        mTvEquipmentNo.setText(Heartbeat.deviceId != null ? Heartbeat.deviceId.substring(Heartbeat.deviceId.length() - 6) : "");
+        Log.d(TAG, "initView: "+Heartbeat.deviceId);
+        if (Heartbeat.deviceId!=null &&Heartbeat.deviceId.length()>7) {
+            mTvEquipmentNo.setText(Heartbeat.deviceId != null ? Heartbeat.deviceId.substring(Heartbeat.deviceId.length() - 6) : "");
+
+        }
         //1.初始化播放器
         mRightsimplePlayer = new SimplePlayerUtils(mAdSurfaceView);
         mRightsimplePlayer.setImageView(mAdImageview);

+ 141 - 2
app/src/main/java/com/sunzee/ui/fragment/GeneralParameterFragment.java

@@ -1,41 +1,180 @@
 package com.sunzee.ui.fragment;
 
+import android.app.ProgressDialog;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
 
+import com.hboxs.serialport.SerialPortDevice;
+import com.hboxs.serialport.SerialPortManager;
+import com.hboxs.serialport.frame.ResponseFrame;
+import com.hboxs.serialport.message.Message;
+import com.hboxs.serialport.util.AsciiUtils;
 import com.sunzee.R;
+import com.sunzee.adapter.GeneralParameterAdapter;
+import com.sunzee.base.BaseApplication;
 import com.sunzee.base.MvpFragment;
 import com.sunzee.mvp.generalparameter.GeneralParameterPresenter;
 import com.sunzee.mvp.generalparameter.GeneralParameterView;
+import com.sunzee.thread.ThreadPoolGeneralParameter;
+import com.sunzee.utils.HexadecimalUtil;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
 
 /**
  * 通用参数界面
  */
 public class GeneralParameterFragment extends MvpFragment<GeneralParameterPresenter> implements GeneralParameterView {
+    private final int[] paraName = {R.string.all_clean};
+    private final String[] paraAddress = {"M17"};
+    private RecyclerView mRvCrrency;
+    private GeneralParameterAdapter mGeneralParameterAdapter;
+    private ThreadPoolGeneralParameter mPoolGeneralParameter = new ThreadPoolGeneralParameter();
 
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         View inflate = inflater.inflate(R.layout.fragment_general_parameter, container, false);
+        initView(inflate);
+        initEvent();
         return inflate;
     }
 
     @Override
+    public void onStart() {
+        super.onStart();
+        EventBus.getDefault().register(this);
+        showLoading();
+        mPoolGeneralParameter.startALLRead();
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        EventBus.getDefault().unregister(this);
+    }
+
+    private void initEvent() {
+        mGeneralParameterAdapter.setItemListener(new GeneralParameterAdapter.ItemParaClickListener() {
+            @Override
+            public void onItemListener(View view, int position, String text) {
+                //点击的时候就开始写入
+                final String address = paraAddress[position];
+                CheckBox checkBox = (CheckBox) view;
+                if (!checkBox.isChecked()) {
+                    mPoolGeneralParameter.startRstM17(address);
+                } else {
+                    mPoolGeneralParameter.startSetM17(address);
+                }
+                showLoading();
+            }
+        });
+    }
+
+    private void initView(View inflate) {
+        mRvCrrency = inflate.findViewById(R.id.rv_currency);
+        mGeneralParameterAdapter = new GeneralParameterAdapter(paraName);
+        GridLayoutManager layoutManager = new GridLayoutManager(BaseApplication.getContext(), 9, GridLayoutManager.HORIZONTAL, false);
+        mRvCrrency.setAdapter(mGeneralParameterAdapter);
+        mRvCrrency.setLayoutManager(layoutManager);
+    }
+
+    @Override
     protected GeneralParameterPresenter createPresenter() {
-        return null;
+        return new GeneralParameterPresenter(this);
     }
 
     @Override
     public void showLoading() {
-
+        showProgressDialog();
     }
 
     @Override
     public void hideLoading() {
+        dismissProgressDialog();
+    }
+
+    private static final String TAG = "GeneralParameterFragmen";
+
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void event(Message messageEvent) {
+        switch (messageEvent.getType()) {
+            case connected:
+                break;
+            case sendError:
+                break;
+            case ack:
+                //写入数据成功的反馈
+                mPoolGeneralParameter.stopRstM17();
+                mPoolGeneralParameter.stopSetM17();
+                hideLoading();
+                break;
+            case nak:
+                break;
+            case disconnected:
+                SerialPortDevice device = new SerialPortDevice("/dev/ttyS2", "9600");
+                SerialPortManager.getInstance().open(device);
+                break;
+            case response:
+                ResponseFrame responseFrame = (ResponseFrame) messageEvent.getContent();
+                String result1 = AsciiUtils.asciiByteArray2HexStr(responseFrame.getData());
+                //通过校验
+                String name = messageEvent.getName();
+                if (name.equals("M17")) {
+                    ArrayList<String> results1 = HexadecimalUtil.flipString(result1);
+                    long data = HexadecimalUtil.hex2dec(results1.get(0));
+                    if (data != 1) {
+                        setStatus(0, 1);
+                    }
+                    mPoolGeneralParameter.stopReadM17();
+                }
+                hideLoading();
+                break;
+        }
+
+    }
+
+    private void setStatus(int position, long data) {
+        View view = mRvCrrency.getChildAt(position);
+        if (null != mRvCrrency.getChildViewHolder(view)) {
+            GeneralParameterAdapter.ViewHolder viewHolder = (GeneralParameterAdapter.ViewHolder) mRvCrrency.getChildViewHolder(view);
+            if (data == 1) {
+                //当它为选择状态时,无需设置,避免闪硕
+                if (!viewHolder.cbManual.isChecked()) {
+                    viewHolder.cbManual.setChecked(true);
+                }
+            } else {
+                if (viewHolder.cbManual.isChecked()) {
+                    viewHolder.cbManual.setChecked(false);
+                }
+
+            }
+        }
+    }
+
+    public ProgressDialog progressDialog;
+
+    public ProgressDialog showProgressDialog() {
+        progressDialog = new ProgressDialog(mActivity);
+        progressDialog.setMessage("加载中");
+        progressDialog.show();
+        return progressDialog;
+    }
 
+    public void dismissProgressDialog() {
+        if (progressDialog != null && progressDialog.isShowing()) {
+            // progressDialog.hide();会导致android.view.WindowLeaked
+            progressDialog.dismiss();
+        }
     }
 }

+ 175 - 0
app/src/main/java/com/sunzee/utils/HexadecimalUtil.java

@@ -0,0 +1,175 @@
+package com.sunzee.utils;
+
+import android.text.TextUtils;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author whw
+ * @time 2019/3/4
+ * @Description 进制操作工具类
+ */
+public class HexadecimalUtil {
+
+    /**
+     *  16进制转2进制
+     * @param hexStr 16进制
+     * @return 2进制
+     */
+    public static byte[] parseHexStr2Byte(String hexStr) {
+        if (hexStr.length() < 1)
+            return null;
+        byte[] result = new byte[hexStr.length() / 2];
+        for (int i = 0; i < hexStr.length() / 2; i++) {
+            int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
+            int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
+            result[i] = (byte) (high * 16 + low);
+        }
+        return result;
+    }
+    /**
+     * 16进制转2进制
+     *
+     * @param hex
+     * @return 2进制字符串
+     */
+    public static String hexStringToByte(String hex) {
+        final int maxNum=16;
+//        int i = Integer.parseInt(hex, 16);
+                BigInteger i = new BigInteger(hex,16);
+        //10进制转2进制
+        String str2 = Integer.toBinaryString(i.intValue());
+        StringBuilder sb=new StringBuilder(str2);
+        int length = str2.length();
+        if (length <maxNum){
+            int len=maxNum-length;
+            for (int j = 0; j < len; j++) {
+                sb.insert(j,0);
+            }
+
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 16进制转10进制
+     * @param text
+     * @return
+     */
+    public static long hex2dec(String text){
+       return Long.parseLong(text, 16);
+    }
+
+    /**
+     * 字符串转化成为16进制字符串
+     * @param s
+     * @return
+     */
+    public static String strTo16(String s) {
+        String str = "";
+        for (int i = 0; i < s.length(); i++) {
+            int ch = (int) s.charAt(i);
+            String s4 = Integer.toHexString(ch);
+            str = str + s4;
+        }
+        return str;
+    }
+
+    /**
+     * 把原始字符串分割成指定长度的字符串列表
+     * @param inputString 原始字符串
+     * @param length 指定长度
+     * @return
+     */
+    public static List<String> getStrList(String inputString, int length) {
+        int size = inputString.length() / length;
+        if (inputString.length() % length != 0) {
+            size += 1;
+        }
+        return getStrList(inputString, length, size);
+    }
+
+    /**
+     * 把原始字符串分割成指定长度的字符串列表
+     * @param inputString 原始字符串
+     * @param length 指定长度
+     * @param size 指定列表大小
+     * @return
+     */
+    public static List<String> getStrList(String inputString, int length,
+                                          int size) {
+        List<String> list = new ArrayList<String>();
+        for (int index = 0; index < size; index++) {
+            String childStr = substring(inputString, index * length,
+                    (index + 1) * length);
+            list.add(childStr);
+        }
+        return list;
+    }
+
+    /**
+     * 分割字符串,如果开始位置大于字符串长度,返回空
+     * @param str 原始字符串
+     * @param f 开始位置
+     * @param t 结束位置
+     * @return
+     */
+    public static String substring(String str, int f, int t) {
+        if (f > str.length())
+            return null;
+        if (t > str.length()) {
+            return str.substring(f, str.length());
+        } else {
+            return str.substring(f, t);
+        }
+    }
+
+    /**
+     * 进行翻转拼接
+     * @param inputString 字符源
+     * @param length 每个字符串长度
+     * @return
+     */
+    public static String flipString(String inputString, int length){
+        StringBuilder sb=new StringBuilder();
+        List<String> strList = getStrList(inputString, length);
+        for (int i=0;i<strList.size();i++) {
+            //进行翻转
+            String s = strList.get(i);
+            String s1 = TextUtils.getReverse(s, 0, s.length()).toString();
+            sb.append(s1);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 将16进制的字符串进行高低位翻转
+     * @param text 16进制字符串
+     * @return 翻转后的列表
+     */
+    public static ArrayList<String> flipString(String text){
+        ArrayList<String> arrayList=new ArrayList();
+
+        if ((text.length()%4)==0){
+            //切割 每隔4位进行切割
+            List<String> strList = HexadecimalUtil.getStrList(text, 4);
+          //  System.out.println("切割后:"+strList.size());
+
+            //每个进行翻转
+            for (int i=0;i<strList.size();i++){
+                String s = strList.get(i);
+               // System.out.println("第"+i+"个:"+ s);
+                List<String> strList1 = HexadecimalUtil.getStrList(s, 2);
+                StringBuilder sb=new StringBuilder();
+                sb.append(strList1.get(1));
+                sb.append(strList1.get(0));
+               // System.out.println("第"+i+"个翻转后的数组为:"+ sb.toString());
+                arrayList.add(sb.toString());
+            }
+        }
+        return arrayList;
+    }
+
+}

BIN
app/src/main/res/drawable-hdpi/back_icon.png


BIN
app/src/main/res/drawable-hdpi/data_icon.png


BIN
app/src/main/res/drawable-hdpi/debug_icon.png


BIN
app/src/main/res/drawable-hdpi/home_icon.png


BIN
app/src/main/res/drawable-hdpi/language_icon.png


BIN
app/src/main/res/drawable-hdpi/login_logo.png


BIN
app/src/main/res/drawable-hdpi/material_icon.png


BIN
app/src/main/res/drawable-hdpi/other_icon.png


BIN
app/src/main/res/drawable-hdpi/parameter1_icon.png


BIN
app/src/main/res/drawable-hdpi/parameter2_icon.png


BIN
app/src/main/res/drawable-hdpi/password_icon.png


BIN
app/src/main/res/drawable-hdpi/random.png


BIN
app/src/main/res/drawable-hdpi/shutdown.png


BIN
app/src/main/res/drawable-hdpi/time.png


BIN
app/src/main/res/drawable-hdpi/timing.png


BIN
app/src/main/res/drawable-hdpi/warring_icon.png


BIN
app/src/main/res/drawable-mdpi/back_icon.png


BIN
app/src/main/res/drawable-mdpi/data_icon.png


BIN
app/src/main/res/drawable-mdpi/debug_icon.png


BIN
app/src/main/res/drawable-mdpi/home_icon.png


BIN
app/src/main/res/drawable-mdpi/language_icon.png


BIN
app/src/main/res/drawable-mdpi/login_logo.png


BIN
app/src/main/res/drawable-mdpi/material_icon.png


BIN
app/src/main/res/drawable-mdpi/other_icon.png


BIN
app/src/main/res/drawable-mdpi/parameter1_icon.png


BIN
app/src/main/res/drawable-mdpi/parameter2_icon.png


BIN
app/src/main/res/drawable-mdpi/password_icon.png


BIN
app/src/main/res/drawable-mdpi/random.png


+ 5 - 0
app/src/main/res/drawable-mdpi/selector_manual_tv_color.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true" android:color="@color/white"></item>
+    <item android:state_checked="false" android:color="@color/logo_blue"></item>
+</selector>

+ 5 - 0
app/src/main/res/drawable-mdpi/selector_orange_bg.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true" android:drawable="@drawable/shape_login_rounded_rectangle"></item>
+    <item android:state_checked="false" android:drawable="@drawable/shape_btn_back"></item>
+</selector>

BIN
app/src/main/res/drawable-mdpi/shutdown.png


BIN
app/src/main/res/drawable-mdpi/time.png


BIN
app/src/main/res/drawable-mdpi/timing.png


BIN
app/src/main/res/drawable-mdpi/warring_icon.png


BIN
app/src/main/res/drawable-xhdpi/back_icon.png


BIN
app/src/main/res/drawable-xhdpi/data_icon.png


BIN
app/src/main/res/drawable-xhdpi/debug_icon.png


BIN
app/src/main/res/drawable-xhdpi/home_icon.png


BIN
app/src/main/res/drawable-xhdpi/language_icon.png


BIN
app/src/main/res/drawable-xhdpi/login_logo.png


BIN
app/src/main/res/drawable-xhdpi/material_icon.png


BIN
app/src/main/res/drawable-xhdpi/other_icon.png


BIN
app/src/main/res/drawable-xhdpi/parameter1_icon.png


BIN
app/src/main/res/drawable-xhdpi/parameter2_icon.png


BIN
app/src/main/res/drawable-xhdpi/password_icon.png


BIN
app/src/main/res/drawable-xhdpi/random.png


BIN
app/src/main/res/drawable-xhdpi/shutdown.png


BIN
app/src/main/res/drawable-xhdpi/time.png


BIN
app/src/main/res/drawable-xhdpi/timing.png


BIN
app/src/main/res/drawable-xhdpi/warring_icon.png


BIN
app/src/main/res/drawable-xxhdpi/back_icon.png


BIN
app/src/main/res/drawable-xxhdpi/data_icon.png


BIN
app/src/main/res/drawable-xxhdpi/debug_icon.png


BIN
app/src/main/res/drawable-xxhdpi/home_icon.png


BIN
app/src/main/res/drawable-xxhdpi/language_icon.png


BIN
app/src/main/res/drawable-xxhdpi/login_logo.png


BIN
app/src/main/res/drawable-xxhdpi/material_icon.png


BIN
app/src/main/res/drawable-xxhdpi/other_icon.png


BIN
app/src/main/res/drawable-xxhdpi/parameter1_icon.png


BIN
app/src/main/res/drawable-xxhdpi/parameter2_icon.png


BIN
app/src/main/res/drawable-xxhdpi/password_icon.png


BIN
app/src/main/res/drawable-xxhdpi/random.png


BIN
app/src/main/res/drawable-xxhdpi/shutdown.png


BIN
app/src/main/res/drawable-xxhdpi/time.png


BIN
app/src/main/res/drawable-xxhdpi/timing.png


BIN
app/src/main/res/drawable-xxhdpi/warring_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/back_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/data_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/debug_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/home_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/language_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/login_logo.png


BIN
app/src/main/res/drawable-xxxhdpi/material_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/other_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/parameter1_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/parameter2_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/password_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/random.png


BIN
app/src/main/res/drawable-xxxhdpi/shutdown.png


BIN
app/src/main/res/drawable-xxxhdpi/time.png


BIN
app/src/main/res/drawable-xxxhdpi/timing.png


BIN
app/src/main/res/drawable-xxxhdpi/warring_icon.png


+ 1 - 0
app/src/main/res/layout/activity_login.xml

@@ -57,6 +57,7 @@
                 android:layout_marginRight="@dimen/dp_50"
                 android:hint="@string/enter_password"
                 android:lines="1"
+                android:text="123456"
                 android:paddingBottom="@dimen/dp_10"
                 android:textColor="@color/gray"
                 android:textColorHint="@color/gray"

+ 184 - 0
app/src/main/res/layout/activity_testserial_port.xml

@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_gravity="center_horizontal"
+        android:orientation="vertical">
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="@dimen/dp_15"
+            android:text="串口通信测试"
+            android:textColor="@color/orange"
+            android:textSize="28sp" />
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginTop="@dimen/dp_15"
+            android:orientation="horizontal">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="指令类型"
+                android:textColor="@color/orange"
+                android:textSize="18sp" />
+
+            <RadioGroup
+                android:id="@+id/rg_type"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal">
+
+                <RadioButton
+                    android:id="@+id/rb_type_read"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:checked="true"
+                    android:text="读" />
+
+                <RadioButton
+                    android:id="@+id/rb_type_write"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="写" />
+            </RadioGroup>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginTop="@dimen/dp_15"
+            android:orientation="horizontal">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="读/写地址"
+                android:textColor="@color/orange"
+                android:textSize="18sp" />
+
+            <Spinner
+                android:id="@+id/sp_address_area"
+                android:layout_width="@dimen/dp_10"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="@dimen/dp_10"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:outlineAmbientShadowColor="@color/orange"
+                android:outlineSpotShadowColor="@color/orange"
+                android:shadowColor="@color/orange"
+                tools:ignore="RtlCompat"></Spinner>
+
+            <EditText
+                android:id="@+id/et_command"
+                android:layout_width="@dimen/dp_10"
+                android:layout_height="@dimen/dp_10"
+                android:layout_marginStart="@dimen/dp_10"
+                android:digits="0123456789"
+                android:maxLines="1"
+                android:padding="@dimen/dp_10"
+                android:textColor="@color/orange"
+                android:textSize="16sp"
+                android:layout_marginLeft="@dimen/dp_10" />
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_read_length"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginTop="@dimen/dp_10"
+            android:orientation="horizontal">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="读取数据长度(字节)"
+                android:textColor="@color/orange"
+                android:textSize="18sp" />
+
+            <Spinner
+                android:id="@+id/sp_data_length"
+                android:layout_width="@dimen/dp_10"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="@dimen/dp_10"
+                android:layout_marginLeft="@dimen/dp_10"></Spinner>
+
+        </LinearLayout>
+
+
+        <LinearLayout
+            android:id="@+id/ll_write_data"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:layout_marginTop="@dimen/dp_10"
+            android:orientation="horizontal"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="写入数据(16进制)"
+                android:textColor="@color/orange"
+                android:textSize="18sp" />
+
+            <EditText
+                android:id="@+id/et_data"
+                android:layout_width="@dimen/dp_10"
+                android:layout_height="@dimen/dp_10"
+                android:layout_marginStart="@dimen/dp_10"
+                android:digits="0123456789ABCDEFabcdef"
+                android:hint="16进制,例如:08C3"
+                android:maxLines="1"
+                android:padding="@dimen/dp_10"
+                android:textColor="@color/orange"
+                android:textSize="16sp"
+                android:layout_marginLeft="@dimen/dp_10" />
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
+            android:layout_marginTop="@dimen/dp_10"
+            android:orientation="horizontal">
+
+
+
+            <Button
+                android:id="@+id/btn_set"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="置位"
+                android:textColor="@color/orange" />
+
+
+            <Button
+                android:id="@+id/btn_rst"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="复位"
+                android:textColor="@color/orange" />
+
+        </LinearLayout>
+    </LinearLayout>
+
+
+</LinearLayout>

+ 29 - 0
app/src/main/res/layout/dialog_result.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_marginStart="@dimen/dp_10"
+    android:layout_marginEnd="@dimen/dp_10"
+    android:background="@color/orange"
+    android:gravity="center"
+    android:orientation="vertical">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_horizontal"
+        android:text="结果"
+        android:textColor="@color/orange"
+        android:textSize="18sp" />
+
+    <TextView
+        android:id="@+id/tv_result"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/dp_10"
+        android:textColor="@color/orange"
+        android:textSize="28sp" />
+
+
+
+</LinearLayout>

+ 14 - 8
app/src/main/res/layout/fragment_general_parameter.xml

@@ -1,14 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:padding="@dimen/dp_5"
-    android:background="@color/shallowblue">
+    android:background="@color/shallowblue"
+    android:padding="@dimen/dp_5">
 
-    <TextView
-        android:gravity="center"
-        android:text="@string/general_parameter"
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/rv_currency"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
+        android:layout_height="wrap_content"
+        android:layout_marginRight="@dimen/dp_30"
+        android:descendantFocusability="beforeDescendants"
+        android:fastScrollEnabled="false"
+        tools:ignore="MissingConstraints">
 
-</android.support.constraint.ConstraintLayout>
+    </android.support.v7.widget.RecyclerView>
+
+</LinearLayout>

+ 42 - 0
app/src/main/res/layout/item_advanceparameter.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/dp_10"
+    android:gravity="center_vertical"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/tv_para_name"
+        android:layout_width="@dimen/dp_55"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:ellipsize="end"
+        android:gravity="center"
+        android:lines="3"
+        android:maxLines="3"
+        android:text="@string/x"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_7" />
+
+    <EditText
+        android:id="@+id/et_para"
+        android:layout_width="@dimen/dp_51"
+        android:layout_height="@dimen/dp_20"
+        android:layout_marginLeft="@dimen/dp_7"
+        android:background="@drawable/shape_btn_back"
+        android:inputType="numberSigned"
+        android:paddingLeft="@dimen/dp_8"
+        android:textColor="@color/colorBg"
+        android:textColorHint="@color/colorHint" />
+
+    <Button
+        android:id="@+id/btn_update_para"
+        android:layout_width="@dimen/dp_30"
+        android:layout_height="@dimen/dp_20"
+        android:layout_marginLeft="@dimen/dp_7"
+        android:background="@drawable/shape_btn_back"
+        android:text="@string/update"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/sp_7" />
+</LinearLayout>

+ 21 - 0
app/src/main/res/layout/item_generalparameter.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="@dimen/dp_60"
+    android:layout_height="@dimen/dp_20"
+    android:layout_gravity="center"
+    android:layout_marginTop="@dimen/dp_10"
+    android:layout_marginRight="@dimen/dp_6"
+    android:gravity="center">
+
+    <CheckBox
+        android:id="@+id/cb_manual"
+        android:layout_width="@dimen/dp_80"
+        android:layout_height="match_parent"
+        android:layout_gravity="center"
+        android:background="@drawable/selector_orange_bg"
+        android:button="@null"
+        android:checked="false"
+        android:gravity="center"
+        android:textColor="@drawable/selector_manual_tv_color"
+        android:textSize="@dimen/sp_7" />
+</LinearLayout>

+ 12 - 11
app/src/main/res/values/strings.xml

@@ -631,17 +631,17 @@
     <string name="offline_statistics">数据统计/线下总统计</string>
     <string name="xingyongkazhibi">信用卡/纸币支付</string>
     <string name="advance_parameter_1">X轴回零速度</string>
-    <string name="advance_parameter_2">Y轴回零速度</string>
-    <string name="advance_parameter_3">Z轴回零速度</string>
-    <string name="advance_parameter_4">X轴爬行速度</string>
-    <string name="advance_parameter_5">Y轴爬行速度</string>
-    <string name="advance_parameter_6">Z轴爬行速度</string>
-    <string name="advance_parameter_7">炉头温度滤波次数</string>
-    <string name="advance_parameter_8">炉头第一段加热时间</string>
-    <string name="advance_parameter_9">炉头第一段停止时间</string>
-    <string name="advance_parameter_10">炉头第二段加热时间</string>
-    <string name="advance_parameter_11">炉头第二段停止时间</string>
-    <string name="advance_parameter_12">炉头第三段加热时间</string>
+    <string name="advance_parameter_2">X轴爬行速度</string>
+    <string name="advance_parameter_3">Y轴回零速度</string>
+    <string name="advance_parameter_4">Y轴爬行速度</string>
+    <string name="advance_parameter_5">E轴回零速度</string>
+    <string name="advance_parameter_6">E轴爬行速度</string>
+    <string name="advance_parameter_7">X轴加速度</string>
+    <string name="advance_parameter_8">X轴减速度</string>
+    <string name="advance_parameter_9">Y轴加速度</string>
+    <string name="advance_parameter_10">Y轴减速度</string>
+    <string name="advance_parameter_11">E轴加速度</string>
+    <string name="advance_parameter_12">E轴减速度</string>
     <string name="advance_parameter_13">炉头第三段停止时间</string>
     <string name="advance_parameter_14">炉头第一段温度(%)</string>
     <string name="advance_parameter_15">炉头第二段温度(%)</string>
@@ -688,5 +688,6 @@
     <string name="card_tips">插入信用卡,如果已经插入,则直接在屏幕上单击\"确定\"!</string>
     <string name="coin_pulse">币数脉冲除以x值</string>
     <string name="oldpas">原始密码不正确</string>
+    <string name="all_clean">全部蹲位清洁</string>
 
 </resources>