|
@@ -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();
|