renevy пре 5 година
родитељ
комит
84681440b6

+ 435 - 134
app/src/main/java/com/ifastore/goodsmanage/MainActivity.java

@@ -17,7 +17,6 @@ import android.view.Window;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
-import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.RelativeLayout;
 import android.widget.Spinner;
@@ -25,6 +24,9 @@ import android.widget.TextView;
 import android.widget.Toast;
 
 
+import com.ifastore.goodsmanage.models.DeviceResult;
+import com.ifastore.goodsmanage.models.MotorStart;
+import com.ifastore.goodsmanage.models.MotorStatus;
 import com.ifastore.goodsmanage.models.ObjectBean;
 import com.ifastore.goodsmanage.serialport.CommTask;
 import com.ifastore.goodsmanage.utils.Logger;
@@ -33,7 +35,6 @@ import com.inks.inkslibrary.Popup.PopupSelect;
 import com.inks.inkslibrary.Popup.PopupView;
 import com.inks.inkslibrary.Popup.PromptSettings;
 import com.inks.inkslibrary.Popup.SelectListDataBean;
-import com.inks.inkslibrary.Popup.SelectSettings;
 import com.inks.inkslibrary.Popup.ViewSettings;
 
 import java.util.ArrayList;
@@ -80,7 +81,7 @@ public class MainActivity extends AppCompatActivity {
     RelativeLayout logLayout;
 
     @BindView(R.id.temp)
-    TextView temp;
+    TextView tempTextView;
     @BindView(R.id.readAddr)
     Button readAddr;
     @BindView(R.id.setAddr)
@@ -101,13 +102,27 @@ public class MainActivity extends AppCompatActivity {
     private Window window;
     private LayoutInflater inflater;
     private View linearLayout;
+    private View controlInLayout;
+    private View controlOutLayout;
+    private View motorTestLayout;
+    private View setAddrLayout;
     private Context context;
     private PopupView popupView;
     private PopupPrompt popupPrompt;
     private PopupSelect popupSelect;
-    public Spinner xSpinGoodsWay;
-    public Spinner ySpinGoodsWay;
-    public Spinner spinGoodsNum;
+    public Spinner motorIndex;
+    public Spinner motorType;
+    public Spinner lightMode;
+    public Spinner maxCurrent;
+    public Spinner minCurrent;
+    public Spinner motorTimerOut;
+
+    public Spinner controlInSpiner;
+    public Spinner controlOutSpiner;
+    public Spinner controlSwitchSpiner;
+
+    public Spinner motorTestSpiner;
+    public Spinner setAddressSpiner;
     private TextView textView;
 
     private SerialPortFinder serialPortFinder;
@@ -119,10 +134,17 @@ public class MainActivity extends AppCompatActivity {
     private BlockingQueue<ObjectBean> queue;
     private static String serialStr = "";
     private static int  bauteValue = 0;
-    private static int  xGoosdWay = 0;
-    private static int  yGoosdWay = 0;
-    private static int  goodsNum = 1;
-    private static int  choosedLight = 0;
+    private static int indexValue = 0;
+    private static int typeValue = 0;
+    private static int lightValue = 0;
+    private static int maxCurrentValue = 0;
+    private static int minCurrentValue = 0;
+    private static int motorTimerOutValue = 0;
+    private static int  controlInValue = 0;
+    private static int  controlOutValue = 0;
+    private static int  controlSwitchValue = 0;
+    private static int  motorTestValue  = 0;
+    private static int  setAddressValue = 1;
     private boolean isFirst = false;
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -184,35 +206,37 @@ public class MainActivity extends AppCompatActivity {
             return;
         }
         switch (id){
-            case R.id.openSerial:
-                openSerial();
-                break;
-            case R.id.closeSerial:
-                closeSerial();
-                break;
             case R.id.motoStart:
                 if(commTask.isopen){
-                    setOutGoodsInfo();
+                    selectMotorStartInfo();
                 }
                 break;
             case R.id.motoTest:
-                selectLight();
+                selectMotorIndex();
                 break;
             case R.id.readAddr:
+                if(commTask.isopen){
+                    commTask.queryAddress();
+                }
                 break;
             case R.id.setAddr:
+                selectAddress();
                 break;
             case R.id.querySerial:
-                selectLight();
+                if(commTask.isopen){
+                    commTask.querySerailNum();
+                }
                 break;
             case R.id.queryStatus:
-                selectLight();
+                if(commTask.isopen){
+                    commTask.queryMotorStatus();
+                }
                 break;
             case R.id.controlOut:
-                selectLight();
+                selectControlOut();
                 break;
             case R.id.controlIn:
-                selectLight();
+                selectControlIn();
                 break;
         }
     }
@@ -240,72 +264,82 @@ public class MainActivity extends AppCompatActivity {
 
         @Override
         public void onReceive(Context context, Intent intent) {
+            DeviceResult deviceResult;
             if (intent != null) {
                 switch (Objects.requireNonNull(intent.getAction())) {
-                    case RESULT_CONTROL_SALE:
-                        int result = intent.getIntExtra(RESULT_CONTROL_SALE, -1);
-                        if(result == 0){
-                            showLog("售卖成功");
-                            pupWindows("售卖成功!");
-                        }else {
-                            showLog("售卖失败!");
-                            pupWindows("售卖失败:"+result);
-                        }
-                        break;
-                    case RESULT_CONTROL_LIGHT:
-                        int lightResult = intent.getIntExtra(RESULT_CONTROL_LIGHT, -1);
-                        Logger.debug("light result::" +lightResult);
-                        if(lightResult == 0){
-                            if(choosedLight == 0){
-                                showLog("关闭光幕成功");
-                                pupWindows("关闭光幕成功");
-                            }else {
-                                showLog("打开光幕成功");
-                                pupWindows("打开光幕成功");
-                            }
-                        }else {
-                            if(choosedLight == 0){
-                                showLog("关闭光幕失败");
-                                pupWindows("关闭光幕失败");
-                            }else {
-                                showLog("打开光幕失败");
-                                pupWindows("打开光幕失败");
-                            }
-                        }
-                        break;
                     case SET_DEVICE_ADDR:
-                        int motorResult = intent.getIntExtra(SET_DEVICE_ADDR, -1);
-                        Logger.debug("motor error result:" +motorResult);
-                        showLog("电机异常:"+motorResult);
-                        pupWindows("电机异常:"+motorResult);
-                        break;
-                    case REPORT_EVENT_GOODS:
-                        int outResult = intent.getIntExtra(REPORT_EVENT_GOODS, -1);
-                        Logger.debug("out goods result::" +outResult);
-                        if(outResult == 0){
-                            showLog("出货成功");
-                            pupWindows("出货成功");
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(SET_DEVICE_ADDR);
+                        if(deviceResult.getResult() == 0){
+                            showLog("设置设备地址成功.");
+                            //pupWindows("设置设备地址成功.");
                         }else {
-                            showLog("出货异常:"+outResult);
-                            pupWindows("出货异常:"+outResult);
-
+                            showLog("设置设备地址失败.");
+                            //pupWindows("设置设备地址失败.");
                         }
+                        /*
+                        * 成功
+                        * 失败
+                        * */
                         break;
                     case QUERY_DEVICE_ADDR:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(QUERY_DEVICE_ADDR);
+                        if(deviceResult.getResult() == 0){
+                            showLog("设备地址:"+deviceResult.getValue());
+                            //pupWindows("设置设备地址成功.");
+                        }else {
+                            showLog("查询设备地址失败.");
+                            //pupWindows("设置设备地址失败.");
+                        }
+                        //pupWindows("设备地址:"+deviceResult.getResult());
                         break;
                     case QUERY_DEVICE_SERIAL:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(QUERY_DEVICE_SERIAL);
+                        showLog("设备序列号:"+deviceResult.getResult());
+                        //pupWindows("设备序列号:"+deviceResult.getResult());
                         break;
                     case QUERY_MOTOR_STATUS:
+                        MotorStatus status = (MotorStatus) intent.getSerializableExtra(QUERY_MOTOR_STATUS);
+                        showLog("执行状态:"+status.getStatus());
+                        showLog("电机编号:"+status.getSerialNum());
+                        showLog("执行结果:"+status.getResult());
+                        showLog("峰值电流:"+status.getPeakCurrent());
+                        showLog("平均电流:"+status.getAverageCurrent());
+                        showLog("运行时间:"+status.getRunTime());
+                        showLog("光幕状态:"+status.getLightStatus());
                         break;
                     case QUERY_TEMP:
+                        float temp = intent.getFloatExtra(QUERY_TEMP,0);
+                        tempTextView.setText(String.valueOf(temp));
                         break;
                     case CONTROL_OUT:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(CONTROL_OUT);
+                        showLog("开关量输出 索引:"+deviceResult.getIndex()+" 结果:"+deviceResult.getResult());
+                        //pupWindows("开关量输出 索引:"+deviceResult.getIndex()+" 结果:"+deviceResult.getResult());
                         break;
                     case CONTROL_IN:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(CONTROL_IN);
+                        showLog("开关量输入 索引:"+deviceResult.getIndex()+" 结果:"+deviceResult.getResult());
+                        //pupWindows("开关量输入 索引:"+deviceResult.getIndex()+" 结果:"+deviceResult.getResult());
                         break;
                     case MOTOR_START:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(MOTOR_START);
+                        if(deviceResult.getResult() == 0){
+                            showLog("启动成功.");
+                            //pupWindows("启动成功.");
+                        }else {
+                            showLog("启动失败.");
+                            //pupWindows("启动失败.");
+                        }
                         break;
                     case MOTOR_TEST:
+                        deviceResult = (DeviceResult) intent.getSerializableExtra(MOTOR_TEST);
+                        if(deviceResult.getResult() == 0){
+                            showLog("测试成功.");
+                            //pupWindows("测试成功.");
+                        }else {
+                            showLog("测试失败.");
+                            //pupWindows("测试失败.");
+                        }
                         break;
                 }
             }
@@ -341,6 +375,7 @@ public class MainActivity extends AppCompatActivity {
         closeSerial.setVisibility(View.VISIBLE);
         pupWindows("打开串口成功");
         showLog("打开串口成功!");
+        commTask.queryTemp();
     }
 
     private void closeSerial(){
@@ -381,10 +416,24 @@ public class MainActivity extends AppCompatActivity {
         textView.setText("售货机测试");
         textView.setLayoutParams(layoutParams);
         logLayout.addView(textView);
-        linearLayout = (LinearLayout) inflater.inflate(R.layout.scrollviewtest, null, false);
-        xSpinGoodsWay = linearLayout.findViewById(R.id.xNum);
-        ySpinGoodsWay = linearLayout.findViewById(R.id.yNum);
-        spinGoodsNum = linearLayout.findViewById(R.id.goodsNum);
+        linearLayout = inflater.inflate(R.layout.scroll_view_motor_start, null, false);
+        motorIndex = linearLayout.findViewById(R.id.indexSpiner);
+        motorType = linearLayout.findViewById(R.id.motorTypeSpiner);
+        lightMode = linearLayout.findViewById(R.id.lightSpiner);
+        maxCurrent = linearLayout.findViewById(R.id.maxCurrentSpiner);
+        minCurrent = linearLayout.findViewById(R.id.minCurrentSpiner);
+        motorTimerOut = linearLayout.findViewById(R.id.timerOutSpiner);
+
+        controlInLayout = inflater.inflate(R.layout.scroll_view_control_in, null, false);
+        controlInSpiner = controlInLayout.findViewById(R.id.controlIn);
+        controlOutLayout = inflater.inflate(R.layout.scroll_view_control_out, null, false);
+        controlOutSpiner = controlOutLayout.findViewById(R.id.controlOut);
+        controlSwitchSpiner = controlOutLayout.findViewById(R.id.controlSwich);
+
+        motorTestLayout = inflater.inflate(R.layout.scroll_view_motor_test, null, false);
+        motorTestSpiner = motorTestLayout.findViewById(R.id.motortest);
+        setAddrLayout = inflater.inflate(R.layout.scroll_view_set_address, null, false);
+        setAddressSpiner = setAddrLayout.findViewById(R.id.setAddr);
         adapter = new ArrayAdapter<String>(this, R.layout.log_item_layout,logList);
         logListView.setAdapter(adapter);
         adapter.notifyDataSetChanged();
@@ -425,21 +474,27 @@ public class MainActivity extends AppCompatActivity {
 
             }
         });
-        final String[] xyNum = new String[]{"0","1", "2", "3", "4", "5", "6", "7", "8", "9"};
-        final String[] selectGoodsNum = new String[]{"1"};
+        final String[] selectData1 = new String[101];
+        final String[] selectData2 = new String[]{"0","1"};
+        final String[] selectData3 = new String[256];
+        final String[] selectData4 = new String[]{"0","1", "2"};
+        final String[] selectData5 = new String[32];
+        for (int i = 0; i <=100; i++) selectData1[i] = String.valueOf(i);
+        for (int i = 0; i <=255; i++) selectData3[i] = String.valueOf(i);
+        for (int i = 0; i <=31; i++) selectData5[i] = String.valueOf(i+1);
         SpAdapter spAdapter3 = new SpAdapter(this);
-        spAdapter3.setDatas(xyNum);
-        if(xSpinGoodsWay == null){
+        spAdapter3.setDatas(selectData1);
+        if(motorIndex == null){
             Logger.debug("xSpinGoodsWay");
         }
-        xSpinGoodsWay.setAdapter(spAdapter3);
-        xSpinGoodsWay.setSelection(0,true);
+        motorIndex.setAdapter(spAdapter3);
+        motorIndex.setSelection(0,true);
 
-        xSpinGoodsWay.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+        motorIndex.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                xGoosdWay = Integer.parseInt(xyNum[position]);
-                Logger.debug(">>>>>>>position %s  xGoosdWay:%s", position, xGoosdWay);
+                indexValue = Integer.parseInt(selectData1[position]);
+                Logger.debug(">>>>>>>position %s  motor Index:%s", position, indexValue);
             }
 
             @Override
@@ -448,15 +503,15 @@ public class MainActivity extends AppCompatActivity {
             }
         });
         SpAdapter spAdapter4 = new SpAdapter(this);
-        spAdapter4.setDatas(xyNum);
-        ySpinGoodsWay.setAdapter(spAdapter4);
-        ySpinGoodsWay.setSelection(0,true);
+        spAdapter4.setDatas(selectData2);
+        motorType.setAdapter(spAdapter4);
+        motorType.setSelection(0,true);
 
-        ySpinGoodsWay.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+        motorType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                yGoosdWay = Integer.parseInt(xyNum[position]);
-                Logger.debug(">>>>>>>position %s  yGoosdWay:%s", position, yGoosdWay);
+                typeValue = Integer.parseInt(selectData2[position]);
+                Logger.debug(">>>>>>>position %s  motor type:%s", position, typeValue);
             }
 
             @Override
@@ -466,14 +521,151 @@ public class MainActivity extends AppCompatActivity {
         });
 
         SpAdapter spAdapter5 = new SpAdapter(this);
-        spAdapter5.setDatas(selectGoodsNum);
-        spinGoodsNum.setAdapter(spAdapter5);
-        spinGoodsNum.setSelection(0,true);
+        spAdapter5.setDatas(selectData4);
+        lightMode.setAdapter(spAdapter5);
+        lightMode.setSelection(0,true);
+
+        lightMode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                lightValue = Integer.parseInt(selectData4[position]);
+                Logger.debug(">>>>>>>position %s  motor type:%s", position, lightValue);
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter6 = new SpAdapter(this);
+        spAdapter6.setDatas(selectData3);
+        maxCurrent.setAdapter(spAdapter6);
+        maxCurrent.setSelection(0,true);
+
+        maxCurrent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                maxCurrentValue = Integer.parseInt(selectData3[position]);
+                Logger.debug(">>>>>>>position %s  maxCurrent Value:%s", position, maxCurrentValue);
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter7 = new SpAdapter(this);
+        spAdapter7.setDatas(selectData3);
+        minCurrent.setAdapter(spAdapter7);
+        minCurrent.setSelection(0,true);
+        minCurrent.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                minCurrentValue = Integer.parseInt(selectData3[position]);
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter8 = new SpAdapter(this);
+        spAdapter8.setDatas(selectData1);
+        motorTimerOut.setAdapter(spAdapter8);
+        motorTimerOut.setSelection(0,true);
+        motorTimerOut.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                motorTimerOutValue = Integer.parseInt(selectData1[position]);
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter9 = new SpAdapter(this);
+        spAdapter9.setDatas(selectData4);
+        controlInSpiner.setAdapter(spAdapter9);
+        controlInSpiner.setSelection(0,true);
+        controlInSpiner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                controlInValue = Integer.parseInt(selectData4[position]);
+                Logger.debug(String.format(">>>>>>>position %s  control In Value:%s", position, controlInValue));
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter10 = new SpAdapter(this);
+        spAdapter10.setDatas(selectData4);
+        controlOutSpiner.setAdapter(spAdapter10);
+        controlOutSpiner.setSelection(0,true);
+        controlOutSpiner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                controlOutValue = Integer.parseInt(selectData4[position]);
+                Logger.debug(String.format(">>>>>>>position %s  control out Value:%s", position, controlOutValue));
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter11 =  new SpAdapter(this);
+        spAdapter11.setDatas(selectData2);
+        controlSwitchSpiner.setAdapter(spAdapter11);
+        controlSwitchSpiner.setSelection(0,true);
+        controlSwitchSpiner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                controlSwitchValue = Integer.parseInt(selectData2[position]);
+                Logger.debug(String.format(">>>>>>>position %s  control out Value:%s", position, controlSwitchValue));
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
+
+        SpAdapter spAdapter12 =  new SpAdapter(this);
+        spAdapter12.setDatas(selectData5);
+        setAddressSpiner.setAdapter(spAdapter12);
+        setAddressSpiner.setSelection(0,true);
+        setAddressSpiner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                setAddressValue = Integer.parseInt(selectData5[position]);
+                Logger.debug(String.format(">>>>>>>position %s  setAddress Value:%s", position, setAddressValue));
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+
+            }
+        });
 
