diff --git a/src/GBNewEnergy.Protocol.Test/DownStream/NEControlDownStreamTest.cs b/src/GBNewEnergy.Protocol.Test/DownStream/NEControlDownStreamTest.cs deleted file mode 100644 index 0f696bd..0000000 --- a/src/GBNewEnergy.Protocol.Test/DownStream/NEControlDownStreamTest.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.DownStream; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.Test.DownStream -{ - public class NEControlDownStreamTest : NEPackageBase - { - #region NEControlCmd.unused - [Fact] - public void NEControlDownStreamConstructor4_1() - { - NEControlProperty nEControlProperty = new NEControlProperty - { - VIN = "LGHC4V1D3HE202652", - CmdID=NEControlCmd.unused, - UpgradeParameter=new NEControlUpgradeParameter { - DialPassword = "123", - DialPointName = "xyz", - DialUserName = "11" - } - }; - NEControlDownStream nEControlDownStream = new NEControlDownStream(nEControlProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEControlDownStream, - MsgId = Enums.NEMsgId.control, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NEControlDownStreamConstructor4_2() - { - byte[] packageBytes = "23 23 82 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 07 12 06 0E 0A 0E 1B 00 57".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - - #region NEControlCmd.remoteupdate - [Fact] - public void NEControlDownStreamConstructor4_3() - { - NEControlProperty nEControlProperty = new NEControlProperty - { - VIN = "LGHC4V1D3HE202652", - CmdID = NEControlCmd.remoteupdate, - UpgradeParameter=new NEControlUpgradeParameter { - DialPassword = "123", - DialPointName = "xyz", - DialUserName = "11" - } - }; - NEControlDownStream nEControlDownStream = new NEControlDownStream(nEControlProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEControlDownStream, - MsgId = Enums.NEMsgId.control, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - [Fact] - public void NEControlDownStreamConstructor4_4() - { - byte[] packageBytes = "23 23 82 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 18 12 06 0E 0A 22 0B 01 3B 78 79 7A 3B 31 31 3B 31 32 33 3B 3B 3B 3B 3B 3B 05".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - - #region NEControlCmd.warning - [Fact] - public void NEControlDownStreamConstructor4_5() - { - NEControlProperty nEControlProperty = new NEControlProperty - { - VIN = "LGHC4V1D3HE202652", - CmdID = NEControlCmd.warning, - AlarmParameter= new NEControlAlarmParameter { nEAlarmLevel= NEAlarmLevel.一级报警 } - }; - NEControlDownStream nEControlDownStream = new NEControlDownStream(nEControlProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEControlDownStream, - MsgId = Enums.NEMsgId.control, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - [Fact] - public void NEControlDownStreamConstructor4_6() - { - byte[] packageBytes = "23 23 82 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08 12 06 0E 0B 2C 0B 06 01 6C".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol.Test/GBNewEnergy.Protocol.Test.csproj b/src/GBNewEnergy.Protocol.Test/GBNewEnergy.Protocol.Test.csproj deleted file mode 100644 index e53e54e..0000000 --- a/src/GBNewEnergy.Protocol.Test/GBNewEnergy.Protocol.Test.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - netcoreapp2.1 - - false - - - - 7.2 - - - - 7.2 - - - - - - - - - - - - - - diff --git a/src/GBNewEnergy.Protocol.Test/NEPackageBase.cs b/src/GBNewEnergy.Protocol.Test/NEPackageBase.cs deleted file mode 100644 index 65b3e46..0000000 --- a/src/GBNewEnergy.Protocol.Test/NEPackageBase.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Test -{ - public class NEPackageBase - { - public readonly NEGlobalConfigs NEGlobalConfigs = new NEGlobalConfigs() - { - - }; - } -} diff --git a/src/GBNewEnergy.Protocol.Test/NEPackageTest.cs b/src/GBNewEnergy.Protocol.Test/NEPackageTest.cs deleted file mode 100644 index 04fb4ad..0000000 --- a/src/GBNewEnergy.Protocol.Test/NEPackageTest.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.UpStream; -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.DownStream; - -namespace GBNewEnergy.Protocol.Test -{ - public class NEPackageTest: NEPackageBase - { - - } -} diff --git a/src/GBNewEnergy.Protocol.Test/UpStream/CommonUpStreamTest.cs b/src/GBNewEnergy.Protocol.Test/UpStream/CommonUpStreamTest.cs deleted file mode 100644 index c619b43..0000000 --- a/src/GBNewEnergy.Protocol.Test/UpStream/CommonUpStreamTest.cs +++ /dev/null @@ -1,152 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.UpStream; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Extensions; - -namespace GBNewEnergy.Protocol.Test.UpStream -{ - public class CommonUpStreamTest: NEPackageBase - { - #region 控制应答 - [Fact] - public void NEControlTest1_1() - { - // "23 23 82 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 21 08 96" - CommonUpStream nEControlDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEControlDownStream, - MsgId = Enums.NEMsgId.control, - AskId = Enums.NEAskId.success, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NEControlTest1_2() - { - // "23 23 82 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 21 08 96" - byte[] packageBytes = "23 23 82 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 21 08 96".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - - #region 设置应答 - [Fact] - public void NESettingsTest1_1() - { - // "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A" - CommonUpStream nESettingsDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nESettingsDownStream, - MsgId = Enums.NEMsgId.settings, - AskId = Enums.NEAskId.success, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NESettingsTest1_2() - { - byte[] packageBytes = "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - - #region 心跳 - - [Fact] - public void NEHeartbeatTest1_1() - { - // "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A" - CommonUpStream nESettingsDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nESettingsDownStream, - MsgId = Enums.NEMsgId.heartbeat, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NEHeartbeatTest1_2() - { - // "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A" - CommonUpStream nESettingsDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nESettingsDownStream, - MsgId = Enums.NEMsgId.heartbeat, - AskId = Enums.NEAskId.success, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - #endregion - - #region 终端校时 - [Fact] - public void NECheckTimeTest1_1() - { - // "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A" - CommonUpStream nESettingsDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nESettingsDownStream, - MsgId = Enums.NEMsgId.checktime, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NECheckTimeTest1_2() - { - // "23 23 81 01 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 06 12 06 0C 0B 23 15 8A" - CommonUpStream nESettingsDownStream = new CommonUpStream(new NEEmptyProperty(), NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nESettingsDownStream, - MsgId = Enums.NEMsgId.checktime, - AskId = Enums.NEAskId.success, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol.Test/UpStream/NELoginUpStreamTest.cs b/src/GBNewEnergy.Protocol.Test/UpStream/NELoginUpStreamTest.cs deleted file mode 100644 index 68f962a..0000000 --- a/src/GBNewEnergy.Protocol.Test/UpStream/NELoginUpStreamTest.cs +++ /dev/null @@ -1,67 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.UpStream; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; - -namespace GBNewEnergy.Protocol.Test.UpStream -{ - public class NELoginUpStreamTest:NEPackageTest - { - #region 车辆登入 - [Fact] - public void NELoginUpStreamConstructor4_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" - // "12 06 08 11 09 14 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 11 09 14 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 DA" - INEProperties nELoginProperty = new NELoginProperty - { - VIN = "LGHC4V1D3HE202652", - BatteryCount = 1, - BatteryLength = 1, - BatteryNos = new List() { "1" }, - SIM = "64743066405" - }; - NELoginUpStream nELoginUpStream = new NELoginUpStream(nELoginProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nELoginUpStream, - MsgId = Enums.NEMsgId.login, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - [Fact] - public void NELoginUpStreamConstructor4_2() - { - // "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 07 11 04 1B 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 07 11 04 1B 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 D7" - 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 = "12 06 07 11 04 1B 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 D7".ToHexBytes(); - NEPackage nEPackage = new NEPackage(header, body, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - [Fact] - public void NELoginUpStreamConstructor4_3() - { - - // "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 07 11 04 1B 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 D7" - byte[] packageBytes = "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 07 11 04 1B 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 D7".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol.Test/UpStream/NELogoutUpStreamTest.cs b/src/GBNewEnergy.Protocol.Test/UpStream/NELogoutUpStreamTest.cs deleted file mode 100644 index c3494fc..0000000 --- a/src/GBNewEnergy.Protocol.Test/UpStream/NELogoutUpStreamTest.cs +++ /dev/null @@ -1,100 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.UpStream; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.Test.UpStream -{ - public class NELogoutUpStreamTest:NEPackageBase - { - #region 车辆登出(依赖车辆登入的流水号所有必须先进行登入产生流水号) - - [Fact] - public void NELogoutUpStream1_1() - { - try - { - INEProperties nELogoutProperty = new NELogoutProperty() - { - VIN = "LGHC4V1D3HE202652" - }; - NELogoutUpStream nELogoutUpStream1 = new NELogoutUpStream(nELogoutProperty, NEGlobalConfigs); - INEProperties nEPackageProperty1 = new NEPackageProperty - { - Bodies = nELogoutUpStream1, - MsgId = Enums.NEMsgId.login, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty1, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - catch (NEException ex) - { - Assert.Equal(NEErrorCode.LoginSerialNoError, ex.ErrorCode); - } - } - - [Fact] - public void NELogoutUpStream2_1() - { - INEProperties nELoginProperty = new NELoginProperty - { - VIN = "LGHC4V1D3HE202652", - BatteryCount = 1, - BatteryLength = 1, - BatteryNos = new List() { "1" }, - SIM = "64743066405" - }; - NELoginUpStream nELoginUpStream = new NELoginUpStream(nELoginProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nELoginUpStream, - MsgId = Enums.NEMsgId.login, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackageLogin = new NEPackage(nEPackageProperty, NEGlobalConfigs); - INEProperties nELogoutProperty = new NELogoutProperty() - { - VIN = "LGHC4V1D3HE202652" - }; - NELogoutUpStream nELogoutUpStream1 = new NELogoutUpStream(nELogoutProperty, NEGlobalConfigs); - INEProperties nEPackageProperty1 = new NEPackageProperty - { - Bodies = nELogoutUpStream1, - MsgId = Enums.NEMsgId.loginout, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty1, NEGlobalConfigs); - // "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08" - // "12 06 08 12 06 3A 00 01" - // "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08 12 06 08 12 06 3A 00 01 E9" - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NELogoutUpStream2_2() - { - byte[] packageBytes = "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08 12 06 08 12 06 3A 00 01 E9".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - Assert.Equal("23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 08", headerHex); - Assert.Equal("12 06 08 12 06 3A 00 01 E9", bodiesHex); - } - - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLoginUpStreamTest.cs b/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLoginUpStreamTest.cs deleted file mode 100644 index 0372d20..0000000 --- a/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLoginUpStreamTest.cs +++ /dev/null @@ -1,52 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.UpStream; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.Test.UpStream -{ - public class NEPlatformLoginUpStreamTest:NEPackageBase - { - #region 平台登入 - - [Fact] - public void NEPlatformLogin1_1() - { - // "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 2F 12 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 CD" - NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty - { - EncryptMethod = NEEncryptMethod.None, - Password = "123456", - UserName = "smallchi", - }; - NEPlatformLoginUpStream nEPlatformLoginUpStream = new NEPlatformLoginUpStream(nEPlatformLoginProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEPlatformLoginUpStream, - MsgId = Enums.NEMsgId.platformlogin, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NEPlatformLogin1_2() - { - byte[] packageBytes = "23 23 05 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 2F 12 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 CD".ToHexBytes(); - NEPackage nEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = nEPackage.Header.ToHexString(); - string bodiesHex = nEPackage.Bodies.Buffer.ToHexString(); - string packageHex = nEPackage.Buffer.ToHexString(); - } - - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLogoutUpStreamTest.cs b/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLogoutUpStreamTest.cs deleted file mode 100644 index a80958d..0000000 --- a/src/GBNewEnergy.Protocol.Test/UpStream/NEPlatformLogoutUpStreamTest.cs +++ /dev/null @@ -1,67 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties; -using GBNewEnergy.Protocol.UpStream; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; -using Xunit; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.Test.UpStream -{ - public class NEPlatformLogoutUpStreamTest : NEPackageBase - { - - #region 平台登出(依赖平台登出的流水号所有必须先进行登入产生流水号) - - [Fact] - public void NEPlatformLogin2_1() - { - //"23 23 06 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 3A 17 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DE" - NEPlatformLoginProperty nEPlatformLoginProperty = new NEPlatformLoginProperty - { - EncryptMethod = NEEncryptMethod.None, - Password = "123456", - UserName = "smallchi", - }; - NEPlatformLoginUpStream nEPlatformLoginUpStream = new NEPlatformLoginUpStream(nEPlatformLoginProperty, NEGlobalConfigs); - INEProperties nEPackageProperty = new NEPackageProperty - { - Bodies = nEPlatformLoginUpStream, - MsgId = Enums.NEMsgId.platformlogin, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage nEPackage = new NEPackage(nEPackageProperty, NEGlobalConfigs); - - NEPlatformLogoutProperty nEPlatformLogoutProperty = new NEPlatformLogoutProperty - { - UserName = "smallchi", - }; - NEPlatformLoginUpStream nEPlatformLogoutUpStream = new NEPlatformLoginUpStream(nEPlatformLoginProperty, NEGlobalConfigs); - INEProperties logoutNEPackageProperty = new NEPackageProperty - { - Bodies = nEPlatformLogoutUpStream, - MsgId = Enums.NEMsgId.platformlogout, - AskId = Enums.NEAskId.cmd, - VIN = "LGHC4V1D3HE202652" - }; - NEPackage loginNEPackage = new NEPackage(logoutNEPackageProperty, NEGlobalConfigs); - string headerHex = loginNEPackage.Header.ToHexString(); - string bodiesHex = loginNEPackage.Bodies.Buffer.ToHexString(); - string packageHex = loginNEPackage.Buffer.ToHexString(); - } - - [Fact] - public void NEPlatformLogin2_2() - { - byte[] packageBytes = "23 23 06 FE 4C 47 48 43 34 56 31 44 33 48 45 32 30 32 36 35 32 01 00 29 12 06 0C 09 3A 17 00 01 00 00 00 00 73 6D 61 6C 6C 63 68 69 31 32 33 34 35 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 DE".ToHexBytes(); - NEPackage loginNEPackage = new NEPackage(packageBytes, NEGlobalConfigs); - string headerHex = loginNEPackage.Header.ToHexString(); - string bodiesHex = loginNEPackage.Bodies.Buffer.ToHexString(); - string packageHex = loginNEPackage.Buffer.ToHexString(); - } - - #endregion - } -} diff --git a/src/GBNewEnergy.Protocol/DownStream/NEControlDownStream.cs b/src/GBNewEnergy.Protocol/DownStream/NEControlDownStream.cs deleted file mode 100644 index 56e1e3a..0000000 --- a/src/GBNewEnergy.Protocol/DownStream/NEControlDownStream.cs +++ /dev/null @@ -1,92 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.DownStream -{ - /// - /// 车载终端控制命令 - /// - public class NEControlDownStream : NEBodies - { - public NEControlDownStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public NEControlDownStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - /// - /// 命令ID 只能发送一个 - /// - public NEControlCmd CmdID { get; set; } - /// - /// 命令参数 没有内容则内容为空 - /// - public string CmdParameter { get; set; } - protected override void InitializeProperties(INEProperties nEProperties) - { - NEControlProperty nEControlProperty = (NEControlProperty)nEProperties; - CmdID = nEControlProperty.CmdID; - if (CmdID == NEControlCmd.remoteupdate) - { - CmdParameter = nEControlProperty.UpgradeParameter.ToString(); - } - else if(CmdID == NEControlCmd.warning) - { - CmdParameter = nEControlProperty.AlarmParameter.nEAlarmLevel.ToString(); - } - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - CmdID = (NEControlCmd)Buffer[6]; - switch (CmdID) - { - case NEControlCmd.remoteupdate: - CmdParameter = Buffer.ReadStringLittle(7, Buffer.Length - 8);//最后一位为校验码,不在参数列 - break; - case NEControlCmd.warning: - CmdParameter = ((NEAlarmLevel)Buffer[7]).ToString(); - break; - case NEControlCmd.unused: - case NEControlCmd.shutdown: - case NEControlCmd.reset: - case NEControlCmd.restorefactorysettings: - case NEControlCmd.interruptrequest: - case NEControlCmd.OpenMonitoring: - default: - break; - } - } - - - protected override void ToBuffer() - { - if (CmdID == NEControlCmd.remoteupdate) - { - var contentLength = NEConfigs.NEEncoding.GetBytes(CmdParameter).Length; - Buffer = new byte[6 + 1 + contentLength]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(CmdID.ToByteValue(), 6); - Buffer.WriteLittle(CmdParameter, 7); - } - else if (CmdID == NEControlCmd.warning) { - Buffer = new byte[6 + 1 + 1]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(CmdID.ToByteValue(), 6); - Buffer.WriteLittle(CmdParameter.ToEnum().ToByteValue(), 7); - } - else - { - Buffer = new byte[6 + 1]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(CmdID.ToByteValue(), 6); - } - } - } -} diff --git a/src/GBNewEnergy.Protocol/DownStream/NELoginDownStream.cs b/src/GBNewEnergy.Protocol/DownStream/NELoginDownStream.cs deleted file mode 100644 index f38071d..0000000 --- a/src/GBNewEnergy.Protocol/DownStream/NELoginDownStream.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Response -{ - public class NELoginDownStream : NEBodies - { - protected NELoginDownStream(byte[] buffer) : base(buffer) - { - } - - protected NELoginDownStream(string vin) : base(vin) - { - - } - - public override void ToBuffer() - { - throw new NotImplementedException(); - } - } -} diff --git a/src/GBNewEnergy.Protocol/DownStream/NEQueryDownStream.cs b/src/GBNewEnergy.Protocol/DownStream/NEQueryDownStream.cs deleted file mode 100644 index d4820f1..0000000 --- a/src/GBNewEnergy.Protocol/DownStream/NEQueryDownStream.cs +++ /dev/null @@ -1,38 +0,0 @@ -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.DownStream -{ - /// - /// 查询命令 - /// - public class NEQueryDownStream : NEBodies - { - public NEQueryDownStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public NEQueryDownStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - } - - protected override void ToBuffer() - { - Buffer = new byte[6]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - } - } -} diff --git a/src/GBNewEnergy.Protocol/DownStream/NESettingsDownStream.cs b/src/GBNewEnergy.Protocol/DownStream/NESettingsDownStream.cs deleted file mode 100644 index 50eaa42..0000000 --- a/src/GBNewEnergy.Protocol/DownStream/NESettingsDownStream.cs +++ /dev/null @@ -1,37 +0,0 @@ -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.DownStream -{ - /// - /// 设置命令 - /// - public class NESettingsDownStream : NEBodies - { - public NESettingsDownStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public NESettingsDownStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - } - - protected override void ToBuffer() - { - Buffer = new byte[6]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - } - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEAlarmLevel.cs b/src/GBNewEnergy.Protocol/Enums/NEAlarmLevel.cs deleted file mode 100644 index 37c9ee6..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEAlarmLevel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 报警等级 - /// - public enum NEAlarmLevel:byte - { - 无报警 = 0x00, - 一级报警 = 0x01, - 二级报警 = 0x02, - 三级报警 = 0x03, - 无效数据 = 0xFF - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEAskId.cs b/src/GBNewEnergy.Protocol/Enums/NEAskId.cs deleted file mode 100644 index b6b5a6f..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEAskId.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 应答标志 - /// - public enum NEAskId:byte - { - /// - /// 接收到的信息正确 - /// - success=0x01, - /// - /// 设置未成功 - /// - error=0x02, - /// - /// VIN重复错误 - /// - vin_repeat_error=0x03, - /// - /// 数据包为命令包,而非应答包 - /// - cmd=0xFE - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEControlCmd.cs b/src/GBNewEnergy.Protocol/Enums/NEControlCmd.cs deleted file mode 100644 index 8dfdcb1..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEControlCmd.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 车载终端控制命令枚举 - /// 0x80-0x7F 预留 - /// 0x80-0xFE 用户自定义 - /// - public enum NEControlCmd:byte - { - /// - /// 未用 - /// - unused= 0x00, - /// - /// 远程升级 见表B.16 - /// - remoteupdate = 0x01, - /// - /// 车载终端关机 - /// - shutdown = 0x02, - /// - /// 车载终端复位 - /// - reset = 0x03, - /// - /// 车载终端恢复出厂设置,其中包括本地存储时间周期、心跳发送时间周期、终端应答超时时间等等 - /// - restorefactorysettings = 0x04, - /// - /// 断开数据通信链路 - /// - interruptrequest = 0x05, - /// - /// 车载终端报警/预警,报警命令参数数据格式和定义见表B.17 - /// - warning = 0x06, - /// - /// 开启抽样检测链路 - /// - OpenMonitoring = 0x07, - - - - - - - - - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEEncryptMethod.cs b/src/GBNewEnergy.Protocol/Enums/NEEncryptMethod.cs deleted file mode 100644 index 03b4d09..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEEncryptMethod.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 数据单元加密方式 - /// 0x01:数据不加密;0x02:数据经过 RSA 算法加密;0x03:数据经过 AES128 位算法加密;“0xFE”表示异常,“0xFF”表示无效 - /// - public enum NEEncryptMethod:byte - { - None= 0x01, - RSA= 0x02, - AES128=0x03, - Exception = 0xFE, - Invalid= 0xFF - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEErrorCode.cs b/src/GBNewEnergy.Protocol/Enums/NEErrorCode.cs deleted file mode 100644 index 1b98a28..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEErrorCode.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - public enum NEErrorCode - { - /// - /// 开始标识错误 - /// - BeginFlagError = 1001, - /// - /// BCC校验错误 - /// - BCCCodeError = 1002, - /// - /// 登入流水号错误 - /// - LoginSerialNoError=1003 - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEInfoType.cs b/src/GBNewEnergy.Protocol/Enums/NEInfoType.cs deleted file mode 100644 index 1b614e7..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEInfoType.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 信息类型标志 - /// - public enum NEInfoType:byte - { - 整车数据=0x01, - 驱动电机数据=0x02, - 燃料电池数据=0x03, - 发动机数据=0x04, - 车辆位置数据=0x05, - 极值数据=0x06, - 报警数据=0x07, - 可充电储能装置电压数据=0x08, - 可充电储能装置温度数据 = 0x09, - 平台交换协议自定义数据 =0x0A, - 预留=0x30, - 用户自定义=0x80 - } -} diff --git a/src/GBNewEnergy.Protocol/Enums/NEMsgId.cs b/src/GBNewEnergy.Protocol/Enums/NEMsgId.cs deleted file mode 100644 index 25bd2e6..0000000 --- a/src/GBNewEnergy.Protocol/Enums/NEMsgId.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Enums -{ - /// - /// 命令单元 - /// - public enum NEMsgId:byte - { - /// - /// 车辆登入 - /// - login = 0x01, - /// - /// 实时信息上传 - /// - uploadim = 0x02, - /// - /// 补传信息上传 - /// - uploadsup = 0x03, - /// - /// 车辆登出 - /// - loginout = 0x04, - /// - /// 平台登入 - /// - platformlogin = 0x05, - /// - /// 平台登出 - /// - platformlogout = 0x06, - /// - /// 心跳 - /// - heartbeat = 0x07, - /// - /// 终端校时 - /// - checktime = 0x08, - /// - /// 查询命令 - /// - query = 0x80, - /// - /// 设置命令 - /// - settings = 0x81, - /// - /// 控制命令 - /// - control = 0x82 - } -} diff --git a/src/GBNewEnergy.Protocol/Exceptions/NEException.cs b/src/GBNewEnergy.Protocol/Exceptions/NEException.cs deleted file mode 100644 index 748a9d8..0000000 --- a/src/GBNewEnergy.Protocol/Exceptions/NEException.cs +++ /dev/null @@ -1,23 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.Exceptions -{ - public class NEException:Exception - { - public NEException(NEErrorCode errorCode) : base(errorCode.ToString()) - { - this.ErrorCode = errorCode; - } - - public NEException(NEErrorCode errorCode, string message) : base(message) - { - this.ErrorCode = errorCode; - } - - - public NEErrorCode ErrorCode { get; } - } -} diff --git a/src/GBNewEnergy.Protocol/Extensions/EnumExtensions.cs b/src/GBNewEnergy.Protocol/Extensions/EnumExtensions.cs deleted file mode 100644 index 9ab863f..0000000 --- a/src/GBNewEnergy.Protocol/Extensions/EnumExtensions.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - -namespace GBNewEnergy.Protocol.Extensions -{ - /// - /// 枚举扩展 - /// - internal static class EnumExtensions - { - /// - /// 转为整型 - /// - /// - /// - /// - public static int ToValue(this T t) where T : struct - { - return Convert.ToInt32(t); - } - /// - /// 转为Byte - /// - /// - /// - /// - public static byte ToByteValue(this T t) where T : struct - { - return Convert.ToByte(t); - } - - /// - /// 字符转枚举 - /// - /// - /// - /// - public static T ToEnum(this string value) where T : struct - { - return (T)Enum.Parse(typeof(T), value); - } - - /// - /// 获取枚举字符串 - /// - /// - public static string GetName(this Enum valueEnum) - { - return valueEnum.ToString(); - } - - /// - /// 获取DescriptionAttribute特性枚举值的描述 - /// - /// - /// - public static string GetDescription(this Enum value) - { - var attribute = value.GetAttribute(); - return attribute == null ? value.ToString() : attribute.Description; - } - - /// - /// 验证是否是枚举类型 - /// - /// - /// - /// - public static bool IsEnumValid(this int enumValue) - { - return Enum.IsDefined(typeof(TEnum), enumValue); - } - - /// - /// 获取DescriptionAttribute特性枚举及描述 - /// - /// - /// - public static Dictionary GetDescriptionAttributeDictionary(this Enum value) - { - Dictionary dictionary = new Dictionary(); - var fields = value.GetType().GetFields(BindingFlags.Static | BindingFlags.Public); - foreach (var fi in fields) - { - DescriptionAttribute attr = Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute), false) as DescriptionAttribute; - dictionary.Add(fi.Name, attr != null ? attr.Description : ""); - } - return dictionary; - } - - /// - /// 获取DisplayNameAttribute特性枚举值的描述 - /// - /// 枚举值 - /// - public static string GetDisplayName(this Enum value) - { - var attribute = value.GetAttribute(); - return attribute == null ? value.ToString() : attribute.DisplayName; - } - - /// - /// 获取DisplayNameAttribute特性枚举及描述 - /// - /// - /// - public static Dictionary GetDisplayNameAttributeDictionary(this Enum value) - { - Dictionary dictionary = new Dictionary(); - var fields = value.GetType().GetFields(BindingFlags.Static | BindingFlags.Public); - foreach (var fi in fields) - { - DisplayNameAttribute attr = Attribute.GetCustomAttribute(fi, typeof(DisplayNameAttribute), false) as DisplayNameAttribute; - dictionary.Add(fi.Name, attr != null ? attr.DisplayName : ""); - } - return dictionary; - } - - /// - /// 获取枚举对应特性 - /// - /// - /// - /// - public static T GetAttribute(this Enum value) where T : Attribute - { - var type = value.GetType(); - var memberInfo = type.GetMember(value.ToString()); - var attributes = memberInfo[0].GetCustomAttributes(typeof(T), false); - return (T)attributes[0]; - } - } -} diff --git a/src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs b/src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs deleted file mode 100644 index 0f4260f..0000000 --- a/src/GBNewEnergy.Protocol/Extensions/NEExtensions.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; - -namespace GBNewEnergy.Protocol.Extensions -{ - public static class NEExtensions - { - /// - /// 日期限制于2000年 - /// - private const int DateLimitYear = 2000; - - public static DateTime ReadDateTimeLittle(this byte[] read,int offset, int len) - { - return new DateTime( - read[offset++] + DateLimitYear, - read[offset++], - read[offset++], - read[offset++], - read[offset++], - read[offset++]); - } - - public static ushort ReadUShortH2LLittle(this byte[] read, int offset, int len) - { - int result = 0; - for (int i = offset; i < offset + len; i++) - { - result += read[i] * (int)Math.Pow(256, len + offset - i - 1); - } - return (ushort)result; - } - - public static string ReadStringLittle(this byte[] read, int offset, int len,Encoding coding) - { - return coding.GetString(read, offset, len).Trim('\0'); - } - - public static string ReadStringLittle(this byte[] read, int offset, int len) - { - return Encoding.ASCII.GetString(read, offset, len).Trim('\0'); - } - - public static void WriteLittle(this byte[] write,string str, int offset, Encoding coding) - { - byte[] strByte = coding.GetBytes(str); - Array.Copy(strByte, 0, write, offset, strByte.Length); - } - - public static void WriteLittle(this byte[] write, string str, int offset) - { - byte[] strByte = Encoding.ASCII.GetBytes(str); - Array.Copy(strByte, 0, write, offset, strByte.Length); - } - - public static void WriteLittle(this byte[] write,int data ,int offset,int len) - { - int n = 1; - for (int i = 0; i < len; i++) - { - write[offset] = (byte)(data >> 8 * (len - n)); - n++; - offset++; - } - } - - public static void WriteLittle(this byte[] write, ushort data, int offset, int len) - { - int n = 1; - for (int i = 0; i < len; i++) - { - write[offset] = (byte)(data >> 8 * (len - n)); - n++; - offset++; - } - } - - public static void WriteLittle(this byte[] write, byte[] bytes, int offset, int len) - { - Array.Copy(bytes, 0, write, offset, len); - } - - public static void WriteLittle(this byte[] write, byte bit, int offset) - { - write[offset] = bit; - } - - 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; - } - - /// - /// 异或 - /// - /// - /// - /// - /// - public static byte ToXor(this byte[] buf, int offset, int len) - { - byte result = buf[offset]; - for (int i = offset + 1; i < offset + len; i++) - { - result = (byte)(result ^ buf[i]); - } - return result; - } - - /// - /// 字节数组转16进制字符串 - /// - /// - /// 默认 " " - /// - public static string ToHexString(this byte[] bytes,string separator=" ") - { - return string.Join(separator, bytes.Select(s => s.ToString("X2"))); - } - - /// - /// 16进制字符串转16进制数组 - /// - /// - /// - /// - public static byte[] ToHexBytes(this string hexString, string separator = " ") - { - return hexString.Split(new string[] { separator }, StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToByte(s, 16)).ToArray(); - } - } -} diff --git a/src/GBNewEnergy.Protocol/GBNewEnergy.Protocol.csproj b/src/GBNewEnergy.Protocol/GBNewEnergy.Protocol.csproj deleted file mode 100644 index a9c3d6d..0000000 --- a/src/GBNewEnergy.Protocol/GBNewEnergy.Protocol.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - netstandard2.0;net40;net45 - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GBNewEnergy.Protocol/INEEncrypt.cs b/src/GBNewEnergy.Protocol/INEEncrypt.cs deleted file mode 100644 index c06d9ec..0000000 --- a/src/GBNewEnergy.Protocol/INEEncrypt.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public interface INEEncrypt - { - byte[] Encrypt(byte[] buffer); - byte[] Decrypt(byte[] buffer); - } -} diff --git a/src/GBNewEnergy.Protocol/INEParameter.cs b/src/GBNewEnergy.Protocol/INEParameter.cs deleted file mode 100644 index 16a6583..0000000 --- a/src/GBNewEnergy.Protocol/INEParameter.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public interface INEParameter - { - /// - /// 车架号 - /// - string VIN { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/INEProperties.cs b/src/GBNewEnergy.Protocol/INEProperties.cs deleted file mode 100644 index 8b639a0..0000000 --- a/src/GBNewEnergy.Protocol/INEProperties.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public interface INEProperties:INEParameter - { - } -} diff --git a/src/GBNewEnergy.Protocol/NEBodies.cs b/src/GBNewEnergy.Protocol/NEBodies.cs deleted file mode 100644 index 0034e72..0000000 --- a/src/GBNewEnergy.Protocol/NEBodies.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public abstract class NEBodies : NEBufferedEntityBase - { - /// - /// VIN - 登入流水号,过期时间(每天置1) - /// 车载终端登入一次,登入流水号自动加1,从1开始循环累加,最大值为65531,循环周期为天 - /// - protected static readonly ConcurrentDictionary LoginNumDict; - - /// - /// 平台登入 登录流水号,过期时间(每天置1) - /// 下级平台登入一次,登入流水号自动加1,从1开始循环累加,最大值为65531,循环周期为天 - /// - protected static readonly ConcurrentDictionary PlatformLoginNumDict; - - static NEBodies() - { - LoginNumDict = new ConcurrentDictionary(); - PlatformLoginNumDict = new ConcurrentDictionary(); - } - - /// - /// 登入流水号 - /// 作用:看数据是否是连续请求 - /// - public ushort LoginNum { get; set; } - - /// - /// 数据采集时间 - /// 采用北京时间 - /// - public DateTime CurrentDateTime { get; set; } = DateTime.Now; - - protected NEBodies(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) { } - - protected NEBodies(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) { } - - protected class LoginInfo - { - public ushort LoginNum { get; set; } - public DateTime ExpirationTime { get; set; } - } - - protected class PlatformLoginInfo - { - public ushort LoginNum { get; set; } - public DateTime ExpirationTime { get; set; } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEBodiesFactory.cs b/src/GBNewEnergy.Protocol/NEBodiesFactory.cs deleted file mode 100644 index 56853bf..0000000 --- a/src/GBNewEnergy.Protocol/NEBodiesFactory.cs +++ /dev/null @@ -1,43 +0,0 @@ -using GBNewEnergy.Protocol.DownStream; -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.UpStream; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public class NEBodiesFactory - { - /// - /// 通过命令id获取数据体 - /// - /// - /// - /// - public static NEBodies GetNEBodiesByMsgId(NEMsgId msgId,byte[] buf, NEGlobalConfigs nEConfigs) - { - switch (msgId) - { - case NEMsgId.login: - return new NELoginUpStream(buf, nEConfigs); - case NEMsgId.uploadim: - return new NERealUploadUpStream(buf, nEConfigs); - case NEMsgId.loginout: - return new NELogoutUpStream(buf, nEConfigs); - case NEMsgId.platformlogin: - return new NEPlatformLoginUpStream(buf, nEConfigs); - case NEMsgId.platformlogout: - return new NEPlatformLogoutUpStream(buf, nEConfigs); - case NEMsgId.control: - return new NEControlDownStream(buf, nEConfigs); - case NEMsgId.settings: - case NEMsgId.heartbeat: - case NEMsgId.checktime: - return new CommonUpStream(buf, nEConfigs); - default: - return null; - } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEBufferedEntityBase.cs b/src/GBNewEnergy.Protocol/NEBufferedEntityBase.cs deleted file mode 100644 index f47b11d..0000000 --- a/src/GBNewEnergy.Protocol/NEBufferedEntityBase.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.IO; - -namespace GBNewEnergy.Protocol -{ - public abstract class NEBufferedEntityBase - { - public byte[] Buffer { get; protected set; } - - public NEGlobalConfigs NEConfigs { get;} - - protected NEBufferedEntityBase(byte[] buffer, NEGlobalConfigs nEConfigs) - { - NEConfigs = nEConfigs; - Buffer = buffer; - InitializePropertiesFromBuffer(); - } - - protected NEBufferedEntityBase(byte[] headerBuffer, byte[] bodyBuffer, NEGlobalConfigs nEConfigs) - { - NEConfigs = nEConfigs; - Buffer = new byte[headerBuffer.Length + bodyBuffer.Length]; - Array.Copy(headerBuffer, 0, Buffer, 0, headerBuffer.Length); - Array.Copy(bodyBuffer, 0, Buffer, headerBuffer.Length, bodyBuffer.Length); - InitializePropertiesFromBuffer(); - } - - protected NEBufferedEntityBase(INEProperties nEProperties,NEGlobalConfigs nEConfigs) - { - NEConfigs = nEConfigs; - InitializeProperties(nEProperties); - ToBuffer(); - } - - protected abstract void InitializeProperties(INEProperties nEProperties); - - protected abstract void ToBuffer(); - - protected abstract void InitializePropertiesFromBuffer(); - } -} diff --git a/src/GBNewEnergy.Protocol/NEDownStreamBase.cs b/src/GBNewEnergy.Protocol/NEDownStreamBase.cs deleted file mode 100644 index b49640c..0000000 --- a/src/GBNewEnergy.Protocol/NEDownStreamBase.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public abstract class NEDownStreamBase - { - - } -} diff --git a/src/GBNewEnergy.Protocol/NEEncryptFactory.cs b/src/GBNewEnergy.Protocol/NEEncryptFactory.cs deleted file mode 100644 index cf18c6a..0000000 --- a/src/GBNewEnergy.Protocol/NEEncryptFactory.cs +++ /dev/null @@ -1,28 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.NEEncrypts; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - internal class NEEncryptFactory - { - internal static INEEncrypt GetNEEncrypt(NEEncryptMethod nEEncryptMethod, NEGlobalConfigs nEConfigs) - { - switch (nEEncryptMethod) - { - case NEEncryptMethod.None: - case NEEncryptMethod.Invalid: - case NEEncryptMethod.Exception: - return null; - case NEEncryptMethod.AES128: - return new NEAES128EncryptImpl(nEConfigs); - case NEEncryptMethod.RSA: - return new NERSAEncryptImpl(nEConfigs); - default: - return null; - } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NEAES128EncryptImpl.cs b/src/GBNewEnergy.Protocol/NEEncrypts/Default_NEAES128EncryptImpl.cs deleted file mode 100644 index 8166b75..0000000 --- a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NEAES128EncryptImpl.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.IO; -using System.Security.Cryptography; - -namespace GBNewEnergy.Protocol.NEEncrypts -{ - public class Default_NEAES128EncryptImpl : NEAESBase - { - public override string PrivateKey { get; } - - public override byte[] SaltBytes { get; } - - public Default_NEAES128EncryptImpl(string privateKey) - { - PrivateKey = privateKey; - SaltBytes = new byte[9] { 13, 34, 27, 67, 189, 255, 104, 219, 122 }; - } - - public Default_NEAES128EncryptImpl(string privateKey, byte[] saltBytes) - { - PrivateKey = privateKey; - SaltBytes = saltBytes; - } - - public override byte[] Encrypt(byte[] buffer) - { - using (Aes encryptor = Aes.Create()) - { - Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(PrivateKey, SaltBytes); - encryptor.Key = pdb.GetBytes(32); - encryptor.IV = pdb.GetBytes(16); - using (MemoryStream ms = new MemoryStream()) - using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(),CryptoStreamMode.Write)) - { - cs.Write(buffer, 0, buffer.Length); - cs.Close(); - return ms.ToArray(); - } - } - } - - public override byte[] Decrypt(byte[] buffer) - { - using (Aes encryptor = Aes.Create()) - { - Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(PrivateKey, SaltBytes); - encryptor.Key = pdb.GetBytes(32); - encryptor.IV = pdb.GetBytes(16); - using (MemoryStream ms = new MemoryStream()) - using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(),CryptoStreamMode.Write)) - { - cs.Write(buffer, 0, buffer.Length); - cs.Close(); - return ms.ToArray(); - } - } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl.cs b/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl.cs deleted file mode 100644 index b707eb8..0000000 --- a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using System.Text; -using System.Xml; - -namespace GBNewEnergy.Protocol.NEEncrypts -{ -#if NETSTANDARD2_0 - public class Default_NERSAEncryptImpl : NERSABase - { - private readonly RSA _privateKeyRsaProvider; - private readonly RSA _publicKeyRsaProvider; - private readonly Encoding _encoding; - - public override string HashAlgorithmStr=>throw new NotImplementedException(); - - public override string PublicKey { get; } - - public override string PrivateKey { get; } - - public override HashAlgorithmName HashAlgorithmName { get; } - - public Default_NERSAEncryptImpl(Encoding encoding, HashAlgorithmName hashAlgorithmName, string publicKey, string privateKey) - { - _privateKeyRsaProvider = CreateRsaProviderFromPrivateKey(privateKey); - _publicKeyRsaProvider = CreateRsaProviderFromPublicKey(publicKey); - HashAlgorithmName = hashAlgorithmName; - _encoding = encoding; - PublicKey = publicKey; - PrivateKey = privateKey; - } - - public override byte[] Decrypt(byte[] buffer) - { - return _privateKeyRsaProvider.Decrypt(buffer, RSAEncryptionPadding.Pkcs1); - } - - public override byte[] Encrypt(byte[] buffer) - { - return _publicKeyRsaProvider.Encrypt(buffer, RSAEncryptionPadding.Pkcs1); - } - - /// - /// 使用私钥签名 - /// - /// 原始数据 - /// - public override string Sign(string data) - { - byte[] dataBytes = _encoding.GetBytes(data); - var signatureBytes = _privateKeyRsaProvider.SignData(dataBytes, HashAlgorithmName, RSASignaturePadding.Pkcs1); - return Convert.ToBase64String(signatureBytes); - } - - /// - /// 使用公钥验证签名 - /// - /// 原始数据 - /// 签名 - /// - public override bool Verify(string data, string sign) - { - byte[] dataBytes = _encoding.GetBytes(data); - byte[] signBytes = Convert.FromBase64String(sign); - var verify = _publicKeyRsaProvider.VerifyData(dataBytes, signBytes, HashAlgorithmName, RSASignaturePadding.Pkcs1); - return verify; - } - - private RSA CreateRsaProviderFromPublicKey(string publicKeyString) - { - var rsa = RSA.Create(); - FromXmlStringExtensions(rsa,publicKeyString); - return rsa; - } - - private RSA CreateRsaProviderFromPrivateKey(string privateKey) - { - var rsa = RSA.Create(); - FromXmlStringExtensions(rsa, privateKey); - return rsa; - } - - private int GetIntegerSize(BinaryReader binr) - { - byte bt = 0; - int count = 0; - bt = binr.ReadByte(); - if (bt != 0x02) - return 0; - bt = binr.ReadByte(); - - if (bt == 0x81) - count = binr.ReadByte(); - else - if (bt == 0x82) - { - var highbyte = binr.ReadByte(); - var lowbyte = binr.ReadByte(); - byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; - count = BitConverter.ToInt32(modint, 0); - } - else - { - count = bt; - } - - while (binr.ReadByte() == 0x00) - { - count -= 1; - } - binr.BaseStream.Seek(-1, SeekOrigin.Current); - return count; - } - - private bool CompareBytearrays(byte[] a, byte[] b) - { - if (a.Length != b.Length) - return false; - int i = 0; - foreach (byte c in a) - { - if (c != b[i]) - return false; - i++; - } - return true; - } - - private static void FromXmlStringExtensions(RSA rsa, string xmlString) - { - var parameters = new RSAParameters(); - var xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(xmlString); - if (xmlDoc.DocumentElement.Name.Equals("RSAKeyValue")) - { - foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) - { - switch (node.Name) - { - case "Modulus": - parameters.Modulus = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "Exponent": - parameters.Exponent = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "P": - parameters.P = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "Q": - parameters.Q = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "DP": - parameters.DP = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "DQ": - parameters.DQ = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "InverseQ": - parameters.InverseQ = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - case "D": - parameters.D = (string.IsNullOrEmpty(node.InnerText) - ? null - : Convert.FromBase64String(node.InnerText)); - break; - } - } - } - else - { - throw new Exception("Invalid XML RSA key."); - } - rsa.ImportParameters(parameters); - } - } -#endif -} diff --git a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl_NET.cs b/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl_NET.cs deleted file mode 100644 index beb0094..0000000 --- a/src/GBNewEnergy.Protocol/NEEncrypts/Default_NERSAEncryptImpl_NET.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Security.Cryptography; -using System.Text; - -namespace GBNewEnergy.Protocol.NEEncrypts -{ - public class Default_NERSAEncryptImpl_NET : NERSABase - { - private readonly Encoding _encoding; - - public Default_NERSAEncryptImpl_NET(Encoding encoding,string hashAlgorithmStr, string publicKey, string privateKey) - { - _encoding = encoding; - HashAlgorithmStr = hashAlgorithmStr; - PublicKey = publicKey; - PrivateKey = privateKey; - } - -#if NETSTANDARD2_0 - public override HashAlgorithmName HashAlgorithmName => throw new NotImplementedException(); -#endif - public override string HashAlgorithmStr { get;} - - public override string PublicKey { get; } - - public override string PrivateKey { get;} - - public override byte[] Decrypt(byte[] buffer) - { - using (RSACryptoServiceProvider provider=new RSACryptoServiceProvider()) - { - provider.FromXmlString(PrivateKey); - return provider.Decrypt(buffer, false); - } - } - - public override byte[] Encrypt(byte[] buffer) - { - using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider()) - { - provider.FromXmlString(PublicKey); - return provider.Encrypt(buffer, false); - } - } - - /// - /// 使用私钥签名 - /// - /// 原始数据 - /// - public override string Sign(string data) - { - byte[] dataBytes = _encoding.GetBytes(data); - byte[] rgbHash = HashAlgorithm.Create(HashAlgorithmStr).ComputeHash(dataBytes); - using (RSACryptoServiceProvider key = new RSACryptoServiceProvider()) - { - key.FromXmlString(PrivateKey); - RSAPKCS1SignatureFormatter formatter = new RSAPKCS1SignatureFormatter(key); - formatter.SetHashAlgorithm(HashAlgorithmStr); - byte[] inArray = formatter.CreateSignature(rgbHash); - return Convert.ToBase64String(inArray); - } - } - - /// - /// 使用公钥验证签名 - /// - /// 原始数据 - /// 签名 - /// - public override bool Verify(string data, string sign) - { - byte[] dataBytes = _encoding.GetBytes(data); - byte[] signBytes = Convert.FromBase64String(sign); - byte[] rgbHash = HashAlgorithm.Create(HashAlgorithmStr).ComputeHash(dataBytes); - using (RSACryptoServiceProvider key = new RSACryptoServiceProvider()) - { - key.FromXmlString(PublicKey); - RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(key); - deformatter.SetHashAlgorithm(HashAlgorithmStr); - byte[] rgbSignature = Convert.FromBase64String(sign); - if (deformatter.VerifySignature(rgbHash, rgbSignature)) - { - return true; - } - return false; - } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEEncrypts/NEAESBase.cs b/src/GBNewEnergy.Protocol/NEEncrypts/NEAESBase.cs deleted file mode 100644 index 3bd8f34..0000000 --- a/src/GBNewEnergy.Protocol/NEEncrypts/NEAESBase.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEEncrypts -{ - public abstract class NEAESBase : INEEncrypt - { - public abstract string PrivateKey { get; } - public abstract byte[] SaltBytes { get; } - public abstract byte[] Decrypt(byte[] buffer); - public abstract byte[] Encrypt(byte[] buffer); - } -} diff --git a/src/GBNewEnergy.Protocol/NEEncrypts/NERSABase.cs b/src/GBNewEnergy.Protocol/NEEncrypts/NERSABase.cs deleted file mode 100644 index cdc3c18..0000000 --- a/src/GBNewEnergy.Protocol/NEEncrypts/NERSABase.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Security.Cryptography; -using System.Text; - -namespace GBNewEnergy.Protocol.NEEncrypts -{ - public abstract class NERSABase : INEEncrypt - { - public abstract byte[] Decrypt(byte[] buffer); - public abstract byte[] Encrypt(byte[] buffer); - -#if NETSTANDARD2_0 - /// - /// dotnet core 使用 - /// - public abstract HashAlgorithmName HashAlgorithmName { get; } -#endif - /// - /// .net framework 使用 - /// 哈希算法 - /// MD5 new MD5CryptoServiceProvider() - /// SHA1 new SHA1CryptoServiceProvider() - /// SHA256 new SHA256CryptoServiceProvider() - /// SHA384 new SHA384CryptoServiceProvider() - /// SHA512 new SHA512CryptoServiceProvider() - /// - public abstract string HashAlgorithmStr { get; } - public abstract string PublicKey { get; } - public abstract string PrivateKey { get; } - /// - /// 使用私钥签名 - /// - /// 原始数据 - /// - public abstract bool Verify(string data, string sign); - /// - /// 使用公钥验证签名 - /// - /// 原始数据 - /// 签名 - /// - public abstract string Sign(string data); - } -} diff --git a/src/GBNewEnergy.Protocol/NEGlobalConfigs.cs b/src/GBNewEnergy.Protocol/NEGlobalConfigs.cs deleted file mode 100644 index e736e0d..0000000 --- a/src/GBNewEnergy.Protocol/NEGlobalConfigs.cs +++ /dev/null @@ -1,27 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public class NEGlobalConfigs - { - /// - /// 加密编码 - /// - public Encoding NEEncryptEncoding { get; set; } = Encoding.UTF8; - /// - /// 字符串编码 - /// - public Encoding NEEncoding { get; set; } = Encoding.UTF8; - /// - /// 数据单元加密方式 - /// 0x01:数据不加密;0x02:数据经过 RSA 算法加密;0x03:数据经过 AES128 位算法加密;“0xFE”表示异常,“0xFF”表示无效 - /// - public NEEncryptMethod EncryptMethod { get; set; } = NEEncryptMethod.None; - /// - /// 数据单元加密 - /// 当数据单元存在加密时,应先加密后校验,先校验后解密 - /// - public INEEncrypt Encrypt { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEHeader.cs b/src/GBNewEnergy.Protocol/NEHeader.cs deleted file mode 100644 index e5cfcd4..0000000 --- a/src/GBNewEnergy.Protocol/NEHeader.cs +++ /dev/null @@ -1,40 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - /// - /// 头部 - /// - public class NEHeader: BufferedEntityBase - { - public NEHeader(byte[] buffer):base(buffer) - { - - } - /// - /// 起始符 - /// - public const byte BeginFlag = 0x23; - /// - /// 命令标识 - /// - public MsgId MsgId { get; private set; } - /// - /// 应答标志 - /// - public AskId AskId { get; private set; } - /// - /// 车辆识别码 - /// - public string VIN { get; private set; } - /// - /// 数据加密方式 - /// 0x01:数据不加密;0x02:数据经过 RSA 算法加密;0x03:数据经过 AES128 位算法加密;“0xFE”表示异常,“0xFF”表示无效 - /// - public EncryptMethod EncryptMethod { get; private set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEPackage.cs b/src/GBNewEnergy.Protocol/NEPackage.cs deleted file mode 100644 index c84637a..0000000 --- a/src/GBNewEnergy.Protocol/NEPackage.cs +++ /dev/null @@ -1,143 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using System; -using System.IO; - -namespace GBNewEnergy.Protocol -{ - /// - /// 新能源包 - /// - public class NEPackage : NEBufferedEntityBase - { - public NEPackage(byte[] header, byte[] body, NEGlobalConfigs nEConfigs) : base(header, body, nEConfigs) - { - } - - public NEPackage(byte[] buf, NEGlobalConfigs nEConfigs) : base(buf, nEConfigs) - { - } - - public NEPackage(INEProperties nEProperties, NEGlobalConfigs nEConfigs) - : base(nEProperties, nEConfigs) - { } - - /// - /// 固定为24个字节长度 - /// - public const int HeaderFixedByteLength = 24; - /// - /// 起始符 - /// - public const byte BeginFlag = 0x23; - /// - /// 校验位1字节 - /// - private const int CheckBit = 1; - /// - /// 命令标识 - /// - public NEMsgId MsgId { get; private set; } - /// - /// 应答标志 - /// - public NEAskId AskId { get; private set; } - /// - /// 车辆识别码 - /// - public string VIN { get; private set; } - /// - /// 数据加密方式 - /// 0x01:数据不加密;0x02:数据经过 RSA 算法加密;0x03:数据经过 AES128 位算法加密;“0xFE”表示异常,“0xFF”表示无效 - /// - public NEEncryptMethod EncryptMethod { get; private set; } - /// - /// 数据单元长度是数据单元的总字节数,有效值范围:0-65531 - /// - public int DataUnitLength { get; private set; } - /// - /// 采用BCC(异或检验)法,校验范围从命令单元的第一个字节开始,同后一个字节异或,直到校验码前一个字节为止, - /// 校验码占用一个字节,当数据单元存在加密时,应先加密后检验,先校验后解密 - /// - public byte BCCCode { get; private set; } - /// - /// 头数据 - /// - public byte[] Header { get; private set; } - /// - /// 数据体 - /// - public NEBodies Bodies { get; protected set; } - - protected override void ToBuffer() - { - // 固定单元长度 - DataUnitLength = Bodies.Buffer.Length; - Buffer = new byte[HeaderFixedByteLength + DataUnitLength + CheckBit]; - Buffer[0] = BeginFlag; - Buffer[1] = BeginFlag; - Buffer[2] = (byte)MsgId; - Buffer[3] = (byte)AskId; - Buffer.WriteLittle(VIN, 4); - Buffer[21] = (byte)EncryptMethod; - Buffer.WriteLittle(DataUnitLength, 22, 2); - if (NEConfigs.Encrypt != null) - { - Buffer.WriteLittle(NEConfigs.Encrypt.Encrypt(Bodies.Buffer), 24, DataUnitLength); - } - else - { - Buffer.WriteLittle(Bodies.Buffer, 24, DataUnitLength); - } - BCCCode = Buffer.ToXor(2, (HeaderFixedByteLength + DataUnitLength - 1)); - Buffer[HeaderFixedByteLength + DataUnitLength] = BCCCode; - Header = new byte[HeaderFixedByteLength]; - Array.Copy(Buffer, 0, Header, 0, HeaderFixedByteLength); - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NEPackageProperty nEPackageProperty = (NEPackageProperty)nEProperties; - VIN = nEPackageProperty.VIN; - MsgId = nEPackageProperty.MsgId; - AskId = nEPackageProperty.AskId; - Bodies = nEPackageProperty.Bodies; - EncryptMethod = NEConfigs.EncryptMethod; - } - - protected override void InitializePropertiesFromBuffer() - { - if (Buffer[0] != BeginFlag && Buffer[1] == BeginFlag) throw new NEException(NEErrorCode.BeginFlagError, $"{Buffer[0]},{Buffer[1]}"); - MsgId = (NEMsgId)Buffer[2]; - AskId = (NEAskId)Buffer[3]; - VIN = Buffer.ReadStringLittle(4, 17); - EncryptMethod = (NEEncryptMethod)Buffer[21]; - DataUnitLength = Buffer.ReadUShortH2LLittle(22, 2); - // 2.4. 验证校验码 - // 进行BCC校验码 - // 校验位 = 报文长度 - 最后一位(校验位) - 偏移量(2) - int checkBit = Buffer.Length - CheckBit - 2; - byte bCCCode = Buffer.ToXor(2, checkBit); - byte bCCCode2 = Buffer[Buffer.Length - CheckBit]; - if (bCCCode != bCCCode2) - { - throw new NEException(NEErrorCode.BCCCodeError, $"request:{bCCCode2}!=calculate:{bCCCode}"); - } - BCCCode = bCCCode2; - byte[] bodiesBytes = new byte[DataUnitLength + CheckBit]; - Array.Copy(Buffer, HeaderFixedByteLength, bodiesBytes, 0, bodiesBytes.Length); - if (NEConfigs.Encrypt != null) - { - Bodies = NEBodiesFactory.GetNEBodiesByMsgId(MsgId, NEConfigs.Encrypt.Decrypt(bodiesBytes),NEConfigs); - } - else - { - Bodies = NEBodiesFactory.GetNEBodiesByMsgId(MsgId, bodiesBytes, NEConfigs); - } - Header = new byte[HeaderFixedByteLength]; - Array.Copy(Buffer, 0, Header, 0, HeaderFixedByteLength); - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEControlAlarmParameter.cs b/src/GBNewEnergy.Protocol/NEProperties/NEControlAlarmParameter.cs deleted file mode 100644 index 6f51269..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEControlAlarmParameter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties -{ - /// - /// 控制命令 报警、预警 - /// - public class NEControlAlarmParameter - { - /// - /// 报警等级 - /// - public NEAlarmLevel nEAlarmLevel { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEControlProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEControlProperty.cs deleted file mode 100644 index bab00e7..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEControlProperty.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties -{ - /// - /// 控制命令属性 - /// - public class NEControlProperty : INEProperties - { - public string VIN { get; set ; } - /// - /// 命令ID 只能发送一个 - /// - public NEControlCmd CmdID { get; set; } - /// - /// 升级参数 - /// - public NEControlUpgradeParameter UpgradeParameter { get; set; } - /// - /// 报警,预警参数 - /// - public NEControlAlarmParameter AlarmParameter { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEControlUpgradeParameter.cs b/src/GBNewEnergy.Protocol/NEProperties/NEControlUpgradeParameter.cs deleted file mode 100644 index e3be834..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEControlUpgradeParameter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - /// - /// 控制命令,升级 - /// - public class NEControlUpgradeParameter - { - /// - /// URL地址 - /// - public string Url { get; set; } - /// - /// 拨号点名称 - /// - public string DialPointName { get; set; } - /// - /// 拨号用户名 - /// - public string DialUserName { get; set; } - /// - /// 拨号密码 - /// - public string DialPassword { get; set; } - /// - /// 服务器地址 - /// - public string ServerUrl { get; set; } - /// - /// 服务器端口 - /// - public string ServerPort { get; set; } - /// - /// 生产厂商代码 - /// - public string ProviderCode { get; set; } - /// - /// 硬件版本 - /// - public string HardwareVersion { get; set; } - /// - /// 固件版本 - /// - public string FirmwareVersion { get; set; } - /// - /// 升级服务器时限 - /// - public string UpLimitTime { get; set; } - public override string ToString() - { - return $"{Url};{DialPointName};{DialUserName};{DialPassword};{ServerUrl};{ServerPort};{ProviderCode};{HardwareVersion};{FirmwareVersion};{UpLimitTime}"; - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEEmptyProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEEmptyProperty.cs deleted file mode 100644 index f3d6ef8..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEEmptyProperty.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - /// - /// 空包属性 - /// - public class NEEmptyProperty : INEProperties - { - public string VIN { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NELoginProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NELoginProperty.cs deleted file mode 100644 index 0a558a3..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NELoginProperty.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - public class NELoginProperty : INEProperties - { - public string VIN { get; set; } - - public string SIM { get; set; } - - public byte BatteryCount { get; set; } - - public byte BatteryLength { get; set; } - - public IEnumerable BatteryNos { get; set;} - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NELogoutProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NELogoutProperty.cs deleted file mode 100644 index e002a99..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NELogoutProperty.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - public class NELogoutProperty : INEProperties - { - public string VIN { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEPackageProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEPackageProperty.cs deleted file mode 100644 index 3e74c9f..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEPackageProperty.cs +++ /dev/null @@ -1,15 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - public class NEPackageProperty : INEProperties - { - public string VIN { get; set; } - public NEMsgId MsgId { get; set; } - public NEAskId AskId { get; set; } - public NEBodies Bodies { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLoginProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLoginProperty.cs deleted file mode 100644 index 7ba7265..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLoginProperty.cs +++ /dev/null @@ -1,27 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - public class NEPlatformLoginProperty : INEProperties - { - [Obsolete("平台登入无用字段")] - public string VIN { get ; set; } - /// - /// 平台用户名 - /// - public string UserName { get; set; } - - /// - /// 加密规则 - /// - public NEEncryptMethod EncryptMethod { get; set; } - - /// - /// 平台密码 - /// - public string Password { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLogoutProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLogoutProperty.cs deleted file mode 100644 index b319ab7..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEPlatformLogoutProperty.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties -{ - public class NEPlatformLogoutProperty : INEProperties - { - [Obsolete("平台登入无用字段")] - public string VIN { get; set; } - /// - /// 平台用户名 - /// - public string UserName { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadAlarmProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadAlarmProperty.cs deleted file mode 100644 index 706d3f8..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadAlarmProperty.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 报警数据 - /// - public class NEUploadAlarmProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.报警数据; - - /// - /// 报警等级 - /// - public byte AlarmLevel { get; set; } - /// - /// 通用报警标志 - /// - public int AlarmBatteryFlag { get; set; } - /// - /// 报警没变化 0,有报警 1 - /// - public byte AlarmBatteryChanged { get; set; } - /// - /// 可充电储能装置故障总数 - /// - public byte AlarmBatteryOtherCount { get; set; } - /// - /// 可充电储能装置故障代码列表 - /// - public List AlarmBatteryOtherList { get; set; } = new List(); - /// - /// 驱动电机故障总数 - /// - public byte AlarmElCount { get; set; } - /// - /// 驱动电机故障代码列表 - /// - public List AlarmElList { get; set; } = new List(); - /// - /// 发动机故障总数 - /// - public byte AlarmEngineCount { get; set; } - /// - /// 发动机故障列表 - /// - public ListAlarmEngineList { get; set; } = new List(); - /// - /// 其他故障总数 - /// - public byte AlarmOtherCount { get; set; } - /// - /// 其他故障代码列表 - /// - public List AlarmOtherList { get; set; } = new List(); - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadDrivenElectricalProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadDrivenElectricalProperty.cs deleted file mode 100644 index 37a685a..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadDrivenElectricalProperty.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 驱动电机数据 - /// - public class NEUploadDrivenElectricalProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.驱动电机数据; - - /// - /// 电机个数 - /// - public byte ElectricalCount; - /// - /// 电机信息集合 - /// - public IEnumerable ElectricalList { get; set; } - - /// - /// 电机信息 - /// - public class ElectricalInfo - { - /// - /// 电机序号 - /// - public byte ElNo { get; set; } - /// - /// 电机状态 - /// - public byte ElStatus { get; set; } - /// - /// 电机控制器温度 - /// - public int ElControlTemp { get; set; } - /// - /// 电机转速 - /// - public int ElSpeed { get; set; } - /// - /// 电机转矩 - /// - public double ElTorque { get; set; } - /// - /// 电机温度 - /// - public int ElTemp { get; set; } - /// - /// 电机电压 - /// - public double ElVoltage { get; set; } - /// - /// 电机母线电流 - /// - public double ElCurrent { get; set; } - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageProperty.cs deleted file mode 100644 index 0541c0f..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageProperty.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 可充电储能装置电压数据 - /// - public class NEUploadEnergyStorageProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.可充电储能装置电压数据; - - /// - /// 可充电储能子系统个数 - /// - public byte BatteryAssemblyCount { get; set; } - - /// - /// 可充电储能子系统电压信息列表 - /// - public List BatteryAssemblyList { get; set; } = new List(); - - /// - /// 每个电池总成数据 - /// - public class BatteryAssembly - { - /// - /// 可充电储能子系统号 - /// - public byte BatteryAssemblyNo { get; set; } - /// - /// 可充电储能装置电压 - /// - public double BatteryAssemblyVoltage { get; set; } - /// - /// 可充电储能装置电流 - /// - public double BatteryAssemblyCurrent { get; set; } - /// - /// 单体电池总数 - /// - public int SingleBatteryCount { get; set; } - /// - /// 本帧起始电池序号 - /// - public int ThisSingleBatteryBeginNo { get; set; } - /// - /// /本帧单体电池总数 - /// - public int ThisSingleBatteryBeginCount { get; set; } - /// - /// 单体电池电压 - /// - public List SingleBatteryVoltageList { get; set; } = new List(); - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageTemperatureProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageTemperatureProperty.cs deleted file mode 100644 index 9302658..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnergyStorageTemperatureProperty.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 可充电储能装置温度数据 - /// - public class NEUploadEnergyStorageTemperatureProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.可充电储能装置温度数据; - - /// - /// 动力蓄电池总成个数 - /// - public byte BatteryAssemblyCount { get; set; } - /// - /// 每个可充电储能子系统温度信息长度 - /// - public List BatteryAssemblyList { get; set; } = new List(); - - /// - /// 每个动力蓄电池上温度数据 - /// - public class BatteryTemperature - { - /// - /// 可充电储能子系统号 - /// - public byte BatteryAssemblyNo { get; set; } - /// - /// 可充电储能温度探针个数 - /// - public int TemperatureProbeCount { get; set; } - /// - /// 可充电储能子系统各温度探针检测到的温度值 - /// - public List TemperatureList { get; set; } = new List(); - } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnginePartProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnginePartProperty.cs deleted file mode 100644 index 0ca2431..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadEnginePartProperty.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 发动机部分数据 - /// - public class NEUploadEnginePartProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.发动机数据; - /// - /// 发动机状态 - /// 0x01:启动状态 - /// 0x02:关闭状态 - /// 0xFE:异常 - /// 0xFF:无效 - /// - public byte EngineStatus { get; set; } - /// - /// 曲轴转速 - /// 有效范围:0-60000(表示0 r/min-60000 r/min) - /// 最小计量单元:1 r/min - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public int Revs { get; set; } - /// - /// 燃料消耗率 - /// 有效值范围:0-60000(表示0L/100km - 600L/100km) - /// 最小计量单元:0.01L/km - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double FuelRate { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadExtremeProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadExtremeProperty.cs deleted file mode 100644 index 84bd2cf..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadExtremeProperty.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 极值数据 - /// - public class NEUploadExtremeProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.极值数据; - - /// - /// 最高电压电池总成号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MaxVoltageBatteryAssemblyNo { get; set; } - /// - /// 最高电压电池单体代号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MaxVoltageSingleBatteryNo { get; set; } - /// - /// 电池单体电压最高值 - /// 有效值范围:0-15000(表示0V - 15V) - /// 最小计量单元:0.001V - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double MaxVoltageSingleBatteryValue { get; set; } - /// - /// 最低电压电池子系统号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MinVoltageBatteryAssemblyNo { get; set; } - /// - /// 最低电压电池单体代号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MinVoltageSingleBatteryNo { get; set; } - /// - /// 最低单体电压最低值 - /// 有效值范围:0-15000(表示0V - 15V) - /// 最小计量单元:0.001V - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double MinVoltageSingleBatteryValue { get; set; } - /// - /// 蓄电池中最高温度子系统号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MaxTempProbeBatteryNo { get; set; } - /// - /// 蓄电池中最高温度探针序号 - /// 有效值范围:1-250 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte MaxTempBatteryAssemblyNo { get; set; } - /// - /// 最高温度值 - /// 有效值范围:0-250(数值偏移量40℃,表示-40℃ - +210℃) - /// 最小计量单元:1℃ - /// 异常:0XFE - /// 无效:0xFF - /// - public int MaxTempProbeBatteryValue { get; set; } - /// - /// 最低温度子系统号 - /// - public byte MinTempProbeBatteryNo { get; set; } - /// - /// 蓄电池中最低温度探针序号 - /// - public byte MinTempBatteryAssemblyNo { get; set; } - /// - /// 最低温度值 - /// - public int MinTempProbeBatteryValue { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadFuelBatteryProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadFuelBatteryProperty.cs deleted file mode 100644 index 77a2dd8..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadFuelBatteryProperty.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 燃料电池数据 - /// - public class NEUploadFuelBatteryProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.燃料电池数据; - /// - /// 燃料电池电压 - /// 有效值范围:0 - 20000(表示 0V-2000V) - /// 最小计量单元:0.1V - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double FuelBatteryVoltage { get; set; } - /// - /// 燃料电池电流 - /// 有效值范围:0 - 20000(表示 0A- +2000A) - /// 最小计量单元:0.1 A - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double FuelBatteryCurrent { get; set; } - /// - /// 燃料消耗率 - /// 有效值范围:0-60000(表示 0kg/100km - 600kg/100km) - /// 最小计量单元:0.01kg/100km - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double FuelConsumptionRate { get; set; } - /// - /// 燃料电池温度探针总数 - /// N个燃料电池温度探针 - /// 有效值范围:0-65531 - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public int TemperatureProbeCount { get; set; } - /// - /// 探针温度值 - /// 有效值范围:0-240(数值偏移量40 ℃,表示-40 ℃ - +200 ℃) - /// 最小计量单元:1 ℃ - /// - public List TemperatureList { get; set; } = new List(); - /// - /// 氢系统中最高温度 - /// 有效值范围:0-2400(偏移量40 ℃,表示-40 ℃ - 200 ℃) - /// 最小计量单元:0.1 ℃ - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double HydrogenSystemMaxTemp { get; set; } - /// - /// 氢系统中最高温度探针代号 - /// 有效值范围:1-252 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte HydrogenSystemMaxTempNo { get; set; } - /// - /// 氢气最高浓度 - /// 有效值范围:0-60000(表示0 mg/kg - 50000 mg/kg) - /// 最小计量单元:1 mg/kg - /// 异常:0xFF,0XFE - /// 无效:0xFF,0xFF - /// - public double HydrogenSystemMaxConcentrations { get; set; } - /// - /// 氢气最高浓度传感器代号 - /// 有效值范围:1-252 - /// 异常:0XFE - /// 无效:0xFF - /// - public byte HydrogenSystemMaxConcentrationsNo { get; set; } - /// - /// 氢气最高压力 - /// 有效值范围:0-1000(表示0MPa - 100MPa),最小计量单位:0.1MPa - /// - public double HydrogenSystemMaxPressure { get; set; } - /// - /// 氢气最高压力传感器代号 - /// 有效值访问:1-252 - /// 异常:0xFE - /// 无效:0xFF - /// - public byte HydrogenSystemMaxPressureNo { get; set; } - /// - /// 高压DC/DC状态 - /// 0x01:工作 - /// 0x02:断开 - /// 0xFE:表示异常 - /// 0xFF:表示无效 - /// - public byte DCStatus { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadProperty.cs deleted file mode 100644 index f31683d..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadProperty.cs +++ /dev/null @@ -1,26 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 上报信息 - /// - public class NEUploadProperty : INEProperties - { - public string VIN { get ; set; } - - public NEUploadProperty(params NEUploadPropertyBase[] NEUploadPropertyBase) - { - if (NEUploadPropertyBase != null) - { - NEUploadPropertys = NEUploadPropertyBase.ToList(); - } - } - - public List NEUploadPropertys { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadPropertyBase.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadPropertyBase.cs deleted file mode 100644 index 97df227..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadPropertyBase.cs +++ /dev/null @@ -1,12 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - public abstract class NEUploadPropertyBase - { - public abstract NEInfoType NEInfoType { get; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehiclePositionProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehiclePositionProperty.cs deleted file mode 100644 index 0bd82cc..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehiclePositionProperty.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 车辆位置数据 - /// - public class NEUploadVehiclePositionProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.车辆位置数据; - /// - /// 定位状态 - /// 0位:0:有效定位;1:无效定位(当数据通信正常,而不能获取定位信息时,发送最后一次有效定位信息,并将定位状态置为无效。) - /// 1位:0:北纬;1:南纬 - /// 2位:0:东经;1:西经 - /// 3-7位:保留 - /// - public byte PositioStatus { get; set; } - /// - /// 经度 - /// 以度位单位的经度值乘以10^6,精确到百万分之一度 - /// - public double Lng { get; set; } - /// - /// 纬度 - /// 以度位单位的纬度值乘以10^6,精确到百万分之一度 - /// - public double Lat { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehicleProperty.cs b/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehicleProperty.cs deleted file mode 100644 index b01a676..0000000 --- a/src/GBNewEnergy.Protocol/NEProperties/NEUploadProperties/NEUploadVehicleProperty.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.Enums; - -namespace GBNewEnergy.Protocol.NEProperties.NEUploadProperties -{ - /// - /// 整车数据 - /// - public class NEUploadVehicleProperty : NEUploadPropertyBase - { - public override NEInfoType NEInfoType => NEInfoType.整车数据; - - /// - /// 车辆状态 - /// - public byte CarStatus { get; set; } - /// - /// 充放电状态 - /// - public byte ChargeStatus { get; set; } - /// - /// 运行模式 - /// - public byte OperationMode { get; set; } - /// - /// 车速 - /// - public double Speed { get; set; } - /// - /// 当前里程 - /// - public double Dis { get; set; } - /// - /// 总里程 - /// - public double TotalDis { get; set; } - /// - /// 总电压 - /// - public double TotalVoltage { get; set; } - /// - /// 总电流 - /// - public double TotalTemp { get; set; } - /// - /// SOC - /// - public byte soc { get; set; } - /// - /// DC-DC 状态 - /// - public byte DCStatus { get; set; } - /// - /// 档位 - /// - public byte Stall { get; set; } - /// - /// 加速踏板行程值 - /// - public byte Accelerator { get; set; } - /// - /// 制动踏板状态 - /// - public byte Brakes { get; set; } - /// - /// 绝缘电阻 - /// - public int Resistance { get; set; } - } -} diff --git a/src/GBNewEnergy.Protocol/NEUpStreamBase.cs b/src/GBNewEnergy.Protocol/NEUpStreamBase.cs deleted file mode 100644 index f94a94e..0000000 --- a/src/GBNewEnergy.Protocol/NEUpStreamBase.cs +++ /dev/null @@ -1,14 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol -{ - public abstract class NEUpStreamBase - { - public DateTime Utc{ get; set; } - public byte[] Buffer { get;protected set; } - public abstract void ToBuffer(); - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/CommonUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/CommonUpStream.cs deleted file mode 100644 index 18ee1f7..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/CommonUpStream.cs +++ /dev/null @@ -1,37 +0,0 @@ -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 通用应答 - /// - public class CommonUpStream : NEBodies - { - public CommonUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public CommonUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - } - - protected override void ToBuffer() - { - Buffer = new byte[6]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - } - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/NELoginUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/NELoginUpStream.cs deleted file mode 100644 index f72593d..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/NELoginUpStream.cs +++ /dev/null @@ -1,106 +0,0 @@ -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 车辆登入 - /// - public class NELoginUpStream : NEBodies - { - public NELoginUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - public NELoginUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - /// - /// SIM 卡号 - /// - public string SIM { get; set; } - /// - /// 电池总成数 - /// 可充电储能子系统数 - /// - public byte BatteryCount { get; set; } - /// - /// 电池编码长度 - /// 可充电储能系统编码长度 - /// - public byte BatteryLength { get; set; } - /// - /// 电池编码 - /// 可充电储能系统编码 - /// - public IEnumerable BatteryNos { get; set; } - - protected override void ToBuffer() - { - // 根据协议说明书 - Buffer = new byte[6 + 2 + 20 + 1 + 1 + (BatteryCount * BatteryLength)]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(LoginNum, 6, 2); - Buffer.WriteLittle(SIM, 8); - Buffer[28] = BatteryCount; - Buffer[29] = BatteryLength; - if ((BatteryCount * BatteryLength) != 0) - { - string str = string.Join("", BatteryNos); - Buffer.WriteLittle(str, 30); - } - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NELoginProperty nELoginProperty = (NELoginProperty)nEProperties; - if (LoginNumDict.ContainsKey(nELoginProperty.VIN)) - { - LoginInfo temp; - if (LoginNumDict.TryGetValue(nELoginProperty.VIN, out temp)) - { - // 不等于当天 - if (temp.ExpirationTime != DateTime.Now.Date) - { - LoginNum = 1; - LoginNumDict.TryUpdate(nELoginProperty.VIN, new LoginInfo { LoginNum = LoginNum, ExpirationTime=DateTime.Now.Date }, temp); - } - else - {// 自增1 更新字典 - LoginNum = temp.LoginNum++; - LoginNumDict.TryUpdate(nELoginProperty.VIN, new LoginInfo { LoginNum = LoginNum, ExpirationTime = DateTime.Now.Date }, temp); - } - } - } - else - { - LoginNum = 1; - LoginNumDict.TryAdd(nELoginProperty.VIN, new LoginInfo { LoginNum = LoginNum, ExpirationTime = DateTime.Now.Date }); - } - SIM = nELoginProperty.SIM; - BatteryCount = nELoginProperty.BatteryCount; - BatteryLength = nELoginProperty.BatteryLength; - BatteryNos = nELoginProperty.BatteryNos; - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - LoginNum = Buffer.ReadUShortH2LLittle(6, 2); - SIM = Buffer.ReadStringLittle(8, 20); - BatteryCount = Buffer[28]; - BatteryLength = Buffer[29]; - List batteryNos = new List(); - for (int i = 0; i < BatteryCount; i++) - { - batteryNos.Add(Buffer.ReadStringLittle(i * BatteryLength + 30, BatteryLength)); - } - BatteryNos = batteryNos; - } - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/NELogoutUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/NELogoutUpStream.cs deleted file mode 100644 index 1be54f8..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/NELogoutUpStream.cs +++ /dev/null @@ -1,50 +0,0 @@ -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Collections.Generic; -using System.Text; -using GBNewEnergy.Protocol.NEProperties; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 车辆登出 - /// - public class NELogoutUpStream : NEBodies - { - public NELogoutUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - public NELogoutUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NELogoutProperty nELogoutProperty = (NELogoutProperty)nEProperties; - LoginInfo temp; - if (LoginNumDict.TryGetValue(nELogoutProperty.VIN, out temp)) - { - LoginNum = temp.LoginNum; - } - else - { - throw new NEException(Enums.NEErrorCode.LoginSerialNoError, "Must Dependency NELoginUpStream Class."); - } - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - LoginNum = Buffer.ReadUShortH2LLittle(6, 2); - } - - protected override void ToBuffer() - { - Buffer = new byte[8]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(LoginNum, 6, 2); - } - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/NEPlatformLoginUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/NEPlatformLoginUpStream.cs deleted file mode 100644 index 7935414..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/NEPlatformLoginUpStream.cs +++ /dev/null @@ -1,88 +0,0 @@ -using GBNewEnergy.Protocol.Enums; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 平台登入 - /// - public class NEPlatformLoginUpStream : NEBodies - { - public NEPlatformLoginUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public NEPlatformLoginUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - /// - /// 平台用户名 - /// - public string UserName { get; set; } - - /// - /// 加密规则 - /// - public NEEncryptMethod EncryptMethod { get; set; } - - /// - /// 平台密码 - /// - public string Password { get; set; } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NEPlatformLoginProperty nEPlatformLoginProperty = (NEPlatformLoginProperty)nEProperties; - if (PlatformLoginNumDict.ContainsKey(nEPlatformLoginProperty.UserName)) - { - PlatformLoginInfo temp; - if (PlatformLoginNumDict.TryGetValue(nEPlatformLoginProperty.UserName, out temp)) - { - // 不等于当天 - if (temp.ExpirationTime != DateTime.Now.Date) - { - LoginNum = 1; - PlatformLoginNumDict.TryUpdate(nEPlatformLoginProperty.UserName, new PlatformLoginInfo { LoginNum = LoginNum, ExpirationTime = DateTime.Now.Date }, temp); - } - else - {// 自增1 更新字典 - LoginNum = temp.LoginNum++; - PlatformLoginNumDict.TryUpdate(nEPlatformLoginProperty.UserName, new PlatformLoginInfo { LoginNum = LoginNum, ExpirationTime = DateTime.Now.Date }, temp); - } - } - } - else - { - LoginNum = 1; - PlatformLoginNumDict.TryAdd(nEPlatformLoginProperty.UserName, new PlatformLoginInfo { LoginNum = LoginNum, ExpirationTime = DateTime.Now.Date }); - } - UserName = nEPlatformLoginProperty.UserName; - EncryptMethod = nEPlatformLoginProperty.EncryptMethod; - Password = nEPlatformLoginProperty.Password; - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - LoginNum = Buffer.ReadUShortH2LLittle(6, 2); - UserName = Buffer.ReadStringLittle(8, 12); - Password = Buffer.ReadStringLittle(20, 20); - EncryptMethod= (NEEncryptMethod)Buffer[40]; - } - - protected override void ToBuffer() - { - Buffer = new byte[6+2+12+20+1]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(LoginNum, 6, 2); - Buffer.WriteLittle(UserName, 12); - Buffer.WriteLittle(Password, 20); - Buffer.WriteLittle((byte)EncryptMethod, 40); - } - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/NEPlatformLogoutUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/NEPlatformLogoutUpStream.cs deleted file mode 100644 index 4323a91..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/NEPlatformLogoutUpStream.cs +++ /dev/null @@ -1,47 +0,0 @@ -using GBNewEnergy.Protocol.Exceptions; -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEProperties; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 平台登出 - /// - public class NEPlatformLogoutUpStream : NEBodies - { - public NEPlatformLogoutUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - public NEPlatformLogoutUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NEPlatformLogoutProperty nEPlatformLogoutProperty = (NEPlatformLogoutProperty)nEProperties; - PlatformLoginInfo temp; - if (PlatformLoginNumDict.TryGetValue(nEPlatformLogoutProperty.UserName, out temp)) - { - LoginNum = temp.LoginNum; - } - else - { - throw new NEException(Enums.NEErrorCode.LoginSerialNoError, "Must Dependency NEPlatformLoginUpStream Class."); - } - } - - protected override void InitializePropertiesFromBuffer() - { - CurrentDateTime = Buffer.ReadDateTimeLittle(0, 6); - LoginNum = Buffer.ReadUShortH2LLittle(6, 2); - } - - protected override void ToBuffer() - { - Buffer = new byte[8]; - Buffer.WriteLittle(CurrentDateTime, 0, 6); - Buffer.WriteLittle(LoginNum, 6, 2); - } - } -} diff --git a/src/GBNewEnergy.Protocol/UpStream/NERealUploadUpStream.cs b/src/GBNewEnergy.Protocol/UpStream/NERealUploadUpStream.cs deleted file mode 100644 index db8217a..0000000 --- a/src/GBNewEnergy.Protocol/UpStream/NERealUploadUpStream.cs +++ /dev/null @@ -1,38 +0,0 @@ -using GBNewEnergy.Protocol.NEProperties.NEUploadProperties; -using System; -using System.Collections.Generic; -using System.Text; - -namespace GBNewEnergy.Protocol.UpStream -{ - /// - /// 实时信息上报 - /// - public class NERealUploadUpStream : NEBodies - { - public NERealUploadUpStream(byte[] buffer, NEGlobalConfigs nEConfigs) : base(buffer, nEConfigs) - { - } - - public NERealUploadUpStream(INEProperties nEProperties, NEGlobalConfigs nEConfigs) : base(nEProperties, nEConfigs) - { - } - - public NEUploadProperty NEUploadProperty { get;private set; } - - protected override void InitializeProperties(INEProperties nEProperties) - { - NEUploadProperty = (NEUploadProperty)nEProperties; - } - - protected override void InitializePropertiesFromBuffer() - { - throw new NotImplementedException(); - } - - protected override void ToBuffer() - { - throw new NotImplementedException(); - } - } -} diff --git a/src/GBNewEnergy.sln b/src/GBNewEnergy.sln deleted file mode 100644 index 36b30b5..0000000 --- a/src/GBNewEnergy.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2018 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GBNewEnergy.Protocol", "GBNewEnergy.Protocol\GBNewEnergy.Protocol.csproj", "{1934F3A6-1396-46C2-BFD6-1E2DC1A26E3A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GBNewEnergy.Protocol.Test", "GBNewEnergy.Protocol.Test\GBNewEnergy.Protocol.Test.csproj", "{AAA669F5-E689-40CA-97EF-B5BA672B11DD}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NEEncrypts.Tests", "NEEncrypts.Tests", "{1D162FFB-5944-470C-B6F0-8F7387C706DF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEEncryptsNET4.Test", "NEEncrypts.Tests\NEEncryptsNET4.Test\NEEncryptsNET4.Test.csproj", "{7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NEEncryptsNET45.Test", "NEEncrypts.Tests\NEEncryptsNET45.Test\NEEncryptsNET45.Test.csproj", "{1ED77002-D542-4013-B71A-C52CE92D5747}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NEEncryptsNETCore.Test", "NEEncrypts.Tests\NEEncryptsNETCore.Test\NEEncryptsNETCore.Test.csproj", "{361FD688-A06B-4D68-9B76-93C6559278E8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1934F3A6-1396-46C2-BFD6-1E2DC1A26E3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1934F3A6-1396-46C2-BFD6-1E2DC1A26E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1934F3A6-1396-46C2-BFD6-1E2DC1A26E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1934F3A6-1396-46C2-BFD6-1E2DC1A26E3A}.Release|Any CPU.Build.0 = Release|Any CPU - {AAA669F5-E689-40CA-97EF-B5BA672B11DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AAA669F5-E689-40CA-97EF-B5BA672B11DD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AAA669F5-E689-40CA-97EF-B5BA672B11DD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AAA669F5-E689-40CA-97EF-B5BA672B11DD}.Release|Any CPU.Build.0 = Release|Any CPU - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92}.Release|Any CPU.Build.0 = Release|Any CPU - {1ED77002-D542-4013-B71A-C52CE92D5747}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1ED77002-D542-4013-B71A-C52CE92D5747}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1ED77002-D542-4013-B71A-C52CE92D5747}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1ED77002-D542-4013-B71A-C52CE92D5747}.Release|Any CPU.Build.0 = Release|Any CPU - {361FD688-A06B-4D68-9B76-93C6559278E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {361FD688-A06B-4D68-9B76-93C6559278E8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {361FD688-A06B-4D68-9B76-93C6559278E8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {361FD688-A06B-4D68-9B76-93C6559278E8}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92} = {1D162FFB-5944-470C-B6F0-8F7387C706DF} - {1ED77002-D542-4013-B71A-C52CE92D5747} = {1D162FFB-5944-470C-B6F0-8F7387C706DF} - {361FD688-A06B-4D68-9B76-93C6559278E8} = {1D162FFB-5944-470C-B6F0-8F7387C706DF} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E7AF20B3-4327-4DF7-B503-9FE08AA92A75} - EndGlobalSection -EndGlobal diff --git a/src/NEEncrypts.Tests/NEEncrypts for linux.png b/src/NEEncrypts.Tests/NEEncrypts for linux.png deleted file mode 100644 index 83c58b3..0000000 Binary files a/src/NEEncrypts.Tests/NEEncrypts for linux.png and /dev/null differ diff --git a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/NEEncryptsNET4.Test.csproj b/src/NEEncrypts.Tests/NEEncryptsNET4.Test/NEEncryptsNET4.Test.csproj deleted file mode 100644 index 3f609c2..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/NEEncryptsNET4.Test.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - - Debug - AnyCPU - {7C7C1511-EB17-4DBF-B04F-EFE8FF4ECE92} - Exe - NEEncryptsNET4.Test - NEEncryptsNET4.Test - v4.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - {1934f3a6-1396-46c2-bfd6-1e2dc1a26e3a} - GBNewEnergy.Protocol - - - - \ No newline at end of file diff --git a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Program.cs b/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Program.cs deleted file mode 100644 index aa38ed5..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Program.cs +++ /dev/null @@ -1,46 +0,0 @@ -using GBNewEnergy.Protocol.NEEncrypts; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using GBNewEnergy.Protocol.Extensions; - -namespace NEEncryptsNET4.Test -{ - class Program - { - static void Main(string[] args) - { - Default_NEAES128EncryptImpl nE_AES128EncryptImpl = new Default_NEAES128EncryptImpl("smallchi"); - string str = "aaasssddd123"; - var bytes = Encoding.UTF8.GetBytes(str); - var encrypt = nE_AES128EncryptImpl.Encrypt(bytes); - Console.WriteLine("原数据:" + str); - Console.WriteLine("加密后:" + encrypt.ToHexString()); - Console.WriteLine("解密后:" + Encoding.UTF8.GetString(nE_AES128EncryptImpl.Decrypt(encrypt))); - - Default_NERSAEncryptImpl_NET rsa = new Default_NERSAEncryptImpl_NET(Encoding.UTF8, - "SHA256", - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
", - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
" - ); - - Console.WriteLine("原始字符串:" + str); - //加密 - byte[] enBytes = rsa.Encrypt(Encoding.UTF8.GetBytes(str)); - Console.WriteLine("加密字符串:" + enBytes.ToHexString()); - //解密 - byte[] deBytes = rsa.Decrypt(enBytes); - Console.WriteLine("解密字符串:" + Encoding.UTF8.GetString(deBytes)); - //私钥签名 - string signStr = rsa.Sign(str); - Console.WriteLine("字符串签名:" + signStr); - //公钥验证签名 - bool signVerify = rsa.Verify(str, signStr); - Console.WriteLine("验证签名:" + signVerify); - Console.ReadKey(); - } - } -} diff --git a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Properties/AssemblyInfo.cs b/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index dc3d42f..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET4.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("NEEncryptsNET4.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NEEncryptsNET4.Test")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("7c7c1511-eb17-4dbf-b04f-efe8ff4ece92")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/App.config b/src/NEEncrypts.Tests/NEEncryptsNET45.Test/App.config deleted file mode 100644 index 8e15646..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/NEEncryptsNET45.Test.csproj b/src/NEEncrypts.Tests/NEEncryptsNET45.Test/NEEncryptsNET45.Test.csproj deleted file mode 100644 index 4772fa8..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/NEEncryptsNET45.Test.csproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - - Debug - AnyCPU - {1ED77002-D542-4013-B71A-C52CE92D5747} - Exe - NEEncryptsNET45.Test - NEEncryptsNET45.Test - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - {1934f3a6-1396-46c2-bfd6-1e2dc1a26e3a} - GBNewEnergy.Protocol - - - - \ No newline at end of file diff --git a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Program.cs b/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Program.cs deleted file mode 100644 index ec6bed1..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -using GBNewEnergy.Protocol.Extensions; -using GBNewEnergy.Protocol.NEEncrypts; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NEEncryptsNET45.Test -{ - class Program - { - static void Main(string[] args) - { - Default_NEAES128EncryptImpl nE_AES128EncryptImpl = new Default_NEAES128EncryptImpl("smallchi"); - string str = "aaasssddd123"; - var bytes = Encoding.UTF8.GetBytes(str); - var encrypt = nE_AES128EncryptImpl.Encrypt(bytes); - Console.WriteLine("原数据:" + str); - Console.WriteLine("加密后:" + encrypt.ToHexString()); - Console.WriteLine("解密后:" + Encoding.UTF8.GetString(nE_AES128EncryptImpl.Decrypt(encrypt))); - - Default_NERSAEncryptImpl_NET rsa = new Default_NERSAEncryptImpl_NET(Encoding.UTF8, - "SHA256", - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
", - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
" - ); - - Console.WriteLine("原始字符串:" + str); - //加密 - byte[] enBytes = rsa.Encrypt(Encoding.UTF8.GetBytes(str)); - Console.WriteLine("加密字符串:" + enBytes.ToHexString()); - //解密 - byte[] deBytes = rsa.Decrypt(enBytes); - Console.WriteLine("解密字符串:" + Encoding.UTF8.GetString(deBytes)); - //私钥签名 - string signStr = rsa.Sign(str); - Console.WriteLine("字符串签名:" + signStr); - //公钥验证签名 - bool signVerify = rsa.Verify(str, signStr); - Console.WriteLine("验证签名:" + signVerify); - Console.ReadKey(); - } - } -} diff --git a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Properties/AssemblyInfo.cs b/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Properties/AssemblyInfo.cs deleted file mode 100644 index 4fc5026..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNET45.Test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("NEEncryptsNET45.Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("NEEncryptsNET45.Test")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("1ed77002-d542-4013-b71a-c52ce92d5747")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/NEEncryptsNETCore.Test.csproj b/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/NEEncryptsNETCore.Test.csproj deleted file mode 100644 index 8062fb2..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/NEEncryptsNETCore.Test.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - - - - - diff --git a/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/Program.cs b/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/Program.cs deleted file mode 100644 index dcaadf5..0000000 --- a/src/NEEncrypts.Tests/NEEncryptsNETCore.Test/Program.cs +++ /dev/null @@ -1,52 +0,0 @@ -using GBNewEnergy.Protocol.NEEncrypts; -using GBNewEnergy.Protocol.Extensions; -using System; -using System.Text; -using System.Security.Cryptography; - -namespace NEEncryptsNETCore.Test -{ - class Program - { - static void Main(string[] args) - { - //Default_NEAES128EncryptImpl nE_AES128EncryptImpl = new Default_NEAES128EncryptImpl("smallchi"); - string str = "aaaaaa111111"; - //var bytes = Encoding.UTF8.GetBytes(str); - //var encrypt = nE_AES128EncryptImpl.Encrypt(bytes); - //Console.WriteLine("原数据:" + str); - //Console.WriteLine("加密后:" + encrypt.ToHexString()); - //Console.WriteLine("解密后:" + Encoding.ASCII.GetString(nE_AES128EncryptImpl.Decrypt(encrypt))); - - //NERSAEncryptImpl rsa = new NERSAEncryptImpl( - // new GBNewEnergy.Protocol.NEGlobalConfigs() - // { - // NEEncryptRSAPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoQh0wEqx/R2H1v00IU12Oc30fosRC/frhH89L6G+fzeaqI19MYQhEPMU13wpeqRONCUta+2iC1sgCNQ9qGGf19yGdZUfueaB1Nu9rdueQKXgVurGHJ+5N71UFm+OP1XcnFUCK4wT5d7ZIifXxuqLehP9Ts6sNjhVfa+yU+VjF5HoIe69OJEPo7OxRZcRTe17khc93Ic+PfyqswQJJlY/bgpcLJQnM+QuHmxNtF7/FpAx9YEQsShsGpVo7JaKgLo+s6AFoJ4QldQKir2vbN9vcKRbG3piElPilWDpjXQkOJZhUloh/jd7QrKFimZFldJ1r6Q59QYUyGKZARUe0KZpMQIDAQAB", - // NEEncryptRSAPrivateKey = "MIIEpAIBAAKCAQEAoQh0wEqx/R2H1v00IU12Oc30fosRC/frhH89L6G+fzeaqI19MYQhEPMU13wpeqRONCUta+2iC1sgCNQ9qGGf19yGdZUfueaB1Nu9rdueQKXgVurGHJ+5N71UFm+OP1XcnFUCK4wT5d7ZIifXxuqLehP9Ts6sNjhVfa+yU+VjF5HoIe69OJEPo7OxRZcRTe17khc93Ic+PfyqswQJJlY/bgpcLJQnM+QuHmxNtF7/FpAx9YEQsShsGpVo7JaKgLo+s6AFoJ4QldQKir2vbN9vcKRbG3piElPilWDpjXQkOJZhUloh/jd7QrKFimZFldJ1r6Q59QYUyGKZARUe0KZpMQIDAQABAoIBAQCRZLUlOUvjIVqYvhznRK1OG6p45s8JY1r+UnPIId2Bt46oSLeUkZvZVeCnfq9k0Bzb8AVGwVPhtPEDh73z3dEYcT/lwjLXAkyPB6gG5ZfI/vvC/k7JYV01+neFmktw2/FIJWjEMMF2dvLNZ/Pm4bX1Dz9SfD/45Hwr8wqrvRzvFZsj5qqOxv9RPAudOYwCwZskKp/GF+L+3Ycod1Wu98imzMZUH+L5dQuDGg3kvf3ljIAegTPoqYBg0imNPYY/EGoFKnbxlK5S5/5uAFb16dGJqAz3XQCz9Is/IWrOTu0etteqV2Ncs8uqPdjed+b0j8CMsr4U1xjwPQ8WwdaJtTkRAoGBANAndgiGZkCVcc9975/AYdgFp35W6D+hGQAZlL6DmnucUFdXbWa/x2rTSEXlkvgk9X/PxOptUYsLJkzysTgfDywZwuIXLm9B3oNmv3bVgPXsgDsvDfaHYCgz0nHK6NSrX2AeX3yO/dFuoZsuk+J+UyRigMqYj0wjmxUlqj183hinAoGBAMYMOBgF77OXRII7GAuEut/nBeh2sBrgyzR7FmJMs5kvRh6Ck8wp3ysgMvX4lxh1ep8iCw1R2cguqNATr1klOdsCTOE9RrhuvOp3JrYzuIAK6MpH/uBICy4w1rW2+gQySsHcH40r+tNaTFQ7dQ1tef//iy/IW8v8i0t+csztE1JnAoGABdtWYt8FOYP688+jUmdjWWSvVcq0NjYeMfaGTOX/DsNTL2HyXhW/Uq4nNnBDNmAz2CjMbZwt0y+5ICkj+2REVQVUinAEinTcAe5+LKXNPx4sbX3hcrJUbk0m+rSu4G0B/f5cyXBsi9wFCAzDdHgBduCepxSr04Sc9Hde1uQQi7kCgYB0U20HP0Vh+TG2RLuE2HtjVDD2L/CUeQEiXEHzjxXWnhvTg+MIAnggvpLwQwmMxkQ2ACr5sd/3YuCpB0bxV5o594nsqq9FWVYBaecFEjAGlWHSnqMoXWijwu/6X/VOTbP3VjH6G6ECT4GR4DKKpokIQrMgZ9DzaezvdOA9WesFdQKBgQCWfeOQTitRJ0NZACFUn3Fs3Rvgc9eN9YSWj4RtqkmGPMPvguWo+SKhlk3IbYjrRBc5WVOdoX8JXb2/+nAGhPCuUZckWVmZe5pMSr4EkNQdYeY8kOXGSjoTOUH34ZdKeS+e399BkBWIiXUejX/Srln0H4KoHnTWgxwNpTsBCgXu8Q==", - // NERSAType = GBNewEnergy.Protocol.NEGlobalConfigs.RSAType.RSA2 - // }); - - Default_NERSAEncryptImpl rsa = new Default_NERSAEncryptImpl( - Encoding.UTF8, - HashAlgorithmName.SHA256, - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
", - "s+rl5mtcckCF9mEECD86L9UE2pbCR4CuiqDepwpiZCEflymQLNC3qNUPDlua9/kltyu6L489uimHRbEp4C7Gl7dDmaXVZLUVGkgUCZoRc8MrOw4+BiVAeQtCDdilPpA7DMN0bMfJAj3U4GuTU89/OWZMb9SYFfqEHM2e60PZHIU=AQAB

8qSTX42w2NaMCXL0PTZuacUFdJj93KopOJPD2q/JfmXSjXHV/IQK9YlCVKXHucqy8xcQgjkaKHqy3Rse14SZ7Q==

vdJfDZ6ZIAQDx0sQbmbadHb6EOr8/oXo8B1CUSG0LqFZgDY7vBj17ujd6UhJWzhsg/5/3L+m4wDjMkUpOExZ+Q==Av3Uc1Ej5QiAIX2xVS/enJ85Of7I4neWmoP33jJcoZpPxj6pDLv0BqLylmiU1c2R9z1JjtF1aRpaKi+zaaTQ4Q==Pv5yhv2MCYDrlBbIJCtD8gSN5lFllj3wWMcM/Am4VwU6w368Aicybo+fHUzc80XdVUx/OE3t30WrIEKtdD56WQ==OcUQg0/kEGi9l2CgXCLKmQ1/1VVb+r89LXTO6rqi2wg5txkJIIXXePx7ce0Bh0eEnZzeSudwBLA3kqXmeAyYaw==mnPL+zwtd7OmjTUJ5h6JUCi56wFDNWjl7gJeQd4rSzQYT4eRyrc/A4QsUbIYXkqXsyCpzExWvGsMQqrtfRQKzR53MBL3MQln5BjAUql2NqCkM2KT/D8Px5M21/TpMAycK4tGLOHgcCQRH1PQLHG1OfpfDASIzLwLgMjvMuHnIyE=
" - ); - - Console.WriteLine("原始字符串:" + str); - //加密 - byte[] enBytes = rsa.Encrypt(Encoding.UTF8.GetBytes(str)); - Console.WriteLine("加密字符串:" + enBytes.ToHexString()); - //解密 - byte[] deBytes = rsa.Decrypt(enBytes); - Console.WriteLine("解密字符串:" + Encoding.UTF8.GetString(deBytes)); - //私钥签名 - string signStr = rsa.Sign(str); - Console.WriteLine("字符串签名:" + signStr); - //公钥验证签名 - bool signVerify = rsa.Verify(str, signStr); - Console.WriteLine("验证签名:" + signVerify); - Console.ReadKey(); - } - } -}