From 4f841eac608f6f22a573b4f7ed713679e89c2e5b Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期一, 30 九月 2019 13:47:49 +0800 Subject: [PATCH] 2019-9-30 1.修改方案,解决不支持控制5台以上空调问题。 --- app/src/main/java/com/hdl/sdk/hdl_sdk/activity/MainActivity.java | 93 +++++ hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLAppliances/HDLAirCondition/Parser/AirCtrlParser.java | 253 +++++++++----- hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Parser/DeviceParser.java | 8 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlActivity.java | 2 app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java | 2 app/src/main/res/values/strings.xml | 2 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLCommand.java | 80 ++-- app/src/main/res/layout/activity_main.xml | 23 + hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java | 16 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLUdpCore.java | 2 hdl_core/build.gradle | 4 hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Core/HDLDeviceManager.java | 524 ++++++++++++++++-------------- 12 files changed, 621 insertions(+), 388 deletions(-) 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 4a09520..25d2d99 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 @@ -630,7 +630,7 @@ @Override public void onClick(View view) { String tempStr = airTempEd.getText().toString(); - if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) { + if (TextUtils.isEmpty(tempStr)) { showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�"); return; } 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 f3a4b01..f474c9a 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 @@ -150,7 +150,7 @@ public void onClick(View view) { String tempStr = tempEditText.getText().toString(); - if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) { + if (TextUtils.isEmpty(tempStr)) { showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�"); return; } 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 a1936d2..6c3e53b 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 @@ -14,12 +14,16 @@ import android.widget.TextView; import android.widget.Toast; +import com.hdl.sdk.hdl_core.Config.Configuration; +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.Bean.DevicesData; import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.BgmInfoEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DevicesInfoEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.ThirdPartyBgmInfoEvent; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.WarningInfoEvent; +import com.hdl.sdk.hdl_sdk.R; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -33,6 +37,7 @@ public class MainActivity extends AppCompatActivity { private Button btn, btn2; + private Button btn_get_all,btn_on_all, btn_off_all; private TextView tv; private EditText editText; private List<DevicesData> devicesDatas; @@ -40,12 +45,12 @@ private ArrayAdapter<String> adapter; private ProgressDialog proDia; private ListView listView; - + private List<AppliancesInfo> airList = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(com.hdl.sdk.hdl_sdk.R.layout.activity_main); + setContentView(R.layout.activity_main); HDLCommand.init(this); // /**閰嶇疆鏄惁寮�鍚疭DK鎵撳嵃鏃ュ織锛岄粯璁や负鎵撳紑*/ // HDLCommand.setHDLLogOpen(false);// @@ -57,17 +62,22 @@ initView(); setOnClick(); - +// hideTestButton(); } private void initView() { - btn = findViewById(com.hdl.sdk.hdl_sdk.R.id.btn); - btn2 = findViewById(com.hdl.sdk.hdl_sdk.R.id.get); - tv = findViewById(com.hdl.sdk.hdl_sdk.R.id.tv); - editText = findViewById(com.hdl.sdk.hdl_sdk.R.id.edt); + btn = findViewById(R.id.btn); + btn2 = findViewById(R.id.get); + + btn_get_all = findViewById(R.id.btn_get_all); + btn_on_all = findViewById(R.id.btn_on_all); + btn_off_all = findViewById(R.id.btn_off_all); + + tv = findViewById(R.id.tv); + editText = findViewById(R.id.edt); editText.setText("172.168.188.100"); adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, listString); - listView = findViewById(com.hdl.sdk.hdl_sdk.R.id.listView1); + listView = findViewById(R.id.listView1); proDia = new ProgressDialog(MainActivity.this); proDia.setTitle("姝e湪鑾峰彇鏁版嵁..."); proDia.setMessage("璇疯�愬績绛夊緟"); @@ -109,6 +119,27 @@ } + } + }); + + btn_get_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getAllAirList(); + } + }); + + btn_on_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendAll(true); + } + }); + + btn_off_all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + sendAll(false); } }); } @@ -219,4 +250,50 @@ } + private void hideTestButton(){ + btn_get_all.setVisibility(View.GONE); + btn_on_all.setVisibility(View.GONE); + btn_off_all.setVisibility(View.GONE); + } + + private void getAllAirList(){ + airList.clear(); + if(devicesDatas == null || devicesDatas.size() == 0) { + showToast("娌℃湁璁惧"); + return; + } + for (int j = 0; j < devicesDatas.size(); j++) { + DevicesData mDevicesData = devicesDatas.get(j); + List<AppliancesInfo> appliancesInfos = mDevicesData.getAppliancesInfoList(); + for (int i = 0; i < appliancesInfos.size(); i++) { + if (appliancesInfos.get(i).getBigType() == Configuration.AIR_BIG_TYPE) { + airList.add(appliancesInfos.get(i)); + } + } + } + + String mes = "鍏辫幏寰楋細" + airList.size() + " 鍙扮┖璋�"; + showToast(mes); + } + + private void sendAll(Boolean bOn){ + if(airList == null || airList.size() == 0) { + showToast("娌℃湁璁惧"); + return; + } + for (int j = 0; j < airList.size(); j++) { + AppliancesInfo info = airList.get(j); + if(bOn){ + HDLCommand.airCtrl(info, AirCtrlParser.airSwich, AirCtrlParser.airOn); + }else { + HDLCommand.airCtrl(info, AirCtrlParser.airSwich, AirCtrlParser.airOff); + } + + } + + } + + private void showToast(String text) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); + } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 79e7906..5879771 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -26,6 +26,26 @@ android:layout_height="wrap_content" android:text="鎼滅储瀹跺眳璁惧" /> + <Button + android:id="@+id/btn_get_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="鑾峰彇鎵�鏈夌┖璋�" /> + <Button + android:id="@+id/btn_on_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="寮�鍚墍鏈夌┖璋�" /> + + <Button + android:id="@+id/btn_off_all" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + android:text="鍏抽棴鎵�鏈夌┖璋�" /> + </LinearLayout> <LinearLayout @@ -33,18 +53,21 @@ android:layout_height="wrap_content" android:orientation="vertical" android:focusable="true" + android:focusableInTouchMode="true"> <EditText android:id="@+id/edt" android:layout_width="match_parent" android:layout_height="wrap_content" + android:visibility="gone" android:hint="鑻ヤ娇鐢ㄩ厭搴楁悳绱紝璇疯緭鍏ラ厭搴梚p鍦板潃" /> <Button android:id="@+id/get" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:visibility="gone" android:text="鎼滅储閰掑簵璁惧" /> </LinearLayout> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9000487..788d204 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ <resources> <string name="app_name">HDL_SDK</string> - <string name="app_version">hdl_lib_v1.0.2.2.20190723_beta</string> + <string name="app_version">hdl_lib_v1.6.2.20190929_beta3</string> </resources> diff --git a/hdl_core/build.gradle b/hdl_core/build.gradle index 0fdf4e1..20a763d 100644 --- a/hdl_core/build.gradle +++ b/hdl_core/build.gradle @@ -6,8 +6,8 @@ defaultConfig { minSdkVersion 17 targetSdkVersion 28 - versionCode 2 - versionName "1.0.2" + versionCode 1 + versionName "1.0.4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 b2f4f1c..b31e4db 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 @@ -120,114 +120,179 @@ return addBytes; } + /** + * 鐢熸垚榛樿鏁版嵁 + * + * @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; + return airBytes; + } + public static byte[] getAcAddByte(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); - switch (newInfo.getChannelNum()) { - case 1: - airBytes = HDLDeviceManager.air1Info; - break; - case 2: - airBytes = HDLDeviceManager.air2Info; - break; - case 3: - airBytes = HDLDeviceManager.air3Info; - break; - case 4: - airBytes = HDLDeviceManager.air4Info; - break; - default: - airBytes = new byte[6]; - break; + 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.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.getArrCurState() == null || newInfo.getArrCurState().length != 6) { + newInfo.setArrCurState(getNewAcByte()); + } + airBytes = newInfo.getArrCurState(); + break outter; } - if (newInfo.getArrCurState() == null) { - newInfo.setArrCurState(new byte[6]); - } - break outter; + } - } } - } - if (airBytes != null && airBytes.length >= 6) { byte[] addBytes = new byte[13]; - 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]; + if (airBytes != null && airBytes.length >= 6) { + 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]; - switch (type) { - case airSwich: - if (state == airOff) { - addBytes[8] = 0; - } else { + 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; - } - 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; + 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; + addBytes[2] = (byte) 28; + addBytes[3] = (byte) 28; + addBytes[4] = (byte) 28; + addBytes[5] = (byte) 28; + addBytes[6] = (byte) 28; + addBytes[7] = 0; + addBytes[8] = 1; + addBytes[9] = 0; + 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; + } } return addBytes; - } else { - return null; + } catch (Exception e) { + e.printStackTrace(); + return new byte[]{fail}; } - } + +} // public static byte[] getRcuAirAddByte(AppliancesInfo info,int type, int arg2){ // byte[] addBytes = new byte[9]; diff --git a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java index 726e26b..079c91d 100644 --- a/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java +++ b/hdl_core/src/main/java/com/hdl/sdk/hdl_core/HDLDeviceManger/Bean/AppliancesInfo.java @@ -30,8 +30,8 @@ private LogicMode logicMode;//閫昏緫妯″潡鐗规湁 private int physicsChannelNum;//RCU 鐏厜鐗规湁 private byte[] feedbackState;//鐘舵�佸弽棣堣褰曟暟鎹� 20190709鏂板 - private int intCurState; + private String deviceKey; public int getIntCurState() { return intCurState; @@ -201,6 +201,20 @@ this.feedbackState = feedbackState; } + public String getDeviceKey() { + if (deviceKey == null) { + deviceKey = "K" + this.bigType + + "-" + this.littleType + + "-" + this.deviceSubnetID + + "-" + this.deviceDeviceID + + "-" + this.channelNum; + } + return deviceKey; + } + + public void setDeviceKey(String deviceKey) { + this.deviceKey = deviceKey; + } @Override public String toString() { 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 63bf0e3..2a44bd2 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 @@ -135,7 +135,8 @@ * @param state */ public static void lightCtrl(final AppliancesInfo info, int state) { - HDLDeviceManager.isLightCtrlSuccess = false; +// HDLDeviceManager.isLightCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (lightCtrlFailTimer != null) { lightCtrlFailTimer.cancel(); lightCtrlFailTimer = null; @@ -179,7 +180,7 @@ lightCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isLightCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { LightCtrlBackInfo lightCtrlBackInfo = new LightCtrlBackInfo(); lightCtrlBackInfo.setAppliancesInfo(info); lightCtrlBackInfo.setChannelNum(info.getChannelNum()); @@ -197,7 +198,8 @@ * @param state */ public static void curtainCtrl(final AppliancesInfo info, int state) { - HDLDeviceManager.isCurtainCtrlSuccess = false; +// HDLDeviceManager.isCurtainCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (curtainCtrlFailTimer != null) { curtainCtrlFailTimer.cancel(); curtainCtrlFailTimer = null; @@ -227,7 +229,7 @@ curtainCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isCurtainCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { CurtainCtrlBackInfo curtainCtrlBackInfo = new CurtainCtrlBackInfo(); curtainCtrlBackInfo.setAppliancesInfo(info); curtainCtrlBackInfo.setNum(info.getChannelNum()); @@ -255,7 +257,8 @@ * @param state */ public static void airCtrl(final AppliancesInfo info, int type, int state) { - HDLDeviceManager.isACCtrlSuccess = false; +// HDLDeviceManager.isACCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (acCtrlFailTimer != null) { acCtrlFailTimer.cancel(); acCtrlFailTimer = null; @@ -280,7 +283,7 @@ acCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isACCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(info); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, false)); @@ -304,7 +307,9 @@ * @param info */ public static void logicCtrl(final AppliancesInfo info) { - HDLDeviceManager.isSceneCtrlSuccess = false; +// HDLDeviceManager.isSceneCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); + if (info.getBigType() == Configuration.LOGIC_BIG_TYPE || info.getBigType() == Configuration.GLOBAL_LOGIC_BIG_TYPE) { if (info.getLogicMode() == null) { @@ -324,7 +329,7 @@ sceneCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isSceneCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { HDLLog.info("閫昏緫鎺у埗澶辫触"); LogicCtrlBackInfo logicCtrlBackInfo = new LogicCtrlBackInfo(); logicCtrlBackInfo.setAppliancesInfo(info); @@ -348,7 +353,8 @@ * @param state 2019-07-09 */ public static void freshAirCtrl(final AppliancesInfo info, int type, int state) { - HDLDeviceManager.isFreshAirCtrlSuccess = false; +// HDLDeviceManager.isFreshAirCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (freshAirCtrlFailTimer != null) { freshAirCtrlFailTimer.cancel(); freshAirCtrlFailTimer = null; @@ -360,7 +366,7 @@ freshAirCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isFreshAirCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { FreshAirBackInfo mFreshAirBackInfo = new FreshAirBackInfo(); mFreshAirBackInfo.setAppliancesInfo(info); EventBus.getDefault().post(new FreshAirFeedBackEvent(mFreshAirBackInfo, false)); @@ -385,7 +391,8 @@ * @param state 2019-07-10 */ public static void geothermalCtrl(final AppliancesInfo info, int type, int state) { - HDLDeviceManager.isGeothermalCtrlSuccess = false; +// HDLDeviceManager.isGeothermalCtrlSuccess = false; + HDLDeviceManager.setDeviceCtrlSuccessStateWithInfo(info, false); if (geothermalCtrlFailTimer != null) { geothermalCtrlFailTimer.cancel(); geothermalCtrlFailTimer = null; @@ -398,7 +405,7 @@ geothermalCtrlFailTimer.schedule(new TimerTask() { @Override public void run() { - if (!HDLDeviceManager.isGeothermalCtrlSuccess) { + if (!HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info)) { GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(); mGeothermalBackInfo.setAppliancesInfo(info); EventBus.getDefault().post(new GeothermalFeedBackEvent(mGeothermalBackInfo, EventCode.FAILURE)); @@ -921,7 +928,7 @@ sendCycleTimer.schedule(new TimerTask() { @Override public void run() { - if (sendDatas.count >= 3) { + if (sendDatas.count >= 4) { sendCycleTimer.cancel(); } else { // HDLLog.info("鎺у埗鍙戦�佺"+sendDatas.count+ "娆�"); @@ -931,29 +938,32 @@ sendDatas.isCtrlSuccess = HDLDeviceManager.isGetDeviceStateSuccess; } else if (type == Configuration.CONTROL) { sendDatas.command = info.getCtrlCommand(); - switch (info.getBigType()) { - case Configuration.LIGTH_BIG_TYPE: - sendDatas.isCtrlSuccess = HDLDeviceManager.isLightCtrlSuccess; - break; - case Configuration.CURTAIN_BIG_TYPE: - sendDatas.isCtrlSuccess = HDLDeviceManager.isCurtainCtrlSuccess; - break; - case Configuration.AIR_BIG_TYPE: - sendDatas.isCtrlSuccess = HDLDeviceManager.isACCtrlSuccess; - break; - case Configuration.LOGIC_BIG_TYPE: - sendDatas.isCtrlSuccess = HDLDeviceManager.isSceneCtrlSuccess; - break; - case Configuration.GEOTHERMAL_BIG_TYPE://20190710鏂板 - sendDatas.isCtrlSuccess = HDLDeviceManager.isGeothermalCtrlSuccess; - break; - case Configuration.FRESH_AIR_BIG_TYPE://20190710鏂板 - sendDatas.isCtrlSuccess = HDLDeviceManager.isFreshAirCtrlSuccess; - break; + HDLLog.info("getDeviceKey锛� " + info.getDeviceKey()); + sendDatas.isCtrlSuccess = HDLDeviceManager.getDeviceCtrlSuccessStateWithInfo(info); - default: - sendDatas.isCtrlSuccess = false; - } +// switch (info.getBigType()) { +// case Configuration.LIGTH_BIG_TYPE: +// sendDatas.isCtrlSuccess = HDLDeviceManager.isLightCtrlSuccess; +// break; +// case Configuration.CURTAIN_BIG_TYPE: +// sendDatas.isCtrlSuccess = HDLDeviceManager.isCurtainCtrlSuccess; +// break; +// case Configuration.AIR_BIG_TYPE: +// sendDatas.isCtrlSuccess = HDLDeviceManager.isACCtrlSuccess; +// break; +// case Configuration.LOGIC_BIG_TYPE: +// sendDatas.isCtrlSuccess = HDLDeviceManager.isSceneCtrlSuccess; +// break; +// case Configuration.GEOTHERMAL_BIG_TYPE://20190710鏂板 +// sendDatas.isCtrlSuccess = HDLDeviceManager.isGeothermalCtrlSuccess; +// break; +// case Configuration.FRESH_AIR_BIG_TYPE://20190710鏂板 +// sendDatas.isCtrlSuccess = HDLDeviceManager.isFreshAirCtrlSuccess; +// break; +// +// default: +// sendDatas.isCtrlSuccess = false; +// } } if (!sendDatas.isCtrlSuccess) { cusSendCommand(sendDatas.command, info.getDeviceSubnetID(), info.getDeviceDeviceID(), sendDatas.addBytes, info.getPort(), info.getIpAddress()); 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 8fb85bf..3203374 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 @@ -47,6 +47,7 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ConcurrentHashMap; import static com.hdl.sdk.hdl_core.Util.TransformUtil.StringUtil.byte2String; @@ -67,27 +68,23 @@ public static List<RcuLight> rcuLightList = new ArrayList<>(); public static List<RcuCurtain> rcuCurtainList = new ArrayList<>(); public static boolean isLogicCtrl = false; + public static ConcurrentHashMap<String, Boolean> ctrlSuccessStateHashMap = new ConcurrentHashMap<>();//2019-8-2 - public static byte[] air1Info = null; - public static byte[] air2Info = null; - public static byte[] air3Info = null; - public static byte[] air4Info = null; +// public static byte[] air1Info = null; +// public static byte[] air2Info = null; +// public static byte[] air3Info = null; +// public static byte[] air4Info = null; + // air4Info[寮�鍏崇姸鎬侊紝妯″紡锛岃缃俯搴︼紝椋庨�燂紝褰撳墠娓╁害锛屾槸鍚︽憜椋� ]; public static boolean isGetRcuIpSuccess = false; - - public static boolean isLightCtrlSuccess = false; //鍒ゆ柇鐏厜鏄惁鎺у埗鎴愬姛 - - public static boolean isCurtainCtrlSuccess = false; //鍒ゆ柇绐楀笜鏄惁鎺у埗鎴愬姛 - - public static boolean isACCtrlSuccess = false; //鍒ゆ柇绌鸿皟鏄惁鎺у埗鎴愬姛 - - public static boolean isSceneCtrlSuccess = false; //鍒ゆ柇鍦烘櫙鏄惁鎺у埗鎴愬姛 - public static boolean isGetDeviceStateSuccess = false; //鍒ゆ柇鑾峰彇璁惧鐘舵�佹槸鍚︽帶鍒舵垚鍔� - public static boolean isFreshAirCtrlSuccess = false; //鍒ゆ柇鏂伴绯荤粺鏄惁鎺у埗鎴愬姛 - - public static boolean isGeothermalCtrlSuccess = false; //鍒ゆ柇鍦扮儹妯″潡鏄惁鎺у埗鎴愬姛 +// public static boolean isLightCtrlSuccess = false; //鍒ゆ柇鐏厜鏄惁鎺у埗鎴愬姛 +// public static boolean isCurtainCtrlSuccess = false; //鍒ゆ柇绐楀笜鏄惁鎺у埗鎴愬姛 +// public static boolean isACCtrlSuccess = false; //鍒ゆ柇绌鸿皟鏄惁鎺у埗鎴愬姛 +// public static boolean isSceneCtrlSuccess = false; //鍒ゆ柇鍦烘櫙鏄惁鎺у埗鎴愬姛 +// public static boolean isFreshAirCtrlSuccess = false; //鍒ゆ柇鏂伴绯荤粺鏄惁鎺у埗鎴愬姛 +// public static boolean isGeothermalCtrlSuccess = false; //鍒ゆ柇鍦扮儹妯″潡鏄惁鎺у埗鎴愬姛 /** @@ -506,7 +503,8 @@ info.setBrightness(getDatas.addBytes[2] & 0xFF); // info.setChannelCount(getDatas.AddBytes[3] & 0xFF); // info.setDeviceChannelCount(getDatas.AddBytes[4] & 0xFF); - isLightCtrlSuccess = true; +// isLightCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LightFeedBackEvent(info, true)); break outter; } @@ -547,7 +545,8 @@ info1.setBrightness(getDatas.addBytes[2] & 0xFF); info1.setChannelCount(getDatas.addBytes[3] & 0xFF); info1.setDeviceChannelCount(getDatas.addBytes[4] & 0xFF); - isLightCtrlSuccess = true; +// isLightCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LightFeedBackEvent(info1, true)); break outter; } @@ -642,7 +641,8 @@ curtainCtrlBackInfo.setRemarks(curtainInfo.getRemarks()); curtainCtrlBackInfo.setParentRemarks(curtainInfo.getParentRemarks()); curtainCtrlBackInfo.setAppliancesInfo(curtainInfo); - isCurtainCtrlSuccess = true; +// isCurtainCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); if (curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_GLYSTRO || curtainInfo.getDeviceType() == HDLApConfig.TYPE_CURTAIN_ROLLER) { @@ -694,7 +694,8 @@ // 濡傛灉鏈夊涓┖璋冮潰鏉匡紝杩欏皢浼氬嚭閿� AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(infos.get(j)); - isACCtrlSuccess = true; +// isACCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); if ((getDatas.addBytes[0] & 0xFF) == AirCtrlParser.airMode) { airCtrlBackInfo.setCurState(new byte[]{getDatas.addBytes[0], getDatas.addBytes[1]}); byte[] airCurState = devicesDataList.get(i).getAppliancesInfoList().get(j).getArrCurState(); @@ -810,33 +811,35 @@ int indexI = devIndex; int indexJ = appIndex; - final byte[] oldAirInfo; - switch (getDatas.addBytes[0] & 0xFF) { - case 1: - oldAirInfo = air1Info; - break; - case 2: - oldAirInfo = air2Info; - break; - case 3: - oldAirInfo = air3Info; - break; - case 4: - oldAirInfo = air4Info; - break; - default: - oldAirInfo = new byte[1]; - break; - } + byte[] oldAirInfo = airInfo.getArrCurState(); +// switch (getDatas.addBytes[0] & 0xFF) { +// case 1: +// oldAirInfo = air1Info; +// break; +// case 2: +// oldAirInfo = air2Info; +// break; +// case 3: +// oldAirInfo = air3Info; +// break; +// case 4: +// oldAirInfo = air4Info; +// break; +// default: +// oldAirInfo = new byte[1]; +// break; +// } byte[] newAirInfo = getDatas.addBytes; byte[] curAirInfo = new byte[]{0}; boolean isModeChange = false; if (oldAirInfo == null || oldAirInfo.length == 0) { - return; + oldAirInfo = AirCtrlParser.getNewAcByte(); + } + setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); for (int oldAirInedx = 0; oldAirInedx < oldAirInfo.length; oldAirInedx++) { if (oldAirInedx == 0) { - if (oldAirInfo[0] != newAirInfo[8]) { +// if (oldAirInfo[0] != newAirInfo[8]) {//2019 鍘绘帀鐩稿悓寮�鍏崇姸鎬佸垽鏂�,瑙e喅寮�鐘舵�佷笅,璋冪敤寮�鍛戒护鐘舵�佷笅,涓嶅仠閲嶅彂闂 oldAirInfo[0] = newAirInfo[8]; curAirInfo = new byte[]{AirCtrlParser.airSwich, newAirInfo[8]}; if (curAirInfo.length > 1) { @@ -845,11 +848,12 @@ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(airInfo); airCtrlBackInfo.setCurState(curAirInfo); - isACCtrlSuccess = true; +// isACCtrlSuccess = true; +// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } - } +// } } else if (oldAirInedx == 1) { // int mode = ((newAirInfo[4] & 0xf0) >> 4); int mode = newAirInfo[9] & 0xff; @@ -863,7 +867,8 @@ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(airInfo); airCtrlBackInfo.setCurState(curAirInfo); - isACCtrlSuccess = true; +// isACCtrlSuccess = true; +// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } @@ -895,7 +900,8 @@ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(airInfo); airCtrlBackInfo.setCurState(curAirInfo); - isACCtrlSuccess = true; +// isACCtrlSuccess = true; +// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } @@ -912,7 +918,8 @@ AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); airCtrlBackInfo.setAppliancesInfo(airInfo); airCtrlBackInfo.setCurState(curAirInfo); - isACCtrlSuccess = true; +// isACCtrlSuccess = true; +// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); } @@ -920,44 +927,18 @@ } } - switch (getDatas.addBytes[0] & 0xFF) { - case 1: - air1Info = oldAirInfo; - break; - case 2: - air2Info = oldAirInfo; - break; - case 3: - air3Info = oldAirInfo; - break; - case 4: - air4Info = oldAirInfo; - break; - } - - if (curAirInfo.length > 1) { -// if (isModeChange) { -// isACCtrlSuccess = true; -// getAirInfo(hvacInfo); -// } else { -// airInfo.setArrCurState(oldAirInfo); -// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); -// airCtrlBackInfo.setAppliancesInfo(airInfo); -// airCtrlBackInfo.setCurState(curAirInfo); -// isACCtrlSuccess = true; -// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); -// } - - devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); - airInfo.setArrCurState(oldAirInfo); - AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); - airCtrlBackInfo.setAppliancesInfo(airInfo); - airCtrlBackInfo.setCurState(curAirInfo); - isACCtrlSuccess = true; - EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); - - } +// if (curAirInfo.length > 1) { +// devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ).setArrCurState(oldAirInfo); +// airInfo.setArrCurState(oldAirInfo); +// AirCtrlBackInfo airCtrlBackInfo = new AirCtrlBackInfo(); +// airCtrlBackInfo.setAppliancesInfo(airInfo); +// airCtrlBackInfo.setCurState(curAirInfo); +//// isACCtrlSuccess = true; +// setDeviceCtrlSuccessStateWithInfo(infos.get(appIndex), true); +// EventBus.getDefault().post(new AirFeedBackEvent(airCtrlBackInfo, true)); +// +// } break outter; @@ -991,7 +972,8 @@ logicCtrlBackInfo.setAppliancesInfo(sceneInfo); logicCtrlBackInfo.setAreaNum(getDatas.addBytes[0] & 0xFF); logicCtrlBackInfo.setSceneNum(getDatas.addBytes[1] & 0xFF); - isSceneCtrlSuccess = true; +// isSceneCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new LogicFeedBackEvent(logicCtrlBackInfo, true)); break outter; } @@ -1015,7 +997,8 @@ devicesDataList.get(i).getAppliancesInfoList().get(j).setFeedbackState(getDatas.addBytes); AppliancesInfo mFreshAirInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); FreshAirBackInfo info = new FreshAirBackInfo(mFreshAirInfo); - isFreshAirCtrlSuccess = true; +// isFreshAirCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new FreshAirFeedBackEvent(info, true)); break outter; } @@ -1060,7 +1043,8 @@ AppliancesInfo mInfo = devicesDataList.get(i).getAppliancesInfoList().get(j); GeothermalBackInfo info = new GeothermalBackInfo(mInfo, true); - isGeothermalCtrlSuccess = true; +// isGeothermalCtrlSuccess = true; + setDeviceCtrlSuccessStateWithInfo(infos.get(j), true); EventBus.getDefault().post(new GeothermalFeedBackEvent(info, EventCode.SUCCESS)); } else { @@ -1224,120 +1208,150 @@ && infos.get(indexJ).getChannelNum() == (getDatas.addBytes[airIndex * 11] & 0xFF)) { AppliancesInfo appliancesInfo = devicesDataList.get(indexI).getAppliancesInfoList().get(indexJ); if (appliancesInfo.getPort() != 0) { -// byte[] airbytes = getDatas.addBytes; -// String airString = "209a 闄勫姞鏁版嵁:"; -// for (int i = 0; i < airbytes.length; i++) { -// airString += (airbytes[i] & 0xff) + ","; -// } -// HDLLog.info( airString); - switch (getDatas.addBytes[airIndex * 11] & 0xff) { - case 1: - handleAirCastData(getDatas, air1Info, airIndex, appliancesInfo); - air1Info[0] = getDatas.addBytes[1 + 0 * 11]; + 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; +// +// } } } } @@ -1530,21 +1544,21 @@ case 0: byte[] airInfo = new byte[6]; System.arraycopy(getDatas.addBytes, 23, airInfo, 0, airInfo.length); - switch (getDatas.addBytes[2] & 0xFF) { - case 1: - air1Info = airInfo; - break; - case 2: - air2Info = airInfo; - break; - case 3: - air3Info = airInfo; - break; - case 4: - air4Info = airInfo; - break; - - } +// switch (getDatas.addBytes[2] & 0xFF) { +// case 1: +// air1Info = airInfo; +// break; +// case 2: +// air2Info = airInfo; +// break; +// case 3: +// air3Info = airInfo; +// break; +// case 4: +// air4Info = airInfo; +// break; +// +// } devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(airInfo); newInfo1 = devicesDataList.get(devPos).getAppliancesInfoList().get(appPos); break; @@ -1557,27 +1571,27 @@ // getAppInfo(newInfo); final AppliancesInfo newInfo = newInfo1; - final byte[] airCurInfo; if (newInfo == null) { return; } - switch (newInfo.getChannelNum()) { - case 1: - airCurInfo = air1Info; - break; - case 2: - airCurInfo = air2Info; - break; - case 3: - airCurInfo = air3Info; - break; - case 4: - airCurInfo = air4Info; - break; - default: - airCurInfo = new byte[]{0, 0}; - break; - } + final byte[] airCurInfo = newInfo1.getArrCurState(); +// switch (newInfo.getChannelNum()) { +// case 1: +// airCurInfo = air1Info; +// break; +// case 2: +// airCurInfo = air2Info; +// break; +// case 3: +// airCurInfo = air3Info; +// break; +// case 4: +// airCurInfo = air4Info; +// break; +// default: +// airCurInfo = new byte[]{0, 0}; +// break; +// } new Timer().schedule(new TimerTask() { @Override @@ -1808,30 +1822,33 @@ for (int i = 23; i < getDatas.addBytes.length; i++) { hvacBytes[i - 23] = getDatas.addBytes[i]; } - devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes); - switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) { - case 1: - if (air1Info == null) { - air1Info = hvacBytes; - } - break; - case 2: - if (air2Info == null) { - air2Info = hvacBytes; - } - break; - case 3: - if (air3Info == null) { - air3Info = hvacBytes; - } - break; - case 4: - if (air4Info == null) { - air4Info = hvacBytes; - } - break; - } + HDLLog.info("鑾峰彇澶囨敞Configuration.AIR_BIG_TYPE锛� "+ StringUtil.ByteArrToHex(hvacBytes,0, hvacBytes.length)); + + devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).setArrCurState(hvacBytes); +// switch (devicesDataList.get(devPos).getAppliancesInfoList().get(appPos).getChannelNum()) { +// case 1: +// if (air1Info == null) { +// air1Info = hvacBytes; +// } +// break; +// case 2: +// if (air2Info == null) { +// air2Info = hvacBytes; +// } +// break; +// case 3: +// if (air3Info == null) { +// air3Info = hvacBytes; +// } +// break; +// case 4: +// if (air4Info == null) { +// air4Info = hvacBytes; +// } +// break; +// +// } break; case 3: byte[] newBytes = new byte[getDatas.addBytes.length - 24 + 1]; @@ -1886,6 +1903,7 @@ } listRemarksOutter: for (int lRPos = 0, len3 = listRemarks.size(); lRPos < len3; lRPos++) { + //鎵惧埌E44B瀵瑰簲鐨勮澶囧洖璺紝鍒ゆ柇鏄惁宸茬粡鎷垮埌浜嗘暟鎹�� if (listRemarks.get(lRPos).getAppliancesInfo().getDeviceSubnetID() == getDatas.sourceSubnetID && listRemarks.get(lRPos).getAppliancesInfo().getDeviceDeviceID() == getDatas.sourceDeviceID @@ -1946,7 +1964,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()); +// 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; @@ -2370,5 +2388,23 @@ } } + /** + * 璁剧疆鎺у埗鏄惁鎴愬姛鐘舵�� + * @param info + * @param success + */ + public static void setDeviceCtrlSuccessStateWithInfo(AppliancesInfo info, Boolean success){ + ctrlSuccessStateHashMap.put(info.getDeviceKey(), success); + } + /** + * 鑾峰彇鏄惁鎺у埗鎴愬姛 + * @param info + * @return 缁撴灉 + */ + public static Boolean getDeviceCtrlSuccessStateWithInfo(AppliancesInfo info){ + Boolean success = ctrlSuccessStateHashMap.get(info.getDeviceKey()); + if(success == null) success = false; + return success; + } } 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 e7babfd..d2ce714 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 @@ -248,7 +248,7 @@ // } // HDLLog.info("鏀跺埌鐨勬暟鎹�"+aa); // sendTestCMD(receiveBytes, HDLTest.REC_TEST_PORT); - +// HDLLog.info("HDL ReceiveBytes22锛� "+ StringUtil.ByteArrToHex(receiveBytes,0, receiveBytes.length)); HandleHDLdata(receiveBytes, dataPacket, Configuration.PORT); } catch (Exception e) { e.printStackTrace(); 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 6e673ad..42d672f 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 @@ -82,6 +82,14 @@ } isExitData = true; + + String key = "K" + appliancesInfo.getBigType() + + "-" + appliancesInfo.getLittleType() + + "-" + appliancesInfo.getDeviceSubnetID() + + "-" + appliancesInfo.getDeviceDeviceID() + + "-" + appliancesInfo.getChannelNum(); + + appliancesInfo.setDeviceKey(key);//2019-8-2 娣诲姞鍞竴鏍囪瘑key appliancesInfoList.add(appliancesInfo); } else { -- Gitblit v1.8.0