-        spinGoodsNum.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+
+        SpAdapter spAdapter13 =  new SpAdapter(this);
+        spAdapter13.setDatas(selectData1);
+        motorTestSpiner.setAdapter(spAdapter13);
+        motorTestSpiner.setSelection(0,true);
+        motorTestSpiner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                goodsNum = Integer.parseInt(selectGoodsNum[position]);
+                motorTestValue = Integer.parseInt(selectData1[position]);
+                Logger.debug(String.format(">>>>>>>position %s  motorTest Value:%s", position, motorTestValue));
             }
 
             @Override
@@ -483,6 +675,8 @@ public class MainActivity extends AppCompatActivity {
         });
     }
 
+
+
     private void pupWindows(String mgs){
         popupPrompt.miss();
         PromptSettings.Builder builder = new PromptSettings.Builder();
@@ -498,30 +692,15 @@ public class MainActivity extends AppCompatActivity {
                 .build();
         popupPrompt.popupPrompt(window,context,inflater,promptSettings,0);
     }
-    private void selectLight(){
-        SelectSettings.Builder builder = new SelectSettings.Builder();
-        SelectSettings promptSettings =
-                        builder.selectListDataBean(selectListDataBeans)
-                                .clickListener(selectBackListener)
-                                .titleTextStr("光幕控制")
-                                .titleTextPaddings(new int[]{10,20,0,20})
-                                .showTitleIcon(true)
-                                .popupWidth(500)
-                                .popupHeight(300)
-                                .multipleSelection(false)
-                                .showListIcon(true)
-                                .build();
-        popupSelect.popupSelect(window,context,inflater,promptSettings,0);
-    }
 
-    private void setOutGoodsInfo(){
+    private void selectMotorStartInfo(){
         ViewSettings.Builder builder = new ViewSettings.Builder();
         ViewSettings promptSettings =
-                builder .clickListener(popupBackListener)
-                        .titleTextStr("设置出货信息")
+                builder .clickListener(popupStartMotorListener)
+                        .titleTextStr("电机启动")
                         .titleTextPaddings(new int[]{10,20,0,20})
                         .showTitleIcon(true)
-                        .popupWidth(500)
+                        .popupWidth(700)
                         .popupHeight(300)
                         .build();
         if(linearLayout.getParent()!=null){
@@ -530,14 +709,91 @@ public class MainActivity extends AppCompatActivity {
         popupView.popupView(window,context,inflater,linearLayout,promptSettings,3);
     }
 
-    PopupView.onClickListener popupBackListener = new PopupView.onClickListener() {
+    private void selectControlIn(){
+        ViewSettings.Builder builder = new ViewSettings.Builder();
+        ViewSettings promptSettings =
+                builder .clickListener(popupControlInListener)
+                        .titleTextStr("开关量输入")
+                        .titleTextPaddings(new int[]{10,20,0,20})
+                        .showTitleIcon(true)
+                        .popupWidth(500)
+                        .popupHeight(300)
+                        .build();
+        if(controlInLayout.getParent()!=null){
+            ((ViewGroup) controlInLayout.getParent()).removeView(controlInLayout);
+        }
+        popupView.popupView(window,context,inflater, controlInLayout,promptSettings,3);
+    }
+
+
+    private void selectControlOut(){
+        ViewSettings.Builder builder = new ViewSettings.Builder();
+        ViewSettings promptSettings =
+                builder .clickListener(popupControlOutListener)
+                        .titleTextStr("开关量输出")
+                        .titleTextPaddings(new int[]{10,20,0,20})
+                        .showTitleIcon(true)
+                        .popupWidth(500)
+                        .popupHeight(300)
+                        .build();
+        if(controlOutLayout.getParent()!=null){
+            ((ViewGroup) controlOutLayout.getParent()).removeView(controlOutLayout);
+        }
+        popupView.popupView(window,context,inflater, controlOutLayout,promptSettings,3);
+    }
+
+    private void selectAddress(){
+        ViewSettings.Builder builder = new ViewSettings.Builder();
+        ViewSettings promptSettings =
+                builder .clickListener(popupSetAddrListener)
+                        .titleTextStr("地址:")
+                        .titleTextPaddings(new int[]{10,20,0,20})
+                        .showTitleIcon(true)
+                        .popupWidth(500)
+                        .popupHeight(300)
+                        .build();
+        if(setAddrLayout.getParent()!=null){
+            ((ViewGroup) setAddrLayout.getParent()).removeView(setAddrLayout);
+        }
+        popupView.popupView(window,context,inflater, setAddrLayout,promptSettings,3);
+    }
+
+
+    private void selectMotorIndex(){
+        ViewSettings.Builder builder = new ViewSettings.Builder();
+        ViewSettings promptSettings =
+                builder .clickListener(popupMotorTestListener)
+                        .titleTextStr("电机索引号:")
+                        .titleTextPaddings(new int[]{10,20,0,20})
+                        .showTitleIcon(true)
+                        .popupWidth(500)
+                        .popupHeight(300)
+                        .build();
+        if(motorTestLayout.getParent()!=null){
+            ((ViewGroup) motorTestLayout.getParent()).removeView(motorTestLayout);
+        }
+        popupView.popupView(window,context,inflater, motorTestLayout,promptSettings,3);
+    }
+
+    PopupView.onClickListener popupStartMotorListener = new PopupView.onClickListener() {
 
         @Override
         public void onYesBack(int what) {
-            pupWindows("X货道:"+xGoosdWay +" Y货道:"+yGoosdWay +" 数量:"+goodsNum);
-            showLog("X货道:"+xGoosdWay +" Y货道:"+yGoosdWay +""+" 数量:"+goodsNum);
+            showLog("电机编号:"+indexValue);
+            showLog("电机类型:"+typeValue);
+            showLog("光幕模式:"+lightValue);
+            showLog("过流阈值:"+maxCurrentValue);
+            showLog("欠流阈值:"+minCurrentValue);
+            showLog("超时时间:"+motorTimerOutValue);
             if(commTask != null){
-                commTask.saleGoods((byte) xGoosdWay,  (byte) yGoosdWay, (byte) 1);
+                MotorStart motorStart = new MotorStart();
+                motorStart.setMotorIndex(indexValue);
+                motorStart.setMotorType(typeValue);
+                motorStart.setLightMode(lightValue);
+                motorStart.setCurrentMax(maxCurrentValue);
+                motorStart.setCurrentMin(minCurrentValue);
+                motorStart.setMotorTime(motorTimerOutValue);
+                commTask.startMotor(motorStart);
             }else {
                 pupWindows("请打开串口!");
             }
@@ -550,34 +806,79 @@ public class MainActivity extends AppCompatActivity {
         }
     };
 
-    PopupSelect.onClickListener selectBackListener = new PopupSelect.onClickListener() {
+    PopupView.onClickListener popupControlOutListener = new PopupView.onClickListener() {
+
         @Override
-        public void onChooseBack(List<SelectListDataBean> selectListDataBeans, int what) {
-            int choosed = -1;
-            for(int i = 0;i<selectListDataBeans.size();i++){
-                if(selectListDataBeans.get(i).isChoosed()){
-                    choosedLight = i;
-                    Logger.debug("choosed:"+choosedLight);
-                }
+        public void onYesBack(int what) {
+            showLog("开关量输出:"+ controlOutValue + " 开关:"+ controlSwitchValue);
+            if(commTask != null){
+                commTask.controlOut(controlOutValue, controlSwitchValue);
+            }else {
+                pupWindows("请打开串口!");
             }
-            Logger.debug("what:"+what);
-            if(what == 0){
-                if(choosedLight >= 0) {
-                    if(commTask == null){
-                        pupWindows("请打开串口!");
-                    }else {
-                        if (commTask.isopen) {
-                            commTask.controlLight((byte) choosedLight);
-                        }
-                    }
-                }
+
+        }
+
+        @Override
+        public void onCancelBack(int what) {
+            pupWindows("pupWindows"+what+"取消按钮");
+        }
+    };
+
+    PopupView.onClickListener popupControlInListener = new PopupView.onClickListener() {
+
+        @Override
+        public void onYesBack(int what) {
+            showLog("开关量输入:"+ controlInValue);
+            if(commTask != null){
+                commTask.controlIn(controlInValue);
+            }else {
+                pupWindows("请打开串口!");
+            }
+
+        }
+
+        @Override
+        public void onCancelBack(int what) {
+            pupWindows("pupWindows"+what+"取消按钮");
+        }
+    };
+
+    PopupView.onClickListener popupSetAddrListener = new PopupView.onClickListener() {
+
+        @Override
+        public void onYesBack(int what) {
+            showLog("设置设备地址:"+ setAddressValue);
+            if(commTask != null){
+                commTask.setAddress(setAddressValue);
+            }else {
+                pupWindows("请打开串口!");
             }
 
         }
 
         @Override
-        public void onCancelBack(List<SelectListDataBean> selectListDataBeans, int what) {
+        public void onCancelBack(int what) {
+            pupWindows("pupWindows"+what+"取消按钮");
+        }
+    };
+
+    PopupView.onClickListener popupMotorTestListener = new PopupView.onClickListener() {
+
+        @Override
+        public void onYesBack(int what) {
+            showLog("开始测试 电机:"+ motorTestValue);
+            if(commTask != null){
+                commTask.testMotor(motorTestValue);
+            }else {
+                pupWindows("请打开串口!");
+            }
+
+        }
 
+        @Override
+        public void onCancelBack(int what) {
+            pupWindows("pupWindows"+what+"取消按钮");
         }
     };
 

+ 37 - 0
app/src/main/java/com/ifastore/goodsmanage/models/DeviceResult.java

@@ -0,0 +1,37 @@
+package com.ifastore.goodsmanage.models;
+
+import java.io.Serializable;
+
+public class DeviceResult implements Serializable {
+    private int result;
+    private int index;
+    private int value;
+
+    public DeviceResult() {
+
+    }
+
+    public int getResult() {
+        return result;
+    }
+
+    public void setResult(int result) {
+        this.result = result;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public int getIndex() {
+        return index;
+    }
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
+}

+ 59 - 0
app/src/main/java/com/ifastore/goodsmanage/models/MotorStart.java

@@ -0,0 +1,59 @@
+package com.ifastore.goodsmanage.models;
+
+public class MotorStart {
+    private int motorIndex;
+    private int motorType;
+    private int lightMode;
+    private int currentMax;
+    private int currentMin;
+    private int motorTime;
+
+
+    public int getMotorIndex() {
+        return motorIndex;
+    }
+
+    public void setMotorIndex(int motorIndex) {
+        this.motorIndex = motorIndex;
+    }
+
+    public int getMotorType() {
+        return motorType;
+    }
+
+    public void setMotorType(int motorType) {
+        this.motorType = motorType;
+    }
+
+    public int getLightMode() {
+        return lightMode;
+    }
+
+    public void setLightMode(int lightMode) {
+        this.lightMode = lightMode;
+    }
+
+    public int getCurrentMax() {
+        return currentMax;
+    }
+
+    public void setCurrentMax(int currentMax) {
+        this.currentMax = currentMax;
+    }
+
+    public int getCurrentMin() {
+        return currentMin;
+    }
+
+    public void setCurrentMin(int currentMin) {
+        this.currentMin = currentMin;
+    }
+
+    public int getMotorTime() {
+        return motorTime;
+    }
+
+    public void setMotorTime(int motorTime) {
+        this.motorTime = motorTime;
+    }
+}

+ 70 - 0
app/src/main/java/com/ifastore/goodsmanage/models/MotorStatus.java

@@ -0,0 +1,70 @@
+package com.ifastore.goodsmanage.models;
+
+import java.io.Serializable;
+
+public class MotorStatus implements Serializable {
+    private int status;
+    private int serialNum;
+    private int result;
+    private int peakCurrent;
+    private int averageCurrent;
+    private int runTime;
+    private int lightStatus;
+
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
+    public int getSerialNum() {
+        return serialNum;
+    }
+
+    public void setSerialNum(int serialNum) {
+        this.serialNum = serialNum;
+    }
+
+    public int getResult() {
+        return result;
+    }
+
+    public void setResult(int result) {
+        this.result = result;
+    }
+
+    public int getPeakCurrent() {
+        return peakCurrent;
+    }
+
+    public void setPeakCurrent(int peakCurrent) {
+        this.peakCurrent = peakCurrent;
+    }
+
+    public int getAverageCurrent() {
+        return averageCurrent;
+    }
+
+    public void setAverageCurrent(int averageCurrent) {
+        this.averageCurrent = averageCurrent;
+    }
+
+    public int getRunTime() {
+        return runTime;
+    }
+
+    public void setRunTime(int runTime) {
+        this.runTime = runTime;
+    }
+
+    public int getLightStatus() {
+        return lightStatus;
+    }
+
+    public void setLightStatus(int lightStatus) {
+        this.lightStatus = lightStatus;
+    }
+}

+ 28 - 12
app/src/main/java/com/ifastore/goodsmanage/serialport/CommSerial.java

@@ -461,33 +461,49 @@ public class CommSerial {
         new Thread(new Runnable() {
             @Override
             public void run() {
-                int cmd = Constant.CMD_CONTROL_SALE;
-                byte[]data = new byte[]{0x1, 0x02, 0x03};
-               /*testRecvFrame(1, cmd, data);
+                int cmd = Constant.CMD_READ_IN;
+                byte[]data = new byte[]{0x00, 0x01};
+               testRecvFrame(1, cmd, data);
                 try {
-                    Thread.sleep(2000);
+                    Thread.sleep(1000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
-                cmd = Constant.CMD_EVENT_MOTOR;
-                data = new byte[]{0x1};
-                testRecvFrame(0, cmd, data);
+                cmd = Constant.CMD_QUERY_SERIAL;
+                data = new byte[]{0x21};
+                testRecvFrame(1, cmd, data);
                 try {
                     Thread.sleep(2000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
-                cmd = Constant.CMD_EVENT_SALE;
-                data = new byte[]{0x00};
-                testRecvFrame(0, cmd, data);
+                cmd = Constant.CMD_QUERY_ADDR;
+                data = new byte[]{0x00, 0x02};
+                testRecvFrame(1, cmd, data);
                 try {
                     Thread.sleep(2000);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
-                }*/
-                cmd = Constant.CMD_CONTROL_LIGHT;
+                }
+                cmd = Constant.CMD_WRITE_OUT;
+                data = new byte[]{0x01,0x00};
+                testRecvFrame(1, cmd, data);
+
+                cmd = Constant.CMD_MOTO_TEST;
+                data = new byte[]{0x01};
+                testRecvFrame(1, cmd, data);
+
+                cmd = Constant.CMD_SET_ADDR;
+                data = new byte[]{0x00, 0x11};
+                testRecvFrame(1, cmd, data);
+
+                cmd = Constant.CMD_MOTO_RUN;
                 data = new byte[]{0x00};
                 testRecvFrame(1, cmd, data);
+
+                cmd = Constant.CMD_QUERY_STATUS;
+                data = new byte[]{0x00, 0x01, 0x00, 0x00, 0x10, 0x10, 0x00, 0x0f, 0x00, 0x01};
+                testRecvFrame(1, cmd, data);
             }
         }).start();
     }

+ 95 - 17
app/src/main/java/com/ifastore/goodsmanage/serialport/CommTask.java

@@ -5,12 +5,15 @@ import android.content.Context;
 import android.content.Intent;
 import android.icu.text.SimpleDateFormat;
 
-import com.ifastore.goodsmanage.serialport.protocol.Constant;
+import com.ifastore.goodsmanage.models.DeviceResult;
+import com.ifastore.goodsmanage.models.MotorStart;
+import com.ifastore.goodsmanage.models.MotorStatus;
 import com.ifastore.goodsmanage.utils.Logger;
 import com.ifastore.goodsmanage.utils.TypeConverter;
 import com.reduxsolutions.serialport.drivers.SerialPort;
 import java.io.File;
 import java.io.IOException;
+import java.io.Serializable;
 import java.util.Date;
 
 import static com.ifastore.goodsmanage.common.Constants.CONTROL_IN;
@@ -69,38 +72,32 @@ public class CommTask{
             @Override
             public void onResponseEvent(byte[] value, CommSerial.ProtocolCMDEnum cmd) {
                 switch (cmd){
-                    case ControlSale:
-                        resultSaleGoods(RESULT_CONTROL_SALE, value);
-                        break;
-                    case ControlLight:
-                        resultLight(RESULT_CONTROL_LIGHT, value);
-                        break;
                     case SetAddress:
-                        resultLight(SET_DEVICE_ADDR, value);
+                        resultDevice(SET_DEVICE_ADDR, value);
                         break;
                     case QueryAddress:
-                        resultLight(QUERY_DEVICE_ADDR, value);
+                        resultDevice(QUERY_DEVICE_ADDR, value);
                         break;
                     case QuerySerial:
-                        resultLight(QUERY_DEVICE_SERIAL, value);
+                        resultDevice(QUERY_DEVICE_SERIAL, value);
                         break;
                     case QueryStatus:
-                        resultLight(QUERY_MOTOR_STATUS, value);
+                        resultQueryStatus(QUERY_MOTOR_STATUS, value);
                         break;
                     case MotoTest:
-                        resultLight(MOTOR_TEST, value);
+                        resultDevice(MOTOR_TEST, value);
                         break;
                     case MotoStart:
-                        resultLight(MOTOR_START, value);
+                        resultDevice(MOTOR_START, value);
                         break;
                     case QueryTemp:
-                        resultLight(QUERY_TEMP, value);
+                        resultQueryTemp(QUERY_TEMP, value);
                         break;
                     case ControlWriteOut:
-                        resultLight(CONTROL_OUT, value);
+                        controlSwitch(CONTROL_OUT, value);
                         break;
                     case ControlReadIn:
-                        resultLight(CONTROL_IN, value);
+                        controlSwitch(CONTROL_IN, value);
                         break;
                 }
             }
@@ -172,8 +169,23 @@ public class CommTask{
         }
     }
 
-    public void startMotor(byte[]data) {
+    /*
+    * 电机索引号      00~100
+    * 电机类型        0 = 两线制电机,1= 三线制电机
+    * 光幕工作模式    0 = 电机运转不参考光幕,1= 启动电机前,需光幕自检成功;电机到位后停止,2 = 启动电机前,需光幕自检成功;当光幕检测到掉货后电机立即停止,未检测到掉货时电机,一直运转直到超时
+    * 电机过流阈值    1-255 代表10mA-2550mA。0表示默认值()
+    * 电机欠流阈值    1-255 代表10mA-2550mA。0表示默认值()
+    * 电机到位超时时间 1-100 代表0.1S – 10.0S,0表示默认值(7秒)
+    * */
+    public void startMotor(MotorStart motorStart) {
         if(commTask.isopen){
+            byte[]data = new byte[6];
+            data[0] = (byte) motorStart.getMotorIndex();
+            data[1] = (byte) motorStart.getMotorType();
+            data[2] = (byte) motorStart.getLightMode();
+            data[3] = (byte) motorStart.getCurrentMax();
+            data[4] = (byte) motorStart.getCurrentMin();
+            data[5] = (byte) motorStart.getMotorTime();
             commSerial.startMotor(data);
         }
     }
@@ -254,6 +266,72 @@ public class CommTask{
         context.sendBroadcast(intent);
     }
 
+
+    private void resultDevice(String action, byte[] result){
+        if(result.length==0) return;
+        DeviceResult deviceResult = new DeviceResult();
+        deviceResult.setResult(result[0]);
+        if(result.length==2) deviceResult.setValue(result[1]);
+        Intent intent = new Intent(action);
+        intent.putExtra(action,  deviceResult);
+        context.sendBroadcast(intent);
+    }
+
+    private void resultQueryTemp(String action, byte[] result){
+        try {
+            float temp;
+            if(result.length == 2){
+                temp = 0;
+                temp += result[0] & 0x000000FF;
+                temp += (result[1] << 8) & 0x0000FF00;
+               /* temp += (result[2] << 16) & 0x00FF0000;
+                temp += (result[3] << 24) & 0xFF000000;*/
+            }else {
+                temp = 999;
+            }
+            Intent intent = new Intent(action);
+            intent.putExtra(action, temp);
+            context.sendBroadcast(intent);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void controlSwitch(String action, byte[] result){
+        if(result.length==0) return;
+        DeviceResult deviceResult = new DeviceResult();
+        deviceResult.setIndex(result[0]);
+        deviceResult.setResult(result[1]);
+        Intent intent = new Intent(action);
+        intent.putExtra(action,  deviceResult);
+        context.sendBroadcast(intent);
+    }
+
+
+    private void resultQueryStatus(String action, byte[] result){
+        int peakCurrent = 0, averageCurrent= 0, runTime = 0;
+        if(result.length==0) return;
+        MotorStatus motorStatus = new MotorStatus();
+        motorStatus.setStatus(result[0]);
+        motorStatus.setSerialNum(result[1]);
+        motorStatus.setResult(result[2]);
+        peakCurrent += result[3];
+        peakCurrent += (result[4] << 8) & 0xff00;
+        averageCurrent += result[5];
+        averageCurrent += (result[6] << 8) & 0xff00;
+        runTime += result[7];
+        runTime += (result[8] << 8) & 0xff00;
+        motorStatus.setPeakCurrent(peakCurrent);
+        motorStatus.setAverageCurrent(averageCurrent);
+        motorStatus.setRunTime(runTime);
+        motorStatus.setLightStatus(result[9]);
+        Intent intent = new Intent(action);
+        intent.putExtra(action, (Serializable) motorStatus);
+        context.sendBroadcast(intent);
+    }
+
+
     public interface ISerialEventListener {
         void transferDataSend(String data);
         void transferDataRecv(String data);

+ 1 - 1
app/src/main/res/drawable/bg_account_shape.xml

@@ -3,7 +3,7 @@
 	>
     <corners android:radius="10dp"/>
 	<stroke android:width="5dp" android:color="@color/theme_secondary_text_inverted"/>
-	<solid android:color="@color/white"/>
+	<solid android:color="@color/github_con_0"/>
 	<padding
 		android:right="5dp"
 		android:left="5dp"

+ 45 - 0
app/src/main/res/layout-land/scroll_view_control_in.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="开关量输入:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/controlIn"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 26 - 26
app/src/main/res/layout-land/scrollviewtest.xml → app/src/main/res/layout-land/scroll_view_control_out.xml

@@ -2,15 +2,21 @@
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/text_linear"
+    android:id="@+id/text_linear1"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
     tools:ignore="MissingDefaultResource">
     <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
         <LinearLayout
+            android:id="@+id/line1"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="center"
@@ -19,44 +25,38 @@
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textSize="24sp"
-                android:text="X货道:"
-                >
-            </TextView>
-            <Spinner
-                android:id="@+id/xNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
-                android:layout_gravity="center"
-                android:background="@drawable/bg_spin_goods" />
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="24sp"
-                android:text="Y货道:"
+                android:text="开关量输出:"
                 >
             </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
             <Spinner
-                android:id="@+id/yNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
+                android:id="@+id/controlOut"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
                 android:layout_gravity="center"
                 android:background="@drawable/bg_spin_goods" />
             <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textSize="24sp"
-                android:text="数量:"
+                android:text="开关:"
                 >
             </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
             <Spinner
-                android:id="@+id/goodsNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
+                android:id="@+id/controlSwich"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
                 android:layout_gravity="center"
                 android:background="@drawable/bg_spin_goods" />
-        </LinearLayout>
-
+            </LinearLayout>
+        </RelativeLayout>
     </ScrollView>
 
-
 </LinearLayout>

+ 142 - 0
app/src/main/res/layout-land/scroll_view_motor_start.xml

@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="电机索引"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/indexSpiner"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="电机类型"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/motorTypeSpiner"
+                android:layout_width="80dp"
+                android:layout_height="40dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="光幕模式"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/lightSpiner"
+                android:layout_width="80dp"
+                android:layout_height="40dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/line2"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/line1"
+            android:layout_marginTop="30dp"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="过流阈值"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/maxCurrentSpiner"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="欠流阈值"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/minCurrentSpiner"
+                android:layout_width="80dp"
+                android:layout_height="40dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="超时时间"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/timerOutSpiner"
+                android:layout_width="80dp"
+                android:layout_height="40dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+        </LinearLayout>
+        </RelativeLayout>
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-land/scroll_view_motor_test.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="电机测试:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/motortest"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-land/scroll_view_set_address.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/white"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="设备地址:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/setAddr"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-port/scroll_view_control_in.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="开关量输入:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/controlIn"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-port/scroll_view_control_out.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <LinearLayout
+                android:id="@+id/line1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:orientation="horizontal">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="开关量输出:"
+                    >
+                </TextView>
+                <View
+                    android:layout_width="10dp"
+                    android:layout_height="wrap_content">
+                </View>
+                <Spinner
+                    android:id="@+id/controlOut"
+                    android:layout_width="68dp"
+                    android:layout_height="50dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 120 - 0
app/src/main/res/layout-port/scroll_view_motor_start.xml

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content">
+            <LinearLayout
+                android:id="@+id/line1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:orientation="horizontal">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="电机索引"
+                    >
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/indexSpiner"
+                    android:layout_width="68dp"
+                    android:layout_height="50dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="电机类型"
+                    >
+                </TextView>
+                <Spinner
+                    android:id="@+id/motorTypeSpiner"
+                    android:layout_width="80dp"
+                    android:layout_height="40dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="光幕模式"
+                    >
+                </TextView>
+                <Spinner
+                    android:id="@+id/lightSpiner"
+                    android:layout_width="80dp"
+                    android:layout_height="40dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/line2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@+id/line1"
+                android:layout_marginTop="30dp"
+                android:gravity="center"
+                android:orientation="horizontal">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="过流阈值"
+                    >
+                </TextView>
+
+                <Spinner
+                    android:id="@+id/maxCurrentSpiner"
+                    android:layout_width="68dp"
+                    android:layout_height="50dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="欠流阈值"
+                    >
+                </TextView>
+                <Spinner
+                    android:id="@+id/minCurrentSpiner"
+                    android:layout_width="80dp"
+                    android:layout_height="40dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="24sp"
+                    android:text="超时时间"
+                    >
+                </TextView>
+                <Spinner
+                    android:id="@+id/timerOut"
+                    android:layout_width="80dp"
+                    android:layout_height="40dp"
+                    android:layout_gravity="center"
+                    android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-port/scroll_view_motor_test.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="电机测试:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/motortest"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 45 - 0
app/src/main/res/layout-port/scroll_view_set_address.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/text_linear1"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    tools:ignore="MissingDefaultResource">
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@color/zhihu_lay_click"
+        >
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+        <LinearLayout
+            android:id="@+id/line1"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:orientation="horizontal">
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textSize="24sp"
+                android:text="设备地址:"
+                >
+            </TextView>
+            <View
+                android:layout_width="10dp"
+                android:layout_height="wrap_content">
+            </View>
+            <Spinner
+                android:id="@+id/setAddr"
+                android:layout_width="68dp"
+                android:layout_height="50dp"
+                android:layout_gravity="center"
+                android:background="@drawable/bg_spin_goods" />
+            </LinearLayout>
+        </RelativeLayout>
+    </ScrollView>
+
+</LinearLayout>

+ 0 - 62
app/src/main/res/layout-port/scrollviewtest.xml

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/text_linear"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    tools:ignore="MissingDefaultResource">
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="center"
-            android:orientation="horizontal">
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="24sp"
-                android:text="X货道:"
-                >
-            </TextView>
-            <Spinner
-                android:id="@+id/xNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
-                android:layout_gravity="center"
-                android:background="@drawable/bg_spin_goods" />
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="24sp"
-                android:text="Y货道:"
-                >
-            </TextView>
-            <Spinner
-                android:id="@+id/yNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
-                android:layout_gravity="center"
-                android:background="@drawable/bg_spin_goods" />
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="24sp"
-                android:text="数量:"
-                >
-            </TextView>
-            <Spinner
-                android:id="@+id/goodsNum"
-                android:layout_width="80dp"
-                android:layout_height="40dp"
-                android:layout_gravity="center"
-                android:background="@drawable/bg_spin_goods" />
-        </LinearLayout>
-
-    </ScrollView>
-
-
-</LinearLayout>