package com.dd.model.protocol;
import java.util.Iterator;
public class Test
{
public static void main(String[] args)
{
//Field field = new Field(new TTL((short)1, DataTypeEnum.STRING), new Value("1234567890"));
Field version = new Field(new TTL((short)1, DataTypeEnum.INT16), new Value<>((short)1));
Field cmd = new Field(new TTL((short)2, DataTypeEnum.INT32), new Value<>(1));
Field handle = new Field(new TTL((short)3, DataTypeEnum.INT32), new Value<>((int)-12866666));
Field userName = new Field(new TTL((short)4, DataTypeEnum.STRING), new Value<>("fang"));
Field password = new Field(new TTL((short)5, DataTypeEnum.STRING), new Value<>("fang"));
CmdLogin cmdLogin = new CmdLogin( version, cmd, handle, userName, password);
//System.out.println(field.toString());
System.out.println(cmdLogin.toString());
short tag = (short)Integer.parseInt("00110002".substring(0,4), 16);
short tag2 = (short)Integer.parseInt("00110002".substring(4,8), 16);
System.out.println(tag);System.out.println(tag);System.out.println(tag);
System.out.println(tag2);System.out.println(tag2);System.out.println(tag2);
byte ss[] = cmdLogin.serial();
System.out.printf("-----------------%d--------------\n",ss.length);
for (int i = 0; i < ss.length; i++)
{
byte string = ss[i];
//System.out.print(Integer.toHexString(string) + " ");
System.out.printf("%02x ",string);
}
FieldDecoder fieldDecoder = new FieldDecoder(handle.serial());
System.out.printf("\n----------------fieldDecoder.doDecoder()-----------\n");
Field f = fieldDecoder.doDecoder();
System.out.println(fieldDecoder.doDecoder().toString());
System.out.printf("\n----------------fieldDecoder.doDecoder()-----------\n");
byte ttt[] = {1,2,3,'a'};
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ttt.length; i++)
{
sb.append(String.format("%02x", ttt[i]));
}
System.out.println(sb.toString());
}
}
阅读(1041) | 评论(0) | 转发(0) |