| | |
| | | import android.util.Log; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.photovoltaic.HDLApp; |
| | | import com.hdl.photovoltaic.bean.BaseEventBus; |
| | |
| | | import com.hdl.sdk.link.core.callback.GatewayCallBack; |
| | | import com.hdl.sdk.link.core.callback.ModbusCallBack; |
| | | import com.hdl.sdk.link.core.connect.HDLModBusConnect; |
| | | import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient; |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setType(ConstantManage.EVENTBUS_POST_HOME_CREATED); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION); |
| | | baseEventBus.setData(getKeyValue("data", data)); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | | break; |
| | | //读取详情 |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_DETAILS: { |
| | | //详情 |
| | | |
| | | } |
| | | break; |
| | | //关闭详情页 |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE: { |
| | | //关闭详情页 |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE); |
| | | baseEventBus.setData(getKeyValue("data", data)); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | | break; |
| | | |
| | |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(event)) { |
| | | //设备模块 |
| | | switch (type) { |
| | | //添加逆变器到云端 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: { |
| | | //添加设备到云端 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().setGatewayRemoteParam(mac, new LinkCallBack<Boolean>() { |
| | | @Override |
| | |
| | | |
| | | } |
| | | break; |
| | | //局域网搜索逆变器列表 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_NET_LIST: { |
| | | //网关搜索 |
| | | HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> gatewayBeanList) { |
| | |
| | | break; |
| | | //获取逆变器列表 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: { |
| | | |
| | | HdlDeviceLogic.getInstance().getLocalGatewayList(new CloudCallBeak<Boolean>() { |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | public void onSuccess(List<GatewayBean> list) { |
| | | if (callback != null) { |
| | | uniCallbackData(HdlDeviceLogic.getInstance().getGatewayList(), callback); |
| | | uniCallbackData(list, callback); |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST); |
| | | baseEventBus.setData(list); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | break; |
| | | //设备时间读取 |
| | | //逆变器时间读取 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_TIME: { |
| | | //添加设备到云端 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | //获取oid列表 |
| | | HdlDeviceLogic.getInstance().getGatewayTime(mac, new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | |
| | | }); |
| | | } |
| | | break; |
| | | //设备时间编辑 |
| | | //逆变器时间编辑 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_TIME_EDIT: { |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | HdlDeviceLogic.getInstance().getGatewayOidList(mac, new LinkCallBack<List<OidBean>>() { |
| | | @Override |
| | | public void onSuccess(List<OidBean> obj) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | |
| | | } |
| | | }); |
| | | HdlDeviceLogic.getInstance().editGatewayTime(mac, new JsonObject(), null); |
| | | } |
| | | break; |
| | | |