package test.hxzon.asn1;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.hxzon.asn1.core.parse.BerInputStream;
import org.hxzon.asn1.core.parse.ext.Asn1Utils;
import org.hxzon.asn1.core.type.base.BerNode;
import org.hxzon.asn1.sv.SvPduParser;
import org.hxzon.util.BytesUtil;
public class TestSmvDecoder {
//MU9-2 smv10.pkt-1
// 0000 01 0c cd 04 00 00 00 50 c2 4f 90 af 88 ba 40 00 .......P.O....@.
// 0010 00 68 00 00 00 00 60 5e 80 01 01 a2 59 30 57 80 .h....`^....Y0W.
// 0020 06 4d 55 30 34 30 31 82 02 00 00 83 04 00 00 00 .MU0401.........
// 0030 01 85 01 01 87 40 00 06 6e d5 00 00 00 00 00 02 .....@..n.......
// 0040 6c d1 00 00 00 00 ff f7 24 59 00 00 00 00 00 00 l.......$Y......
// 0050 00 00 00 00 00 00 00 6b 37 44 00 00 00 00 00 28 .......k7D.....(
// 0060 6a fd 00 00 00 00 ff 6c 5d bf 00 00 00 00 00 00 j......l].......
// 0070 00 00 00 00 00 00 ......
//60=application 0
//80=context 0
public static String smv1 = "60 5e 80 01 01 a2 59 30 57 80"//
+ "06 4d 55 30 34 30 31 82 02 00 00 83 04 00 00 00" + "01 85 01 01 87 40 00 06 6e d5 00 00 00 00 00 02"
+ "6c d1 00 00 00 00 ff f7 24 59 00 00 00 00 00 00"
+ "00 00 00 00 00 00 00 6b 37 44 00 00 00 00 00 28" + "6a fd 00 00 00 00 ff 6c 5d bf 00 00 00 00 00 00" + "00 00 00 00 00 00 ";
//number of ASDUs: 1
//svID: MU0401
//sample count: 0
//config Ref: 1
//sample synched:true
//samples{}
//-----------------------------------------------------
//9-2 dongfangSMV92.pkt-1
//0000 01 0c cd 04 00 01 00 1c 23 3d 00 7a 81 00 80 0a ........#=.z....
//0010 88 ba 40 00 02 89 00 00 00 00 60 82 02 7d 80 01 ..@.......`..}..
//0020 05 a2 82 02 76 30 7c 80 0b 64 6f 6e 67 66 61 6e ....v0|..dongfan
//0030 67 73 6d 76 82 02 08 20 83 04 00 00 00 01 85 01 gsmv... ........
//0040 00 87 60 00 00 00 00 00 00 00 00 00 00 03 53 00 ..`...........S.
//0050 00 00 00 ff ff fc ad 00 00 00 00 00 00 00 00 00 ................
//0060 00 00 00 00 00 00 00 00 00 00 00 00 00 03 53 00 ..............S.
//0070 00 00 00 ff ff fc ad 00 00 00 00 00 00 00 00 00 ................
//0080 00 00 00 00 00 37 a1 00 00 00 00 ff ff c8 5f 00 .....7........_.
//0090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
//00a0 00 00 00 30 7c 80 0b 64 6f 6e 67 66 61 6e 67 73 ...0|..dongfangs
//00b0 6d 76 82 02 08 21 83 04 00 00 00 01 85 01 00 87 mv...!..........
//00c0 60 00 00 00 4d 00 00 00 00 00 00 03 29 00 00 00 `...M.......)...
//00d0 00 ff ff fc 8a 00 00 00 00 00 00 00 4d 00 00 00 ............M...
//00e0 00 00 00 00 4d 00 00 00 00 00 00 03 29 00 00 00 ....M.......)...
//00f0 00 ff ff fc 8a 00 00 00 00 00 00 05 0a 00 00 00 ................
//0100 00 00 00 34 f0 00 00 00 00 ff ff c6 06 00 00 00 ...4............
//0110 00 00 00 05 0a 00 00 00 00 00 00 05 0a 00 00 00 ................
//0120 00 30 7c 80 0b 64 6f 6e 67 66 61 6e 67 73 6d 76 .0|..dongfangsmv
//0130 82 02 08 22 83 04 00 00 00 01 85 01 00 87 60 00 ..."..........`.
//0140 00 00 9a 00 00 00 00 00 00 02 fb 00 00 00 00 ff ................
//0150 ff fc 6b 00 00 00 00 00 00 00 9a 00 00 00 00 00 ..k.............
//0160 00 00 9a 00 00 00 00 00 00 02 fb 00 00 00 00 ff ................
//0170 ff fc 6b 00 00 00 00 00 00 0a 0c 00 00 00 00 00 ..k.............
//0180 00 31 ec 00 00 00 00 ff ff c4 08 00 00 00 00 00 .1..............
//0190 00 0a 0c 00 00 00 00 00 00 0a 0c 00 00 00 00 30 ...............0
//01a0 7c 80 0b 64 6f 6e 67 66 61 6e 67 73 6d 76 82 02 |..dongfangsmv..
//01b0 08 23 83 04 00 00 00 01 85 01 00 87 60 00 00 00 .#..........`...
//01c0 e5 00 00 00 00 00 00 02 c8 00 00 00 00 ff ff fc ................
//01d0 52 00 00 00 00 00 00 00 e5 00 00 00 00 00 00 00 R...............
//01e0 e5 00 00 00 00 00 00 02 c8 00 00 00 00 ff ff fc ................
//01f0 52 00 00 00 00 00 00 0e ff 00 00 00 00 00 00 2e R...............
//0200 98 00 00 00 00 ff ff c2 69 00 00 00 00 00 00 0e ........i.......
//0210 ff 00 00 00 00 00 00 0e ff 00 00 00 00 30 7c 80 .............0|.
//0220 0b 64 6f 6e 67 66 61 6e 67 73 6d 76 82 02 08 24 .dongfangsmv...$
//0230 83 04 00 00 00 01 85 01 00 87 60 00 00 01 2f 00 ..........`.../.
//0240 00 00 00 00 00 02 91 00 00 00 00 ff ff fc 3f 00 ..............?.
//0250 00 00 00 00 00 01 2f 00 00 00 00 00 00 01 2f 00 ....../......./.
//0260 00 00 00 00 00 02 91 00 00 00 00 ff ff fc 3f 00 ..............?.
//0270 00 00 00 00 00 13 da 00 00 00 00 00 00 2a fb 00 .............*..
//0280 00 00 00 ff ff c1 2b 00 00 00 00 00 00 13 da 00 ......+.........
//0290 00 00 00 00 00 13 da 00 00 00 00 ...........
public static String smv2 = "60 82 02 7d 80 01" + "05 a2 82 02 76 30 7c 80 0b 64 6f 6e 67 66 61 6e" + "67 73 6d 76 82 02 08 20 83 04 00 00 00 01 85 01"
+ "00 87 60 00 00 00 00 00 00 00 00 00 00 03 53 00" + "00 00 00 ff ff fc ad 00 00 00 00 00 00 00 00 00" + "00 00 00 00 00 00 00 00 00 00 00 00 00 03 53 00"
+ "00 00 00 ff ff fc ad 00 00 00 00 00 00 00 00 00" + "00 00 00 00 00 37 a1 00 00 00 00 ff ff c8 5f 00" + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+ "00 00 00 30 7c 80 0b 64 6f 6e 67 66 61 6e 67 73" + "6d 76 82 02 08 21 83 04 00 00 00 01 85 01 00 87" + "60 00 00 00 4d 00 00 00 00 00 00 03 29 00 00 00"
+ "00 ff ff fc 8a 00 00 00 00 00 00 00 4d 00 00 00" + "00 00 00 00 4d 00 00 00 00 00 00 03 29 00 00 00" + "00 ff ff fc 8a 00 00 00 00 00 00 05 0a 00 00 00"
+ "00 00 00 34 f0 00 00 00 00 ff ff c6 06 00 00 00" + "00 00 00 05 0a 00 00 00 00 00 00 05 0a 00 00 00" + "00 30 7c 80 0b 64 6f 6e 67 66 61 6e 67 73 6d 76"
+ "82 02 08 22 83 04 00 00 00 01 85 01 00 87 60 00" + "00 00 9a 00 00 00 00 00 00 02 fb 00 00 00 00 ff" + "ff fc 6b 00 00 00 00 00 00 00 9a 00 00 00 00 00"
+ "00 00 9a 00 00 00 00 00 00 02 fb 00 00 00 00 ff" + "ff fc 6b 00 00 00 00 00 00 0a 0c 00 00 00 00 00" + "00 31 ec 00 00 00 00 ff ff c4 08 00 00 00 00 00"
+ "00 0a 0c 00 00 00 00 00 00 0a 0c 00 00 00 00 30" + "7c 80 0b 64 6f 6e 67 66 61 6e 67 73 6d 76 82 02" + "08 23 83 04 00 00 00 01 85 01 00 87 60 00 00 00"
+ "e5 00 00 00 00 00 00 02 c8 00 00 00 00 ff ff fc" + "52 00 00 00 00 00 00 00 e5 00 00 00 00 00 00 00" + "e5 00 00 00 00 00 00 02 c8 00 00 00 00 ff ff fc"
+ "52 00 00 00 00 00 00 0e ff 00 00 00 00 00 00 2e" + "98 00 00 00 00 ff ff c2 69 00 00 00 00 00 00 0e" + "ff 00 00 00 00 00 00 0e ff 00 00 00 00 30 7c 80"
+ "0b 64 6f 6e 67 66 61 6e 67 73 6d 76 82 02 08 24" + "83 04 00 00 00 01 85 01 00 87 60 00 00 01 2f 00" + "00 00 00 00 00 02 91 00 00 00 00 ff ff fc 3f 00"
+ "00 00 00 00 00 01 2f 00 00 00 00 00 00 01 2f 00" + "00 00 00 00 00 02 91 00 00 00 00 ff ff fc 3f 00" + "00 00 00 00 00 13 da 00 00 00 00 00 00 2a fb 00"
+ "00 00 00 ff ff c1 2b 00 00 00 00 00 00 13 da 00" + "00 00 00 00 00 13 da 00 00 00 00 ";
//number of asdu:5
//svId:dongfangsmv
//sample count:2080
//confRef:1
//sample synch:0
public static void main(String[] args) throws IOException {
byte[] data = BytesUtil.fromHexString(smv2);
String reverse = BytesUtil.toHexString(data);
System.out.println(reverse);
ByteArrayInputStream inStream = new ByteArrayInputStream(data);
BerInputStream in = new BerInputStream(inStream);
SvPduParser parser = SvPduParser.parser;
BerNode node;
while (null != (node = parser.readPacket(in))) {
System.out.println(Asn1Utils.printBerNode(node));
}
}
}