| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.OidBean; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.uni.UniToAndroidBean; |
| | |
| | | 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.gateway.HDLLinkLocalGateway; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.json.JSONObject; |
| | |
| | | //设备模块 |
| | | switch (type) { |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: { |
| | | //添加 |
| | | //添加设备到云端 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | |
| | | HdlDeviceLogic.getInstance().steGatewayParam(mac, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlDeviceLogic.getInstance().editGatewayParam(mac, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(mac); |
| | | if (gatewayBean == null) { |
| | | uniCallbackData(null, -100, "本地找不到网关", callback); |
| | | return; |
| | | } |
| | | HdlDeviceLogic.getInstance().addInverterDeviceToCloud(mac, |
| | | gatewayBean.getGatewayType(), |
| | | gatewayBean.getSid(), |
| | | gatewayBean.getOid(), |
| | | gatewayBean.getDevice_name(), |
| | | new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | uniCallbackData(null, callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | uniCallbackData(null, -100, exception.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | uniCallbackData(null, -100, exception.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception exception) { |
| | | uniCallbackData(null, -100, exception.getMessage(), callback); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | break; |
| | |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: { |
| | | sendModBus(data, callback); |
| | | } |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OID: { |
| | | //添加设备到云端 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | //获取oid列表 |
| | | HdlDeviceLogic.getInstance().getGatewayOidList(mac, new CloudCallBeak<List<OidBean>>() { |
| | | @Override |
| | | public void onSuccess(List<OidBean> list) { |
| | | if (callback != null) { |
| | | uniCallbackData(list, callback); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(Exception e) { |
| | | uniCallbackData(null, -2, e.getMessage(), callback); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | ModBusBean modBusBean = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(tempData), ModBusBean.class); |
| | | // ModBusBean modBusBean = new ModBusBean(); |
| | | // modBusBean.setOid("0101050219D44A00"); |
| | | // modBusBean.setData(new byte[]{00,01,00,00,00,0x09,00,00,00,01,03,00,00,00,01}); |
| | | if (modBusBean.getOid() == null || modBusBean.getData() == null) { |
| | | LogUtils.i("内容为空,oid=" + modBusBean.getOid() + " data=" + modBusBean.getData()); |
| | | return; |
| | |
| | | if (TextUtils.isEmpty(obj.toString())) { |
| | | return new JSONObject(); |
| | | } |
| | | if (obj.toString().startsWith("{") && obj.toString().endsWith("}")) { |
| | | return new JSONObject(obj.toString()); |
| | | } |
| | | if (obj instanceof JSONObject) { |
| | | return (JSONObject) obj; |
| | | } |