JLChen
2020-03-16 7a951ecdc084ea8643e29e1ade59c1877fd7fbe5
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java
@@ -141,6 +141,7 @@
                }
            }
        });
@@ -150,7 +151,7 @@
            public void onClick(View view) {
                String tempStr = tempEditText.getText().toString();
                if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) {
                if (TextUtils.isEmpty(tempStr)) {
                    showToast("设置的温度不能为空");
                    return;
                }
@@ -161,40 +162,43 @@
                    return;
                }
                proDialog.show();
                switch (gModeState) {
                    case 1:
                        //当前地热模式为普通
                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//普通温度
                        ctrlId = GeothermalParser.gNormalTemp;
                        break;
                    case 2:
                        //当前地热模式为白天
                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gDayTemp, tempInt);//白天温度
                        ctrlId = GeothermalParser.gDayTemp;
                        break;
                    case 3:
                        //当前地热模式为夜间
                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNightTemp, tempInt);//夜间温度
                        ctrlId = GeothermalParser.gNightTemp;
                        break;
                    case 4:
                        //当前地热模式为离开
                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gLeaveTemp, tempInt);//离开温度
                        ctrlId = GeothermalParser.gLeaveTemp;
                        break;
                    case 5:
                        proDialog.dismiss();
                        //当前地热模式为自动
                        showToast("自动模式,不能控制温度");
                        break;
                    default:
                        proDialog.dismiss();
                        //当前地热模式为自动
                        showToast("未知模式,不能控制温度");
                        break;
                HDLCommand.geothermalCtrlTemp(appliancesInfo, tempInt);//自动根据当前模式设置当前模式的温度。
                }
//                switch (gModeState) {
//
//                    case 1:
//                        //当前地热模式为普通
//                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//普通温度
//                        ctrlId = GeothermalParser.gNormalTemp;
//                        break;
//                    case 2:
//                        //当前地热模式为白天
//                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gDayTemp, tempInt);//白天温度
//                        ctrlId = GeothermalParser.gDayTemp;
//                        break;
//                    case 3:
//                        //当前地热模式为夜间
//                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNightTemp, tempInt);//夜间温度
//                        ctrlId = GeothermalParser.gNightTemp;
//                        break;
//                    case 4:
//                        //当前地热模式为离开
//                        HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gLeaveTemp, tempInt);//离开温度
//                        ctrlId = GeothermalParser.gLeaveTemp;
//                        break;
//                    case 5:
//                        proDialog.dismiss();
//                        //当前地热模式为自动
//                        showToast("自动模式,不能控制温度");
//                        break;
//                    default:
//                        proDialog.dismiss();
//                        //当前地热模式为自动
//                        showToast("未知模式,不能控制温度");
//                        break;
//
//                }
            }
@@ -309,41 +313,43 @@
                showToast("地热模块,返回数据为空");
                return;
            }
            String message = "";
            GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo();
            showGeothermalBackInfo(mGeothermalBackInfo);
            switch (ctrlId) {   //ctrlId 当前控制类型,只反馈控制的状态
                case GeothermalParser.gSwich:
                    message = getSwichStateString(mGeothermalBackInfo.getIsOn());
                    break;
                case GeothermalParser.gMode:
                    message = getModeStateString(mGeothermalBackInfo.getgMode());
                    break;
                case GeothermalParser.gNormalTemp:
//                    gTempState = mGeothermalBackInfo.getgNormalTemp();
                    message = "普通模式温度:" + mGeothermalBackInfo.getgNormalTemp();
                    break;
//            String message = "";
//            GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo();
                case GeothermalParser.gDayTemp:
                    message = "白天模式温度:" + mGeothermalBackInfo.getgDayTemp();
                    break;
                case GeothermalParser.gNightTemp:
                    message = "夜间模式温度:" + mGeothermalBackInfo.getgNightTemp();
                    break;
                case GeothermalParser.gLeaveTemp:
                    message = "离开模式温度:" + mGeothermalBackInfo.getgLeaveTemp();
                    break;
                default:
                    break;
            }
            mTextView.setText(message);
            showToast(message);
            HDLLog.I(message);
//            switch (ctrlId) {   //ctrlId 当前控制类型,只反馈控制的状态
//                case GeothermalParser.gSwich:
//                    message = getSwichStateString(mGeothermalBackInfo.getIsOn());
//                    break;
//                case GeothermalParser.gMode:
//                    message = getModeStateString(mGeothermalBackInfo.getgMode());
//                    break;
//                case GeothermalParser.gNormalTemp:
////                    gTempState = mGeothermalBackInfo.getgNormalTemp();
//                    message = "普通模式温度:" + mGeothermalBackInfo.getgNormalTemp();
//                    break;
//
//
//                case GeothermalParser.gDayTemp:
//                    message = "白天模式温度:" + mGeothermalBackInfo.getgDayTemp();
//                    break;
//                case GeothermalParser.gNightTemp:
//                    message = "夜间模式温度:" + mGeothermalBackInfo.getgNightTemp();
//                    break;
//                case GeothermalParser.gLeaveTemp:
//                    message = "离开模式温度:" + mGeothermalBackInfo.getgLeaveTemp();
//                    break;
//                default:
//                    break;
//
//            }
//
//
//            mTextView.setText(message);
//            showToast(message);
//            HDLLog.I(message);
        }
    }
@@ -369,26 +375,35 @@
                            return;
                        }
                        if(mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) {
                            message = getSwichStateString(mGeothermalBackInfo.getIsOn());
                            message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode());
                            message += "\n" + "普通模式温度:" + mGeothermalBackInfo.getgNormalTemp();
                            message += "\n" + "白天模式温度:" + mGeothermalBackInfo.getgDayTemp();
                            message += "\n" + "夜间模式温度:" + mGeothermalBackInfo.getgNightTemp();
                            message += "\n" + "离开模式温度:" + mGeothermalBackInfo.getgLeaveTemp();
                        }else {
                            message = getSwichStateString(mGeothermalBackInfo.getIsOn());
                        }
                        mTextView.setText(message);
                        showToast(message);
                        HDLLog.I(message);
                        showGeothermalBackInfo(mGeothermalBackInfo);
                    }
                    break;
            }
        }
    }
    /**
     * showGeothermalBackInfo
     * @param mGeothermalBackInfo
     */
    private void showGeothermalBackInfo(GeothermalBackInfo mGeothermalBackInfo){
        String message = "";
        if(mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) {
            message = getSwichStateString(mGeothermalBackInfo.getIsOn());
            message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode());
            message += "\n" + "普通模式温度:" + mGeothermalBackInfo.getgNormalTemp();
            message += "\n" + "白天模式温度:" + mGeothermalBackInfo.getgDayTemp();
            message += "\n" + "夜间模式温度:" + mGeothermalBackInfo.getgNightTemp();
            message += "\n" + "离开模式温度:" + mGeothermalBackInfo.getgLeaveTemp();
        }else {
            message = getSwichStateString(mGeothermalBackInfo.getIsOn());
        }
        mTextView.setText(message);
        showToast(message);
        HDLLog.I(message);
    }
}