Procházet zdrojové kódy

1.完善车辆登入封包、解包

2.修改时间扩展方法
tags/1.0.0
SmallChi před 7 roky
rodič
revize
111c48ea03
2 změnil soubory, kde provedl 14 přidání a 13 odebrání
  1. +4
    -3
      src/GBNewEnergy.Protocol.Test/NEPackageTest.cs
  2. +10
    -10
      src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs

+ 4
- 3
src/GBNewEnergy.Protocol.Test/NEPackageTest.cs Zobrazit soubor

@@ -68,8 +68,8 @@ namespace GBNewEnergy.Protocol.Test
public void NELoginUpStreamConstructor3_1()
{
// "23 23 01 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 1F"
// "06 07 12 37 02 00 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31"
// "23 23 01 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 1F 06 07 12 37 02 00 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31 EC"
// "12 06 08 0A 26 2E 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31"
// "23 23 01 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 1F 12 06 08 0A 26 2E 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31 D4"
NELoginUpStream nELoginUpStream = new NELoginUpStream("LGHC4V1D3HE202652", "64743066405", 1, 1, new string[] { "1" });
NEPackage nEPackage = new NEPackage("LGHC4V1D3HE202652", Enums.MsgId.login, Enums.AskId.cmd, nELoginUpStream, EncryptMethod.None);
string headerHex = nEPackage.Header.ToHexString();
@@ -81,10 +81,11 @@ namespace GBNewEnergy.Protocol.Test
public void NELoginUpStreamConstructor3_2()
{
byte[] header = "23 23 01 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 1F".ToHexBytes();
byte[] body = "06 07 12 37 02 00 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31 EC".ToHexBytes();
byte[] body = "12 06 08 0A 26 2E 00 01 36 34 37 34 33 30 36 36 34 30 35 00 00 00 00 00 00 00 00 00 01 01 31 D4".ToHexBytes();
NEPackage nEPackage = new NEPackage(header, body);
string headerHex = nEPackage.Header.ToHexString();
string bodiesHex = nEPackage.Bodies.Buffer.ToHexString();
string packageHex = nEPackage.Buffer.ToHexString();
}
}
}

+ 10
- 10
src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs Zobrazit soubor

@@ -16,11 +16,11 @@ namespace GBNewEnergy.Protocol.Extensions
{
return new DateTime(
read[offset] + DateLimitYear,
read[offset++],
read[offset++],
read[offset++],
read[offset++],
read[offset++]);
read[++offset],
read[++offset],
read[++offset],
read[++offset],
read[++offset]);
}

public static ushort ReadUShortH2LLittle(this byte[] read, int offset, int len)
@@ -85,11 +85,11 @@ namespace GBNewEnergy.Protocol.Extensions
public static void WriteLittle(this byte[] write, DateTime date, int offset,int len)
{
write[offset] = (byte)(date.Year - DateLimitYear);
write[offset++] = (byte)date.Month;
write[offset++] = (byte)date.Day;
write[offset++] = (byte)date.Hour;
write[offset++] = (byte)date.Minute;
write[offset++] = (byte)date.Second;
write[++offset] = (byte)date.Month;
write[++offset] = (byte)date.Day;
write[++offset] = (byte)date.Hour;
write[++offset] = (byte)date.Minute;
write[++offset] = (byte)date.Second;
}

/// <summary>


Načítá se…
Zrušit
Uložit