| | |
| | | * @param homeId 电站id |
| | | * @param mac 逆变器mac |
| | | */ |
| | | public void removeLocalCacheMemoryGateway(String homeId, String mac) { |
| | | public void removeLocalCacheMemoryGatewayToMac(String homeId, String mac) { |
| | | if (TextUtils.isEmpty(mac)) { |
| | | return; |
| | | } |
| | |
| | | list.remove(index); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 移除缓存列表里面逆变器 |
| | | * |
| | | * @param homeId 电站id |
| | | * @param deviceId 逆变器deviceId |
| | | */ |
| | | public void removeLocalCacheMemoryGatewayToDeviceId(String homeId, String deviceId) { |
| | | if (TextUtils.isEmpty(deviceId)) { |
| | | return; |
| | | } |
| | | List<GatewayBean> list = getCurrentHomeGatewayList(homeId); |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | int index = -1; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | if (gatewayBean.getDeviceId().equals(deviceId)) { |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | if (index > 0) { |
| | | list.remove(index); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加【设备列表】到本地缓存 |
| | | * |
| | | * @param list -设备列表 |
| | | */ |
| | | public void setListDevice(List<CloudInverterDeviceBean> list) { |
| | | try { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | if (this.mListDevice.size() == 0) { |
| | | this.mListDevice.addAll(list); |
| | | return; |
| | | } |
| | | for (int i = 0; i < list.size(); i++) { |
| | | this.setSingleDevice(list.get(i)); |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取设备列表(安装商) |
| | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加【设备列表】到本地缓存 |
| | | * |
| | | * @param list -设备列表 |
| | | */ |
| | | public void setListDevice(List<CloudInverterDeviceBean> list) { |
| | | try { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | if (this.mListDevice.size() == 0) { |
| | | this.mListDevice.addAll(list); |
| | | return; |
| | | } |
| | | for (int i = 0; i < list.size(); i++) { |
| | | this.setSingleDevice(list.get(i)); |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改设备名称逆变器BMS电池包 |
| | | * 描述: 修改设备名称,支持逆变器,BMS,电池包设备名称修改 |
| | | * |
| | | * @param homeId 住宅id |
| | | * @param deviceType 设备类型(INV:逆变器,BMS:BMS控制盒,BATTERY:电池单元) |
| | | * @param deviceId 设备id(deviceType = INV 是逆变器deviceId;deviceType = BMS 是BMS的deviceOidId;deviceType = BATTERY 是电池包的deviceOidId) |
| | | * @param cloudCallBeak 回调update |
| | | */ |
| | | public void setRename(String homeId, String deviceType, String deviceId, String name, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | String requestUrl = HttpApi.POST_Device_Rename; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("homeId", homeId); |
| | | json.addProperty("name", name); |
| | | json.addProperty("deviceType", deviceType);//设备类型(INV:逆变器,BMS:BMS控制盒,BATTERY:电池单元) |
| | | json.addProperty("deviceId", deviceId);//设备id(deviceType = INV 是逆变器deviceId;deviceType = BMS 是BMS的deviceOidId;deviceType = BATTERY 是电池包的deviceOidId) |
| | | // json.addProperty("zoneType", "password");//区域 |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String str) { |
| | | |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置网关远程参数 |
| | |
| | | * @param cloudCallBeak 返回逆变器列表 |
| | | */ |
| | | public void getCurrentHomeLocalAndCloudGatewayList(String homeId, CloudCallBeak<List<GatewayBean>> cloudCallBeak) { |
| | | HdlDeviceLogic.getInstance().searchCurrentHomeGateway(homeId,new GatewayCallBack() { |
| | | HdlDeviceLogic.getInstance().searchCurrentHomeGateway(homeId, new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | | //局域网有2种情况(1:有局域网,有外网;2:有局域网,没有外网); |
| | | HdlDeviceLogic.getInstance().getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() { |
| | | @Override |
| | | public void onSuccess(List<CloudInverterDeviceBean> list) { |
| | | ///情况1:有局域网,有外网; |
| | | List<String> removeSidList = new ArrayList<>(); |
| | | for (int j = 0; j < HDLLinkLocalGateway.getInstance().getGatewayList().size(); j++) { |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayList().get(j); |
| | | if (!querySidInverter(list, gatewayBean.getSid())) { |
| | | //本地有,云端没有,删除本地; |
| | | removeSidList.add(gatewayBean.getSid()); |
| | | } |
| | | } |
| | | for (int i = 0; i < removeSidList.size(); i++) { |
| | | //删除本地的逆变器 |
| | | removeLocalInverter(removeSidList.get(i)); |
| | | } |
| | | //情况1:有局域网,有外网; |
| | | setDeviceRemoteInfo(list, homeId, cloudCallBeak); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param gatewayCallBack - |
| | | */ |
| | | public void searchCurrentHomeGateway(String homeId,GatewayCallBack gatewayCallBack) { |
| | | public void searchCurrentHomeGateway(String homeId, GatewayCallBack gatewayCallBack) { |
| | | List<String> spks = this.getGatewaySpk(); |
| | | //网关搜索 |
| | | HDLLinkLocalGateway.getInstance().refreshGatewayByHomeIdAndSpk(homeId, spks, true, gatewayCallBack); |
| | |
| | | * @param deviceMac 设备mac, |
| | | * @param callBeak 返回 true=本地连接;false=远程; |
| | | */ |
| | | public void isLocalConnect(String homeId,String deviceMac, CloudCallBeak<Boolean> callBeak) { |
| | | searchCurrentHomeGateway(homeId,new GatewayCallBack() { |
| | | public void isLocalConnect(String homeId, String deviceMac, CloudCallBeak<Boolean> callBeak) { |
| | | searchCurrentHomeGateway(homeId, new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | | if (gatewayBeanList == null || gatewayBeanList.size() == 0) { |