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; } 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; } 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); // /**配置是否开启SDK打印日志,默认为打开*/ // 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("正在获取数据..."); 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(); } } 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="若使用酒店搜索,请输入酒店ip地址" /> <Button android:id="@+id/get" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:text="搜索酒店设备" /> </LinearLayout> 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> 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" 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]; 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() { 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()); 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 去掉相同开关状态判断,解决开状态下,调用开命令状态下,不停重发问题 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; } } 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(); 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 {