Package com.chaosinmotion.asn1

Examples of com.chaosinmotion.asn1.BerNode


    public static void main(String[] args) throws IOException {
        byte[] data=BytesUtil.fromHexString(s3);
//        String reverse=BytesUtils.bytesToHexString(data);
//        System.out.println(reverse);
        ByteArrayInputStream inStream = new ByteArrayInputStream(data);
        BerInputStream in = new BerInputStream(inStream);
       
        TestParser parser = new TestParser();
        BerNode node;
        while (null != (node = parser.readPacket(in))) {
            System.out.println(node.toString());
View Full Code Here


//        System.out.println(reverse);
        ByteArrayInputStream inStream = new ByteArrayInputStream(data);
        BerInputStream in = new BerInputStream(inStream);
       
        TestParser parser = new TestParser();
        BerNode node;
        while (null != (node = parser.readPacket(in))) {
            System.out.println(node.toString());
        }
    }
View Full Code Here

//        goose.addElement(dataset);
       
      Sequence goose2 = new Sequence();
      goose2.setTagClass(Tag.APPLICATION);
      goose2.setTagNumber(1);
      BerNode gocbRef=new BerVisibleString("X7212_1JD_GOPROT/LLN0$GO$gocbTx");
      gocbRef.setTagClass(Tag.CONTEXT);
      gocbRef.setTagNumber(0);
      goose2.addElement(gocbRef);
      BerNode timeAllowedtoLive=new ASN1Integer(10000);
      timeAllowedtoLive.setTagClass(Tag.CONTEXT);
      timeAllowedtoLive.setTagNumber(1);
      goose2.addElement(timeAllowedtoLive);
      BerNode datSet=new BerVisibleString(2,"X7212_1JD_GOPROT/LLN0$dsGooseTx");
      datSet.setTagClass(Tag.CONTEXT);
      datSet.setTagNumber(2);
      goose2.addElement(datSet);
      BerNode goID=new BerVisibleString(3,"X7212_GOOSE_TX_ID");
      goID.setTagClass(Tag.CONTEXT);
      goID.setTagNumber(3);
      goose2.addElement(goID);
      //前4个字节是从1970年1月1日0时0分0秒开始的秒数,紧跟的3个字节是秒的小数部分,最后一个字节是时间品质和精度。
      //秒值=0x49 56 dc 03 = 1230429187s;
      //秒的小数部分=(0x6d 0e 56) / (2^24) = 0.426000s;
      //时间品质=0x50=0101 0000B:时钟错误,精度为16(25微秒,T3级时钟)。
      //84 08 49 56 dc 03 6d 0e 56 50
      //参见:61850-7-2:5.5.3.7.2,61850-7-2:5.5.3.7.3,61850-8-1:8.1.3.6。
      Calendar date=Calendar.getInstance();
      date.set(2000,3,1,6,55,47);
      date.set(Calendar.MILLISECOND, 232997);
      long millis=date.getTimeInMillis();
      long secends=millis/1000;
      millis=millis%1000;
      String utcTime=Long.toHexString(secends)+Long.toHexString(millis)+"0a";
      BerNode t=new OctetString(BytesUtil.fromHexString(utcTime));//new UTCTime(new Date());
      t.setTagClass(Tag.CONTEXT);
      t.setTagNumber(4);
      goose2.addElement(t);
      BerNode stNum=new ASN1Integer(10);
      stNum.setTagClass(Tag.CONTEXT);
      stNum.setTagNumber(5);
      goose2.addElement(stNum);
      BerNode sqNum=new ASN1Integer(3309572);
      sqNum.setTagClass(Tag.CONTEXT);
      sqNum.setTagNumber(6);
      goose2.addElement(sqNum);
      BerNode test=new ASN1Boolean(false);
      test.setTagClass(Tag.CONTEXT);
      test.setTagNumber(7);
      goose2.addElement(test);
      BerNode confRev=new ASN1Integer(0);
      confRev.setTagClass(Tag.CONTEXT);
      confRev.setTagNumber(8);
      goose2.addElement(confRev);
      BerNode ndsCom=new ASN1Boolean(false);
      ndsCom.setTagClass(Tag.CONTEXT);
      ndsCom.setTagNumber(9);
      goose2.addElement(ndsCom);
      BerNode numDatSetEntries=new ASN1Integer(32);
      numDatSetEntries.setTagClass(Tag.CONTEXT);
      numDatSetEntries.setTagNumber(10);
      goose2.addElement(numDatSetEntries);
      Sequence datasetChoice2 = new Sequence();//new Choice();
      datasetChoice2.setTagClass(Tag.CONTEXT);
      datasetChoice2.setTagNumber(11);
      for (int i = 0; i < 16; i++) {
          BerNode tmp=new ASN1Boolean(false);
          tmp.setTagClass(Tag.CONTEXT);
          tmp.setTagNumber(3);
          datasetChoice2.addElement(tmp);
          tmp=new BitString(new BitSet(0));
          tmp.setTagClass(Tag.CONTEXT);
          tmp.setTagNumber(4);
          datasetChoice2.addElement(tmp);
      }
//      SequenceOf dataset2=new SequenceOf(datasetChoice2);
//      dataset2.setTagClass(Tag.CONTEXT);
//      dataset2.setTagNumber(11);
View Full Code Here

//      dataset2.setTagClass(Tag.CONTEXT);
//      dataset2.setTagNumber(11);
      goose2.addElement(datasetChoice2);

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        BerOutputStream out = new BerOutputStream(stream);
        goose2.writeElement(out);
        stream.close();

        String reverse = BytesUtil.toHexString(stream.toByteArray());
        System.out.println(reverse);
View Full Code Here

//        goose.addElement(dataset);
       
      Sequence goose2 = new Sequence();
      goose2.setTagClass(Tag.APPLICATION);
      goose2.setTagNumber(1);
      BerNode gocbRef=new BerVisibleString("X7212_1JD_GOPROT/LLN0$GO$gocbTx");
      gocbRef.setTagClass(Tag.CONTEXT);
      gocbRef.setTagNumber(0);
      goose2.addElement(gocbRef);
      BerNode timeAllowedtoLive=new ASN1Integer(10000);
      timeAllowedtoLive.setTagClass(Tag.CONTEXT);
      timeAllowedtoLive.setTagNumber(1);
      goose2.addElement(timeAllowedtoLive);
      BerNode datSet=new BerVisibleString(2,"X7212_1JD_GOPROT/LLN0$dsGooseTx");
      datSet.setTagClass(Tag.CONTEXT);
      datSet.setTagNumber(2);
      goose2.addElement(datSet);
      BerNode goID=new BerVisibleString(3,"X7212_GOOSE_TX_ID");
      goID.setTagClass(Tag.CONTEXT);
      goID.setTagNumber(3);
      goose2.addElement(goID);
      //前4个字节是从1970年1月1日0时0分0秒开始的秒数,紧跟的3个字节是秒的小数部分,最后一个字节是时间品质和精度。
      //秒值=0x49 56 dc 03 = 1230429187s;
      //秒的小数部分=(0x6d 0e 56) / (2^24) = 0.426000s;
      //时间品质=0x50=0101 0000B:时钟错误,精度为16(25微秒,T3级时钟)。
View Full Code Here

//        String reverse=BytesUtils.bytesToHexString(data);
//        System.out.println(reverse);
        ByteArrayInputStream inStream = new ByteArrayInputStream(data);
        BerInputStream in = new BerInputStream(inStream);
       
        TestParser parser = new TestParser();
        BerNode node;
        while (null != (node = parser.readPacket(in))) {
            System.out.println(node.toString());
        }
    }
View Full Code Here

TOP

Related Classes of com.chaosinmotion.asn1.BerNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.