From c4b015770e8a29f18e19cc44b3df46c20a4762f4 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 10 八月 2021 10:17:42 +0800 Subject: [PATCH] 2021-08-10 1.更新 --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java | 149 +++++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java | 7 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java | 1 hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java | 4 app/src/main/AndroidManifest.xml | 1 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java | 9 app/src/main/res/layout/activity_ctrl_air_hvac.xml | 75 ++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java | 25 hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java | 50 + hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 481 ++++++++++------ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 442 ++++---------- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java | 20 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java | 9 hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java | 2 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirHVACActivity.java | 437 +++++++++++++++ 15 files changed, 1,208 insertions(+), 504 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c33c0b0..07313b4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,6 +38,7 @@ <activity android:name=".activity.CtrlCommonSwitchActivity" /> <activity android:name=".activity.CtrlSecurityActivity" /> <activity android:name=".activity.SensorActivity" /> + <activity android:name=".activity.CtrlAirHVACActivity" /> <receiver android:name=".activity.BootComplete"> <intent-filter> diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java index a645dfc..e7bfeeb 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/AppliancesActivity.java @@ -79,7 +79,14 @@ } } - + else if (appliancesInfos.get(position).getBigType() == Configuration.AIR_BIG_TYPE) { + //绌鸿皟妯″潡 + if(appliancesInfos.get(position).getDeviceType() == HDLApConfig.TYPE_AC_HVAC){ + intent.setClass(AppliancesActivity.this, CtrlAirHVACActivity.class); + }else { + intent.setClass(AppliancesActivity.this, CtrlActivity.class); + } + } else { intent.setClass(AppliancesActivity.this, CtrlActivity.class); diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirHVACActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirHVACActivity.java new file mode 100644 index 0000000..a4ce08d --- /dev/null +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlAirHVACActivity.java @@ -0,0 +1,437 @@ +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.AirHVACBackInfo; +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.AirHVACFeedBackEvent; +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 + * 绌鸿皟绫绘ā鍧楁帶鍒堕〉闈� + * HVAC 绫诲瀷绌鸿皟妯″潡 + * 16~30鎽勬皬搴�(鈩�) + */ +public class CtrlAirHVACActivity extends BaseActivity { + + + private Button airBtnSwitch, airBtnMode, airBtnTemp, airBtnSpeed; + private TextView airText; + 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() 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true + * + * @return true + */ + @Override + protected boolean isRegisterEventBus() { + return true; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_ctrl_air_hvac); + initToolbar(); + initView(); + initOnClick(); + initcurState(); + showStateView(); + +// if(appliancesInfo.getDeviceType() == HDLApConfig.TYPE_AC_HVAC) { +// HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo); +// } + HDLCommand.getHVACDeviceStateFromNetwork(appliancesInfo); + } + + + + /** + * 鍒濆鍖朤oolbar + */ + 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(); + + } + + + + 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); + + } + + 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) { + HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.downTem,1);//涓婂崌娓╁害 鑼冨洿0-5 + return; +// 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) { + HDLCommand.airCtrl(appliancesInfo,AirCtrlParser.upTem,1);//涓婂崌娓╁害 鑼冨洿0-5 + return; +// 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 showStateView() { + if (appliancesInfo.getArrCurState() != null) { + AirHVACBackInfo mAirHVACBackInfo = new AirHVACBackInfo(appliancesInfo); + String stringState = ""; + if (mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOff) { + stringState = "HVAC绌鸿皟妯″潡锛氬叧闂�"; + } else if (mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOn) { + stringState = "HVAC绌鸿皟妯″潡锛氭墦寮�"; + + stringState += "\n" + getModeStateString(mAirHVACBackInfo.getAirMode());//妯″紡 + stringState += "\n" + getSpeedStateString(mAirHVACBackInfo.getAirSpeed());//椋庨�� + stringState += "\n瀹ゅ唴娓╁害锛�" + mAirHVACBackInfo.getIndoorTemp(); + stringState += "\n鍒跺喎妯″紡娓╁害锛�" + mAirHVACBackInfo.getRefTemp(); + stringState += "\n鍒剁儹妯″紡娓╁害锛�" + mAirHVACBackInfo.getHeatTemp(); + stringState += "\n鑷姩妯″紡娓╁害锛�" + mAirHVACBackInfo.getAutoTemp(); + stringState += "\n鎶芥箍妯″紡娓╁害锛�" + mAirHVACBackInfo.getWettedTemp(); + } else { + stringState = "鏈煡寮�鍏崇姸鎬�"; + } + airText.setText(stringState); + } else { + airText.setText("鏈幏鍙栧埌HVAC绌鸿皟妯″潡鐘舵��"); + } + } + + + /** + * getModeStateString + * + * @param mState + * @return + */ + private String getModeStateString(int mState) { + String mStrState = "鏈煡"; + airModeState = mState; //鏇存柊妯″紡鐘舵�� + switch (mState) { + case AirCtrlParser.airModeRefTem: + mStrState = "妯″紡锛氬埗鍐�"; + break; + case AirCtrlParser.airModeHeatTem: + mStrState = "妯″紡锛氬埗鐑�"; + break; + case AirCtrlParser.airModeVen: + mStrState = "妯″紡锛氶�氶"; + break; + case AirCtrlParser.airModeAuto: + mStrState = "妯″紡锛氳嚜鍔�"; + break; + case AirCtrlParser.airModeDehum: + mStrState = "妯″紡锛氭娊婀�"; + break; + default: + mStrState = "鏈煡妯″紡鐘舵��"; + break; + } + return mStrState; + } + + /** + * getSpeedStateString + * + * @param mState + * @return + */ + private String getSpeedStateString(int mState) { + String mStrState = "鏈煡"; + airSpeedState = mState; //鏇存柊褰撳墠椋庨�熺姸鎬� + switch (mState) { + case AirCtrlParser.airSpeedAuto: + mStrState = "椋庨�燂細鑷姩"; + break; + case AirCtrlParser.airSpeedHigh: + mStrState = "椋庨�燂細楂�"; + break; + case AirCtrlParser.airSpeedMid: + mStrState = "椋庨�燂細涓�"; + break; + case AirCtrlParser.airSpeedLow: + mStrState = "椋庨�燂細浣�"; + break; + + default: + mStrState = "鏈煡椋庨�熺姸鎬�"; + break; + } + return mStrState; + } + + + /** + * getSwichStateString + * + * @param mState + * @return + */ + private String getSwichStateString(int mState) { + String mStrState = "鏈煡"; + airSwitchState = mState; //鏇存柊寮�鍏崇姸鎬� + switch (mState) { + case AirCtrlParser.airOn: + mStrState = "HVAC绌鸿皟妯″潡锛氭墦寮�"; + break; + case AirCtrlParser.airOff: + mStrState = "HVAC绌鸿皟妯″潡锛氬叧闂�"; + break; + + default: + mStrState = "鏈煡鐘舵��"; + break; + } + return mStrState; + } + + + private void showAirHVACBackInfo(AirHVACBackInfo mAirHVACBackInfo){ + String message = ""; + if(mAirHVACBackInfo.getIsOn() == AirCtrlParser.airOn) { + message = getSwichStateString(mAirHVACBackInfo.getIsOn()); + message += "\n" + getModeStateString(mAirHVACBackInfo.getAirMode());//妯″紡 + message += "\n" + getSpeedStateString(mAirHVACBackInfo.getAirSpeed());//椋庨�� + message += "\n瀹ゅ唴娓╁害锛�" + mAirHVACBackInfo.getIndoorTemp(); + message += "\n鍒跺喎妯″紡娓╁害锛�" + mAirHVACBackInfo.getRefTemp(); + message += "\n鍒剁儹妯″紡娓╁害锛�" + mAirHVACBackInfo.getHeatTemp(); + message += "\n鑷姩妯″紡娓╁害锛�" + mAirHVACBackInfo.getAutoTemp(); + message += "\n鎶芥箍妯″紡娓╁害锛�" + mAirHVACBackInfo.getWettedTemp(); + }else { + message = getSwichStateString(mAirHVACBackInfo.getIsOn()); + } + airText.setText(message); + showToast(message); + HDLLog.I(message); + + } + + + + + /** + * 绌鸿皟妯″潡鎺у埗鍥炶皟Event + * + * @param event + */ + @Subscribe(threadMode = ThreadMode.MAIN) + public void onAirHVACFeedBackEventMain(AirHVACFeedBackEvent event) { + if (event.getAirHVACBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() + && event.getAirHVACBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() + && event.getAirHVACBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() + ) { + // 鍏堝垽鏂槸鍚﹁秴鏃� + if (!event.isSuccess()) { + showToast("绌鸿皟鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + AirHVACBackInfo mAirHVACBackInfo = event.getAirHVACBackInfo(); + showAirHVACBackInfo(mAirHVACBackInfo); + + } + } + + /** + * 鑾峰彇鍗曚竴璁惧鐘舵�佸洖璋僂vent + * + * @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: + if (appliancesInfo.getChannelNum() == event.getAppliancesInfo().getChannelNum()) { + if (!event.isSuccess()) { + showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + AirHVACBackInfo mAirHVACBackInfo = new AirHVACBackInfo(event.getAppliancesInfo()); + if (mAirHVACBackInfo == null) { + showToast("鑾峰彇绌鸿皟鐘舵�佸け璐ワ紝璇烽噸鏂板啀璇�"); + return; + } + showAirHVACBackInfo(mAirHVACBackInfo); + } + break; + default: + //涓嶅鐞� + break; + } + } + } + + + +} diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java index 957b70e..0e00897 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java @@ -412,6 +412,7 @@ message = getSwichStateString(mGeothermalBackInfo.getIsOn()); message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); + message += "\n" + "瀹ゅ唴娓╁害锛�" + mGeothermalBackInfo.getgCurrentTemp(); message += "\n" + "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); message += "\n" + "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); message += "\n" + "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); diff --git a/app/src/main/res/layout/activity_ctrl_air_hvac.xml b/app/src/main/res/layout/activity_ctrl_air_hvac.xml new file mode 100644 index 0000000..14ea0e7 --- /dev/null +++ b/app/src/main/res/layout/activity_ctrl_air_hvac.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/activity_ctrl" + android:layout_width="match_parent" + android:layout_height="match_parent"> + +<!-- <include--> +<!-- android:id="@+id/hdl_top_bar_layout"--> +<!-- layout="@layout/hdl_toolbar_top_view_b"/>--> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginRight="20dp" + android:layout_marginLeft="20dp" + android:orientation="vertical"> + + <TextView + android:layout_width="match_parent" + android:layout_height="40dp" + android:text="HVAC绌鸿皟鍔熻兘绫绘ā鍧�" + android:gravity="center|left" + android:textSize="@dimen/ts_24" + /> + + <LinearLayout + android:id="@+id/air" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:id="@+id/airText" + android:textSize="@dimen/ts_20" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="杩欎釜鎸夐挳鍋氱┖璋冮潰鏉跨殑婕旂ず" /> + <Button + android:id="@+id/airbtn_switch" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="绌鸿皟寮�鍏�" /> + + + <Button + android:id="@+id/airbtn_mode" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="绌鸿皟妯″紡" /> + <Button + android:id="@+id/airbtn_speed" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="绌鸿皟椋庨��" /> + <LinearLayout + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <Button + android:id="@+id/airbtn_tempBtn" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鐐瑰嚮璁剧疆绌鸿皟娓╁害:" /> + <EditText + android:id="@+id/airet_tempet" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:inputType="number"/> + </LinearLayout> + + + </LinearLayout> + </LinearLayout> + +</RelativeLayout> \ No newline at end of file diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java index 4ab1609..ebe67fb 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java @@ -113,8 +113,8 @@ public static final int AIR_HVAC_CTRL_COMMAND = 0x193A; public static final int AIR_HVAC_CTRL_BACK_COMMAND = 0x193B; - // public static final int AIR_HVAC_STATE_COMMAND = 0x1938; - public static final int AIR_HVAC_STATE_BACK_COMMAND = 0x209A; + public static final int AIR_HVAC_STATE_COMMAND = 0x1938; + public static final int AIR_HVAC_STATE_BACK_COMMAND = 0x1939; //閫昏緫妯″潡鎿嶄綔鐮併�佺姸鎬佽鍙栫爜 diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java new file mode 100644 index 0000000..75fe529 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/AirHVACBackInfo.java @@ -0,0 +1,149 @@ +package com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition; + + + +import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; + +import java.io.Serializable; + +/** + * Created by JLChen on 2019/8/6 + */ +public class AirHVACBackInfo implements Serializable { + private AppliancesInfo appliancesInfo; + private String remarks; + private int channelNum;//鍥炶矾鍙� + private int isOn;//0=鍏筹紝1=寮� + private int indoorTemp;//瀹ゅ唴娓╁害鐐� 0-84 + private int refTemp;//鍒跺喎娓╁害鐐� 0-84 + private int heatTemp;//鍒剁儹娓╁害鐐� 0-84 + private int autoTemp;//鑷姩娓╁害鐐� 0-84 + private int wettedTemp;//鎶芥箍娓╁害鐐� + private int airSpeed;//椋庨�� 0 =鑷姩, 1 = 楂橀, 1 = 涓, 3 = 浣庨 + private int airMode;//绌鸿皟妯″紡0 = 鍒跺喎, 1 = 鍒剁儹, 1 = 閫氶, 3 =鑷姩, 4 = 鎶芥箍 + // private int upTemp;//涓婂崌娓╁害 +// private int downTemp;//涓嬮檷娓╁害 + private byte[] curState ;//鎺у埗鍥為淇℃伅 + + public AirHVACBackInfo(){ + + } + + public AirHVACBackInfo(AppliancesInfo mAppliancesInfo) { + this.appliancesInfo = mAppliancesInfo; + this.curState = mAppliancesInfo.getArrCurState(); + this.remarks = mAppliancesInfo.getRemarks(); + + if (this.curState == null) return; + + if (this.curState.length >= 13) { + this.channelNum = this.curState[0] & 0xFF; + this.indoorTemp = this.curState[2] & 0xFF; + this.refTemp = this.curState[3] & 0xFF;//鍒跺喎娓╁害鐐� 0-84 + this.heatTemp = this.curState[4] & 0xFF;//鍒剁儹娓╁害鐐� 0-84 + this.autoTemp = this.curState[5] & 0xFF;//鑷姩娓╁害鐐� 0-84 + this.wettedTemp = this.curState[6] & 0xFF;//鎶芥箍娓╁害鐐� 0-84 + this.isOn = this.curState[8] & 0xFF;//鍙彇浣�4浣� + this.airMode = this.curState[9] & 0xFF; + this.airSpeed = this.curState[10] & 0xFF; + } + + } + + public int getIndoorTemp() { + return indoorTemp; + } + + public void setIndoorTemp(int indoorTemp) { + this.indoorTemp = indoorTemp; + } + + public AppliancesInfo getAppliancesInfo() { + return appliancesInfo; + } + + public void setAppliancesInfo(AppliancesInfo appliancesInfo) { + this.appliancesInfo = appliancesInfo; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + public int getChannelNum() { + return channelNum; + } + + public void setChannelNum(int channelNum) { + this.channelNum = channelNum; + } + + public int getIsOn() { + return isOn; + } + + public void setIsOn(int isOn) { + this.isOn = isOn; + } + + public int getRefTemp() { + return refTemp; + } + + public void setRefTemp(int refTemp) { + this.refTemp = refTemp; + } + + public int getHeatTemp() { + return heatTemp; + } + + public void setHeatTemp(int heatTemp) { + this.heatTemp = heatTemp; + } + + public int getAutoTemp() { + return autoTemp; + } + + public void setAutoTemp(int autoTemp) { + this.autoTemp = autoTemp; + } + + public int getWettedTemp() { + return wettedTemp; + } + + public void setWettedTemp(int wettedTemp) { + this.wettedTemp = wettedTemp; + } + + public int getAirSpeed() { + return airSpeed; + } + + public void setAirSpeed(int airSpeed) { + this.airSpeed = airSpeed; + } + + public int getAirMode() { + return airMode; + } + + public void setAirMode(int airMode) { + this.airMode = airMode; + } + + public byte[] getCurState() { + return curState; + } + + public void setCurState(byte[] curState) { + this.curState = curState; + } + +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java index fdd542d..c253b8d 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java @@ -121,22 +121,59 @@ } /** - * 鐢熸垚榛樿鏁版嵁 + * 鐘舵�佹暟鎹紓甯哥殑鏃跺�欙紝鐢熸垚榛樿绌鸿皟鏁版嵁 + * @return + */ + public static byte[] getNewAcByte() { + byte[] airBytes = new byte[13]; + airBytes[0] = 0; + airBytes[1] = 0; + airBytes[2] = (byte) 28; + airBytes[3] = (byte) 28; + airBytes[4] = (byte) 28; + airBytes[5] = (byte) 28; + airBytes[6] = (byte) 28; + airBytes[7] = 0; + airBytes[8] = 1; + airBytes[9] = 0; + airBytes[10] = 0; + airBytes[11] = (byte) 28; + airBytes[12] = 0; + return airBytes; + } + + /** + * 绠�鏄撶紪绋嬫悳绱� 鐘舵�佹暟鎹産ytes鏍煎紡锛屽姣旀棫鐘舵�佹暟鎹慨鏀规洿鏂扮姸鎬佸鐞嗭紝涓嶇敤绠�鏄撶紪绋嬫悳绱㈠娉ㄦ帴鏀剁姸鎬佺殑璇濓紝璇ユ柟娉曞彲浠ュ拷鐣� * 0 寮�鍏崇姸鎬� * 1 妯″紡 * 2 娓╁害 * 3 椋庨�� - * 4 + * 4 褰撳墠瀹ゆ俯 + * 5 鏄惁鎽嗛 + * * @return */ - public static byte[] getNewAcByte() { - byte[] airBytes = new byte[6]; - airBytes[0] = (byte) 0; - airBytes[1] = (byte) 0; - airBytes[2] = (byte) 28; - airBytes[3] = (byte) 0; - airBytes[4] = (byte) 28; - airBytes[5] = (byte) 0; + public static byte[] getNewAcByteWithE44B(byte[] bytes, byte[] oldBytes) { + byte[] airBytes = getNewAcByte(); + if(oldBytes != null && oldBytes.length >= 13){ + airBytes = oldBytes; + } + + if (bytes.length > 5) { +// airBytes[0] = 0; +// airBytes[1] = 0; + airBytes[2] = bytes[4]; +// airBytes[3] = bytes[2]; +// airBytes[4] = bytes[2]; +// airBytes[5] = bytes[2]; +// airBytes[6] = bytes[2]; + airBytes[7] = (byte) ((airBytes[2] & 0xff) * 16 + (airBytes[3] & 0xff)); + airBytes[8] = bytes[0]; + airBytes[9] = bytes[1]; + airBytes[10] = bytes[3]; + airBytes[11] = bytes[2]; + airBytes[12] = bytes[5]; + } return airBytes; } @@ -154,7 +191,7 @@ && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); - if (newInfo.getArrCurState() == null || newInfo.getArrCurState().length != 6) { + if (newInfo.getArrCurState() == null || newInfo.getArrCurState().length != 13) { newInfo.setArrCurState(getNewAcByte()); } airBytes = newInfo.getArrCurState(); @@ -166,73 +203,27 @@ } byte[] addBytes = new byte[13]; - if (airBytes != null && airBytes.length >= 6) { + if (airBytes != null && airBytes.length >= 13) { //2020-05-28 濡傛灉娓╁害涓�0鑷姩淇敼涓�28 - if((airBytes[2] & 0xff) == 0){ - airBytes[2] = (byte)28; + if ((airBytes[11] & 0xff) == 0) { + airBytes[11] = (byte) 28; } addBytes[0] = (byte) newInfo.getChannelNum(); addBytes[1] = 0; - addBytes[2] = airBytes[4]; - addBytes[3] = airBytes[2]; - addBytes[4] = airBytes[2]; - addBytes[5] = airBytes[2]; - addBytes[6] = airBytes[2]; - addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + (airBytes[3] & 0xff)); - addBytes[8] = airBytes[0]; - addBytes[9] = airBytes[1]; - addBytes[10] = airBytes[3]; - addBytes[11] = airBytes[2]; - addBytes[12] = airBytes[5]; + addBytes[2] = airBytes[2]; + addBytes[3] = airBytes[3]; + addBytes[4] = airBytes[4]; + addBytes[5] = airBytes[5]; + addBytes[6] = airBytes[6]; + addBytes[7] = (byte) ((airBytes[9] & 0xff) * 16 + (airBytes[10] & 0xff)); + addBytes[8] = airBytes[8]; + addBytes[9] = airBytes[9]; + addBytes[10] = airBytes[10]; + addBytes[11] = airBytes[11]; + addBytes[12] = airBytes[12]; - switch (type) { - case airSwich: - if (state == airOff) { - addBytes[8] = 0; - } else { - addBytes[8] = 1; - } - break; - case refTem: - case heatTem: - case autoTem: - case dehumTem: - addBytes[8] = 1; - addBytes[3] = (byte) state; - addBytes[4] = (byte) state; - addBytes[5] = (byte) state; - addBytes[6] = (byte) state; - addBytes[11] = (byte) state; - break; - case upTem: - addBytes[8] = 1; - addBytes[3] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[4] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[5] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[6] = (byte) ((airBytes[2] & 0xff) + state); - addBytes[11] = (byte) ((airBytes[2] & 0xff) + state); - break; - case downTem: - addBytes[8] = 1; - addBytes[3] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[4] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[5] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[6] = (byte) ((airBytes[2] & 0xff) - state); - addBytes[11] = (byte) ((airBytes[2] & 0xff) - state); - break; - case airMode: - addBytes[8] = 1; - addBytes[7] = (byte) (state * 16 + (airBytes[3] & 0xff)); - addBytes[9] = (byte) state; - break; - case airSpeed: - addBytes[8] = 1; - addBytes[7] = (byte) ((airBytes[1] & 0xff) * 16 + state); - addBytes[10] = (byte) state; - break; - } - return addBytes; + } else { addBytes[0] = (byte) newInfo.getChannelNum(); addBytes[1] = 0; @@ -247,53 +238,87 @@ addBytes[10] = 0; addBytes[11] = (byte) 28; addBytes[12] = 0; - switch (type) { - case airSwich://璁剧疆寮�鍏崇姸鎬� - if (state == airOff) { - addBytes[8] = 0; - } else { - addBytes[8] = 1; - } - break; - case refTem: - case heatTem: - case autoTem: - case dehumTem://璁剧疆娓╁害 - addBytes[8] = 1; - addBytes[3] = (byte) state; - addBytes[4] = (byte) state; - addBytes[5] = (byte) state; - addBytes[6] = (byte) state; - addBytes[11] = (byte) state; - break; - case upTem://鍗囨俯 - addBytes[8] = 1; - addBytes[3] = (byte) (28 + state); - addBytes[4] = (byte) (28 + state); - addBytes[5] = (byte) (28 + state); - addBytes[6] = (byte) (28 + state); - addBytes[11] = (byte) (28 + state); - break; - case downTem://闄嶆俯 - addBytes[8] = 1; - addBytes[3] = (byte) (28 - state); - addBytes[4] = (byte) (28 - state); - addBytes[5] = (byte) (28 - state); - addBytes[6] = (byte) (28 - state); - addBytes[11] = (byte) (28 - state); - break; - case airMode://璁剧疆绌鸿皟妯″紡 - addBytes[8] = 1; - addBytes[7] = (byte) (state * 16); - addBytes[9] = (byte) state; - break; - case airSpeed://璁剧疆椋庨�� - addBytes[8] = 1; - addBytes[7] = (byte) (state); - addBytes[10] = (byte) state; - break; - } + } + + switch (type) { + case airSwich: + if (state == airOff) { + addBytes[8] = 0; + } else { + addBytes[8] = 1; + } + break; + case refTem: + addBytes[8] = 1; + addBytes[3] = (byte) state; + addBytes[11] = (byte) state; + break; + case heatTem: + addBytes[8] = 1; + addBytes[4] = (byte) state; + addBytes[11] = (byte) state; + break; + case autoTem: + addBytes[8] = 1; + addBytes[5] = (byte) state; + addBytes[11] = (byte) state; + break; + case dehumTem: + addBytes[8] = 1; + addBytes[6] = (byte) state; + addBytes[11] = (byte) state; + break; + case upTem: + addBytes[8] = 1; + byte tempByte = (byte) ((airBytes[11] & 0xff) + state); + //鍒ゆ柇褰撳墠妯″紡 + if(addBytes[9] == 0){//鍒跺喎 + tempByte = (byte) ((airBytes[3] & 0xff) + state); + addBytes[3] = tempByte; + }else if(addBytes[9] == 1){//鍒剁儹 + tempByte = (byte) ((airBytes[4] & 0xff) + state); + addBytes[4] = tempByte; + }else if(addBytes[9] == 3){//鑷姩 + tempByte = (byte) ((airBytes[5] & 0xff) + state); + addBytes[5] = tempByte; + }else if(addBytes[9] == 4){//鎶芥箍 + tempByte = (byte) ((airBytes[6] & 0xff) + state); + addBytes[6] = tempByte; + } + addBytes[11] = tempByte; + break; + case downTem: + addBytes[8] = 1; + byte tempByte2 = (byte) ((airBytes[11] & 0xff) - state); + //鍒ゆ柇褰撳墠妯″紡 + if(addBytes[9] == 0){//鍒跺喎 + tempByte2 = (byte) ((airBytes[3] & 0xff) - state); + addBytes[3] = tempByte2; + }else if(addBytes[9] == 1){//鍒剁儹 + tempByte2 = (byte) ((airBytes[4] & 0xff) - state); + addBytes[4] = tempByte2; + }else if(addBytes[9] == 3){//鑷姩 + tempByte2 = (byte) ((airBytes[5] & 0xff) - state); + addBytes[5] = tempByte2; + }else if(addBytes[9] == 4){//鎶芥箍 + tempByte2 = (byte) ((airBytes[6] & 0xff) - state); + addBytes[6] = tempByte2; + } + addBytes[11] = tempByte2; + break; + case airMode: + addBytes[8] = 1; + addBytes[7] = (byte) (state * 16 + (airBytes[10] & 0xff)); + addBytes[9] = (byte) state; + break; + case airSpeed: + addBytes[8] = 1; + addBytes[7] = (byte) ((airBytes[9] & 0xff) * 16 + state); + addBytes[10] = (byte) state; + break; + } + return addBytes; } catch (Exception e) { e.printStackTrace(); @@ -301,185 +326,6 @@ } -} + } -// public static byte[] getRcuAirAddByte(AppliancesInfo info,int type, int arg2){ -// byte[] addBytes = new byte[9]; -// addBytes[4] = 1; -// byte[] curAirInfo = info.getArrCurState(); -// switch (info.getChannelNum()){ -// case 1: -// curAirInfo = HDLDeviceManager.air1Info; -// break; -// case 2: -// curAirInfo = HDLDeviceManager.air2Info; -// break; -// case 3: -// curAirInfo = HDLDeviceManager.air3Info; -// break; -// case 4: -// curAirInfo = HDLDeviceManager.air4Info; -// break; -// } -// -// byte airSwitch = curAirInfo[0]; -// byte aircurMode = curAirInfo[1]; -// byte airTem = curAirInfo[2]; -// byte aircurSpeed = curAirInfo[3]; -// byte aircurTem = curAirInfo[4]; -// byte airBAIFENG = curAirInfo[5]; -// -// addBytes[0] = (byte) info.getChannelNum(); -// addBytes[1] = airSwitch; -// switch (aircurMode){ -// case 0: -// addBytes[2] = airTem; -// break; -// case 1: -// addBytes[5] = airTem; -// break; -// case 2: -// break; -// case 3: -// addBytes[6] = airTem; -// break; -// } -// addBytes[3] = (byte) ((aircurMode << 4) | aircurSpeed); -// addBytes[4] = 1; -// addBytes[8] = airBAIFENG; -// switch (type){ -// case airSwich: -// if(arg2 == airOff){ -// addBytes[1] = 0; -// }else if(arg2 == airOn){ -// addBytes[1] = 1; -// } -// break; -// case refTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case airSpeed : -// int modifyLow; -// int height = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -// switch (arg2){ -// case airSpeedAuto: -// modifyLow = 0; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedHigh: -// modifyLow = 1; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedMid: -// modifyLow = 2; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// case airSpeedLow: -// modifyLow = 3; -// addBytes[3] = (byte)((height<<4)|modifyLow); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// break; -// case airMode: -// int modify; -// int low = (addBytes[3] & 0x0f);//鑾峰彇浣�4浣� -// switch (arg2){ -// case airModeRefTem: -// -// modify = 0; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeHeatTem: -// modify = 1; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeVen: -// modify = 2; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeAuto: -// modify = 3; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// case airModeDehum: -// modify = 4; -// addBytes[3] = (byte)((modify<<4)|low); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// break; -// case heatTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case autoTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case dehumTem: -// addBytes[2] = (byte) arg2; -// addBytes[5] = (byte) arg2; -// addBytes[6] = (byte) arg2; -// addBytes[7] = (byte) arg2; -// break; -// case upTem: -//// int height2 = ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -//// switch (height2){ -//// case 0: -//// addBytes[2] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 1: -//// addBytes[5] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 3: -//// addBytes[6] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// case 4: -//// addBytes[7] = (byte) (arg2 + (airTem & 0xFF)); -//// break; -//// } -// addBytes[2] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[5] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[6] = (byte) (arg2 + (airTem & 0xFF)); -// addBytes[7] = (byte) (arg2 + (airTem & 0xFF)); -// break; -// case downTem: -//// int height3= ((addBytes[3] & 0xf0) >> 4);//鑾峰彇楂�4浣� -//// switch (height3){ -//// case 0: -//// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 1: -//// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 3: -//// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// case 4: -//// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 ); -//// break; -//// } -// addBytes[2] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[5] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[6] = (byte) ((airTem & 0xFF)-arg2 ); -// addBytes[7] = (byte) ((airTem & 0xFF)-arg2 ); -// break; -// default: -// addBytes = new byte[]{fail}; -// break; -// } -// return addBytes; -// } } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java index 4a97001..3e6d3a9 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/GeothermalBackInfo.java @@ -49,8 +49,13 @@ this.gNightTemp = this.curState[6] & 0xFF; this.gLeaveTemp = this.curState[7] & 0xFF; this.gAutoTemp = this.curState[8] & 0xFF; - this.gCurrentTemp = this.curState[9] & 0xFF; - +// this.gCurrentTemp = this.curState[9] & 0xFF; + //褰撳墠娓╁害锛堢幆澧冩俯搴︼級 bit7 0=姝e�� 1=璐熷�� + if(((this.curState[9] & 0xFF) >> 7) > 0){ + this.gCurrentTemp = -(this.curState[9] & 0x7F); + }else{ + this.gCurrentTemp = this.curState[9] & 0x7F; + } } } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java index c35cd63..91ad04a 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java @@ -1255,6 +1255,26 @@ // } + /** + * 鑾峰彇HVAC绌鸿皟璁惧鐘舵�� + * @param info + */ + public static void getHVACDeviceStateFromNetwork(final AppliancesInfo info) { + if (info == null) { + return; + } + HDLDeviceManager.isGetDeviceStateSuccess = false; + switch (info.getDeviceType()) { + case HDLApConfig.TYPE_AC_HVAC: +// case HDLApConfig.TYPE_AC_PANEL: + //鍙戦�丠VAC鐘舵�佹暟鎹� + addSendData(info, new byte[]{(byte) info.getChannelNum()}, Configuration.STATE); + break; + default: + HDLLog.info("涓嶆槸HVAC绌鸿皟璁惧"); + break; + } + } /** * 鑾峰彇骞叉帴鐐逛紶鎰熷櫒妯″潡鐘舵�� diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java index 0888dc8..3124f53 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java @@ -10,6 +10,7 @@ import com.hdl.sdk.hdl_core.Config.Configuration; import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirCtrlBackInfo; +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirHVACBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.Parser.AirCtrlParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLAudio.HDLAudio; import com.hdl.sdk.hdl_core.HDLAppliances.HDLCommonSwitch.CommonSwitchBackInfo; @@ -32,6 +33,7 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.RcuLight; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.UdpDataBean; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirHVACFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchCtrlBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CommonSwitchStateBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; @@ -52,6 +54,7 @@ import com.hdl.sdk.hdl_core.Util.NetUtil.NetWorkUtil; import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; import com.hdl.sdk.hdl_core.Util.TransformUtil.DataConverseUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; import org.greenrobot.eventbus.EventBus; @@ -189,9 +192,12 @@ case Configuration.CURTAIN_CTRL_BACK_COMMAND: case Configuration.AIR_CTRL_BACK_COMMAND: case Configuration.LOGIC_CTRL_BACK_COMMAND: - case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: +// case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: case Configuration.FRESH_AIR_CTRL_BACK_COMMAND: //20190709鏂板 handleCtrlData(getDatas); + break; + case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: + handleHVACCtrlData(getDatas); break; case Configuration.LIGHT_RGB_CTRL_BACK_COMMAND: //2020-10-19鏂板 handleRGBCCTCtrlData(getDatas); @@ -241,7 +247,7 @@ case Configuration.SENSOR_STATE_BACK_COMMAND: handleSensorAnalogStateData(getDatas, true); break; - case Configuration.SENSOR_BROADCAST_COMMAND://浼犳劅鍣ㄦā鎷熼噺骞挎挱 + case Configuration.SENSOR_BROADCAST_COMMAND://2021-08-10 浼犳劅鍣ㄦā鎷熼噺骞挎挱 handleSensorAnalogStateData(getDatas, false); break; //鑾峰彇鏂伴璁惧鐘舵�� 20190709鏂板 @@ -254,7 +260,8 @@ break; case Configuration.AIR_HVAC_STATE_BACK_COMMAND: - handleRcuAirCastData(getDatas); +// handleRcuAirCastData(getDatas); + handleHVACStateData(getDatas);//2019-06-27 break; case Configuration.RCU_ROOM_CAST_COMMAND: handleRcuLightCastData(getDatas); @@ -1405,182 +1412,182 @@ } } - /** - * 澶勭悊RCU绌鸿皟骞挎挱娑堟伅 - * - * @param getDatas - */ - private static void handleRcuAirCastData(UdpDataBean getDatas) { - int count = getDatas.addBytes.length / 11; - - for (int airIndex = 0; airIndex < count; airIndex++) { - outter: - for (int indexI = 0, len = devicesDataList.size(); indexI < len; indexI++) { - if (devicesDataList.get(indexI).getSourceSubnetID() == getDatas.sourceSubnetID - && devicesDataList.get(indexI).getSourceDeviceID() == getDatas.sourceDeviceID - ) { - List<AppliancesInfo> infos = devicesDataList.get(indexI).getAppliancesInfoList(); - for (int indexJ = 0, len2 = infos.size(); indexJ < len2; indexJ++) { - if (infos.get(indexJ).getBigType() == Configuration.AIR_BIG_TYPE - && infos.get(indexJ).getDeviceType() != HDLApConfig.TYPE_AC_PANEL - && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) { - AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ); - if (appliancesInfo.getPort() != 0) { - byte[] oldAirInfo = appliancesInfo.getArrCurState(); - - if (oldAirInfo == null || oldAirInfo.length == 0) { - oldAirInfo = AirCtrlParser.getNewAcByte(); - } - - - handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo); - - oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11]; - - oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); - - - switch (oldAirInfo[0] & 0xff) { - case 0: - oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11]; - break; - case 1: - oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11]; - break; - case 3: - oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11]; - break; - case 4: - oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11]; - break; - - } - - oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); - oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11]; - oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11]; - devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); - - -// switch (getDatas.addBytes[airIndex * 11] & 0xff) { -// case 1: -// handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo); -// air1Info[0] = getDatas.addBytes[1 + 0 * 11]; +// /** +// * 澶勭悊RCU绌鸿皟骞挎挱娑堟伅 +// * +// * @param getDatas +// */ +// private static void handleRcuAirCastData(UdpDataBean getDatas) { +// int count = getDatas.addBytes.length / 11; +// +// for (int airIndex = 0; airIndex < count; airIndex++) { +// outter: +// for (int indexI = 0, len = devicesDataList.size(); indexI < len; indexI++) { +// if (devicesDataList.get(indexI).getSourceSubnetID() == getDatas.sourceSubnetID +// && devicesDataList.get(indexI).getSourceDeviceID() == getDatas.sourceDeviceID +// ) { +// List<AppliancesInfo> infos = devicesDataList.get(indexI).getAppliancesInfoList(); +// for (int indexJ = 0, len2 = infos.size(); indexJ < len2; indexJ++) { +// if (infos.get(indexJ).getBigType() == Configuration.AIR_BIG_TYPE +// && infos.get(indexJ).getDeviceType() != HDLApConfig.TYPE_AC_PANEL +// && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) { +// AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ); +// if (appliancesInfo.getPort() != 0) { +// byte[] oldAirInfo = appliancesInfo.getArrCurState(); +// +// if (oldAirInfo == null || oldAirInfo.length == 0) { +// oldAirInfo = AirCtrlParser.getNewAcByte(); +// } // // -// air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); +// handleAirCastData(getDatas, oldAirInfo, airIndex, appliancesInfo); +// +// oldAirInfo[0] = getDatas.addBytes[1 + 0 * 11]; +// +// oldAirInfo[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); // // -// switch (air1Info[0] & 0xff) { -// case 0: -// air1Info[2] = getDatas.addBytes[2 + 0 * 11]; -// break; -// case 1: -// air1Info[2] = getDatas.addBytes[6 + 0 * 11]; -// break; -// case 3: -// air1Info[2] = getDatas.addBytes[8 + 0 * 11]; -// break; -// case 4: -// air1Info[2] = getDatas.addBytes[9 + 0 * 11]; -// break; -// -// } -// -// air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); -// air1Info[4] = getDatas.addBytes[5 + 0 * 11]; -// air1Info[5] = getDatas.addBytes[10 + 0 * 11]; -//// HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]); -//// String arrString = "209a 闄勫姞鏁版嵁锛�"; -//// for (int i = 0; i < getDatas.addBytes.length; i++) { -//// arrString += (getDatas.addBytes[i] & 0xff) + ","; -//// } -//// HDLLog.info( arrString); -// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info); +// switch (oldAirInfo[0] & 0xff) { +// case 0: +// oldAirInfo[2] = getDatas.addBytes[2 + 0 * 11]; // break; -// case 2: -// handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo); -// air2Info[0] = getDatas.addBytes[1 + 1 * 11]; -// air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4); -// switch (air2Info[0] & 0xff) { -// case 0: -// air2Info[2] = getDatas.addBytes[2 + 1 * 11]; -// break; -// case 1: -// air2Info[2] = getDatas.addBytes[6 + 1 * 11]; -// break; -// case 3: -// air2Info[2] = getDatas.addBytes[8 + 1 * 11]; -// break; -// case 4: -// air2Info[2] = getDatas.addBytes[9 + 1 * 11]; -// break; -// -// } -// air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f); -// air2Info[4] = getDatas.addBytes[5 + 1 * 11]; -// air2Info[5] = getDatas.addBytes[10 + 1 * 11]; -// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info); +// case 1: +// oldAirInfo[2] = getDatas.addBytes[6 + 0 * 11]; // break; // case 3: -// handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo); -// air3Info[0] = getDatas.addBytes[1 + 2 * 11]; -// air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4); -// switch (air3Info[0] & 0xff) { -// case 0: -// air3Info[2] = getDatas.addBytes[2 + 2 * 11]; -// break; -// case 1: -// air3Info[2] = getDatas.addBytes[6 + 2 * 11]; -// break; -// case 3: -// air3Info[2] = getDatas.addBytes[8 + 2 * 11]; -// break; -// case 4: -// air3Info[2] = getDatas.addBytes[9 + 2 * 11]; -// break; -// } -// air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f); -// air3Info[4] = getDatas.addBytes[5 + 2 * 11]; -// air3Info[5] = getDatas.addBytes[10 + 2 * 11]; -// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info); +// oldAirInfo[2] = getDatas.addBytes[8 + 0 * 11]; // break; // case 4: -// handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo); -// air4Info[0] = getDatas.addBytes[1 + 3 * 11]; -// air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4); -// switch (air4Info[0] & 0xff) { -// case 0: -// air4Info[2] = getDatas.addBytes[2 + 3 * 11]; -// break; -// case 1: -// air4Info[2] = getDatas.addBytes[6 + 3 * 11]; -// break; -// case 3: -// air4Info[2] = getDatas.addBytes[8 + 3 * 11]; -// break; -// case 4: -// air4Info[2] = getDatas.addBytes[9 + 3 * 11]; -// break; -// } -// air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f); -// air4Info[4] = getDatas.addBytes[5 + 3 * 11]; -// air4Info[5] = getDatas.addBytes[10 + 3 * 11]; -// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info); +// oldAirInfo[2] = getDatas.addBytes[9 + 0 * 11]; // break; // // } - } - } - } - } - } - - - } - - - } +// +// oldAirInfo[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); +// oldAirInfo[4] = getDatas.addBytes[5 + 0 * 11]; +// oldAirInfo[5] = getDatas.addBytes[10 + 0 * 11]; +// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); +// +// +//// switch (getDatas.addBytes[airIndex * 11] & 0xff) { +//// case 1: +//// handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo); +//// air1Info[0] = getDatas.addBytes[1 + 0 * 11]; +//// +//// +//// air1Info[1] = (byte) ((getDatas.addBytes[3 + 0 * 11] & 0xf0) >> 4); +//// +//// +//// switch (air1Info[0] & 0xff) { +//// case 0: +//// air1Info[2] = getDatas.addBytes[2 + 0 * 11]; +//// break; +//// case 1: +//// air1Info[2] = getDatas.addBytes[6 + 0 * 11]; +//// break; +//// case 3: +//// air1Info[2] = getDatas.addBytes[8 + 0 * 11]; +//// break; +//// case 4: +//// air1Info[2] = getDatas.addBytes[9 + 0 * 11]; +//// break; +//// +//// } +//// +//// air1Info[3] = (byte) (getDatas.addBytes[3 + 0 * 11] & 0x0f); +//// air1Info[4] = getDatas.addBytes[5 + 0 * 11]; +//// air1Info[5] = getDatas.addBytes[10 + 0 * 11]; +////// HDLLog.info( "209a air1Info = " + air1Info[0] + " " + air1Info[1] + " " + air1Info[2] + " " + air1Info[3] + " " + air1Info[4] + " " + air1Info[5]); +////// String arrString = "209a 闄勫姞鏁版嵁锛�"; +////// for (int i = 0; i < getDatas.addBytes.length; i++) { +////// arrString += (getDatas.addBytes[i] & 0xff) + ","; +////// } +////// HDLLog.info( arrString); +//// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air1Info); +//// break; +//// case 2: +//// handleAirCastData(getDatas, air2Info, airIndex, appliancesInfo); +//// air2Info[0] = getDatas.addBytes[1 + 1 * 11]; +//// air2Info[1] = (byte) ((getDatas.addBytes[3 + 1 * 11] & 0xf0) >> 4); +//// switch (air2Info[0] & 0xff) { +//// case 0: +//// air2Info[2] = getDatas.addBytes[2 + 1 * 11]; +//// break; +//// case 1: +//// air2Info[2] = getDatas.addBytes[6 + 1 * 11]; +//// break; +//// case 3: +//// air2Info[2] = getDatas.addBytes[8 + 1 * 11]; +//// break; +//// case 4: +//// air2Info[2] = getDatas.addBytes[9 + 1 * 11]; +//// break; +//// +//// } +//// air2Info[3] = (byte) (getDatas.addBytes[3 + 1 * 11] & 0x0f); +//// air2Info[4] = getDatas.addBytes[5 + 1 * 11]; +//// air2Info[5] = getDatas.addBytes[10 + 1 * 11]; +//// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air2Info); +//// break; +//// case 3: +//// handleAirCastData(getDatas, air3Info, airIndex, appliancesInfo); +//// air3Info[0] = getDatas.addBytes[1 + 2 * 11]; +//// air3Info[1] = (byte) ((getDatas.addBytes[3 + 2 * 11] & 0xf0) >> 4); +//// switch (air3Info[0] & 0xff) { +//// case 0: +//// air3Info[2] = getDatas.addBytes[2 + 2 * 11]; +//// break; +//// case 1: +//// air3Info[2] = getDatas.addBytes[6 + 2 * 11]; +//// break; +//// case 3: +//// air3Info[2] = getDatas.addBytes[8 + 2 * 11]; +//// break; +//// case 4: +//// air3Info[2] = getDatas.addBytes[9 + 2 * 11]; +//// break; +//// } +//// air3Info[3] = (byte) (getDatas.addBytes[3 + 2 * 11] & 0x0f); +//// air3Info[4] = getDatas.addBytes[5 + 2 * 11]; +//// air3Info[5] = getDatas.addBytes[10 + 2 * 11]; +//// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air3Info); +//// break; +//// case 4: +//// handleAirCastData(getDatas, air4Info, airIndex, appliancesInfo); +//// air4Info[0] = getDatas.addBytes[1 + 3 * 11]; +//// air4Info[1] = (byte) ((getDatas.addBytes[3 + 3 * 11] & 0xf0) >> 4); +//// switch (air4Info[0] & 0xff) { +//// case 0: +//// air4Info[2] = getDatas.addBytes[2 + 3 * 11]; +//// break; +//// case 1: +//// air4Info[2] = getDatas.addBytes[6 + 3 * 11]; +//// break; +//// case 3: +//// air4Info[2] = getDatas.addBytes[8 + 3 * 11]; +//// break; +//// case 4: +//// air4Info[2] = getDatas.addBytes[9 + 3 * 11]; +//// break; +//// } +//// air4Info[3] = (byte) (getDatas.addBytes[3 + 3 * 11] & 0x0f); +//// air4Info[4] = getDatas.addBytes[5 + 3 * 11]; +//// air4Info[5] = getDatas.addBytes[10 + 3 * 11]; +//// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(air4Info); +//// break; +//// +//// } +// } +// } +// } +// } +// } +// +// +// } +// +// +// } /** @@ -2036,14 +2043,24 @@ case Configuration.AIR_BIG_TYPE: switch (infos.get(appPos).getLittleType()) { case 0: + byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; for (int i = 23; i < getDatas.addBytes.length; i++) { hvacBytes[i - 23] = getDatas.addBytes[i]; } - - HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� " + StringUtil.ByteArrToHex(hvacBytes, 0, hvacBytes.length)); - - devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes); + // hvacBytes * 绠�鏄撶紪绋嬫悳绱� 鐘舵�佹暟鎹産ytes鏍煎紡 + // * 0 寮�鍏崇姸鎬� + // * 1 妯″紡 + // * 2 娓╁害 + // * 3 椋庨�� + // * 4 褰撳墠瀹ゆ俯 + // * 5 鏄惁鎽嗛 + byte[] oldHvacBytes = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getArrCurState(); + //涓轰簡涓嶆敼鍙樺師鏉ュ叾浠栨ā寮忕殑娓╁害鏁版嵁锛岄渶瑕佽幏鍙栧師鏉ョ殑鐘舵�佷慨鏀瑰鐞� + byte[] newHvacBytes = AirCtrlParser.getNewAcByteWithE44B(hvacBytes, oldHvacBytes); +// HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� " + StringUtil.ByteArrToHex(hvacBytes, 0, hvacBytes.length)); +// HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPEnewhvacBytes锛� " + StringUtil.ByteArrToHex(newHvacBytes, 0, newHvacBytes.length)); + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(newHvacBytes); // switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) { // case 1: // if (air1Info == null) { @@ -2066,7 +2083,7 @@ // } // break; // -// } +// break; case 3: byte[] newBytes = new byte[getDatas.addBytes.length - 24 + 1]; @@ -2078,12 +2095,6 @@ } break; case Configuration.SENSOR_BIG_TYPE: -// String aa = "浼犳劅鍣ㄥ娉細"; -// for (int i = 0; i < getDatas.addBytes.length; i++) { -// aa += (getDatas.addBytes[i] & 0xff) + ","; -// } -// HDLLog.info( aa); - //浣跨敤骞茶妭鐐规寚浠ょ殑浼犳劅鍣� if (DeviceParser.getIfDryContactSensor(infos.get(appPos).getLittleType())) { //骞茶妭鐐逛紶鎰熷櫒锛岃鐗规畩澶勭悊淇敼鍥炶矾鍙� @@ -2099,18 +2110,30 @@ devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState); } else { - //鏍囧噯妯℃嫙閲忎紶鎰熷櫒 + //鏍囧噯妯℃嫙閲忎紶鎰熷櫒 2021-08-09 float curState; - if (getDatas.addBytes.length >= 28) { - curState = DataConverseUtil.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 24, 27)); - + if (getDatas.addBytes.length >= 26) { + curState = (float) ((getDatas.addBytes[24] & 0xff) * 256 + (getDatas.addBytes[25] & 0xff)); + //TVOC 鍜屾俯搴︿紶鎰熷櫒瑕佺壒娈婂鐞� + if (infos.get(appPos).getLittleType() == 5) {//TVOC + //TVOC鍥哄畾锛�2锛�10 ug/m3锛夋墍浠ヨ涔樹互10 鎵嶆槸ug/m3 + curState = curState * 10; + HDLLog.info("curStatecurState TVOC锛�" + curState); + } else if (infos.get(appPos).getLittleType() == 2) {//娓╁害 + //杞负Float + if (getDatas.addBytes.length >= 28) { + curState = HDLUtlis.byteArrayToFloatWithSign((byte) 3, getDatas.addBytes[24], getDatas.addBytes[25], getDatas.addBytes[26], getDatas.addBytes[27]); + HDLLog.info("curStatecurState temp锛�" + curState); + } + } } else { - curState = (float) (getDatas.addBytes[getDatas.addBytes.length - 1] & 0xff); + //鏍煎紡涓嶅锛岃祴鍊肩姸鎬佷负0 + curState = 0; } + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setCurState(curState); devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setIntCurState((int) curState); } - break; case Configuration.FRESH_AIR_BIG_TYPE://20190711鏂板 @@ -2312,6 +2335,12 @@ /** * 澶勭悊鍚勭浼犳劅鍣ㄦā鎷熼噺鐘舵�佹暟鎹� * 2021-08-05 + * 灏忕被 + * 2锛氭俯搴� + * 3锛氭箍搴� + * 5锛歍VOC + * 6锛歅M2.5 + * 7锛欳O2 * * @param getDatas */ @@ -2332,10 +2361,15 @@ isGetDeviceStateSuccess = true; } AppliancesInfo sensorInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); - float value = DataConverseUtil.byte2Float(Arrays.copyOfRange(getDatas.addBytes, 5, 8)); +// float value = HDLUtlis.byteArrayToFloat(Arrays.copyOfRange(getDatas.addBytes, 5, 8)); + float value = HDLUtlis.byteArrayToFloatWithSign(getDatas.addBytes[3], getDatas.addBytes[5], getDatas.addBytes[6], getDatas.addBytes[7], getDatas.addBytes[8]); + if (devicesDataList.get(i).getAppliancesInfoList().get(j).getLittleType() == 5) { + //TVOC鍥哄畾锛�2锛�0.01ug/m3锛夋墍浠ヨ闄や互100 鎵嶆槸寰厠/m3 + value = value / 100; + } devicesDataList.get(i).getAppliancesInfoList().get(j).setCurState(value); devicesDataList.get(i).getAppliancesInfoList().get(j).setIntCurState((int) value); - + HDLLog.info("curStatecurState ug锛�" + value); sensorInfo.setCurState(value); String unite = ""; @@ -2362,7 +2396,7 @@ unite = "LUX"; break; case HDLApConfig.TYPE_SENSOR_VOC: - unite = ""; + unite = "ug/m3"; break; case HDLApConfig.TYPE_SENSOR_PM_2_POINT_5: switch (getDatas.addBytes[4] & 0xff) { @@ -3093,4 +3127,77 @@ } + /** + * 澶勭悊HVAC 鎺у埗鍥炶皟 + * 2019-8-6 + * + * @param getDatas + */ + private static void handleHVACCtrlData(UdpDataBean getDatas) { + switch (getDatas.command) { + case Configuration.AIR_HVAC_CTRL_BACK_COMMAND: + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (getDatas.addBytes.length > 0) { + if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + + devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); + AppliancesInfo mHvacAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + AirHVACBackInfo info = new AirHVACBackInfo(mHvacAirInfo); + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); + EventBus.getDefault().post(new AirHVACFeedBackEvent(info, true)); + break outter; + } +// else { +// HDLLog.E("鎺у埗HVAC鐘舵�佸弽棣堟暟鎹紓甯�"); +// } + } + } + + break outter; + } + } + break; + } + + } + + /** + * 璇诲彇HVAC鐘舵�佸弽棣� + * + * @param getDatas + */ + private static void handleHVACStateData(UdpDataBean getDatas) { + outter: + for (int i = 0, len = devicesDataList.size(); i < len; i++) { + if (devicesDataList.get(i).getSourceSubnetID() == getDatas.sourceSubnetID + && devicesDataList.get(i).getSourceDeviceID() == getDatas.sourceDeviceID + ) { + List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); + for (int j = 0, len2 = infos.size(); j < len2; j++) { + if (infos.get(j).getBigType() == Configuration.AIR_BIG_TYPE + && infos.get(j).getDeviceType() == HDLApConfig.TYPE_AC_HVAC + && infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) {//2019-8-6 + + isGetDeviceStateSuccess = true; + devicesDataList.get(i).getAppliancesInfoList().get(j).setArrCurState(getDatas.addBytes); + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + break outter; + } else { + HDLLog.info("handleHVACStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + } + } + break outter; + } + } + } + + } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java new file mode 100644 index 0000000..a583833 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/AirHVACFeedBackEvent.java @@ -0,0 +1,25 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + + +import com.hdl.sdk.hdl_core.HDLAppliances.HDLAirCondition.AirHVACBackInfo; + +/** + * Created by JLChen on 2019/8/6 + */ +public class AirHVACFeedBackEvent { + AirHVACBackInfo mAirHVACBackInfo; + boolean isSuccess; + + public AirHVACFeedBackEvent(AirHVACBackInfo airHVACBackInfo, boolean isSuccess){ + this.mAirHVACBackInfo = airHVACBackInfo; + this.isSuccess = isSuccess; + } + + public AirHVACBackInfo getAirHVACBackInfo() { + return mAirHVACBackInfo; + } + + public boolean isSuccess() { + return isSuccess; + } +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java index af1d94d..182442c 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java @@ -429,7 +429,7 @@ if (littleType == 0) { appliancesInfo.setCtrlCommand(Configuration.AIR_HVAC_CTRL_COMMAND); appliancesInfo.setCtrlBackCommand(Configuration.AIR_HVAC_CTRL_BACK_COMMAND); -// appliancesInfo.setStateCommand(Configuration.AIR_HVAC_STATE_COMMAND); + appliancesInfo.setStateCommand(Configuration.AIR_HVAC_STATE_COMMAND); appliancesInfo.setStateBackCommand(Configuration.AIR_HVAC_STATE_BACK_COMMAND); } else { appliancesInfo.setCtrlCommand(Configuration.AIR_CTRL_COMMAND); @@ -659,11 +659,6 @@ appliancesInfo.setChannelNum(curChannelNum); appliancesInfo.setBigType(Configuration.SENSOR_BIG_TYPE); appliancesInfo.setLittleType(littleType); -// appliancesInfo.setCtrlCommand(Configuration.LOGIC_CTRL_COMMAND); -// appliancesInfo.setCtrlBackCommand(Configuration.LOGIC_CTRL_BACK_COMMAND); - -// appliancesInfo.setStateCommand(Configuration.SENSOR_STATE_COMMAND); -// appliancesInfo.setStateBackCommand(Configuration.SENSOR_STATE_BACK_COMMAND); appliancesInfo.setDeviceSubnetID(devicesData.getSourceSubnetID()); appliancesInfo.setDeviceDeviceID(devicesData.getSourceDeviceID()); appliancesInfo.setParentRemarks(parentRemarks); diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java index b019d3b..43099a7 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/DataConverseUtil.java @@ -15,4 +15,6 @@ float f2 = buf.getFloat(); return f2; } + + } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java index 514bda7..e46a12e 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java @@ -55,17 +55,26 @@ * @return */ public static float byteToFloat(byte b1, byte b2, byte b3, byte b4) { - byte[] mByte = new byte[4]; - mByte[0] = b1; - mByte[1] = b2; - mByte[2] = b3; - mByte[3] = b4; + byte[] mByte = new byte[]{b4, b3, b2, b1}; return byteArrayToFloat(mByte); } - - public static double byteToDouble(byte b1, byte b2, byte b3, byte b4) { - return b1 * 256 * 256 * 256 + b2 * 256 * 256 + b3 * 256 + b4; + /** + * 鏃犵鍙�4Byte鏁村舰 + */ + public static float byteToFloat_UnsignedInteger(byte b1, byte b2, byte b3, byte b4) { + return (b1 & 0xFF) * 256 * 256 * 256 + (b2 & 0xFF) * 256 * 256 + (b3 & 0xFF) * 256 + (b4 & 0xFF); + } + /** + * 鏈夌鍙�4Byte鏁村舰 + */ + public static float byteToFloat_SignedInteger(byte b1, byte b2, byte b3, byte b4) { + float mfloat = (b1 & 0x7F) * 256 * 256 * 256 + (b2 & 0xFF) * 256 * 256 + (b3 & 0xFF) * 256 + (b4 & 0xFF); + if(((b1 & 0xFF) >> 7) > 0){ + return -mfloat; + }else{ + return mfloat; + } } @@ -108,5 +117,30 @@ return getByteArray(intbits); } + /** + * byte[4]鏁扮粍 杞崲涓篺loat绫诲瀷 + * @param sign 鏁版嵁绫诲瀷 0淇濈暀 1鏃犵鍙�4Byte鏁村舰 2鏈夌鍙�4Byte鏁村舰 3Float褰紙浠B憋級 娉細灏忔暟鐐圭殑鐢ㄦ诞鐐硅〃绀猴紝鏁存暟涓嶈〃绀哄皬鏁扮偣 + * @param b1~b5 sign == 3 鐨勬椂鍊� 鏁版嵁鍊奸珮浣嶅湪鍓嶏紝浣庝綅鍦ㄥ悗 锛堟暟鎹粠鍚庡線鍓嶈杞斤紝渚嬪100鐨勫�硷紝搴旇鏃�0x00000064锛� + * @return + */ + public static float byteArrayToFloatWithSign(byte sign, byte b1, byte b2, byte b3, byte b4) { + try { + + if(sign == 1){//1鏃犵鍙�4Byte鏁村舰 + return byteToFloat_UnsignedInteger(b1, b2, b3, b4); + }else if(sign == 2){//2鏈夌鍙�4Byte鏁村舰 + return byteToFloat_SignedInteger(b1, b2, b3, b4); + }else if(sign == 3){//3Float褰紙浠B憋級 + byte[] mByte = new byte[]{b4, b3, b2, b1}; + return byteArrayToFloat(mByte); + }else{ + return byteToFloat_UnsignedInteger(b1, b2, b3, b4); + } + + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } } -- Gitblit v1.8.0