diff --git a/BatCharging.Model/客户端发送/CMD1401.cs b/BatCharging.Model/客户端发送/CMD1401.cs index 34b74b7..6913d8b 100644 --- a/BatCharging.Model/客户端发送/CMD1401.cs +++ b/BatCharging.Model/客户端发送/CMD1401.cs @@ -20,7 +20,7 @@ namespace BatCharging.Model /// 升级软件文件版本号 /// HEX 整形,例如:209.02 表示为:A6 51 /// - public UInt16 UpgradeSoftwareFileVersionNum { get; set; } + public string UpgradeSoftwareFileVersionNum { get; set; } /// /// FTP 服务器 IP 地址 32 /// 例:IP:16.80.1.20 指令为:0x10 0x50 0x01 0x14 diff --git a/BatCharging.Service/ChargerMgrTool.cs b/BatCharging.Service/ChargerMgrTool.cs index 7d34543..f83e7a2 100644 --- a/BatCharging.Service/ChargerMgrTool.cs +++ b/BatCharging.Service/ChargerMgrTool.cs @@ -943,7 +943,6 @@ namespace BatCharging.Service } } - /// /// 接收事件 /// diff --git a/BatCharging.Service/ChargerSendMsg.cs b/BatCharging.Service/ChargerSendMsg.cs index 2069514..549bd80 100644 --- a/BatCharging.Service/ChargerSendMsg.cs +++ b/BatCharging.Service/ChargerSendMsg.cs @@ -1013,16 +1013,6 @@ namespace BatCharging.Service /// internal void Send1401(TcpClientChargerTool tcp_client, CMD1401 CMD) { - //CMD1401 CMD = new CMD1401(); - //CMD.reserved1 = 0; - //CMD.reserved2 = 0; - //CMD.UpgradeSoftwareFileVersionNum = UpgradeSoftwareFileVersionNum; - //CMD.ftpServerIPaddress = ftpServerIPaddress; - //CMD.ftpUserName = ftpUserName; - //CMD.ftpPassWord = ftpPassWord; - //CMD.ftpDownloadPath = ftpDownloadPath; - //CMD.executeWay = executeWay; - //CMD.nowUpgradeDeviceType = nowUpgradeDeviceType; byte[] bytes = new ChargerSendCMD().SendRCMD1401(out APDUModel APDUModel, CMD); string result = "站控响应充放电机上报模块状态-发送字节内容:" + ByteUtils.BytesToHexStr(bytes) + ";"; diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs index 4d497d5..95d8234 100644 --- a/BatCharging.Service/发送方法/ChargerSendCMD.cs +++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs @@ -1580,87 +1580,87 @@ namespace BatCharging.Service { List lstContent = new List(); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute1)); + lstContent.Add(CMD.startHour1); + lstContent.Add(CMD.startMinute1); + lstContent.Add(CMD.endHour1); + lstContent.Add(CMD.endMinute1); lstContent.AddRange(BitConverter.GetBytes(CMD.rate1)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate1)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute2)); + lstContent.Add(CMD.startHour2); + lstContent.Add(CMD.startMinute2); + lstContent.Add(CMD.endHour2); + lstContent.Add(CMD.endMinute2); lstContent.AddRange(BitConverter.GetBytes(CMD.rate2)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour3)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute3)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour3)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute3)); + lstContent.Add(CMD.startHour3); + lstContent.Add(CMD.startMinute3); + lstContent.Add(CMD.endHour3); + lstContent.Add(CMD.endMinute3); lstContent.AddRange(BitConverter.GetBytes(CMD.rate3)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate3)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour4)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute4)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour4)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute4)); + lstContent.Add(CMD.startHour4); + lstContent.Add(CMD.startMinute4); + lstContent.Add(CMD.endHour4); + lstContent.Add(CMD.endMinute4); lstContent.AddRange(BitConverter.GetBytes(CMD.rate4)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate4)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour5)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute5)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour5)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute5)); + lstContent.Add(CMD.startHour5); + lstContent.Add(CMD.startMinute5); + lstContent.Add(CMD.endHour5); + lstContent.Add(CMD.endMinute5); lstContent.AddRange(BitConverter.GetBytes(CMD.rate5)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate5)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour6)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute6)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour6)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute6)); + lstContent.Add(CMD.startHour6); + lstContent.Add(CMD.startMinute6); + lstContent.Add(CMD.endHour6); + lstContent.Add(CMD.endMinute6); lstContent.AddRange(BitConverter.GetBytes(CMD.rate6)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate6)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour7)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute7)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour7)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute7)); + lstContent.Add(CMD.startHour7); + lstContent.Add(CMD.startMinute7); + lstContent.Add(CMD.endHour7); + lstContent.Add(CMD.endMinute7); lstContent.AddRange(BitConverter.GetBytes(CMD.rate7)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate7)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour8)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute8)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour8)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute8)); + lstContent.Add(CMD.startHour8); + lstContent.Add(CMD.startMinute8); + lstContent.Add(CMD.endHour8); + lstContent.Add(CMD.endMinute8); lstContent.AddRange(BitConverter.GetBytes(CMD.rate8)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate8)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour9)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute9)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour9)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute9)); + lstContent.Add(CMD.startHour9); + lstContent.Add(CMD.startMinute9); + lstContent.Add(CMD.endHour9); + lstContent.Add(CMD.endMinute9); lstContent.AddRange(BitConverter.GetBytes(CMD.rate9)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate9)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute10)); + lstContent.Add(CMD.startHour10); + lstContent.Add(CMD.startMinute10); + lstContent.Add(CMD.endHour10); + lstContent.Add(CMD.endMinute10); lstContent.AddRange(BitConverter.GetBytes(CMD.rate10)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour11)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute11)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour11)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute11)); + lstContent.Add(CMD.startHour11); + lstContent.Add(CMD.startMinute11); + lstContent.Add(CMD.endHour11); + lstContent.Add(CMD.endMinute11); lstContent.AddRange(BitConverter.GetBytes(CMD.rate11)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate11)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startHour12)); - lstContent.AddRange(BitConverter.GetBytes(CMD.startMinute12)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endHour12)); - lstContent.AddRange(BitConverter.GetBytes(CMD.endMinute12)); + lstContent.Add(CMD.startHour12); + lstContent.Add(CMD.startMinute12); + lstContent.Add(CMD.endHour12); + lstContent.Add(CMD.endMinute12); lstContent.AddRange(BitConverter.GetBytes(CMD.rate12)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserveRate12)); @@ -1738,8 +1738,28 @@ namespace BatCharging.Service return result; } + /// + /// 针对CMD1301 充电卡号 不足30byte补\0 + /// + /// + /// + public byte[] AddByteArray(byte[] byteArray, int len) + { + byte[] result = new byte[len]; + if (byteArray != null) + { + if (byteArray.Length <= len) + { + Array.Copy(byteArray, result, byteArray.Length); + } + } + return result; + } + + /// /// 获取鉴权消息体字节数组 + /// 白名单1-充电卡号 32byte\2-VIN码 17byte /// /// /// 鉴权消息体字节数组 @@ -1751,22 +1771,41 @@ namespace BatCharging.Service List lstContent = new List(); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.chargingStationCode)); - lstContent.AddRange(BitConverter.GetBytes(CMD.whitelistType)); - lstContent.AddRange(BitConverter.GetBytes(CMD.operation)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.chargingStationCode), 32)); + lstContent.Add(CMD.whitelistType); + lstContent.Add(CMD.operation); lstContent.AddRange(BitConverter.GetBytes(CMD.whitelistVersionNum)); - lstContent.AddRange(BitConverter.GetBytes(CMD.DistributeWhitelistNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum01)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum02)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum03)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum04)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum05)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum06)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum07)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum08)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum09)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.carVinOrChargCardNum10)); - + //操作为查询 即=4,后面字段不需要 + if (CMD.operation != 4) + { + lstContent.AddRange(BitConverter.GetBytes(CMD.DistributeWhitelistNum)); + if (CMD.whitelistType == 1) + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum01), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum02), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum03), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum04), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum05), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum06), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum07), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum08), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum09), 32)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum10), 32)); + } + else + { + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum01), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum02), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum03), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum04), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum05), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum06), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum07), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum08), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum09), 17)); + lstContent.AddRange(AddByteArray(Encoding.ASCII.GetBytes(CMD.carVinOrChargCardNum10), 17)); + } + } results = lstContent.ToArray(); } return results; @@ -1811,8 +1850,19 @@ namespace BatCharging.Service List lstContent = new List(); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved1)); lstContent.AddRange(BitConverter.GetBytes(CMD.reserved2)); - lstContent.AddRange(BitConverter.GetBytes(CMD.UpgradeSoftwareFileVersionNum)); - lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpServerIPaddress)); + + lstContent.AddRange(BitConverter.GetBytes(Convert.ToUInt16(CMD.UpgradeSoftwareFileVersionNum) * 100)); + + string[] parts = CMD.ftpServerIPaddress.Split("."); + if (parts.Length == 4) + { + lstContent.Add(byte.Parse(parts[0])); + lstContent.Add(byte.Parse(parts[1])); + lstContent.Add(byte.Parse(parts[2])); + lstContent.Add(byte.Parse(parts[3])); + } + + lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpUserName)); lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpPassWord)); lstContent.AddRange(ByteUtils.ToByteByHexStr(CMD.ftpDownloadPath)); diff --git a/Monitor.ChargeTest/FrmChargeResult.cs b/Monitor.ChargeTest/FrmChargeResult.cs index e87c919..6afee4b 100644 --- a/Monitor.ChargeTest/FrmChargeResult.cs +++ b/Monitor.ChargeTest/FrmChargeResult.cs @@ -469,20 +469,20 @@ namespace Monitor.ChargeTest CMD1103 cMD1103 = new CMD1103(); cMD1103.startHour1 = 00; cMD1103.startMinute1 = 00; - cMD1103.startHour1 = 10; - cMD1103.endHour1 = 30; + cMD1103.endHour1 = 10; + cMD1103.endMinute1 = 30; cMD1103.rate1 = 120; cMD1103.startHour2 = 10; cMD1103.startMinute2 = 30; - cMD1103.startHour2 = 20; - cMD1103.endHour2 = 00; + cMD1103.endHour2 = 20; + cMD1103.endMinute2 = 00; cMD1103.rate2 = 100; cMD1103.startHour3 = 20; cMD1103.startMinute3 = 00; - cMD1103.startHour3 = 24; - cMD1103.endHour3 = 00; + cMD1103.endHour3 = 24; + cMD1103.endMinute3 = 00; cMD1103.rate3 = 160; CmnChargerParam._CHR00TCPCLIENT.Send1103(cMD1103); @@ -495,6 +495,26 @@ namespace Monitor.ChargeTest private void button3_Click(object sender, EventArgs e) { CMD1105 cMD1105 = new CMD1105(); + cMD1105.startHour1 = 00; + cMD1105.startMinute1 = 00; + cMD1105.endHour1 = 10; + cMD1105.endMinute1 = 30; + cMD1105.rate1 = 1000; + cMD1105.reserveRate1 = 1000; + + cMD1105.startHour2 = 10; + cMD1105.startMinute2 = 30; + cMD1105.endHour2 = 20; + cMD1105.endMinute2 = 30; + cMD1105.rate2 = 2000; + cMD1105.reserveRate2 = 3000; + + cMD1105.startHour3 = 20; + cMD1105.startMinute3 = 30; + cMD1105.endHour3 = 24; + cMD1105.endMinute3 = 00; + cMD1105.rate3 = 1000; + cMD1105.reserveRate3 = 1000; CmnChargerParam._CHR00TCPCLIENT.Send1105(cMD1105); } @@ -521,6 +541,26 @@ namespace Monitor.ChargeTest { CMD1301 cMD1301 = new CMD1301(); + cMD1301.chargingStationCode = "0001"; + //cMD1301.whitelistType = 1;//充电卡号 + cMD1301.whitelistType = 2;//VIN码 + cMD1301.operation =4;//查询 + //cMD1301.operation =0;//增加 + cMD1301.whitelistVersionNum = 10; + //每次固定下发10条 + cMD1301.carVinOrChargCardNum01 = "11101"; + cMD1301.carVinOrChargCardNum02 = "11102"; + cMD1301.carVinOrChargCardNum03 = "11103"; + cMD1301.carVinOrChargCardNum04 = "11104"; + cMD1301.carVinOrChargCardNum05 = "11105"; + cMD1301.carVinOrChargCardNum06 = "11106"; + cMD1301.carVinOrChargCardNum07 = "11107"; + cMD1301.carVinOrChargCardNum08 = "11108"; + cMD1301.carVinOrChargCardNum09 = "11109"; + cMD1301.carVinOrChargCardNum10 = "11110"; + + + CmnChargerParam._CHR00TCPCLIENT.Send1301(cMD1301); } #endregion @@ -534,6 +574,10 @@ namespace Monitor.ChargeTest private void button6_Click(object sender, EventArgs e) { CMD1401 cMD1401 = new CMD1401(); + cMD1401.UpgradeSoftwareFileVersionNum = "209.02"; + cMD1401.ftpServerIPaddress = "16.80.1.20"; + cMD1401.ftpUserName = "ftpuserName"; + cMD1401.ftpPassWord = "123456"; CmnChargerParam._CHR00TCPCLIENT.Send1401(cMD1401); }