Browse Source

011D ,模式运行不可调参数

zhangshenjie 1 month ago
parent
commit
0f9413545f
1 changed files with 45 additions and 38 deletions
  1. 45 38
      BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

+ 45 - 38
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -55,7 +55,7 @@ public class TuyaUtilsSo {
     private static Map<Integer, Integer> map;
     public boolean isUser = false;  //避免重复上报问题
 
-    private  int codeTime = -1;
+    private int codeTime = -1;
 
 
     private int remain_time = -1;
@@ -189,7 +189,7 @@ public class TuyaUtilsSo {
                     //启动/停止
                     String str = boolValue == 1 ? "start" : "stop";
                     tuyaEvent(str);
-                    if (str.equals("start")){
+                    if (str.equals("start")) {
                         startDevInfo(0);
                     }
                     break;
@@ -252,7 +252,7 @@ public class TuyaUtilsSo {
                         aa = "start";
                     }
                     tuyaEvent(aa);
-                    if (aa.equals("start")){
+                    if (aa.equals("start")) {
                         startDevInfo(1);
                     }
 //                    if (aa.equals("pause")){
@@ -277,18 +277,17 @@ public class TuyaUtilsSo {
                     DevInfo infoTimes = CofarSDK.devInfo();
                     BaseDevMode modesTimes = infoTimes.getMode();
                     if (modesTimes.isTimeChange()
-                            &&AppActivityManager.getInstance().getTopActivity()
+                            && AppActivityManager.getInstance().getTopActivity()
                             .getLocalClassName().contains("ModesDetailActivity")
-                            &&infoTimes.getStatus()==2) {
+                            && infoTimes.getStatus() == 2) {
                         //烹饪时间
-                        tuyaEventTime("remain_time",(int) intValue);
+                        tuyaEventTime("remain_time", (int) intValue);
                     }
 
 
                     break;
 
 
-
                 case TuyaSoDp.WEIGHT:
                     //称重功能
                     break;
@@ -351,7 +350,7 @@ public class TuyaUtilsSo {
         EventBus.getDefault().post(tuya);
     }
 
-    private void tuyaEventTime(String type,int time) {
+    private void tuyaEventTime(String type, int time) {
         TuyaEvent tuya = new TuyaEvent();
         tuya.setTime(time);
         tuya.setType(type);
@@ -571,10 +570,20 @@ public class TuyaUtilsSo {
                 int motorDirectionChange = 1;
                 if (mode == null) {
                 } else {
-                    timeChange = mode.isTimeChange() ? 1 : 0;
-                    tempChange = mode.isTempChange() ? 1 : 0;
-                    motorGearChange = mode.isMotorGearChange() ? 1 : 0;
-                    motorDirectionChange = mode.isMotorDirectionChange() ? 1 : 0;
+                    //getStatus    0 stop  1 start  2 pause
+                    //正在运行的时候给app那边下发不可修改状态
+                    //其他就按照本来是否可以改的值去走
+                    if (status == 1) {
+                        timeChange = 0;
+                        tempChange = 0;
+                        motorGearChange = 0;
+                        motorDirectionChange = 0;
+                    } else {
+                        timeChange = mode.isTimeChange() ? 1 : 0;
+                        tempChange = mode.isTempChange() ? 1 : 0;
+                        motorGearChange = mode.isMotorGearChange() ? 1 : 0;
+                        motorDirectionChange = mode.isMotorDirectionChange() ? 1 : 0;
+                    }
                 }
 
 
@@ -650,8 +659,6 @@ public class TuyaUtilsSo {
                 }
 
 
-
-
             }
         }).start();
 //        ioTSDKManager.sendDP(dpEvents);
@@ -661,7 +668,6 @@ public class TuyaUtilsSo {
     private int getModes(String enumValue) {
 
 
-
 //        if (autoMaticType != -1) {
 //            return autoMaticType;
 //        }
@@ -673,7 +679,7 @@ public class TuyaUtilsSo {
          * 17 食谱运行模式(Recipes_mode)
          * */
 
-        if (enumValue.contains(":")){
+        if (enumValue.contains(":")) {
             return 17;
         }
 
@@ -851,7 +857,7 @@ public class TuyaUtilsSo {
             }
         }
         //如果是滑动时间得时候,需要上报暂停数据
-        if (dpid==TuyaSoDp.COOKING_TIME&&CofarSDK.devInfo().getStatus()==2){
+        if (dpid == TuyaSoDp.COOKING_TIME && CofarSDK.devInfo().getStatus() == 2) {
             pauseDpTime(time_stamp);
             return;
         }
@@ -880,27 +886,28 @@ public class TuyaUtilsSo {
         }
     }
 
-    public  void  pauseDpTime(int time_stamp){
+    public void pauseDpTime(int time_stamp) {
         DevInfo info = CofarSDK.devInfo();
         int time = info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime();
-        if (remain_time == time){
+        if (remain_time == time) {
             return;
         }
         //由于app处理问题,特殊处理在当前模式页面而且暂停得时候,烹饪时间给剩余时间,剩余时间给烹饪时间
         if (info.getMode().isTimeChange()
-                &&AppActivityManager.getInstance().getTopActivity()
+                && AppActivityManager.getInstance().getTopActivity()
                 .getLocalClassName().contains("ModesDetailActivity")
-                &&info.getStatus()==2){
+                && info.getStatus() == 2) {
             remain_time = info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime();
-             int code = getTuyaApi().send_dp_value(TuyaSoDp.COOKING_TIME,  info.getRemainTime(), time_stamp);
-             codeTime = getTuyaApi().send_dp_value(TuyaSoDp.REMAINING_TIME, remain_time, time_stamp);
-             if (codeTime!=0){
-                 remain_time=-1;
-             }
+            int code = getTuyaApi().send_dp_value(TuyaSoDp.COOKING_TIME, info.getRemainTime(), time_stamp);
+            codeTime = getTuyaApi().send_dp_value(TuyaSoDp.REMAINING_TIME, remain_time, time_stamp);
+            if (codeTime != 0) {
+                remain_time = -1;
+            }
 
         }
 
     }
+
     public void setDpCurrentActivity() {
         int time = (int) System.currentTimeMillis();
         Timer timer = new Timer();
@@ -916,7 +923,7 @@ public class TuyaUtilsSo {
 
     }
 
-    public void  startDevInfo(int type){
+    public void startDevInfo(int type) {
         //因为下发了start ,需要延迟几秒后判断设备是否正常start
         //0 stop  1 start  2 pause
         Timer timer = new Timer();
@@ -926,13 +933,13 @@ public class TuyaUtilsSo {
             public void run() {
                 //加入你在延时之后要做的事
                 DevInfo info = CofarSDK.devInfo();
-                Log.e("TAG startDevInfo","startDevInfostartDevInfostartDevInfo");
-                if (type==0){
-                    if (info.getStatus()==0){
+                Log.e("TAG startDevInfo", "startDevInfostartDevInfostartDevInfo");
+                if (type == 0) {
+                    if (info.getStatus() == 0) {
                         setDpStop();
                     }
-                }else {
-                    if (info.getStatus()==2){
+                } else {
+                    if (info.getStatus() == 2) {
                         setDpPause();
                     }
                 }
@@ -942,7 +949,7 @@ public class TuyaUtilsSo {
         timer.schedule(task, 2500); //task为你想要延时执行的事件,2000为延时2000毫秒
     }
 
-    public void  pauseDevInfo(){
+    public void pauseDevInfo() {
         //因为下发了pause ,需要延迟0.5秒后上报暂停数据
 
         /**
@@ -955,7 +962,7 @@ public class TuyaUtilsSo {
             public void run() {
                 //加入你在延时之后要做的事
                 DevInfo info = CofarSDK.devInfo();
-                Log.e("TAG startDevInfo","startDevInfostartDevInfostartDevInfo");
+                Log.e("TAG startDevInfo", "startDevInfostartDevInfostartDevInfo");
                 setDpRemainTime(info.getRemainTime());
             }
         };
@@ -963,7 +970,7 @@ public class TuyaUtilsSo {
         timer.schedule(task, 1000); //task为你想要延时执行的事件,2000为延时2000毫秒
     }
 
-    public void setDpRemainTime(int value){
+    public void setDpRemainTime(int value) {
         //由于app 下发了start指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个stop
         int time = (int) System.currentTimeMillis();
         int code = getTuyaApi().send_dp_value(TuyaSoDp.REMAINING_TIME, value, time);
@@ -972,14 +979,14 @@ public class TuyaUtilsSo {
     }
 
 
-    public void setDpStop(){
+    public void setDpStop() {
         //由于app 下发了start指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个stop
         int time = (int) System.currentTimeMillis();
         int code = getTuyaApi().send_dp_bool(TuyaSoDp.START_STOP, 0, time);
 
     }
 
-    public void setDpPause(){
+    public void setDpPause() {
         //由于app 下发了Pause指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个Pause
         int time = (int) System.currentTimeMillis();
         int code = getTuyaApi().send_dp_bool(TuyaSoDp.PAUSE, 1, time);
@@ -1070,4 +1077,4 @@ public class TuyaUtilsSo {
     }
 
 
-    }
+}