Browse Source

处理涂鸦暂停时间问题

zhangshenjie 2 months ago
parent
commit
bfeafd2c9a

+ 2 - 1
BusinessCommon/src/main/java/com/develop/common/utils/TuyaSoDp.java

@@ -8,7 +8,7 @@ public class TuyaSoDp {
     public static final int COOKING_TEMPERATURE = 6; //烹饪温度
     public static final int CURRENT_TEMPERATURE = 7; //当前温度  (只上报)
     public static final int COOKING_TIME = 10; //烹饪时间
-    public static final int REMAINING_TIME = 11; //剩余时间  (只上报)
+//    public static final int REMAINING_TIME = 11; //剩余时间  (只上报)
     public static final int STEP_EXECUTION = 12; //多步骤执行
     public static final int FAULT_WARNING = 13; //故障警告  (只上报)
     public static final int PAUSE = 18; //暂停
@@ -21,6 +21,7 @@ public class TuyaSoDp {
     public static final int WEIGHT_CLEAR = 105; //称重清零
     public static final int POT_STATUS = 106;//锅状态  (只上报)
     public static final int WEIGHT_NUMBER = 107; //称重数据  (只上报)
+    public static final int REMAINING_TIME = 108; //剩余时间  (只上报可下发)
     public static final int DEV_READY = 110; //机器是否准备就绪
     public static final int POT_CLOVER_STATUS = 111; //开盖状态  (只上报)
     public static final int DEVICE_FUNCTION_MODE = 114; //设备功能模式

+ 91 - 10
BusinessCommon/src/main/java/com/develop/common/utils/TuyaUtilsSo.java

@@ -55,6 +55,10 @@ public class TuyaUtilsSo {
     private static Map<Integer, Integer> map;
     public boolean isUser = false;  //避免重复上报问题
 
+    private  int codeTime = -1;
+
+
+    private int remain_time = -1;
 
     public static TuyaUtilsSo getInstance() {
         if (singleton == null) {
@@ -250,6 +254,10 @@ public class TuyaUtilsSo {
                     if (aa.equals("start")){
                         startDevInfo(1);
                     }
+//                    if (aa.equals("pause")){
+//                        pauseDevInfo();
+//                    }
+
                     break;
                 case TuyaSoDp.COOKING_TIME:
                     isUser = true;
@@ -260,9 +268,26 @@ public class TuyaUtilsSo {
                         CofarSDK.cfgTime((int) intValue);
                         tuyaEvent("change_time");
                     }
+                    break;
+
+
+                case TuyaSoDp.REMAINING_TIME:
+                    isUser = true;
+                    DevInfo infoTimes = CofarSDK.devInfo();
+                    BaseDevMode modesTimes = infoTimes.getMode();
+                    if (modesTimes.isTimeChange()
+                            &&AppActivityManager.getInstance().getTopActivity()
+                            .getLocalClassName().contains("ModesDetailActivity")
+                            &&infoTimes.getStatus()==2) {
+                        //烹饪时间
+                        tuyaEventTime("remain_time",(int) intValue);
+                    }
 
 
                     break;
+
+
+
                 case TuyaSoDp.WEIGHT:
                     //称重功能
                     break;
@@ -325,6 +350,13 @@ public class TuyaUtilsSo {
         EventBus.getDefault().post(tuya);
     }
 
+    private void tuyaEventTime(String type,int time) {
+        TuyaEvent tuya = new TuyaEvent();
+        tuya.setTime(time);
+        tuya.setType(type);
+        EventBus.getDefault().post(tuya);
+    }
+
 
     private void getModes(int enumValue) {
         /**
@@ -499,14 +531,6 @@ public class TuyaUtilsSo {
                 DevInfo info = CofarSDK.devInfo();
                 BaseDevMode mode = info.getMode();
                 int time = (int) System.currentTimeMillis();
-
-//                if (getAutoMaticModes(info.getRunningInstId()) != autoMaticType) {
-//                    //称重的时候不忽略   由于称重的runningId 是 diy 对应不上,估在下面再处理多一个判断
-//                    if (!info.isWeightStatus()){
-//                        return;
-//                    }
-//                }
-
 //                Log.e("tuya_iot",info.toString());
                 int status = info.getStatus();
                 //getStatus    0 stop  1 start  2 pause
@@ -605,6 +629,7 @@ public class TuyaUtilsSo {
                         value = (int) eventValue;
                     }
 
+
                     if (event.type == DPEvent.Type.PROP_BOOL) {
                         sendDpBool(event.dpid, value, time);
                     }
@@ -618,6 +643,10 @@ public class TuyaUtilsSo {
                         sendDpEnum(event.dpid, value, time);
                     }
                 }
+
+
+
+
             }
         }).start();
 //        ioTSDKManager.sendDP(dpEvents);
@@ -806,6 +835,12 @@ public class TuyaUtilsSo {
                 return;
             }
         }
+        //如果是滑动时间得时候,需要上报暂停数据
+        if (dpid==TuyaSoDp.COOKING_TIME&&CofarSDK.devInfo().getStatus()==2){
+            pauseDpTime(time_stamp);
+            return;
+        }
+
         int code = getTuyaApi().send_dp_value(dpid, value, time_stamp);
         //上报成功,避免同一个值重复上报,估在这加map做缓存
         if (code == 0) {
@@ -822,8 +857,6 @@ public class TuyaUtilsSo {
                 return;
             }
         }
-
-
         int code = getTuyaApi().send_dp_bool(dpid, value, time_stamp);
 
         //上报成功,避免同一个值重复上报,估在这加map做缓存
@@ -832,6 +865,27 @@ public class TuyaUtilsSo {
         }
     }
 
+    public  void  pauseDpTime(int time_stamp){
+        DevInfo info = CofarSDK.devInfo();
+        int time = info.getTargetTimeBuffer() != -1 ? info.getTargetTimeBuffer() : info.getTargetTime();
+        if (remain_time == time){
+            return;
+        }
+        //由于app处理问题,特殊处理在当前模式页面而且暂停得时候,烹饪时间给剩余时间,剩余时间给烹饪时间
+        if (info.getMode().isTimeChange()
+                &&AppActivityManager.getInstance().getTopActivity()
+                .getLocalClassName().contains("ModesDetailActivity")
+                &&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;
+             }
+
+        }
+
+    }
     public void setDpCurrentActivity() {
         int time = (int) System.currentTimeMillis();
         Timer timer = new Timer();
@@ -871,11 +925,38 @@ public class TuyaUtilsSo {
         };
         //写好上面的声明之后,要调用则可像如下所示:
         timer.schedule(task, 2500); //task为你想要延时执行的事件,2000为延时2000毫秒
+    }
+
+    public void  pauseDevInfo(){
+        //因为下发了pause ,需要延迟0.5秒后上报暂停数据
+
+        /**
+         *   new DPEvent(TuyaSoDp.REMAINING_TIME, (byte) DPEvent.Type.PROP_VALUE, info.getRemainTime(), 0),
+         * */
+        Timer timer = new Timer();
+        TimerTask task = new TimerTask() {
+
+            @Override
+            public void run() {
+                //加入你在延时之后要做的事
+                DevInfo info = CofarSDK.devInfo();
+                Log.e("TAG startDevInfo","startDevInfostartDevInfostartDevInfo");
+                setDpRemainTime(info.getRemainTime());
+            }
+        };
+        //写好上面的声明之后,要调用则可像如下所示:
+        timer.schedule(task, 1000); //task为你想要延时执行的事件,2000为延时2000毫秒
+    }
 
+    public void setDpRemainTime(int value){
+        //由于app 下发了start指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个stop
+        int time = (int) System.currentTimeMillis();
+        int code = getTuyaApi().send_dp_value(TuyaSoDp.REMAINING_TIME, value, time);
 
 
     }
 
+
     public void setDpStop(){
         //由于app 下发了start指令,,参数没设置好,或者没把锅盖好, 设备是没运行的,估需要在上报个stop
         int time = (int) System.currentTimeMillis();

+ 65 - 0
BusinessStep/src/main/java/com/develop/step/ui/ModesDetailActivity.kt

@@ -768,6 +768,71 @@ class ModesDetailActivity : CommonBVMActivity<ActivityModeDetailBinding, ModesVi
         }
 
 
+        if ("remain_time" == event.type){
+            ThreadUtils.runOnMainThread {
+                //当前调节时间
+                var targetTime = event.time
+                if (targetTime < 0) {
+                    targetTime = 0;
+                }
+                if (targetTime > currDevInfo.mode.maxTime) {
+                    targetTime = currDevInfo.mode.maxTime
+                }
+                if (targetTime < currDevInfo.mode.minTime) {
+                    targetTime = currDevInfo.mode.minTime
+                }
+                val sec = targetTime % 60
+                val min = ((targetTime / 60) % 60)
+                val hour = (targetTime / 3600)
+                var time = ""
+                if (hour > 0) {
+                    time += if (hour < 10) {
+                        "0${hour}"
+                    } else {
+                        "$hour"
+                    }
+
+                    time += if (min < 10) {
+                        ":0${min}"
+                    } else {
+                        ":${min}"
+                    }
+                } else {
+                    time += if (min < 10) {
+                        "0${min}"
+                    } else {
+                        "$min"
+                    }
+
+                    time += if (sec < 10) {
+                        ":0${sec}"
+                    } else {
+                        ":${sec}"
+                    }
+                }
+                rollTimeEvent(hour, min, sec, time, setByUser = true, "change_time")
+                currDevInfo.apply {
+                    updateTimeUI(
+                        mode.minTime,
+                        mode.maxTime,
+                        remainTime,
+                        targetTime.toLong(),
+                        true, false, "change_time"
+                    )
+                }
+                binding.clSetTime.setTimeInternal(
+                    hour,
+                    min,
+                    sec,
+                    changeSetting = true,
+                    setByUser = true
+                )
+            }
+
+
+        }
+
+
         if ("change_temp" == event.type) {
 
             ThreadUtils.runOnMainThread({

+ 22 - 8
BusinessStep/src/main/java/com/develop/step/ui/cook_step/CookStepActivity.kt

@@ -2057,6 +2057,7 @@ class CookStepActivity : CookStepBaseActivity() {
                     }
                 }
 
+
                 override fun onCancel() {
                     FloatWindowManager.hideStepFlowWindow()
                     CofarSDK.stop(false)
@@ -2091,24 +2092,37 @@ class CookStepActivity : CookStepBaseActivity() {
                 }
             }
 
-            if (recipeBean != null) {
-
+            //新版本涂鸦,需要SOURCE_TAG 都传 local ,不然 开始按钮会变 下载
+            if (baseSn.startsWith("011D")){
                 navigateTo(Screens.Cook.COOK_DETAIL) {
                     withString(
                         SOURCE_TAG, "local"
                     )
                     withString(NUMBER_TAG, number)
                 }
-            } else {
-                navigateTo(Screens.Cook.COOK_DETAIL) {
-                    withString(
-                        SOURCE_TAG, "remote"
-                    )
-                    withString(NUMBER_TAG, number)
+
+            }else{
+                if (recipeBean != null) {
+                    navigateTo(Screens.Cook.COOK_DETAIL) {
+                        withString(
+                            SOURCE_TAG, "local"
+                        )
+                        withString(NUMBER_TAG, number)
+                    }
+                } else {
+                    navigateTo(Screens.Cook.COOK_DETAIL) {
+                        withString(
+                            SOURCE_TAG, "remote"
+                        )
+                        withString(NUMBER_TAG, number)
+                    }
+
                 }
 
+
             }
 
+
         }
     }
 }

+ 2 - 2
libBase/src/main/java/com/develop/base/ext/GlobaExt.kt

@@ -225,11 +225,11 @@ fun getSN(): String {
 //        return "011D10390020123010190001"
 //        return "011A10390020123010190002"
 //        return "011A10390020123010190002"
-//        return  "011D10390020123010190021"
+        return  "011D10390020123010190021"
 //        return  "011D10390020123010190088"
 
 
-        return  "011D10390020123010190019"
+//        return  "011D10390020123010190019"
 //        return  "011D10390020123010190003"
 //        return  "011A10390020123010190188"
 //        returffn "011A10390020123010190099"