/** * 传输位图块请求对象 * * @param req * @param dr * @param blockNum * @param block */ public void blockTransferRequest(DlmsRequest dr, Integer blockNum, byte[] block) { setRequestParam(dr, new ObisDescription(18, "0.0.44.0.0.255", 2)); DlmsData data = new DlmsData(); DlmsData[] datas = new DlmsData[2]; datas[0] = new DlmsData(); datas[0].setDoubleLongUnsigned(blockNum); datas[1] = new DlmsData(); datas[1].setOctetString(block); ASN1SequenceOf struct = new ASN1SequenceOf(datas); data.setStructure(struct); dr.getParams()[0].data = data; }
/** * 升级初始化 * * @param req * @param dr * @param i_maxSize */ private void upgradeInit(DlmsRequest req, DlmsRequest dr, int i_maxSize) { dr.removeAppendParam(DlmsUpgradeAssisant.CURRENT_BLOCK_NUM); dr.addAppendParam(DlmsUpgradeAssisant.MAX_SIZE, i_maxSize); dr.setOpType(DLMS_OP_TYPE.OP_ACTION); setRequestParam(dr, new ObisDescription(18, "0.0.44.0.0.255", 1)); // 初始化 DlmsData data = new DlmsData(); DlmsData[] datas = new DlmsData[2]; byte[] content = DlmsUpgradeAssisant.getInstance().getFtpFileContent(req); dr.addAppendParam(DlmsUpgradeAssisant.UPGRADE_CONTENT, content); dr.addAppendParam(DlmsUpgradeAssisant.BLOCK_COUNT, content.length / i_maxSize); // 块数 byte[] fileHead = fileHeadConstruct(req); dr.addAppendParam(DlmsUpgradeAssisant.FILE_HEAD, HexDump.toHex(fileHead)); datas[0] = new DlmsData(); // image_identifier datas[0].setOctetString(fileHead); datas[1] = new DlmsData(); // image_szie datas[1].setDoubleLongUnsigned(content.length); ASN1SequenceOf struct = new ASN1SequenceOf(datas); data.setStructure(struct); dr.getParams()[0].data = data; dr.setOperator(DlmsUpgradeAssisant.UPGRADE_02); }