From db21de901bb1bbc6ec66b59e7b0766d0d2c5c6cc Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 16 七月 2019 13:54:44 +0800 Subject: [PATCH] 20190716 1.提供声必可SDK,部分数据处理调整; 2.演示DemoAPP,地热和新风页面调整; --- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java | 62 ++-- app/src/main/res/layout/activity_geothermal.xml | 4 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java | 23 + app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java | 71 ++++- hdl_core/src/main/java/com/hdl/sdk/hdl_core/Config/Configuration.java | 7 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java | 14 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java | 4 hdl_core/build.gradle | 6 hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java | 94 +++++++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java | 46 +-- README.md | 4 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 116 +++++++-- app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java | 1 /dev/null | 39 --- app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java | 2 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java | 15 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java | 10 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java | 60 +++- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java | 103 ++++---- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java | 26 + app/build.gradle | 11 21 files changed, 470 insertions(+), 248 deletions(-) diff --git a/README.md b/README.md index 283083e..fc98032 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,7 @@ 鎻愪緵鍚戝線SDK椤圭洰 +##Version 1.0.2 +1.鏂板鍦扮儹妯″潡鍜屾柊椋庣郴缁熸帶鍒跺拰璇诲彇鐘舵�佹帴鍙o紱 +2.鏂板鍦扮儹妯″潡鍜屾柊椋庣郴缁熸帶鍒舵紨绀洪〉闈紱 +3.targetSdkVersion 28锛� \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 9e8dba2..7e631d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { applicationId "com.hdl.sdk.hdl_sdk" minSdkVersion 17 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 - versionName "1.0" + versionName "1.0.1" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -16,12 +17,12 @@ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } -// buildToolsVersion '28.0.3' + } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28+' implementation 'com.android.support.constraint:constraint-layout:1.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java index 979c3fc..ba76b9f 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java @@ -62,7 +62,7 @@ initView(); initClickOnEvent(); - + HDLCommand.getDeviceState(appliancesInfo); } diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java index 3169827..12d84e4 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/FreshAirActivity.java @@ -1,6 +1,7 @@ package com.hdl.sdk.hdl_sdk.activity; +import android.app.ProgressDialog; import android.os.Bundle; import android.view.View; import android.widget.Button; @@ -34,6 +35,8 @@ private int airSpeedState; private int ctrlId; + private ProgressDialog proDialog; + /** * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true * @@ -61,6 +64,8 @@ @Override protected void onDestroy() { super.onDestroy(); + proDialog.dismiss(); + HDLLog.I("onDestroy: FreshAirActivity"); } private void initcurState() { @@ -73,7 +78,10 @@ btn_speed = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn_speed); btn_mode = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn_mode); - + proDialog = new ProgressDialog(this); + proDialog.setTitle("姝e湪鍙戦�佹帶鍒跺懡浠�..."); + proDialog.setMessage("璇疯�愬績绛夊緟"); + proDialog.onStart(); } private void initClickOnEvent() { @@ -81,6 +89,7 @@ btn_switch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = FreshAirParser.freshAirSwich; //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� if (airSwitchState == 0) { @@ -97,6 +106,7 @@ btn_speed.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = FreshAirParser.freshAirSpeed; switch (airSpeedState) { case 0: @@ -130,6 +140,7 @@ btn_mode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = FreshAirParser.freshAirMode; switch (airModeState) { case 0: @@ -142,7 +153,7 @@ break; case 2: //鑻ュ綋鍓嶆ā寮忔櫤鑳斤紝鍒欑偣鍑绘寜閽缃负瀹氭椂 - HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeAuto); + HDLCommand.freshAirCtrl(appliancesInfo, FreshAirParser.freshAirMode, FreshAirParser.freshAirModeTiming); break; case 3: //鑻ュ綋鍓嶆ā寮忓畾鏃讹紝鍒欑偣鍑绘寜閽缃负鎵嬪姩 @@ -218,13 +229,14 @@ @Subscribe(threadMode = ThreadMode.MAIN) public void onFreshAirFeedBackEventMain(FreshAirFeedBackEvent event) { + proDialog.dismiss(); if (event.getFreshAirBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() && event.getFreshAirBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getFreshAirBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() ) { //鍏堝垽鏂槸鍚﹁秴鏃� if (!event.isSuccess()) { - showToast("绌鸿皟鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + showToast("鏂伴鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); return; } @@ -245,12 +257,14 @@ } + //*********鏍规嵁闇�姹傛樉绀�********* message += "\n" + "瀹ゅ唴娓╁害锛�" + mFreshAirBackInfo.getInTemp(); message += "\n" + "瀹ゅ娓╁害锛�" + mFreshAirBackInfo.getOutTemp(); message += "\n" + "瀹ゅ唴婀垮害锛�" + mFreshAirBackInfo.getHumidty(); message += "\n" + "PM2.5锛�" + mFreshAirBackInfo.getInTemp(); message += "\n" + "TVOC锛�" + mFreshAirBackInfo.getInTemp(); message += "\n" + "CO2锛�" + mFreshAirBackInfo.getInTemp(); + //*********鏍规嵁闇�姹傛樉绀�********* mTextView.setText(message); showToast(message); @@ -260,6 +274,7 @@ @Subscribe(threadMode = ThreadMode.MAIN) public void onDeviceStateEventMain(DeviceStateEvent event) { + proDialog.dismiss(); if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() ) { @@ -278,15 +293,20 @@ return; } - message += "\n" + getSwichStateString(mFreshAirBackInfo.getIsOn()); - message += "\n" + getSpeedStateString(mFreshAirBackInfo.getFreshAirSpeed()); - message += "\n" + getModeStateString(mFreshAirBackInfo.getFreshAirMode()); - message += "\n" + "瀹ゅ唴娓╁害锛�" + mFreshAirBackInfo.getInTemp(); - message += "\n" + "瀹ゅ娓╁害锛�" + mFreshAirBackInfo.getOutTemp(); - message += "\n" + "瀹ゅ唴婀垮害锛�" + mFreshAirBackInfo.getHumidty(); - message += "\n" + "PM2.5锛�" + mFreshAirBackInfo.getInTemp(); - message += "\n" + "TVOC锛�" + mFreshAirBackInfo.getInTemp(); - message += "\n" + "CO2锛�" + mFreshAirBackInfo.getInTemp(); + if(mFreshAirBackInfo.getIsOn() == FreshAirParser.freshAirOn) { + message = getSwichStateString(mFreshAirBackInfo.getIsOn()); + message += "\n" + getSpeedStateString(mFreshAirBackInfo.getFreshAirSpeed()); + message += "\n" + getModeStateString(mFreshAirBackInfo.getFreshAirMode()); + + message += "\n" + "瀹ゅ唴娓╁害锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "瀹ゅ娓╁害锛�" + mFreshAirBackInfo.getOutTemp(); + message += "\n" + "瀹ゅ唴婀垮害锛�" + mFreshAirBackInfo.getHumidty(); + message += "\n" + "PM2.5锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "TVOC锛�" + mFreshAirBackInfo.getInTemp(); + message += "\n" + "CO2锛�" + mFreshAirBackInfo.getInTemp(); + }else { + message = getSwichStateString(mFreshAirBackInfo.getIsOn()); + } mTextView.setText(message); showToast(message); @@ -335,16 +355,16 @@ airSpeedState = mState; //鏇存柊褰撳墠椋庨�熺姸鎬� switch (mState) { case FreshAirParser.freshAirSpeedOff: - mStrState = " 椋庨�燂細鍏�"; + mStrState = "椋庨�燂細鍏�"; break; case FreshAirParser.freshAirSpeedLow: - mStrState = " 椋庨�燂細浣�"; + mStrState = "椋庨�燂細浣�"; break; case FreshAirParser.freshAirSpeedMid: - mStrState = " 椋庨�燂細涓�"; + mStrState = "椋庨�燂細涓�"; break; case FreshAirParser.freshAirSpeedHigh: - mStrState = " 椋庨�燂細楂�"; + mStrState = "椋庨�燂細楂�"; break; default: @@ -365,16 +385,16 @@ airModeState = mState; //鏇存柊妯″紡鐘舵�� switch (mState) { case FreshAirParser.freshAirModeManual: - mStrState = " 妯″紡锛氭墜鍔�"; + mStrState = "妯″紡锛氭墜鍔�"; break; case FreshAirParser.freshAirModeAuto: - mStrState = " 妯″紡锛氳嚜鍔�"; + mStrState = "妯″紡锛氳嚜鍔�"; break; case FreshAirParser.freshAirModeIntelligent: - mStrState = " 妯″紡锛氭櫤鑳�"; + mStrState = "妯″紡锛氭櫤鑳�"; break; case FreshAirParser.freshAirModeTiming: - mStrState = " 妯″紡锛氬畾鏃�"; + mStrState = "妯″紡锛氬畾鏃�"; break; default: 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 7a752f0..740955b 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 @@ -1,6 +1,7 @@ package com.hdl.sdk.hdl_sdk.activity; +import android.app.ProgressDialog; import android.os.Bundle; import android.text.TextUtils; import android.view.View; @@ -9,12 +10,12 @@ import android.widget.TextView; import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; -import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; 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.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; import com.hdl.sdk.hdl_sdk.R; import com.hdl.sdk.hdl_sdk.base.BaseActivity; @@ -37,7 +38,7 @@ private int gModeState; private int gTempState; private int ctrlId; - + private ProgressDialog proDialog; /** * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true * @@ -63,6 +64,13 @@ HDLCommand.getDeviceState(appliancesInfo); } + @Override + protected void onDestroy() { + super.onDestroy(); + proDialog.dismiss(); + HDLLog.I("onDestroy: GeothermalActivity"); + } + private void initcurState() { appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); } @@ -74,12 +82,17 @@ btn_temp = findViewById(R.id.btn_temp); tempEditText = findViewById(R.id.et_temp); + proDialog = new ProgressDialog(this); + proDialog.setTitle("姝e湪鍙戦�佹帶鍒跺懡浠�..."); + proDialog.setMessage("璇疯�愬績绛夊緟"); + proDialog.onStart(); } private void initClickOnEvent() { btn_switch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = GeothermalParser.gSwich; //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� if (gSwitchState == 0) { @@ -97,6 +110,7 @@ btn_mode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = GeothermalParser.gMode; switch (gModeState) { case 1: @@ -146,11 +160,10 @@ showToast("娓╁害璁剧疆鑼冨洿涓猴細16~35鎽勬皬搴�(鈩�)"); return; } - + proDialog.show(); switch (gModeState) { case 1: - //褰撳墠鍦扮儹妯″紡涓烘櫘閫� HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//鏅�氭俯搴� ctrlId = GeothermalParser.gNormalTemp; @@ -171,10 +184,14 @@ ctrlId = GeothermalParser.gLeaveTemp; break; case 5: + proDialog.dismiss(); //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� - showToast("鑷姩妯″紡涓嶈兘鎺у埗娓╁害"); + showToast("鑷姩妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); break; default: + proDialog.dismiss(); + //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� + showToast("鏈煡妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); break; } @@ -191,9 +208,9 @@ GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(appliancesInfo, false); String stringState = ""; - if (mGeothermalBackInfo.getIsOn() == 0) { + if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOff) { stringState = "鍦扮儹妯″潡锛氬叧闂�"; - } else if (mGeothermalBackInfo.getIsOn() == 1) { + } else if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) { stringState = "鍦扮儹妯″潡锛氭墦寮�"; stringState += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); @@ -227,10 +244,10 @@ String mStrState = "鏈煡"; gSwitchState = mState; //鏇存柊寮�鍏崇姸鎬� switch (mState) { - case FreshAirParser.freshAirOn: + case GeothermalParser.gSwichOn: mStrState = "鍦扮儹妯″潡锛氭墦寮�"; break; - case FreshAirParser.freshAirOff: + case GeothermalParser.gSwichOff: mStrState = "鍦扮儹妯″潡锛氬叧闂�"; break; @@ -253,19 +270,19 @@ gModeState = mState; //鏇存柊妯″紡鐘舵�� switch (mState) { case GeothermalParser.gModeNormal: - mStrState = " 妯″紡锛氭櫘閫�"; + mStrState = "妯″紡锛氭櫘閫�"; break; case GeothermalParser.gModeDay: - mStrState = " 妯″紡锛氱櫧澶�"; + mStrState = "妯″紡锛氱櫧澶�"; break; case GeothermalParser.gModeNight: - mStrState = " 妯″紡锛氬闂�"; + mStrState = "妯″紡锛氬闂�"; break; case GeothermalParser.gModeLeave: - mStrState = " 妯″紡锛氱寮�"; + mStrState = "妯″紡锛氱寮�"; break; case GeothermalParser.gModeAuto: - mStrState = " 妯″紡锛氳嚜鍔�"; + mStrState = "妯″紡锛氳嚜鍔�"; break; default: @@ -277,13 +294,19 @@ @Subscribe(threadMode = ThreadMode.MAIN) public void onGeothermalFeedBackEventMain(GeothermalFeedBackEvent event) { + proDialog.dismiss(); if (event.getGeothermalBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() && event.getGeothermalBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getGeothermalBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() ) { //鍏堝垽鏂槸鍚﹁秴鏃� - if (!event.isSuccess()) { + if (event.getStatusID() == EventCode.FAILURE) { showToast("鍦扮儹妯″潡鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); + return; + } + + if (event.getStatusID() == EventCode.DATAEMPTY) { + showToast("鍦扮儹妯″潡,杩斿洖鏁版嵁涓虹┖"); return; } @@ -326,6 +349,7 @@ @Subscribe(threadMode = ThreadMode.MAIN) public void onDeviceStateEventMain(DeviceStateEvent event) { + proDialog.dismiss(); if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() ) { @@ -345,12 +369,17 @@ return; } - message += "\n" + getSwichStateString(mGeothermalBackInfo.getIsOn()); - message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); - message += "\n" + "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); - message += "\n" + "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); - message += "\n" + "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); - message += "\n" + "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); + 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); diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java index 29fa5ed..a1936d2 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java @@ -95,7 +95,6 @@ HDLCommand.getHomeDevices(MainActivity.this); proDia.show(); - } }); diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLUtlis.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLUtlis.java deleted file mode 100644 index 08ccee5..0000000 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/utlis/HDLUtlis.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hdl.sdk.hdl_sdk.utlis; - -import android.content.Context; -import android.os.Build; - -import java.math.BigDecimal; - -/** - * Created by JLChen on 2019/7/4 - */ -public class HDLUtlis { - - /** - * 灏唎bject杞负Integer绫诲瀷 - * @param object - * @return - */ - public static Integer getIntegerByObject(Object object){ - Integer in = null; - if(object!=null){ - if(object instanceof Integer){ - in = (Integer)object; - }else if(object instanceof String){ - in = Integer.parseInt((String)object); - }else if(object instanceof Double){ - in = (int)((double)object); - }else if(object instanceof Float){ - in = (int)((float)object); - }else if(object instanceof BigDecimal){ - in = ((BigDecimal)object).intValue(); - }else if(object instanceof Long){ - in = ((Long)object).intValue(); - } - } - return in; - } - - -} diff --git a/app/src/main/res/layout/activity_geothermal.xml b/app/src/main/res/layout/activity_geothermal.xml index 8596b09..1ea914d 100644 --- a/app/src/main/res/layout/activity_geothermal.xml +++ b/app/src/main/res/layout/activity_geothermal.xml @@ -26,7 +26,9 @@ <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="50dp"> + android:layout_height="50dp" + android:focusable="true" + android:focusableInTouchMode="true"> <Button android:id="@+id/btn_temp" android:layout_width="wrap_content" diff --git a/hdl_core/build.gradle b/hdl_core/build.gradle index 8601e16..fb4b6ab 100644 --- a/hdl_core/build.gradle +++ b/hdl_core/build.gradle @@ -2,10 +2,10 @@ //apply plugin: 'com.novoda.bintray-release' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { minSdkVersion 17 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0.2" @@ -28,7 +28,7 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28+' api 'org.greenrobot:eventbus:3.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' 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 d595e8b..6a84fd1 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 @@ -22,6 +22,11 @@ */ public static final int FRESH_AIR_BIG_TYPE = 19; + //鏀寔鐨勫皬绫� + public static final int FRESH_AIR_LITTLE_TYPE_0 = 0; + public static final int GEOTHERMAL_LITTLE_TYPE_0 = 0; + + //灏忕被 鍏堜笉鍋氬垎绫� // public static final int AIR_LITTLE_TYPE = 0; @@ -147,8 +152,6 @@ /** * RCU 閰嶇疆鏁版嵁 */ - - //鍥哄畾RCU鍙戦�佺鍙� public static final int RCU_SEND_PORT = 6006; //鍥哄畾RCU鎺ユ敹绔彛 diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java index a4fdca6..6e986f5 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/FreshAirBackInfo.java @@ -1,7 +1,7 @@ package com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; -import com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; import java.io.Serializable; @@ -47,12 +47,12 @@ this.freshAirMode = this.curState[3] & 0xFF; this.enableValue1 = this.curState[4] & 0xFF; this.enableValue2 = this.curState[5] & 0xFF; - this.mInTemp = StringUtil.byteToFloat(this.curState[6], this.curState[7], this.curState[8], this.curState[9]); - this.mOutTemp = StringUtil.byteToFloat(this.curState[10], this.curState[11], this.curState[12], this.curState[13]); - this.mHumidty = StringUtil.byteToFloat(this.curState[14], this.curState[15], this.curState[16], this.curState[17]); - this.mPM25 = StringUtil.byteToFloat(this.curState[18], this.curState[19], this.curState[20], this.curState[21]); - this.mTVOC = StringUtil.byteToFloat(this.curState[22], this.curState[23], this.curState[24], this.curState[25]); - this.mCO2 = StringUtil.byteToFloat(this.curState[26], this.curState[27], this.curState[28], this.curState[29]); + this.mInTemp = HDLUtlis.byteToFloat(this.curState[6], this.curState[7], this.curState[8], this.curState[9]); + this.mOutTemp = HDLUtlis.byteToFloat(this.curState[10], this.curState[11], this.curState[12], this.curState[13]); + this.mHumidty = HDLUtlis.byteToFloat(this.curState[14], this.curState[15], this.curState[16], this.curState[17]); + this.mPM25 = HDLUtlis.byteToFloat(this.curState[18], this.curState[19], this.curState[20], this.curState[21]); + this.mTVOC = HDLUtlis.byteToFloat(this.curState[22], this.curState[23], this.curState[24], this.curState[25]); + this.mCO2 = HDLUtlis.byteToFloat(this.curState[26], this.curState[27], this.curState[28], this.curState[29]); } } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java index 4c9b432..88e7b29 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLFreshAir/Parser/FreshAirParser.java @@ -33,37 +33,43 @@ return new byte[]{fail}; } - AppliancesInfo newInfo = null; - byte[] freshAirBytes = null; + try { + AppliancesInfo newInfo = null; + byte[] freshAirBytes = null; - outter: - for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { - if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() - && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) { - for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) { - if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.AIR_BIG_TYPE - && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() != HDLApConfig.TYPE_AC_PANEL - && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { - newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); - if (newInfo.getFeedbackState() == null) { - newInfo.setFeedbackState(new byte[30]); + outter: + for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { + if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() + && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) { + for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) { + if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.FRESH_AIR_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_FRESH_AIR + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getFeedbackState() == null) { + newInfo.setFeedbackState(new byte[30]); + } + freshAirBytes = newInfo.getFeedbackState(); + break outter; } - break outter; - } + } } } - } - - freshAirBytes = newInfo.getFeedbackState(); - - if (freshAirBytes != null && freshAirBytes.length >= 4) { byte[] addBytes = new byte[4]; - addBytes[0] = (byte) appliancesInfo.getChannelNum(); - addBytes[1] = freshAirBytes[1]; - addBytes[2] = freshAirBytes[2]; - addBytes[3] = freshAirBytes[3]; + if (freshAirBytes != null && freshAirBytes.length >= 4) { + addBytes[0] = (byte) appliancesInfo.getChannelNum(); + addBytes[1] = freshAirBytes[1]; + addBytes[2] = freshAirBytes[2]; + addBytes[3] = freshAirBytes[3]; + + } else { + addBytes[0] = (byte) appliancesInfo.getChannelNum(); + addBytes[1] = 0;//鍙戦�侀粯璁ゅ弬鏁� + addBytes[2] = 0; + addBytes[3] = 0; + } switch (type) { case freshAirSwich: @@ -74,16 +80,18 @@ } break; case freshAirSpeed: + addBytes[1] = 1;//鎵撳紑鎿嶄綔 addBytes[2] = (byte) state; - break; case freshAirMode: + addBytes[1] = 1;//鎵撳紑鎿嶄綔 addBytes[3] = (byte) state; break; } return addBytes; - } else { - return null; + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; } } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java index 870ec37..f099917 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLGeothermal/Parser/GeothermalParser.java @@ -18,56 +18,66 @@ public static final int gMode = 4; //妯″紡 - public static final int gModeNormal = 0;//鏅�氭ā寮� - public static final int gModeDay = 1;//鐧藉ぉ妯″紡 - public static final int gModeNight = 2;//澶滈棿妯″紡 - public static final int gModeLeave = 3;//绂诲紑妯″紡 - public static final int gModeAuto = 4;//鑷姩妯″紡 + public static final int gModeNormal = 1;//鏅�氭ā寮� + public static final int gModeDay = 2;//鐧藉ぉ妯″紡 + public static final int gModeNight = 3;//澶滈棿妯″紡 + public static final int gModeLeave = 4;//绂诲紑妯″紡 + public static final int gModeAuto = 5;//鑷姩妯″紡 public static final int gNormalTemp = 5;//鏅�氭ā寮忔俯搴� public static final int gDayTemp = 6;//鐧藉ぉ妯″紡娓╁害 public static final int gNightTemp = 7;//澶滈棿妯″紡娓╁害 public static final int gLeaveTemp = 8;//绂诲紑妯″紡娓╁害 -// [鍥炶矾锛屽紑鍏崇姸鎬侊紝娓╁害绫诲瀷锛屾ā寮忥紝鏅�氭俯搴︼紝鐧藉ぉ娓╁害锛屽闂存俯搴︼紝绂诲紑娓╁害锛岃嚜鍔ㄦ俯搴︼紝褰撳墠娓╁害] + // feedbackState [鍥炶矾锛屽紑鍏崇姸鎬侊紝娓╁害绫诲瀷锛屾ā寮忥紝鏅�氭俯搴︼紝鐧藉ぉ娓╁害锛屽闂存俯搴︼紝绂诲紑娓╁害锛岃嚜鍔ㄦ俯搴︼紝褰撳墠娓╁害] public static byte[] getGeothermalAddByte(AppliancesInfo appliancesInfo, int type, int state) { - AppliancesInfo newInfo = null; - byte[] airBytes = null; - outter: - for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { - if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() - && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) { - for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) { - if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.AIR_BIG_TYPE - && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() != HDLApConfig.TYPE_AC_PANEL - && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { - newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); - if (newInfo.getFeedbackState() == null) { - newInfo.setFeedbackState(new byte[10]); + try { + AppliancesInfo newInfo = null; + byte[] airBytes = null; + outter: + for (int i = 0; i < HDLDeviceManager.devicesDataList.size(); i++) { + if (appliancesInfo.getDeviceSubnetID() == HDLDeviceManager.devicesDataList.get(i).getSourceSubnetID() + && appliancesInfo.getDeviceDeviceID() == HDLDeviceManager.devicesDataList.get(i).getSourceDeviceID()) { + for (int j = 0; j < HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().size(); j++) { + if (HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType() == Configuration.GEOTHERMAL_BIG_TYPE + && HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType() == HDLApConfig.TYPE_GEOTHERMAL_MODULE + && appliancesInfo.getChannelNum() == HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j).getChannelNum()) { + newInfo = HDLDeviceManager.devicesDataList.get(i).getAppliancesInfoList().get(j); + if (newInfo.getFeedbackState() == null) { + newInfo.setFeedbackState(new byte[10]); + } + airBytes = newInfo.getFeedbackState(); + break outter; } - break outter; - } + } } } - } - airBytes = newInfo.getFeedbackState(); - - if (airBytes != null && airBytes.length >= 10) { byte[] addBytes = new byte[10]; - addBytes[0] = (byte) newInfo.getChannelNum(); - addBytes[1] = airBytes[1]; - addBytes[2] = 0; - addBytes[3] = airBytes[3]; - addBytes[4] = airBytes[4]; - addBytes[5] = airBytes[5]; - addBytes[6] = airBytes[6]; - addBytes[7] = airBytes[7]; - addBytes[8] = airBytes[8]; - addBytes[9] = 0; - addBytes[10] = 0; - + if (airBytes != null && airBytes.length >= 10) { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = airBytes[1]; + addBytes[2] = 0; + addBytes[3] = airBytes[3]; + addBytes[4] = airBytes[4]; + addBytes[5] = airBytes[5]; + addBytes[6] = airBytes[6]; + addBytes[7] = airBytes[7]; + addBytes[8] = 0; + addBytes[9] = 0; + } else { + addBytes[0] = (byte) newInfo.getChannelNum(); + addBytes[1] = 0; + addBytes[2] = 0; + addBytes[3] = 1; + addBytes[4] = 30; + addBytes[5] = 30; + addBytes[6] = 30; + addBytes[7] = 30; + addBytes[8] = 0; + addBytes[9] = 0; + } switch (type) { case gSwich: @@ -79,7 +89,7 @@ break; case gMode: addBytes[1] = 1; - addBytes[3] = (byte) state; + addBytes[3] = (byte) state; break; case gNormalTemp: addBytes[1] = 1;//鎵撳紑 @@ -99,21 +109,14 @@ break; } return addBytes; - } else { - return null; + + + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; } } - - - - - - - - - - } 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 0b6f7b8..6324e04 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 @@ -21,12 +21,14 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LogicFeedBackEvent; import com.hdl.sdk.hdl_core.Util.LogUtil.HDLLog; import com.hdl.sdk.hdl_core.Util.SPUtil.SPUtils; +import com.hdl.sdk.hdl_core.Util.TransformUtil.HDLUtlis; import org.greenrobot.eventbus.EventBus; @@ -399,7 +401,7 @@ if (!HDLDeviceManager.isGeothermalCtrlSuccess) { GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); mGeothermalBackInfo.setAppliancesInfo(info); - EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, false)); + EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE)); } } }, 5000); @@ -640,7 +642,9 @@ && info.getLittleType() == infos.get(j).getLittleType() && info.getChannelNum() == infos.get(j).getChannelNum() ) { - curState = (int) infos.get(j).getCurState(); +// curState = (int) infos.get(j).getCurState();//鏃� + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + curState = HDLUtlis.getIntegerByObject(infos.get(j).getCurState()); break outter; } @@ -670,7 +674,9 @@ && info.getChannelNum() == infos.get(j).getChannelNum() ) { //杩欓噷搴旇鏄淇鐨勶紝鏆傛椂鏈壘鍒般�� - switch ((int) infos.get(j).getCurState()) { + //20190712瑙e喅寮哄埗杞崲int绫诲瀷闂�� + int state = HDLUtlis.getIntegerByObject(infos.get(j).getCurState()); + switch (state) { case -1: curState = 0; break; @@ -681,7 +687,8 @@ curState = 2; break; default: - curState = (int) infos.get(j).getCurState(); +// curState = (int) infos.get(j).getCurState(); + curState = state; 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 2e581fe..721b46f 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 @@ -27,6 +27,7 @@ import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.AirFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.CurtainFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.FreshAirFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.LightFeedBackEvent; @@ -169,8 +170,11 @@ case Configuration.CURTAIN_STATE_BACK_COMMAND: case Configuration.AIR_STATE_BACK_COMMAND: case Configuration.SENSOR_STATE_BACK_COMMAND: - case Configuration.FRESH_AIR_STATE_BACK_COMMAND://20190709鏂板 handleStateData(getDatas); + break; + //鑾峰彇鏂伴璁惧鐘舵�� 20190709鏂板 + case Configuration.FRESH_AIR_STATE_BACK_COMMAND: + handleFreshAirStateData(getDatas); break; //鑾峰彇鍦扮儹璁惧鐘舵�� case Configuration.GEOTHERMAL_MODULE_STATE_BACK_COMMAND: @@ -1040,26 +1044,32 @@ List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { - if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { - if(getDatas.addBytes.length >= 8){ - byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); - if(getBytes.length < 10){ - getBytes = new byte[10]; + if(getDatas.addBytes.length > 0) { + if (infos.get(j).getChannelNum() == (getDatas.addBytes[0] & 0xFF)) { + if (getDatas.addBytes.length >= 8) { + byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); + if (getBytes == null || getBytes.length < 10) { + getBytes = new byte[10]; + } + System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 8);//鎺у埗鍦扮儹鐘舵�佸弽棣堬紝鍙彇鍓�8浣嶆暟鎹� + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); + AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); + + GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); + isGeothermalCtrlSuccess = true; + EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS)); + } else { + +// AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); +// GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); +// isGeothermalCtrlSuccess = true; +// EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.DATAEMPTY)); + + HDLLog.E("鎺у埗鍦扮儹鐘舵�佸弽棣堟暟鎹紓甯�"); } - System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 8);//鎺у埗鍦扮儹鐘舵�佸弽棣堬紝鍙彇鍓�8浣嶆暟鎹� - devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getBytes); - AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); - - GeothermalBackInfo info = new GeothermalBackInfo(mInfo , true); - isGeothermalCtrlSuccess = true; - EventBus.getDefault().post(new GeothermalFeedBackEvent(info, true)); - }else{ - HDLLog.E("鎺у埗鍦扮儹鐘舵�佸弽棣堟暟鎹紓甯�"); + break outter; } - - break outter; } - } } } @@ -1844,6 +1854,28 @@ 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鏂板 + switch (infos.get(appPos).getLittleType()) { + case Configuration.FRESH_AIR_LITTLE_TYPE_0: + byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; + for (int i = 23; i < getDatas.addBytes.length; i++) { + hvacBytes[i - 23] = getDatas.addBytes[i]; + } + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setFeedbackState(hvacBytes); + break; + } + break; + case Configuration.GEOTHERMAL_BIG_TYPE://20190711鏂板 + switch (infos.get(appPos).getLittleType()) { + case Configuration.GEOTHERMAL_LITTLE_TYPE_0: + byte[] hvacBytes = new byte[getDatas.addBytes.length - 23]; + for (int i = 23; i < getDatas.addBytes.length; i++) { + hvacBytes[i - 23] = getDatas.addBytes[i]; + } + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setFeedbackState(hvacBytes); + break; + } + break; default: HDLLog.info("鏈壘鍒版绫诲瀷璁惧锛�" + infos.get(appPos).getBigType()); break; @@ -1910,6 +1942,7 @@ ) { List<AppliancesInfo> infos = devicesDataList.get(i).getAppliancesInfoList(); for (int j = 0, len2 = infos.size(); j < len2; j++) { + HDLLog.info("HDL big:锛�"+devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()); switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getBigType()) { case Configuration.LIGTH_BIG_TYPE: isGetDeviceStateSuccess = true; @@ -2157,23 +2190,48 @@ HDLLog.info("鍙戦�佷紶鎰熷櫒閫氱煡鏇存柊"); EventBus.getDefault().post(new SensorStateBackInfo(sensorInfo, true, unite)); break; - case Configuration.FRESH_AIR_BIG_TYPE://20190709鏂板 - isGetDeviceStateSuccess = true; - devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); - - EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); - - break; default: HDLLog.info("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷"); break; } - break outter; +// break outter; } break outter; } } } + + /** + * 澶勭悊鏂伴璁惧鐘舵�佹暟鎹� + * 20190710鏂板 + * @param getDatas + */ + private static void handleFreshAirStateData(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++) { + switch (devicesDataList.get(i).getAppliancesInfoList().get(j).getDeviceType()) { + case HDLApConfig.TYPE_FRESH_AIR: + isGetDeviceStateSuccess = true; + devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); + EventBus.getDefault().post(new DeviceStateEvent(devicesDataList.get(i).getAppliancesInfoList().get(j), true)); + + break; + default: + HDLLog.info("handleFreshAirStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + break; + } + + } + break outter; + } + } + } + /** * 澶勭悊鍦扮儹璁惧鐘舵�佹暟鎹� @@ -2193,7 +2251,7 @@ if(getDatas.addBytes.length >= 10) { byte[] getBytes = devicesDataList.get(i).getAppliancesInfoList().get(j).getFeedbackState(); - if (getBytes.length < 10) { + if (getBytes == null || getBytes.length < 10) { getBytes = new byte[10]; } System.arraycopy(getDatas.addBytes, 0, getBytes, 0, 10);//20190710鏌ヨ鍦扮儹鐘舵�佸弽棣堬紝鍙彇鍓�10浣嶆暟鎹� @@ -2206,10 +2264,10 @@ break; default: - HDLLog.info("handle state 娌℃湁鎵惧埌鍖归厤绫诲瀷"); + HDLLog.info("handleGeothermalStateData 娌℃湁鎵惧埌鍖归厤绫诲瀷"); break; } - break outter; + } break outter; } diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java index dd85682..3f26a0e 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java @@ -39,6 +39,8 @@ * @param sendDatas */ public static void sendData(final Crc sendDatas) { +// HDLLog.info("HDLsendData锛� "+ StringUtil.ByteArrToHex(sendDatas.GetSendBytes(),0, sendDatas.GetSendBytes().length)); + // sendTestCMD(sendDatas.GetSendBytes(), HDLTest.SEND_TEST_PORT); new Thread(new Runnable() { @@ -335,6 +337,8 @@ return; } +// HDLLog.info("HDL ReceiveBytes锛� "+ StringUtil.ByteArrToHex(receiveBytes,0, receiveBytes.length)); + //鏍¢獙鏄惁涓篐DL 鏁版嵁 byte[] hdlDataVerify = new byte[10]; System.arraycopy(receiveBytes, 4, hdlDataVerify, 0, 10); diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java new file mode 100644 index 0000000..568171d --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/EventCode.java @@ -0,0 +1,10 @@ +package com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent; + +/** + * Created by JLChen on 2019/7/15 + */ +public class EventCode { + public static final int SUCCESS = 0; + public static final int FAILURE = -1;//澶辫触瓒呮椂 + public static final int DATAEMPTY = -2;//鏁版嵁涓虹┖ +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java index d70de83..a372f6c 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/EventBusEvent/GeothermalFeedBackEvent.java @@ -7,21 +7,35 @@ * 鍦扮儹妯″潡 */ public class GeothermalFeedBackEvent { - GeothermalBackInfo mGeothermalBackInfo; +// boolean isSuccess; - boolean isSuccess; + int mStatusID; - public GeothermalFeedBackEvent( GeothermalBackInfo geothermalBackInfo, boolean isSuccess){ + public GeothermalFeedBackEvent( GeothermalBackInfo geothermalBackInfo, int mStatusID){ this.mGeothermalBackInfo = geothermalBackInfo; - this.isSuccess = isSuccess; + this.mStatusID = mStatusID; } public GeothermalBackInfo getGeothermalBackInfo() { return mGeothermalBackInfo; } - public boolean isSuccess() { - return isSuccess; + public int getStatusID() { + return mStatusID; } + + +// public GeothermalFeedBackEvent( GeothermalBackInfo geothermalBackInfo, boolean isSuccess){ +// this.mGeothermalBackInfo = geothermalBackInfo; +// this.isSuccess = isSuccess; +// } +// +// public GeothermalBackInfo getGeothermalBackInfo() { +// return mGeothermalBackInfo; +// } +// +// 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 90a070a..6e673ad 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 @@ -104,6 +104,7 @@ * @return */ private static boolean isWantData(int bigType, int littleType) { +// HDLLog.info("isWantData锛歜igType锛�" + bigType + "littleType锛�" + littleType); boolean isWant; switch (bigType) { case Configuration.LIGTH_BIG_TYPE: @@ -190,6 +191,26 @@ case Configuration.GLOBAL_LOGIC_BIG_TYPE: switch (littleType) { case 0: + isWant = true; + break; + default: + isWant = false; + break; + } + break; + case Configuration.GEOTHERMAL_BIG_TYPE://20190711 鏂板 + switch (littleType) { + case Configuration.GEOTHERMAL_LITTLE_TYPE_0: + isWant = true; + break; + default: + isWant = false; + break; + } + break; + case Configuration.FRESH_AIR_BIG_TYPE: + switch (littleType) { + case Configuration.FRESH_AIR_LITTLE_TYPE_0: isWant = true; break; default: @@ -574,7 +595,7 @@ */ private static void parseGeothermalData(int littleType, AppliancesInfo appliancesInfo, DevicesData devicesData, String parentRemarks, int channelNum, int port, String ipAddress) { switch (littleType) { - case 0: + case Configuration.GEOTHERMAL_LITTLE_TYPE_0: appliancesInfo.setDeviceName("鍦扮儹妯″潡"); appliancesInfo.setDeviceType(HDLApConfig.TYPE_GEOTHERMAL_MODULE); break; 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 new file mode 100644 index 0000000..ed18c79 --- /dev/null +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/HDLUtlis.java @@ -0,0 +1,94 @@ +package com.hdl.sdk.hdl_core.Util.TransformUtil; + +import java.math.BigDecimal; + +/** + * Created by JLChen on 2019/7/4 + */ +public class HDLUtlis { + + /** + * 灏唎bject杞负Integer绫诲瀷 + * + * @param object + * @return + */ + public static Integer getIntegerByObject(Object object) { + Integer in = 0; + if (object != null) { + if (object instanceof Integer) { + in = (Integer) object; + } else if (object instanceof String) { + in = Integer.parseInt((String) object); + } else if (object instanceof Double) { + in = (int) ((double) object); + } else if (object instanceof Float) { + in = (int) ((float) object); + } else if (object instanceof BigDecimal) { + in = ((BigDecimal) object).intValue(); + } else if (object instanceof Long) { + in = ((Long) object).intValue(); + } + } + return in; + } + + /** + * 4 byte 杞崲涓篺loat绫诲瀷 + * + * @param b1 + * @param b2 + * @param b3 + * @param b4 + * @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; + return byteArrayToFloat(mByte); + } + + /** + * byte[4]鏁扮粍 杞崲涓篺loat绫诲瀷 + * + * @param arr 闀垮害涓�4 + * @return + */ + public static float byteArrayToFloat(byte[] arr) { + try { + return Float.intBitsToFloat(getInt(arr)); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 杩炵画4涓瓧鑺傝幏寰椾竴涓猧nt + * + * @param arr + * @return int + */ + public static int getInt(byte[] arr) { + return (0xff000000 & (arr[0] << 24)) | + (0x00ff0000 & (arr[1] << 16)) | + (0x0000ff00 & (arr[2] << 8)) | + (0x000000ff & arr[3]); + } + + /** + * float杞崲涓篵yte[4]鏁扮粍 + * + * @param f + * @return + */ + public static byte[] getByteArray(float f) { + int intbits = Float.floatToIntBits(f);//灏唂loat閲岄潰鐨勪簩杩涘埗涓茶В閲婁负int鏁存暟 + return getByteArray(intbits); + } + + +} diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java index 1a66699..6e81c1c 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/Util/TransformUtil/StringUtil.java @@ -85,38 +85,7 @@ } - 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; - return byteArrayToFloat(mByte); - } - // 浠巄yte鏁扮粍鐨刬ndex澶勭殑杩炵画4涓瓧鑺傝幏寰椾竴涓猧nt - public static int getInt(byte[] arr) { - return (0xff000000 & (arr[0] << 24)) | - (0x00ff0000 & (arr[1] << 16)) | - (0x0000ff00 & (arr[2] << 8)) | - (0x000000ff & arr[3]); - } - - // float杞崲涓篵yte[4]鏁扮粍 - public static byte[] getByteArray(float f) { - int intbits = Float.floatToIntBits(f);//灏唂loat閲岄潰鐨勪簩杩涘埗涓茶В閲婁负int鏁存暟 - return getByteArray(intbits); - } - - // 浠巄yte鏁扮粍鐨刬ndex澶勭殑杩炵画4涓瓧鑺傝幏寰椾竴涓猣loat - public static float byteArrayToFloat(byte[] arr) { - try { - return Float.intBitsToFloat(getInt(arr)); - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - } // private byte[] formatStyleHDLResponse(String responsePart1, String responsePart2, int maxLen) throws UnsupportedEncodingException { // String responsePart3 = HDL_END_STR; @@ -191,5 +160,20 @@ // return; // } + //------------------------------------------------------- + //瀛楄妭鏁扮粍杞浆hex瀛楃涓诧紝鍙�夐暱搴� + public static String ByteArrToHex(byte[] inBytArr, int offset, int byteCount) { + StringBuilder strBuilder = new StringBuilder(); + int j = byteCount; + for (int i = offset; i < j; i++) { + strBuilder.append(Byte2Hex(Byte.valueOf(inBytArr[i]))); + } + return strBuilder.toString(); + } + //------------------------------------------------------- + //1瀛楄妭杞�2涓狧ex瀛楃 + public static String Byte2Hex(Byte inByte) { + return String.format("%02x", new Object[]{inByte}).toUpperCase(); + } } -- Gitblit v1.8.0