| | |
| | | //registerListener(String.format(TopicConstant.NATIVE_ZIGBEE_UP_SLAVE, "+", "+"), eventListener); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送原生数据 |
| | | * |
| | |
| | | * @param baseCallBack 结果回调 |
| | | */ |
| | | public void Send(String gatewayOidOrGatewayId, byte[] payload, final ModbusCallBack baseCallBack) { |
| | | Send(gatewayOidOrGatewayId, payload, 5, baseCallBack); |
| | | } |
| | | |
| | | /** |
| | | * 发送原生数据 |
| | | * |
| | | * @param gatewayOidOrGatewayId 目标网关的oid或者网关Id |
| | | * @param payload 发送数据 |
| | | * @param timeout 超时时间(s) |
| | | * @param baseCallBack 结果回调 |
| | | */ |
| | | public void Send(String gatewayOidOrGatewayId, byte[] payload, int timeout, final ModbusCallBack baseCallBack) { |
| | | if (payload == null || payload.length == 0) { |
| | | if (baseCallBack != null) { |
| | | baseCallBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); |
| | | System.out.println("发送数据时负载数据时空的--->"); |
| | | } |
| | | return; |
| | | } |
| | | //如果本地有链接这个网关,则用本地连接 |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayByOidOrGatewayId(gatewayOidOrGatewayId); |
| | | if (null == gatewayBean) { |
| | |
| | | // request.setCloudTopic(String.format(TopicConstant.NATIVE_MODBUS_DOWN_SLAVE, HDLLinkConfig.getInstance().getGatewayId(), gatewayOidOrGatewayId)); |
| | | // } |
| | | request.setReplyTopic("Modbus" + payload[0] + payload[1]); |
| | | long timeout = 5 * 1000; |
| | | long awaitTime = timeout * 1000L; |
| | | |
| | | new HDLConnectHelper(timeout, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { |
| | | new HDLConnectHelper(awaitTime, 1, gatewayBean.getIp_address(), 8586, request, new HDLConnectHelper.HdlSocketListener() { |
| | | @Override |
| | | public void onSucceed(Object msg) { |
| | | if (msg instanceof int[]) { |
| | |
| | | plugins { |
| | | id 'com.android.application' |
| | | // 添加如下配置(华为极光推送) |
| | | id 'com.huawei.agconnect' |
| | | } |
| | | //必须配置uni |
| | | def mfph = [ |
| | |
| | | // VIVO_APPKEY : "vivo的APPKEY", |
| | | // VIVO_APPID : "vivo的APPID", |
| | | // HONOR_APPID : "Honor的APP ID", |
| | | // MEIZU_APPKEY : "MZ-魅族的APPKEY", |
| | | // MEIZU_APPID : "110098313", |
| | | |
| | | ] |
| | | |
| | |
| | | implementation 'com.contrarywind:Android-PickerView:4.1.9' |
| | | |
| | | |
| | | // //若不集成厂商通道,可直接跳过以下依赖 |
| | | // // 极光厂商插件版本与接入 JPush 版本保持一致,下同 |
| | | // // 接入华为厂商 |
| | | // implementation 'com.huawei.hms:push:6.9.0.300' |
| | | // implementation 'cn.jiguang.sdk.plugin:huawei:5.0.3' |
| | | //若不集成厂商通道,可直接跳过以下依赖 |
| | | // 极光厂商插件版本与接入 JPush 版本保持一致,下同 |
| | | // 接入华为厂商 |
| | | implementation 'com.huawei.hms:push:6.9.0.300' |
| | | implementation 'cn.jiguang.sdk.plugin:huawei:5.0.3' |
| | | implementation 'com.huawei.agconnect:agconnect-core:1.9.1.301' |
| | | // // 接入 FCM 厂商 |
| | | // implementation 'com.google.firebase:firebase-messaging:23.1.2' |
| | | // implementation 'cn.jiguang.sdk.plugin:fcm:5.0.3' |
New file |
| | |
| | | { |
| | | "agcgw":{ |
| | | "backurl":"connect-drcn.hispace.hicloud.com", |
| | | "url":"connect-drcn.dbankcloud.cn", |
| | | "websocketbackurl":"connect-ws-drcn.hispace.dbankcloud.com", |
| | | "websocketurl":"connect-ws-drcn.hispace.dbankcloud.cn" |
| | | }, |
| | | "agcgw_all":{ |
| | | "CN":"connect-drcn.dbankcloud.cn", |
| | | "CN_back":"connect-drcn.hispace.hicloud.com", |
| | | "DE":"connect-dre.dbankcloud.cn", |
| | | "DE_back":"connect-dre.hispace.hicloud.com", |
| | | "RU":"connect-drru.hispace.dbankcloud.ru", |
| | | "RU_back":"connect-drru.hispace.dbankcloud.cn", |
| | | "SG":"connect-dra.dbankcloud.cn", |
| | | "SG_back":"connect-dra.hispace.hicloud.com" |
| | | }, |
| | | "websocketgw_all":{ |
| | | "CN":"connect-ws-drcn.hispace.dbankcloud.cn", |
| | | "CN_back":"connect-ws-drcn.hispace.dbankcloud.com", |
| | | "DE":"connect-ws-dre.hispace.dbankcloud.cn", |
| | | "DE_back":"connect-ws-dre.hispace.dbankcloud.com", |
| | | "RU":"connect-ws-drru.hispace.dbankcloud.ru", |
| | | "RU_back":"connect-ws-drru.hispace.dbankcloud.cn", |
| | | "SG":"connect-ws-dra.hispace.dbankcloud.cn", |
| | | "SG_back":"connect-ws-dra.hispace.dbankcloud.com" |
| | | }, |
| | | "client":{ |
| | | "cp_id":"2850086000428177029", |
| | | "product_id":"388421841221912061", |
| | | "client_id":"1334607718899553344", |
| | | "client_secret":"16C06FC0240591855E34A0F1F1B3EDD28D9AD47CD6EB8049FE9434244D110D08", |
| | | "project_id":"388421841221912061", |
| | | "app_id":"110103729", |
| | | "api_key":"DAEDAL9meDhjmXsa+iGSNzr9ChvpxvAamFjPSLrX8FPrxCrS2s2nMKvrUjHD1g6dIuGB+Gd21AvXzG2aFytNBvGEUSRZBTQ3lQhVJQ==", |
| | | "package_name":"com.hdl.photovoltaic" |
| | | }, |
| | | "oauth_client":{ |
| | | "client_id":"110103729", |
| | | "client_type":1 |
| | | }, |
| | | "app_info":{ |
| | | "app_id":"110103729", |
| | | "package_name":"com.hdl.photovoltaic" |
| | | }, |
| | | "service":{ |
| | | "analytics":{ |
| | | "collector_url":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", |
| | | "collector_url_ru":"datacollector-drru.dt.dbankcloud.ru,datacollector-drru.dt.hicloud.com", |
| | | "collector_url_sg":"datacollector-dra.dt.hicloud.com,datacollector-dra.dt.dbankcloud.cn", |
| | | "collector_url_de":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn", |
| | | "collector_url_cn":"datacollector-drcn.dt.hicloud.com,datacollector-drcn.dt.dbankcloud.cn", |
| | | "resource_id":"p1", |
| | | "channel_id":"" |
| | | }, |
| | | "edukit":{ |
| | | "edu_url":"edukit.cloud.huawei.com.cn", |
| | | "dh_url":"edukit.cloud.huawei.com.cn" |
| | | }, |
| | | "search":{ |
| | | "url":"https://search-drcn.cloud.huawei.com" |
| | | }, |
| | | "cloudstorage":{ |
| | | "storage_url_sg_back":"https://agc-storage-dra.cloud.huawei.asia", |
| | | "storage_url_ru_back":"https://agc-storage-drru.cloud.huawei.ru", |
| | | "storage_url_ru":"https://agc-storage-drru.cloud.huawei.ru", |
| | | "storage_url_de_back":"https://agc-storage-dre.cloud.huawei.eu", |
| | | "storage_url_de":"https://ops-dre.agcstorage.link", |
| | | "storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn", |
| | | "storage_url_sg":"https://ops-dra.agcstorage.link", |
| | | "storage_url_cn_back":"https://agc-storage-drcn.cloud.huawei.com.cn", |
| | | "storage_url_cn":"https://agc-storage-drcn.platform.dbankcloud.cn" |
| | | }, |
| | | "ml":{ |
| | | "mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn" |
| | | } |
| | | }, |
| | | "region":"CN", |
| | | "configuration_version":"3.0", |
| | | "appInfos":[ |
| | | { |
| | | "package_name":"com.hdl.photovoltaic", |
| | | "client":{ |
| | | "app_id":"110103729" |
| | | }, |
| | | "app_info":{ |
| | | "package_name":"com.hdl.photovoltaic", |
| | | "app_id":"110103729" |
| | | }, |
| | | "oauth_client":{ |
| | | "client_type":1, |
| | | "client_id":"110103729" |
| | | } |
| | | } |
| | | ] |
| | | } |
| | |
| | | package com.hdl.photovoltaic.internet; |
| | | |
| | | |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import com.hdl.log.utils.PointUtil; |
| | | import com.hdl.photovoltaic.other.HdlAccountLogic; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.core.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.link.core.callback.ModbusCallBack; |
| | | import com.hdl.sdk.link.core.connect.HDLModBusConnect; |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.Arrays; |
| | | import java.nio.ByteBuffer; |
| | | |
| | | |
| | | /** |
| | | * 客户端操作逻辑 |
| | |
| | | * @param jObject 负载数据<没有填null></> |
| | | * @param sendPath 发送路径<类名+方法名>class->methodName</> |
| | | */ |
| | | public void sendDataToLinkGateway(String mac, boolean isEncrypt, |
| | | String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) { |
| | | public void sendDataToLinkGateway(String mac, boolean isEncrypt, String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) { |
| | | HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, isEncrypt, topic, jObject, sendPath, callBack); |
| | | |
| | | } |
| | |
| | | * @param jObject 负载数据<没有填null></> |
| | | * @param sendPath 发送路径<类名+方法名>class->methodName</> |
| | | */ |
| | | public void sendDataToLinkGateway(String mac, |
| | | String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) { |
| | | public void sendDataToLinkGateway(String mac, String topic, Object jObject, String sendPath, HDLLinkCallBack callBack) { |
| | | HDLLinkLocalGateway.getInstance().sendDataToLinkGateway(mac, topic, jObject, sendPath, callBack); |
| | | |
| | | } |
| | |
| | | * 下发主题底层默认 |
| | | * |
| | | * @param mac 网关mac |
| | | * @param oidAddresses oid里面Addresses地址 |
| | | * @param functionCode 功能码【3=(读取多个寄存器)),6=(写入单个寄存器),16=(写入多个寄存器)】 |
| | | * @param registerAddress 寄存器地址 |
| | | * @param contentData 内容数据(不含寄存器地址)【注意:功能码=3时,填数值;实际读多少byte就填多少,例如填"20"】 |
| | | * @param oidAddresses oid物理信息里面Addresses地址 |
| | | * @param functionCode 功能码【3=(读取多个寄存器),6=(写入单个寄存器),16=(写入多个寄存器)】 |
| | | * @param registerAddress 寄存器地址(根据文档上填十进制值) |
| | | * @param contentData 内容数据(不含寄存器地址)【注意:功能码=3时,根据文档上填数据字节数,例如读取设备备注,填20Byte】 |
| | | */ |
| | | public void SendModBusDataToLinkGateway(String mac, String oidAddresses, int functionCode, int registerAddress, String contentData, ModbusCallBack modbusCallBack) { |
| | | String s = ""; |
| | | public void sendModBusDataToLinkGateway(String mac, String oidAddresses, FunctionCode functionCode, int registerAddress, String contentData, ModbusCallBack modbusCallBack) { |
| | | String data = ""; |
| | | switch (functionCode) { |
| | | case 3: { |
| | | s = getReadModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | case ReadMultipleRegisters: { |
| | | data = readModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | } |
| | | break; |
| | | case 6: { |
| | | s = getWriteSingleModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | case WriteSingleRegister: { |
| | | data = writeSingleModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | } |
| | | break; |
| | | case 16: { |
| | | s = getWriteMultipleModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | case WriteMultipleRegisters: { |
| | | data = writeMultipleModbusPassData(oidAddresses, registerAddress, functionCode, contentData); |
| | | } |
| | | break; |
| | | } |
| | | HDLModBusConnect.getInstance().Send(mac, s.getBytes(), modbusCallBack); |
| | | HDLModBusConnect.getInstance().Send(mac, getDataByteArray(data), modbusCallBack); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 寄存器长度=(内容数据/2); |
| | | * 例子:new byte[]{00,01,00,00,00,0x09,00,00,00,01,03,00,00,00,01}; |
| | | * |
| | | * @param oidAddresses oid里面Addresses的值 |
| | | * @param oidAddresses oid物理信息里面Addresses地址 |
| | | * @param functionCode 功能码【3=(读取多个寄存器)),6=(写入单个寄存器),16=(写入多个寄存器)】 |
| | | * @param registerAddress 寄存器地址 |
| | | * @param registerAddress 寄存器地址(根据文档上十进制值填) |
| | | * @param contentData 内容数据(不含寄存器地址) |
| | | */ |
| | | public String getReadModbusPassData(String oidAddresses, int functionCode, int registerAddress, String contentData) { |
| | | private String readModbusPassData(String oidAddresses, int registerAddress, FunctionCode functionCode, String contentData) { |
| | | String data = ""; |
| | | try { |
| | | String eventID = to2ByteHexString(registerAddress);//事件ID(2byte) |
| | | String agreement = "0000";//协议(2byte) |
| | | String dataByteLength = "";//长度(N byte) |
| | | String oidAddresses_1 = oidAddresses;//标识符(4byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode);//功能码(=1byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode.value());//功能码(1byte) |
| | | String registerAddress_1 = to2ByteHexString(registerAddress);//寄存器地址(2byte) |
| | | String registerLength_1 = to2ByteHexString(Integer.getInteger(contentData) / 2);//寄存器长度(2byte) |
| | | String registerLength_1 = to2ByteHexString(Integer.parseInt(contentData) / 2);//寄存器长度(2byte) |
| | | byte[] bytes = (oidAddresses_1 + functionCode_1 + registerAddress_1 + registerLength_1).getBytes(); |
| | | dataByteLength = to1ByteHexString(bytes.length / 2); |
| | | dataByteLength = to2ByteHexString(bytes.length / 2); |
| | | data = eventID + agreement + dataByteLength + oidAddresses_1 + functionCode_1 + registerAddress_1 + registerLength_1; |
| | | return data; |
| | | } catch (Exception ignored) { |
| | |
| | | * 长度(2个byte)=标识符(4个byte)+功能码(1个byte)+负载数据(N个byte); |
| | | * 负载数据=寄存器地址(2个byte)+寄存器长度(2个byte)+内容长度(1个byte)+内容数据(N个byte)【注意:单个写入寄存器-->去掉<寄存器长度>和<内容长度>】; |
| | | * 寄存器长度=(内容数据/2); |
| | | * 例子:new byte[]{[0, 11, 0, 0, 0, 30, 0, 0, 0, 26, 6, 0, 11, 49, 50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]}; |
| | | * 例子:new byte[]{199, 112, 0, 0, 0, 9, 0, 0, 0, 26, 6, 199, 112, 0, 110}; |
| | | * |
| | | * @param oidAddresses oid里面Addresses的值 |
| | | * @param oidAddresses oid物理信息里面Addresses地址 |
| | | * @param functionCode 功能码【3=(读取多个寄存器)),6=(写入单个寄存器),16=(写入多个寄存器)】 |
| | | * @param registerAddress 寄存器地址 |
| | | * @param registerAddress 寄存器地址(根据文档上十进制值填) |
| | | * @param contentData 内容数据(不含寄存器地址) |
| | | */ |
| | | public String getWriteSingleModbusPassData(String oidAddresses, int functionCode, int registerAddress, String contentData) { |
| | | private String writeSingleModbusPassData(String oidAddresses, int registerAddress, FunctionCode functionCode, String contentData) { |
| | | String data = ""; |
| | | try { |
| | | String eventID = to2ByteHexString(registerAddress);//事件ID(2byte) |
| | | String agreement = "0000";//协议(2byte) |
| | | String dataByteLength = "";//长度(N byte) |
| | | String oidAddresses_1 = oidAddresses;//标识符(4byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode);//功能码(=1byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode.value());//功能码(1byte) |
| | | String registerAddress_1 = to2ByteHexString(registerAddress);//寄存器地址(2byte) |
| | | String contentData_1 = contentData;//内容数据(N byte) |
| | | byte[] bytes = (oidAddresses_1 + functionCode_1 + registerAddress_1 + contentData_1).getBytes(); |
| | | dataByteLength = to1ByteHexString(bytes.length / 2); |
| | | dataByteLength = to2ByteHexString(bytes.length / 2); |
| | | data = eventID + agreement + dataByteLength + oidAddresses_1 + functionCode_1 + registerAddress_1 + contentData_1; |
| | | return data; |
| | | } catch (Exception ignored) { |
| | |
| | | * |
| | | * @param oidAddresses oid里面Addresses的值 |
| | | * @param functionCode 功能码【3=(读取多个寄存器)),6=(写入单个寄存器),16=(写入多个寄存器)】 |
| | | * @param registerAddress 寄存器地址 |
| | | * @param registerAddress 寄存器地址(根据文档上十进制值填) |
| | | * @param contentData 内容数据(不含寄存器地址) |
| | | */ |
| | | public String getWriteMultipleModbusPassData(String oidAddresses, int functionCode, int registerAddress, String contentData) { |
| | | private String writeMultipleModbusPassData(String oidAddresses, int registerAddress, FunctionCode functionCode, String contentData) { |
| | | |
| | | String data = ""; |
| | | try { |
| | |
| | | String agreement = "0000";//协议(2byte) |
| | | String dataByteLength = "";//长度(N byte) |
| | | String oidAddresses_1 = oidAddresses;//标识符(4byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode);//功能码(=1byte) |
| | | String functionCode_1 = to1ByteHexString(functionCode.value());//功能码(1byte) |
| | | String registerAddress_1 = to2ByteHexString(registerAddress);//寄存器地址(2byte) |
| | | String registerLength_1 = to2ByteHexString(contentData.length() / 2);//寄存器长度(2byte) |
| | | String contentLength_1 = to1ByteHexString(contentData.length());//内容长度(1byte) |
| | | String contentData_1 = contentData;//内容数据(N byte) |
| | | byte[] bytes = (oidAddresses_1 + functionCode_1 + registerAddress_1 + registerLength_1 + contentLength_1 + contentData_1).getBytes(); |
| | | dataByteLength = to1ByteHexString(bytes.length / 2); |
| | | dataByteLength = to2ByteHexString(bytes.length / 2); |
| | | data = eventID + agreement + dataByteLength + oidAddresses_1 + functionCode_1 + registerAddress_1 + registerLength_1 + contentLength_1 + contentData_1; |
| | | return data; |
| | | } catch (Exception ignored) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 逐个解析两个字符,将其转换为字节 |
| | | * |
| | | * @param hexString 16进制的字符串 |
| | | * @return 返回数组 |
| | | */ |
| | | private byte[] getDataByteArray(String hexString) { |
| | | try { |
| | | if (TextUtils.isEmpty(hexString)) { |
| | | return new byte[]{}; |
| | | } |
| | | //去除字符串前后的空格 |
| | | hexString = hexString.trim(); |
| | | // 确保字符串的长度是偶数 |
| | | if (hexString.length() % 2 != 0) { |
| | | //无效的十六进制字符串 |
| | | return new byte[]{}; |
| | | } |
| | | // 计算字节数组的长度 |
| | | int byteArrayLength = hexString.length() / 2; |
| | | byte[] byteArray = new byte[byteArrayLength]; |
| | | //逐个解析两个字符,将其转换为字节 |
| | | for (int i = 0; i < byteArrayLength; i++) { |
| | | byteArray[i] = (byte) Integer.parseInt(hexString.substring(i * 2, i * 2 + 2), 16); |
| | | } |
| | | return byteArray; |
| | | } catch (Exception ignored) { |
| | | return new byte[]{}; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取十六进制字符串(不够两位前面补0) |
| | |
| | | * @param value 寄存器地址(十进制) |
| | | * @return (2byte)十六进制字符串 |
| | | */ |
| | | public String to2ByteHexString(int value) { |
| | | private String to2ByteHexString(int value) { |
| | | String high = ""; |
| | | String low = ""; |
| | | if (value > 255) { |
| | |
| | | * @param value 十进制 |
| | | * @return (1byte)十六进制字符串 |
| | | */ |
| | | public String to1ByteHexString(int value) { |
| | | private String to1ByteHexString(int value) { |
| | | try { |
| | | String hexString = Integer.toHexString(value); |
| | | if (hexString.length() == 1) { |
| | |
| | | * @param dataBytes 数组 |
| | | * @return -(n byte)十六进制字符串 |
| | | */ |
| | | public String toNByteHexString(byte[] dataBytes) { |
| | | private String toNByteHexString(byte[] dataBytes) { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (byte dataByte : dataBytes) { |
| | | String dataB = Integer.toHexString(dataByte & 0xFF); |
| | |
| | | return high + low; |
| | | } |
| | | |
| | | /** |
| | | * bytes数组转Int值 |
| | | * |
| | | * @param bytes 数据 |
| | | */ |
| | | public int toByteArrayInt(byte[] bytes) { |
| | | int ans = 0; |
| | | for (byte b : bytes) { |
| | | ans <<= 8; |
| | | ans |= (b & 0xff); |
| | | } |
| | | return ans; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 功能码 |
| | | */ |
| | | public enum FunctionCode { |
| | | |
| | | /** |
| | | * 读取单个或者多个寄存器 |
| | | */ |
| | | ReadMultipleRegisters(3), |
| | | /** |
| | | * 写入单个寄存器 |
| | | */ |
| | | WriteSingleRegister(6), |
| | | /** |
| | | * 写入多个寄存器 |
| | | */ |
| | | WriteMultipleRegisters(16); |
| | | private int mValue; |
| | | |
| | | FunctionCode(int value) { |
| | | this.mValue = value; |
| | | } |
| | | |
| | | public int value() { |
| | | return this.mValue; |
| | | } |
| | | } |
| | | } |
| | |
| | | this.nullDataUpdateUi(); |
| | | } |
| | | |
| | | /** |
| | | * 刷新【已恢复】信息数量总数 |
| | | */ |
| | | private void refreshRecoverCount() { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TextView textView = _mActivity.findViewById(R.id.message_tab_recover_title_tv); |
| | | if (textView != null) { |
| | | textView.setText(getText(R.string.message_recover)); |
| | | if (mList.size() > 0) { |
| | | String s = getText(R.string.message_recover) + "(" + mList.size() + ")"; |
| | | textView.setText(s); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN, sticky = true) |
| | | public void onEventMessage(BaseEventBus eventBus) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 刷新【已恢复】信息数量总数 |
| | | */ |
| | | private void refreshRecoverCount() { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | TextView textView = _mActivity.findViewById(R.id.message_tab_recover_title_tv); |
| | | if (textView != null) { |
| | | textView.setText(getText(R.string.message_recover)); |
| | | if (mList.size() > 0) { |
| | | String s = getText(R.string.message_recover) + "(" + mList.size() + ")"; |
| | | textView.setText(s); |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 没有电站列表的样式 |
| | | */ |
| | | private void nullDataUpdateUi() { |
| | |
| | | viewBinding.nullDataIc.nullDataGifAnimationIv, |
| | | viewBinding.nullDataIc.nullDataTv, getString(R.string.message_alarm_data_null), mList.size() > 0); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.ActivityTestMainBinding; |
| | | import com.hdl.photovoltaic.enums.ShowErrorMode; |
| | | import com.hdl.photovoltaic.internet.HttpClient; |
| | | import com.hdl.photovoltaic.internet.TcpClient; |
| | | import com.hdl.photovoltaic.internet.api.TopicApi; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | |
| | | import com.hdl.sdk.link.core.bean.response.BaseLocalResponse; |
| | | import com.hdl.sdk.link.core.callback.GatewayCallBack; |
| | | import com.hdl.sdk.link.core.callback.HDLLinkCallBack; |
| | | import com.hdl.sdk.link.core.callback.ModbusCallBack; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | |
| | | s.add("清除逆变器住宅Id(4)"); |
| | | s.add("上传oid列表给云端(5)"); |
| | | s.add("获取逆变器下挂设备列表(6)"); |
| | | // s.add("获取逆变器的信息(7)"); |
| | | return s; |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | break; |
| | | case "获取逆变器的信息(7)": { |
| | | TcpClient.getInstance().sendModBusDataToLinkGateway(gatewayBean.getDevice_mac(), "0000001A", TcpClient.FunctionCode.ReadMultipleRegisters, 550, "8", new ModbusCallBack() { |
| | | @Override |
| | | public void onSuccess(int[] data) { |
| | | gsonConvertJsonStr(data); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | setError(e.getMsg(), e.getCode()); |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | default: { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | |
| | | |
| | | import android.annotation.SuppressLint; |
| | | |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.sdk.link.core.utils.LanguageUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | |
| | | */ |
| | | public static String getTimeFromTimestamp(long timestamp) { |
| | | try { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); |
| | | String pattern = "yyyy-MM-dd HH:mm"; |
| | | if (UserConfigManage.getInstance().getCurrentAppLanguage().equals(LocalManageUtil.en)) { |
| | | pattern = "dd-MM-yyyy HH:mm"; |
| | | } |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH); |
| | | Date date = new Date(timestamp); |
| | | return dateFormat.format(date); |
| | | } catch (Exception e) { |
| | |
| | | maven { |
| | | url "https://jitpack.io" |
| | | } |
| | | maven { url 'https://developer.huawei.com/repo/' }//(华为极光推送) |
| | | |
| | | } |
| | | dependencies { |
| | | classpath "com.android.tools.build:gradle:4.1.2" |
| | | classpath 'io.github.didi.dokit:dokitx-plugin:3.5.0.1' |
| | | // NOTE: Do not place your application dependencies here; they belong |
| | | // in the individual module build.gradle files |
| | | //增加AGC插件配置,以便能同步“agconnect-services.json”文件中的信息.(华为极光推送) |
| | | classpath 'com.huawei.agconnect:agcp:1.6.1.300' |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | url 'https://packages.aliyun.com/maven/repository/2012126-release-Mc0DNo/' |
| | | } |
| | | //(华为极光推送) |
| | | maven { |
| | | url 'https://developer.huawei.com/repo/' |
| | | } |
| | | } |
| | | } |
| | | |