| | |
| | | import android.view.View; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseActivity; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityTestMainBinding; |
| | | import com.hdl.photovoltaic.enums.ShowErrorMode; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.listener.LinkCallBack; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.ui.bean.CloudInverterChildDeviceBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.widget.ConfirmationCancelDialog; |
| | | import com.hdl.photovoltaic.widget.ConfirmationExceptionDialog; |
| | |
| | | |
| | | private ActivityTestMainBinding viewBinding; |
| | | private TestTitleAdapter testTitleAdapter; |
| | | |
| | | private List<OidBean> mOidList; |
| | | |
| | | @Override |
| | | public Object getContentView() { |
| | |
| | | return; |
| | | } |
| | | GatewayBean gatewayBean = HdlDeviceLogic.getInstance().getCurrentHomeMainGateway(); |
| | | if (gatewayBean == null && !title.equals("搜索逆变器列表")) { |
| | | if (gatewayBean == null && !title.equals("搜索逆变器列表(0)") && !title.equals("搜索【住宅】逆变器列表(1)")) { |
| | | // TODO: 10/30/23 找不到住宅的主逆变器,请先确认是否绑定逆变器,再进行逆变器指令测试; |
| | | TipDialog("找不到住宅的【主逆变器】,请先确认是否绑定过逆变器,再进行逆变器指令测试.", null); |
| | | return; |
| | |
| | | */ |
| | | private List<String> getTitleList() { |
| | | List<String> s = new ArrayList<>(); |
| | | s.add("搜索逆变器列表"); |
| | | s.add("获取逆变器oid列表"); |
| | | s.add("读取逆变器详情"); |
| | | s.add("清除逆变器住宅Id"); |
| | | s.add("搜索逆变器列表(0)"); |
| | | s.add("搜索【住宅】逆变器列表(1)"); |
| | | s.add("获取逆变器oid列表(2)"); |
| | | s.add("读取逆变器详情(3)"); |
| | | s.add("清除逆变器住宅Id(4)"); |
| | | s.add("上传oid列表给云端(5)"); |
| | | s.add("获取逆变器下挂设备列表(6)"); |
| | | return s; |
| | | } |
| | | |
| | |
| | | private void startRequest(int position, GatewayBean gatewayBean) { |
| | | String title = getTitleList().get(position); |
| | | switch (title) { |
| | | case "搜索逆变器列表": { |
| | | HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() { |
| | | case "搜索逆变器列表(0)": { |
| | | HdlDeviceLogic.getInstance().searchAllGateway(new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | | List<GatewayBean> newGatewayBeanList = new ArrayList<>(); |
| | | for (int i = 0; i < gatewayBeanList.size(); i++) { |
| | | if (HdlDeviceLogic.getInstance().isGatewaySpk(gatewayBeanList.get(i).getGatewayType())) { |
| | | newGatewayBeanList.add(gatewayBeanList.get(i)); |
| | | } |
| | | } |
| | | gsonConvertJsonStr(newGatewayBeanList); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case "搜索【住宅】逆变器列表(1)": { |
| | | HdlDeviceLogic.getInstance().searchCurrentHomeGateway(new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | | gsonConvertJsonStr(gatewayBeanList); |
| | |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e); |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | |
| | | case "获取逆变器oid列表": { |
| | | case "获取逆变器oid列表(2)": { |
| | | HdlDeviceLogic.getInstance().getInverterOidList(gatewayBean.getDevice_mac(), new LinkCallBack<List<OidBean>>() { |
| | | @Override |
| | | public void onSuccess(List<OidBean> obj) { |
| | | mOidList = obj; |
| | | gsonConvertJsonStr(obj); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e); |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | |
| | | case "读取逆变器详情": { |
| | | case "读取逆变器详情(3)": { |
| | | HdlDeviceLogic.getInstance().getGatewayInfo(gatewayBean.getDevice_mac(), new LinkCallBack<GatewayBean>() { |
| | | @Override |
| | | public void onSuccess(GatewayBean obj) { |
| | |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e); |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case "清除逆变器住宅Id": { |
| | | case "清除逆变器住宅Id(4)": { |
| | | TipDialog("一旦清除掉逆变器住宅id,逆变器需要重新绑定住宅,否则无法测试逆变器指令;", new Listener() { |
| | | @Override |
| | | public void Confirmation() { |
| | |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e); |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case "上传oid列表给云端(5)": { |
| | | if (this.mOidList == null || this.mOidList.size() == 0) { |
| | | hideLoading(); |
| | | HdlThreadLogic.toast(this, "没有oid列表数据,请先获取逆变器oid列表数据,再重新上传."); |
| | | return; |
| | | } |
| | | HdlDeviceLogic.getInstance().fullUpdateOid(UserConfigManage.getInstance().getHomeId(), this.mOidList, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | gsonConvertJsonStr(obj); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | case "获取逆变器下挂设备列表(6)": { |
| | | HdlDeviceLogic.getInstance().getInverterDeviceChildDeviceList(gatewayBean.getOid(), new CloudCallBeak<List<CloudInverterChildDeviceBean>>() { |
| | | @Override |
| | | public void onSuccess(List<CloudInverterChildDeviceBean> obj) { |
| | | gsonConvertJsonStr(obj); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | default: { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | hideLoading(); |
| | | } |
| | | }, this, ShowErrorMode.YES); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | private void setError(HDLLinkException hdlLinkException) { |
| | | String error = hdlLinkException.getMsg() + "(" + hdlLinkException.getCode() + ")"; |
| | | private void setError(String msg, int code) { |
| | | String error = msg + "(" + code + ")"; |
| | | showText(error); |
| | | } |
| | | |