New file |
| | |
| | | package com.hdl.sdk.hdl_sdk.activity; |
| | | |
| | | |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.Button; |
| | | import android.widget.EditText; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; |
| | | import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; |
| | | import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; |
| | | import com.hdl.sdk.hdl_sdk.R; |
| | | import com.hdl.sdk.hdl_sdk.base.BaseActivity; |
| | | import com.hdl.sdk.hdl_sdk.utlis.HDLLog; |
| | | |
| | | import org.greenrobot.eventbus.Subscribe; |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | |
| | | /** |
| | | * Created by JLChen on 2019/7/4 |
| | | * 空调类模块控制页面 |
| | | * PANEL 类型空调模块 |
| | | * 16~30摄氏度(℃) |
| | | */ |
| | | public class CtrlAirActivity extends BaseActivity { |
| | | // /**Topbar*/ |
| | | // private RelativeLayout topBarBack; |
| | | // private TextView topBarTitle; |
| | | |
| | | private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed; |
| | | private TextView airText; |
| | | private TextView tv_switch, tv_mode, tv_speed, tv_tempet; |
| | | private EditText airTempEd; |
| | | private AppliancesInfo appliancesInfo; |
| | | |
| | | |
| | | private int airSwitchState;//Demo仅以此作为演示,实际请根据需求开发设计 |
| | | private int airModeState; |
| | | private int airTempState; |
| | | private int airSpeedState; |
| | | // /** |
| | | // * true为设置摄氏度 false为设置华氏度 |
| | | // * 参数范围 16~30摄氏度(℃) |
| | | // * ~86华氏度(℉) |
| | | // */ |
| | | // private boolean bCelsius = true; |
| | | |
| | | /** |
| | | * 复写isRegisterEventBus() 要注册使用EventBus,这里要设置返回true |
| | | * |
| | | * @return true |
| | | */ |
| | | @Override |
| | | protected boolean isRegisterEventBus() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | setContentView(R.layout.activity_ctrl_air); |
| | | initToolbar(); |
| | | initView(); |
| | | initOnClick(); |
| | | initcurState(); |
| | | displayStateView(); |
| | | |
| | | // if(appliancesInfo.getDeviceType() == HDLApConfig.TYPE_AC_HVAC) { |
| | | // HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo); |
| | | // } |
| | | // //从本地获取空调面板状态 |
| | | // HDLCommand.getDeviceStateFromLocal(appliancesInfo); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 初始化Toolbar |
| | | */ |
| | | private void initToolbar() { |
| | | // topBarBack = findViewById(R.id.ll_top_b_left); |
| | | // setViewVisible(topBarBack); |
| | | // topBarTitle = findViewById(R.id.tv_top_b_header_title); |
| | | // topBarBack.setOnClickListener(new View.OnClickListener() { |
| | | // @Override |
| | | // public void onClick(View view) { |
| | | // finish(); |
| | | // } |
| | | // }); |
| | | } |
| | | |
| | | private void initcurState() { |
| | | appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); |
| | | String titleStr = appliancesInfo.getRemarks(); |
| | | // topBarTitle.setText(titleStr); |
| | | } |
| | | |
| | | private void displayStateView(){ |
| | | switch (appliancesInfo.getDeviceType()) { |
| | | // case HDLApConfig.TYPE_AC_HVAC: |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | loadDeviceData(); |
| | | break; |
| | | default: |
| | | finish();//设备类型不对结束页面 |
| | | break; |
| | | } |
| | | /**根据需求是否发送一次获取刷新状态请求*/ |
| | | } |
| | | |
| | | private void initView() { |
| | | airBtnSwitch = findViewById(R.id.airbtn_switch); |
| | | airBtnMode = findViewById(R.id.airbtn_mode); |
| | | airBtnSpeed = findViewById(R.id.airbtn_speed); |
| | | airBtnTemp = findViewById(R.id.airbtn_tempBtn); |
| | | airTempEd = findViewById(R.id.airet_tempet); |
| | | airText = findViewById(R.id.airText); |
| | | |
| | | tv_switch = findViewById(R.id.tv_switch); |
| | | tv_mode = findViewById(R.id.tv_mode); |
| | | tv_speed = findViewById(R.id.tv_speed); |
| | | tv_tempet = findViewById(R.id.tv_tempet); |
| | | } |
| | | |
| | | private void initOnClick() { |
| | | airBtnSwitch.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | //演示当前状态为关,设置为开。开,设置为关。 |
| | | if (airSwitchState == 0) { |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOn);//空调开 |
| | | } else { |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSwich, AirCtrlParser.airOff);//空调关 |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | airBtnMode.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | switch (airModeState) { |
| | | case 0: |
| | | //若当前空调模式为制冷,则点击按钮设置为制热 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeHeatTem);//空调模式制热 |
| | | break; |
| | | case 1: |
| | | //若当前空调模式为制热,则点击按钮设置为通风 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeVen);//空调模式通风 |
| | | break; |
| | | case 2: |
| | | //若当前空调模式为通风,则点击按钮设置为自动 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeAuto);//空调模式自动 |
| | | break; |
| | | case 3: |
| | | //若当前空调模式为自动,则点击按钮设置为抽湿 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeDehum);//空调模式抽湿 |
| | | break; |
| | | case 4: |
| | | //若当前空调模式为抽湿,则点击按钮设置为制冷 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//空调模式制冷 |
| | | break; |
| | | default: |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airMode, AirCtrlParser.airModeRefTem);//空调模式制冷 |
| | | break; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | airBtnSpeed.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | switch (airSpeedState) { |
| | | case 0: |
| | | //若当前空调风速为自动,则点击按钮设置为高风 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedHigh);//风速高风 |
| | | break; |
| | | case 1: |
| | | //若当前空调风速为高风,则点击按钮设置为中风 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedMid);//风速中风 |
| | | break; |
| | | case 2: |
| | | //若当前空调风速为中风,则点击按钮设置为低风 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedLow);//风速低风 |
| | | break; |
| | | case 3: |
| | | //若当前空调风速为低风,则点击按钮设置为自动 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.airSpeed, AirCtrlParser.airSpeedAuto);//风速自动 |
| | | break; |
| | | |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | airBtnTemp.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | String tempStr = airTempEd.getText().toString(); |
| | | if (TextUtils.isEmpty(tempStr)) { |
| | | showToast("设置的温度不能为空"); |
| | | return; |
| | | } |
| | | int tempInt = Integer.parseInt(tempStr); |
| | | |
| | | if (tempInt < 16 || tempInt > 30) { |
| | | showToast("温度设置范围为:16~30摄氏度(℃)"); |
| | | return; |
| | | } |
| | | |
| | | switch (airModeState) { |
| | | case 0: |
| | | //当前空调模式为制冷 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.refTem, tempInt);//制冷温度 |
| | | break; |
| | | case 1: |
| | | //当前空调模式为制热 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.heatTem, tempInt);//制热温度 |
| | | break; |
| | | case 2: |
| | | //当前空调模式为通风 |
| | | showToast("通风模式不能控制温度"); |
| | | break; |
| | | case 3: |
| | | //当前空调模式为自动 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.autoTem, tempInt);//自动温度 范围16-30 |
| | | break; |
| | | case 4: |
| | | //当前空调模式为抽湿 |
| | | HDLCommand.airCtrl(appliancesInfo, AirCtrlParser.dehumTem, tempInt);//抽湿温度 范围16-30 |
| | | break; |
| | | default: |
| | | break; |
| | | |
| | | } |
| | | |
| | | // HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//上升温度 范围0-5 |
| | | // HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//下降温度 范围0-5 |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | private void loadDeviceData() { |
| | | if (appliancesInfo.getArrCurState() != null) { |
| | | String stringACState = ""; |
| | | byte[] acCurState = appliancesInfo.getArrCurState(); |
| | | for (int index = 0; index < acCurState.length; index++) { |
| | | if (index == 0 && acCurState[index] == 0) { |
| | | airSwitchState = 0; |
| | | stringACState += "空调已关闭"; |
| | | //如果空调关闭状态,则无需再遍历 |
| | | break; |
| | | } |
| | | if (index == 0 && acCurState[index] == 1) { |
| | | airSwitchState = 1; |
| | | stringACState += "空调正在运行"; |
| | | } |
| | | |
| | | switch (index) { |
| | | |
| | | case 1: |
| | | switch (acCurState[index]) { |
| | | case 0: |
| | | airModeState = 0; |
| | | stringACState += " 空调模式:制冷"; |
| | | break; |
| | | case 1: |
| | | airModeState = 1; |
| | | stringACState += " 空调模式:制热"; |
| | | break; |
| | | case 2: |
| | | airModeState = 2; |
| | | stringACState += " 空调模式:通风"; |
| | | break; |
| | | case 3: |
| | | airModeState = 3; |
| | | stringACState += " 空调模式:自动"; |
| | | break; |
| | | case 4: |
| | | airModeState = 4; |
| | | stringACState += " 空调模式:抽湿"; |
| | | break; |
| | | default: |
| | | airModeState = -1; |
| | | stringACState += " 未知空调模式"; |
| | | break; |
| | | } |
| | | break; |
| | | case 2: |
| | | switch (acCurState[1]) { |
| | | case 0: |
| | | airTempState = acCurState[index] & 0xff; |
| | | stringACState += " 制冷温度:" + (acCurState[index] & 0xff); |
| | | break; |
| | | case 1: |
| | | airTempState = acCurState[index] & 0xff; |
| | | stringACState += " 制热温度:" + (acCurState[index] & 0xff); |
| | | break; |
| | | case 2: |
| | | airTempState = -1; |
| | | stringACState += " 通风无温度显示"; |
| | | break; |
| | | case 3: |
| | | airTempState = acCurState[index] & 0xff; |
| | | stringACState += " 自动温度:" + (acCurState[index] & 0xff); |
| | | break; |
| | | case 4: |
| | | airTempState = acCurState[index] & 0xff; |
| | | stringACState += " 抽湿温度:" + (acCurState[index] & 0xff); |
| | | break; |
| | | default: |
| | | airTempState = -2; |
| | | stringACState += " 未知温度"; |
| | | break; |
| | | } |
| | | break; |
| | | case 3: |
| | | String curSpeed; |
| | | switch (appliancesInfo.getArrCurState()[index]) { |
| | | case 0: |
| | | airSpeedState = 0; |
| | | curSpeed = " 风速自动"; |
| | | break; |
| | | case 1: |
| | | airSpeedState = 1; |
| | | curSpeed = " 风速高"; |
| | | break; |
| | | case 2: |
| | | airSpeedState = 2; |
| | | curSpeed = " 风速中"; |
| | | break; |
| | | case 3: |
| | | airSpeedState = 3; |
| | | curSpeed = " 风速低"; |
| | | break; |
| | | default: |
| | | airSpeedState = -1; |
| | | curSpeed = " 未知风速"; |
| | | break; |
| | | } |
| | | switch (appliancesInfo.getArrCurState()[1]) { |
| | | case 0: |
| | | stringACState += curSpeed; |
| | | break; |
| | | case 1: |
| | | stringACState += curSpeed; |
| | | break; |
| | | case 2: |
| | | stringACState += curSpeed; |
| | | break; |
| | | case 3: |
| | | stringACState += curSpeed; |
| | | break; |
| | | case 4: |
| | | stringACState += " 抽湿无风速"; |
| | | break; |
| | | default: |
| | | stringACState += " 未知空调模式"; |
| | | break; |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | airText.setText(stringACState); |
| | | } else { |
| | | airText.setText("未获取到空调设备状态"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 空调模块控制回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onAirFeedBackInfoEventMain(AirFeedBackEvent event) { |
| | | if (event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | && event.getAirCtrlBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getAirCtrlBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() |
| | | ) { |
| | | // 先判断是否超时 |
| | | if (!event.isSuccess()) { |
| | | showToast("空调控制超时,请重新再试"); |
| | | return; |
| | | } |
| | | String mes = ""; |
| | | byte[] curState = event.getAirCtrlBackInfo().getCurState(); |
| | | readAirState(curState); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取单一设备状态回调Event |
| | | * |
| | | * @param event |
| | | */ |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void onDeviceStateEventMain(DeviceStateEvent event) { |
| | | if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() |
| | | && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() |
| | | ) { |
| | | //这个返回的信息是当前状态的 |
| | | switch (event.getAppliancesInfo().getDeviceType()) { |
| | | // case HDLApConfig.TYPE_AC_HVAC: |
| | | case HDLApConfig.TYPE_AC_PANEL: |
| | | if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { |
| | | if (!event.isSuccess()) { |
| | | showToast("获取空调状态失败,请重新再试"); |
| | | return; |
| | | } |
| | | |
| | | byte[] curState = event.getAppliancesInfo().getArrCurState(); |
| | | |
| | | readAirState(curState); |
| | | // switch (curState[0] & 0xFF) { |
| | | // case AirCtrlParser.airSwich: |
| | | // switch (curState[1] & 0xFF) { |
| | | // case AirCtrlParser.airOff: |
| | | // airSwitchState = 0; |
| | | // airText.setText("空调关"); |
| | | // showToast("空调关"); |
| | | // HDLLog.I("空调关"); |
| | | // break; |
| | | // case AirCtrlParser.airOn: |
| | | // airSwitchState = 1; |
| | | // airText.setText("空调开"); |
| | | // showToast("空调开"); |
| | | // HDLLog.I("空调开"); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // |
| | | // break; |
| | | // |
| | | // case AirCtrlParser.airSpeed: |
| | | // switch (curState[1] & 0xFF) { |
| | | // case AirCtrlParser.airSpeedAuto: |
| | | // airSpeedState = 0; |
| | | // airText.setText("空调风速,风速模式为:airSpeedAuto自动风速"); |
| | | // showToast("空调风速,风速模式为:airSpeedAuto自动风速"); |
| | | // HDLLog.I("空调风速,风速模式为:airSpeedAuto自动风速"); |
| | | // break; |
| | | // case AirCtrlParser.airSpeedHigh: |
| | | // airSpeedState = 1; |
| | | // airText.setText("空调风速,风速模式为:airSpeedHigh风速高"); |
| | | // showToast("空调风速,风速模式为:airSpeedHigh风速高"); |
| | | // HDLLog.I("空调风速,风速模式为:airSpeedHigh风速高"); |
| | | // break; |
| | | // case AirCtrlParser.airSpeedMid: |
| | | // airSpeedState = 2; |
| | | // airText.setText("空调风速,风速模式为:airSpeedMid风速中"); |
| | | // showToast("空调风速,风速模式为:airSpeedMid风速中"); |
| | | // HDLLog.I("空调风速,风速模式为:airSpeedMid风速中"); |
| | | // break; |
| | | // case AirCtrlParser.airSpeedLow: |
| | | // airSpeedState = 3; |
| | | // airText.setText("空调风速,风速模式为:airSpeedLow风速低"); |
| | | // showToast("空调风速,风速模式为:airSpeedLow风速低"); |
| | | // HDLLog.I("空调风速,风速模式为:airSpeedLow风速低"); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // break; |
| | | // case AirCtrlParser.airMode: |
| | | // switch (curState[1] & 0xFF) { |
| | | // case AirCtrlParser.airModeRefTem: |
| | | // airModeState = 0; |
| | | // airText.setText("空调模式,模式为:制冷"); |
| | | // showToast("空调模式,模式为:制冷"); |
| | | // HDLLog.I("空调模式,模式为:制冷"); |
| | | // break; |
| | | // case AirCtrlParser.airModeHeatTem: |
| | | // airModeState = 1; |
| | | // airText.setText("空调模式,模式为:制热"); |
| | | // showToast("空调模式,模式为:制热"); |
| | | // HDLLog.I("空调模式,模式为:制热"); |
| | | // break; |
| | | // case AirCtrlParser.airModeVen: |
| | | // airModeState = 2; |
| | | // airText.setText("空调模式,模式为:通风"); |
| | | // showToast("空调模式,模式为:通风"); |
| | | // HDLLog.I("空调模式,模式为:通风"); |
| | | // break; |
| | | // case AirCtrlParser.airModeAuto: |
| | | // airModeState = 3; |
| | | // airText.setText("空调模式,模式为:自动"); |
| | | // showToast("空调模式,模式为:自动"); |
| | | // HDLLog.I("空调模式,模式为:自动"); |
| | | // break; |
| | | // case AirCtrlParser.airModeDehum: |
| | | // airModeState = 4; |
| | | // airText.setText("空调模式,模式为:抽湿"); |
| | | // showToast("空调模式,模式为:抽湿"); |
| | | // HDLLog.I("空调模式,模式为:抽湿"); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // break; |
| | | // case AirCtrlParser.refTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调制冷,温度为:" + (curState[1] & 0xFF)); |
| | | // showToast("空调制冷,温度为:" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调制冷,温度为:" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // case AirCtrlParser.heatTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调制热,制热温度为" + (curState[1] & 0xFF)); |
| | | // showToast("空调制热,制热温度为" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调制热,制热温度为" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // case AirCtrlParser.autoTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调自动,自动温度为" + (curState[1] & 0xFF)); |
| | | // showToast("空调自动,自动温度为" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调自动,自动温度为" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // case AirCtrlParser.dehumTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调抽湿,抽湿温度为" + (curState[1] & 0xFF)); |
| | | // showToast("空调抽湿,抽湿温度为" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调抽湿,抽湿温度为" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // case AirCtrlParser.upTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调调温,上升温度:" + (curState[1] & 0xFF)); |
| | | // showToast("空调调温,上升温度:" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调调温,上升温度:" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // case AirCtrlParser.downTem: |
| | | // airTempState = curState[1] & 0xFF; |
| | | // airText.setText("空调调温,下降温度:" + (curState[1] & 0xFF)); |
| | | // showToast("空调调温,下降温度:" + (curState[1] & 0xFF)); |
| | | // HDLLog.I("空调调温,下降温度:" + (curState[1] & 0xFF)); |
| | | // break; |
| | | // } |
| | | } |
| | | break; |
| | | default: |
| | | //不处理 |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void readAirState( byte[] curState ){ |
| | | String mes = ""; |
| | | switch (curState[0] & 0xFF) { |
| | | case AirCtrlParser.airSwich: |
| | | switch (curState[1] & 0xFF) { |
| | | case AirCtrlParser.airOff: |
| | | airSwitchState = 0; |
| | | |
| | | tv_switch.setText("关"); |
| | | |
| | | mes = "空调关"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.airOn: |
| | | airSwitchState = 1; |
| | | // airText.setText("空调开"); |
| | | // showToast("空调开"); |
| | | // HDLLog.I("空调开"); |
| | | tv_switch.setText("开"); |
| | | |
| | | mes = "空调开"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | break; |
| | | |
| | | case AirCtrlParser.airSpeed: |
| | | switch (curState[1] & 0xFF) { |
| | | case AirCtrlParser.airSpeedAuto: |
| | | airSpeedState = 0; |
| | | tv_speed.setText("自动"); |
| | | |
| | | mes = "自动风速"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | case AirCtrlParser.airSpeedHigh: |
| | | airSpeedState = 1; |
| | | |
| | | tv_speed.setText("高速"); |
| | | mes = "风速高"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.airSpeedMid: |
| | | airSpeedState = 2; |
| | | tv_speed.setText("中速"); |
| | | mes = "风速中"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | case AirCtrlParser.airSpeedLow: |
| | | airSpeedState = 3; |
| | | |
| | | tv_speed.setText("低速"); |
| | | mes = "风速低"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | break; |
| | | case AirCtrlParser.airMode: |
| | | switch (curState[1] & 0xFF) { |
| | | case AirCtrlParser.airModeRefTem: |
| | | airModeState = 0; |
| | | |
| | | tv_mode.setText("制冷"); |
| | | |
| | | mes = "模式为:制冷"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | case AirCtrlParser.airModeHeatTem: |
| | | airModeState = 1; |
| | | tv_mode.setText("制热"); |
| | | |
| | | mes = "模式为:制热"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.airModeVen: |
| | | airModeState = 2; |
| | | tv_mode.setText("通风"); |
| | | |
| | | mes = "模式为:通风"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.airModeAuto: |
| | | airModeState = 3; |
| | | tv_mode.setText("自动"); |
| | | |
| | | mes = "模式为:自动"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.airModeDehum: |
| | | airModeState = 4; |
| | | tv_mode.setText("抽湿"); |
| | | |
| | | mes = "模式为:抽湿"; |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | default: |
| | | airModeState = -1; |
| | | break; |
| | | } |
| | | break; |
| | | case AirCtrlParser.refTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | |
| | | tv_tempet.setText("" + airTempState); |
| | | mes = "空调制冷,温度为:" + (airTempState); |
| | | |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | case AirCtrlParser.heatTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | tv_tempet.setText("" + airTempState); |
| | | mes = "空调制热,制热温度为:" + (airTempState); |
| | | |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | |
| | | break; |
| | | case AirCtrlParser.autoTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | |
| | | tv_tempet.setText(""+airTempState); |
| | | mes = "空调自动,自动温度为:" + (airTempState); |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.dehumTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | |
| | | tv_tempet.setText("" + airTempState); |
| | | mes = "空调抽湿,抽湿温度为:" + (airTempState); |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.upTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | |
| | | |
| | | tv_tempet.setText("" + airTempState); |
| | | mes = "空调调温,上升温度:" + (airTempState); |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | case AirCtrlParser.downTem: |
| | | airTempState = curState[1] & 0xFF; |
| | | tv_tempet.setText("" + airTempState); |
| | | mes = "空调调温,下降温度:" + (airTempState); |
| | | tv_mesSetText(mes); |
| | | HDLLog.I(mes); |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * TextView 显示信息并且showToast提示 |
| | | * |
| | | * @param mes |
| | | */ |
| | | private void tv_mesSetText(String mes) { |
| | | airText.setText(mes); |
| | | showToast(mes); |
| | | } |
| | | } |