| | |
| | | |
| | | } |
| | | break; |
| | | //设备定位 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_DEVICE_LOCATION: { |
| | | this.uniGetDeviceFind(mode_type, data, TopicApi.DELETING_GATEWAY_FIND, callback);; |
| | | } |
| | | break; |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL.equals(topic)) { |
| | | //无网模式 |
| | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | |
| | | if (callback != null) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 设备定位 |
| | | */ |
| | | private void uniGetDeviceFind(String type, Object data, String TopicApi, DCUniMPJSCallback callback) { |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | JsonArray jsonArray = new JsonArray(); |
| | | JsonObject jObject = null; |
| | | String attribute_data = getKeyValue("attribute_data", getKeyValue("data", data)); |
| | | if (!TextUtils.isEmpty(attribute_data)) { |
| | | try { |
| | | jObject = new Gson().fromJson(attribute_data, JsonObject.class); |
| | | } catch (Exception ignored) { |
| | | jObject = new JsonObject(); |
| | | } |
| | | } |
| | | jsonArray.add(jObject); |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jsonArray, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String s) { |
| | | if (callback != null) { |
| | | try { |
| | | if (s.startsWith("{")) { |
| | | uniSuccessCallback(type, new Gson().fromJson(s, JsonObject.class), callback); |
| | | } else if (s.startsWith("[")) { |
| | | uniSuccessCallback(type, new Gson().fromJson(s, JsonArray.class), callback); |
| | | } else { |
| | | uniSuccessCallback(type, s, callback); |
| | | } |
| | | } catch (Exception e) { |
| | | uniSuccessCallback(type, s, callback); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | if (callback != null) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | |
| | | } |
| | | List<GatewayBean> newList = new ArrayList<>(); |
| | | List<GatewayBean> inverterList = new ArrayList<>(); |
| | | List<GatewayBean> inverterUnactivatedList = new ArrayList<>(); |
| | | List<GatewayBean> lcList = new ArrayList<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).getSpk().equals(HdlDeviceLogic.getInstance().INVERTER_DEVICE_SPK)) { |
| | | inverterList.add(list.get(i)); |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean == null) { |
| | | continue; |
| | | } |
| | | if (gatewayBean.isActivate()) { |
| | | if (gatewayBean.getSpk().equals(HdlDeviceLogic.getInstance().INVERTER_DEVICE_SPK) |
| | | || gatewayBean.getSpk().equals(HdlDeviceLogic.getInstance().OFF_INVERTER_OG_SPK)) { |
| | | inverterList.add(gatewayBean); |
| | | } else { |
| | | lcList.add(gatewayBean); |
| | | } |
| | | } else { |
| | | lcList.add(list.get(i)); |
| | | inverterUnactivatedList.add(gatewayBean); |
| | | } |
| | | } |
| | | newList.addAll(inverterUnactivatedList); |
| | | newList.addAll(inverterList); |
| | | newList.addAll(lcList); |
| | | return newList; |
| | |
| | | inverterDeviceBean.setDeviceStatus(gatewayBean.getDeviceStatus()); |
| | | inverterDeviceBean.setSpk(gatewayBean.getSpk()); |
| | | inverterDeviceBean.setDeviceType(gatewayBean.getDeviceType()); |
| | | inverterDeviceBean.setActivate(gatewayBean.isActivate()); |
| | | newList.add(inverterDeviceBean); |
| | | } |
| | | } |