| | |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(topic)) { |
| | | //设备模块 |
| | | switch (type) { |
| | | //modBus协议专用 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: { |
| | | sendModBus(mode_type, data, callback); |
| | | } |
| | | break; |
| | | //添加逆变器到云端 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: { |
| | | this.uniAddInverterDeviceToCloud(mode_type, data, callback); |
| | |
| | | //获取逆变器列表 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: { |
| | | this.uniGetCurrentHomeLocalAndCloudGatewayList(mode_type, data, callback); |
| | | } |
| | | break; |
| | | //modBus协议专用 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODBUS_SEND: { |
| | | sendModBus(mode_type, data, callback); |
| | | } |
| | | break; |
| | | //获取oid列表 |
| | |
| | | //初始化逆变器 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_INITIALIZEINVERTER: { |
| | | this.setInitializeGateway(mode_type, data, callback); |
| | | } |
| | | break; |
| | | //读取设备远程信息 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_REMOTEINFO: { |
| | | this.setInverterDeviceRemoteInfo(mode_type, data, callback); |
| | | } |
| | | break; |
| | | |
| | |
| | | //uni主页点击返回通知 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK: { |
| | | //EventBus事件分发 |
| | | BaseEventBus baseEventBus = new BaseEventBus(); |
| | | baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL); |
| | | baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK); |
| | | EventBus.getDefault().post(baseEventBus); |
| | | HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL, HDLUniMP.UNI_EVENT_REPLY_OTHER_BACK); |
| | | |
| | | } |
| | | break; |
| | |
| | | * @param callback uni回调 |
| | | */ |
| | | public void startTcpThreadSendAccountAndPassword(String type, String ssid, String password, DCUniMPJSCallback callback) { |
| | | new Thread( |
| | | () -> { |
| | | new Thread(() -> { |
| | | Socket socket = null; |
| | | OutputStream outputStreamTcp = null; |
| | | InputStream inputStreamTcp = null; |
| | |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | } |
| | | ).start(); |
| | | }).start(); |
| | | } |
| | | |
| | | /** |
| | | * 初始化你逆变器 |
| | | * 初始化逆变器 |
| | | * |
| | | * @param type 账号 |
| | | * @param data uni请求数据 |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 初始化逆变器 |
| | | * |
| | | * @param type 账号 |
| | | * @param data uni请求数据 |
| | | * @param callback uni回调 |
| | | */ |
| | | public void setInverterDeviceRemoteInfo(String type, Object data, DCUniMPJSCallback callback) { |
| | | String homeId = getKeyValue("homeId", getKeyValue("data", data)); |
| | | String json = getKeyValue("list", getKeyValue("data", data)); |
| | | List<CloudInverterDeviceBean> newList = new ArrayList<>(); |
| | | try { |
| | | List<GatewayBean> list = new Gson().fromJson(json, new TypeToken<List<GatewayBean>>() { |
| | | }.getType()); |
| | | if (list != null && list.size() > 0) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | CloudInverterDeviceBean inverterDeviceBean = new CloudInverterDeviceBean(); |
| | | inverterDeviceBean.setCategorySecondName(gatewayBean.getCategorySecondName()); |
| | | inverterDeviceBean.setOsn(gatewayBean.getDevice_mac()); |
| | | inverterDeviceBean.setOmodel(gatewayBean.getDevice_model()); |
| | | inverterDeviceBean.setOid(gatewayBean.getOid()); |
| | | inverterDeviceBean.setAddresses(gatewayBean.getAddresses()); |
| | | inverterDeviceBean.setSid(gatewayBean.getSid()); |
| | | inverterDeviceBean.setDeviceId(gatewayBean.getDeviceId()); |
| | | inverterDeviceBean.setName(gatewayBean.getDevice_name()); |
| | | inverterDeviceBean.setDeviceStatus(gatewayBean.getDeviceStatus()); |
| | | inverterDeviceBean.setSpk(gatewayBean.getSpk()); |
| | | inverterDeviceBean.setDeviceType(gatewayBean.getDeviceType()); |
| | | newList.add(inverterDeviceBean); |
| | | } |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, homeId, new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> obj) { |
| | | uniCallbackData(type, obj, callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送modbus协议数据 |