private Map<String, String> getTestResults(MTO_376 MTO, String key) throws Exception {
    RealTimeProxy376 instance = proxy;
    long SequenceCode = instance.writeParameters(MTO);
    RealTimeTaskDAO task = taskService.getTask(SequenceCode);
    PmPacket376 packet = new PmPacket376();
    packet.setValue(BcdUtils.stringToByteArray(task.getSendmsg()), 0);
    Map<String, Map<String, String>> results = decode.decode2Map(packet);

    return results.get(key);
  }
  //  @Test
  public void testTransmitMsg() throws Exception {
    Map datacellParams1 = new TreeMap();
    datacellParams1.put("8001C04F01", "2"); // 保护器型号ID
    datacellParams1.put("8001C04F02", "00000001");
    datacellParams1.put("8001C04F03", "0");
    datacellParams1.put("8001C04F04", "0");
    datacellParams1.put("8001C04F05", "0");
    datacellParams1.put("8001C04F06", "01111111");

    CommandItem commandItem = new CommandItem();
    commandItem.setIdentifier("8001C04F");
    commandItem.setDatacellParam(datacellParams1);

    CollectObject_TransMit cob = new CollectObject_TransMit();
    cob.setFuncode((byte) 4);
    cob.setMeterAddr("1");
    cob.setMeterType(MeterType.Meter645);
    cob.setPort((byte) 1);
    SerialPortPara spp = new SerialPortPara();
    spp.setBaudrate(BaudRate.bps_9600);
    spp.setCheckbit(0);
    spp.setStopbit(1);
    spp.setOdd_even_bit(1);
    spp.setDatabit(8);
    cob.setSerialPortPara(spp);
    cob.setTerminalAddr("96123456");
    cob.setWaitforByte((byte) 5);
    cob.setWaitforPacket((byte) 10);
    cob.addCommandItem(commandItem);

    MTO_376 MTO = new MTO_376();
    MTO.addCollectObject_Transmit(cob);

    RealTimeProxy376 instance = proxy;
    long expResult = 0L;
    long SequenceCode = instance.transmitMsg(MTO);

    RealTimeTaskDAO task = taskService.getTask(SequenceCode);
    PmPacket376 packet = new PmPacket376();
    packet.setValue(BcdUtils.stringToByteArray(task.getSendmsg()), 0);
    assertTrue(packet.getAddress().getRtua().equals("96123456"));

    byte[] databuff = packet.getDataBuffer().getValue();
    int head = Gb645MeterPacket.getMsgHeadOffset(databuff, 0);
    Gb645MeterPacket pack = Gb645MeterPacket.getPacket(databuff, head);
    assertTrue(pack.getAddress().getAddress().equals("000000000001"));
    assertTrue(pack.getControlCode().getValue() == 4);
    PmPacketData databuf = pack.getDataAsPmPacketData();
    databuf.rewind();
    assertTrue(databuf.getA8().getValue() == 36);
  }
  //  @Test
  public void testReadRealtimeData() throws Exception {
    System.out.println("ReadRealtimeData");

    CommandItem commandItem = new CommandItem();
    commandItem.setIdentifier("100C0025");

    CollectObject obj = new CollectObject();
    obj.setLogicalAddr("96123456");
    obj.setMpSn(new int[] {1});
    obj.AddCommandItem(commandItem);

    MTO_376 MTO3 = new MTO_376();
    MTO3.addCollectObject(obj);

    RealTimeProxy376 instance = proxy;
    long SequenceCode = instance.readData(MTO3);
    RealTimeTaskDAO task = taskService.getTask(SequenceCode);
    PmPacket376 packet = new PmPacket376();
    packet.setValue(BcdUtils.stringToByteArray(task.getSendmsg()), 0);
    assertTrue(packet.getAddress().getRtua().equals("96123456"));
    assertTrue(packet.getAfn() == 0x0C);
    PmPacket376DA da = new PmPacket376DA();
    PmPacket376DT dt = new PmPacket376DT();
    packet.getDataBuffer().rewind();
    packet.getDataBuffer().getDA(da);
    packet.getDataBuffer().getDT(dt);
    assertTrue(da.getPn() == 1);
    assertTrue(dt.getFn() == 25);
  }