/* 单元测试 */ public static void Test() { byte[] frame = { /* int8 */ 0xa3, 0xa8, 0x10, 0xfc, /* -4 */ 0xa3, 0xa8, 0x10, 0xfd, /* -3 */ 0xa3, 0xa8, 0x10, 0xfe, /* -2 */ 0xa3, 0xa8, 0x10, 0xff, /* -1 */ 0xa3, 0xa8, 0x10, 0x00, /* 0 */ 0xa3, 0xa8, 0x10, 0x01, /* 1 */ 0xa3, 0xa8, 0x10, 0x02, /* 2 */ 0xa3, 0xa8, 0x10, 0x03, /* 3 */ 0xa3, 0xa8, 0x10, 0x04, /* 4 */ /* [OK] */ 0x5b, 0x4f, 0x4b, 0x5d, /* int16 */ 0xa3, 0xa8, 0x21, 0x80, 0x01, /* -32767 */ 0xa3, 0xa8, 0x21, 0xff, 0xfe, /* -2 */ 0xa3, 0xa8, 0x21, 0xff, 0xff, /* -1 */ 0xa3, 0xa8, 0x21, 0x00, 0x00, /* 0 */ 0xa3, 0xa8, 0x21, 0x00, 0x01, /* 1 */ 0xa3, 0xa8, 0x21, 0x00, 0x02, /* 2 */ 0xa3, 0xa8, 0x21, 0x7f, 0xff, /* 32767 */ /* [ERR] */ 0x5b, 0x45, 0x52, 0x52, 0x5d, /* int32 */ 0xa3, 0xa8, 0x32, 0xff, 0xfb, 0x00, 0x0a, /* -327670 */ 0xa3, 0xa8, 0x32, 0xff, 0xff, 0xff, 0xfe, /* -2 */ 0xa3, 0xa8, 0x32, 0xff, 0xff, 0xff, 0xff, /* -1 */ 0xa3, 0xa8, 0x32, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0xa3, 0xa8, 0x32, 0x00, 0x00, 0x00, 0x01, /* 1 */ 0xa3, 0xa8, 0x32, 0x00, 0x00, 0x00, 0x02, /* 2 */ 0xa3, 0xa8, 0x32, 0x00, 0x04, 0xff, 0xf6, /* 327670 */ /* float */ 0xa3, 0xa8, 0x03, 0xc0, 0x80, 0xa3, 0xd7, /* -4.020000 */ 0xa3, 0xa8, 0x03, 0xc0, 0x40, 0xa3, 0xd7, /* -3.010000 */ 0xa3, 0xa8, 0x03, 0xc0, 0x00, 0x00, 0x00, /* -2.000000 */ 0xa3, 0xa8, 0x03, 0xbf, 0x80, 0x00, 0x00, /* -1.000000 */ 0xa3, 0xa8, 0x03, 0x00, 0x00, 0x00, 0x00, /* 0.000000 */ 0xa3, 0xa8, 0x03, 0x3f, 0x80, 0x00, 0x00, /* 1.000000 */ 0xa3, 0xa8, 0x03, 0x40, 0x00, 0x00, 0x00, /* 2.000000 */ 0xa3, 0xa8, 0x03, 0x40, 0x41, 0xeb, 0x85, /* 3.030000 */ 0xa3, 0xa8, 0x03, 0x40, 0x81, 0x47, 0xae, /* 4.040000 */ /* timestamp */ 0xa3, 0xaa, 0x27, 0x85, 0x5c, 0x8a, 0x19, 0x00, 0x00, 0x96, /* 19-12-05 11:36:20: 0200 0150 */ }; FrameDecoder decoder = new FrameDecoder(); decoder.WaveDataRecved += new WaveDataRecvHandler((byte channel, double value) => { Console.WriteLine($"WaveDataRespRecved: {channel} {value}"); }); decoder.CmdRespRecved += new CmdRespRecvHandler((string cmdResp) => { Console.WriteLine($"CmdRespRecved: {cmdResp}"); }); decoder.TimeStampRecved += new TimeStampRecvHandler((TimeStamp timeStamp) => { Console.WriteLine($"TimeStampRespRecved: {timeStamp}"); }); decoder.FrameDecode(frame); }