| | |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.bean.InverterBean; |
| | | import com.hdl.photovoltaic.bean.LocalResponse; |
| | | import com.hdl.photovoltaic.bean.PageNumberObject; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | |
| | |
| | | * @param mac 网关mac |
| | | * @param linkCallBack 回调 |
| | | */ |
| | | public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) { |
| | | public void getGatewayInfo(String mac, LinkCallBack<InverterBean> linkCallBack) { |
| | | String requestUrl = TopicApi.GET_GATEWAY_INFO; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("device_mac", mac); |
| | |
| | | } |
| | | |
| | | Gson gson = new Gson(); |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() { |
| | | Type typeOfT = new TypeToken<BaseLocalResponse<InverterBean>>() { |
| | | }.getType(); |
| | | BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | BaseLocalResponse<InverterBean> baseLocalResponse = gson.fromJson(json, typeOfT); |
| | | if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { |
| | | linkCallBack.onSuccess(new GatewayBean()); |
| | | linkCallBack.onSuccess(new InverterBean()); |
| | | } else { |
| | | linkCallBack.onSuccess(baseLocalResponse.getObjects()); |
| | | } |
| | |
| | | List<String> removeSidList = new ArrayList<>(); |
| | | for (int j = 0; j < HDLLinkLocalGateway.getInstance().getGatewayList().size(); j++) { |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayList().get(j); |
| | | if (gatewayBean.getSpk().equals(INVERTER_DEVICE_SPK)) { |
| | | if (!isLoadCenterSpk(gatewayBean.getSpk())) { |
| | | //不是负载中心的spk不做处理; |
| | | continue; |
| | | } |
| | |
| | | if (gatewayBean != null) { |
| | | HDLLinkLocalGateway.getInstance().getGatewayList().remove(gatewayBean); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断spk是否是负载中心 |
| | | * |
| | | * @param spk spk |
| | | * @return 真=true,否则返回false |
| | | */ |
| | | private boolean isLoadCenterSpk(String spk) { |
| | | return Objects.equals(spk, LC_SPK); |
| | | } |
| | | |
| | | /** |
| | |
| | | gatewayBean.setDevice_name(cloudInverterDeviceBean.getName());//设备名称 |
| | | gatewayBean.setGatewayType(cloudInverterDeviceBean.getSpk());//设置spk |
| | | gatewayBean.setLocalEncrypt(true); |
| | | //离网逆变器 |
| | | gatewayBean.setOgMaster(cloudInverterDeviceBean.isOgMaster()); |
| | | //逆变器 |
| | | gatewayBean.setMaster(GatewayMasterType.MasterTrue);//默认都是主逆变器(以后支持从逆变器要更改) |
| | | gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());//设备状态 |
| | | gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());//软件版本号 |
| | |
| | | List<String> spks = new ArrayList<>(); |
| | | spks.add(INVERTER_DEVICE_SPK); |
| | | spks.add(LC_SPK); |
| | | spks.add(OFF_INVERTER_OG_SPK); |
| | | return spks; |
| | | } |
| | | |
| | |
| | | * 负载中心spk |
| | | */ |
| | | public final String LC_SPK = "energy.hdl_lc"; |
| | | /** |
| | | * 离线逆变器spk |
| | | */ |
| | | public final String OFF_INVERTER_OG_SPK = "energy.inverter_og"; |
| | | } |