diff --git a/BatCharging.Model/客户端发送/CMD1103.cs b/BatCharging.Model/客户端发送/CMD1103.cs index 04489af..eb9005a 100644 --- a/BatCharging.Model/客户端发送/CMD1103.cs +++ b/BatCharging.Model/客户端发送/CMD1103.cs @@ -29,7 +29,7 @@ namespace BatCharging.Model /// 费率1 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate1 { get; set; } + public uint rate1 { get; set; } #endregion 1 #region 2 @@ -53,7 +53,7 @@ namespace BatCharging.Model /// 费率2 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate2 { get; set; } + public uint rate2 { get; set; } #endregion 2 #region 3 @@ -77,7 +77,7 @@ namespace BatCharging.Model /// 费率3 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate3 { get; set; } + public uint rate3 { get; set; } #endregion 3 #region 4 @@ -101,7 +101,7 @@ namespace BatCharging.Model /// 费率4 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate4 { get; set; } + public uint rate4 { get; set; } #endregion 4 #region 5 @@ -125,7 +125,7 @@ namespace BatCharging.Model /// 费率5 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate5 { get; set; } + public uint rate5 { get; set; } #endregion 5 #region 6 @@ -149,7 +149,7 @@ namespace BatCharging.Model /// 费率6 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate6 { get; set; } + public uint rate6 { get; set; } #endregion 6 #region 7 @@ -173,7 +173,7 @@ namespace BatCharging.Model /// 费率7 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate7 { get; set; } + public uint rate7 { get; set; } #endregion 7 #region 8 @@ -197,7 +197,7 @@ namespace BatCharging.Model /// 费率8 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate8 { get; set; } + public uint rate8 { get; set; } #endregion 8 #region 9 @@ -221,7 +221,7 @@ namespace BatCharging.Model /// 费率9 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate9 { get; set; } + public uint rate9 { get; set; } #endregion 9 #region 10 @@ -245,7 +245,7 @@ namespace BatCharging.Model /// 费率10 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate10 { get; set; } + public uint rate10 { get; set; } #endregion 10 #region 11 @@ -269,7 +269,7 @@ namespace BatCharging.Model /// 费率11 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate11 { get; set; } + public uint rate11 { get; set; } #endregion 11 #region 12 @@ -293,7 +293,7 @@ namespace BatCharging.Model /// 费率12 /// 该时段内每度电的电费,用整型值表示,要乘 0.01才能得到真实的值 /// - public int rate12 { get; set; } + public uint rate12 { get; set; } #endregion 12 } } diff --git a/BatCharging.Model/客户端发送/CMD7.cs b/BatCharging.Model/客户端发送/CMD7.cs index cfce0dd..61ade42 100644 --- a/BatCharging.Model/客户端发送/CMD7.cs +++ b/BatCharging.Model/客户端发送/CMD7.cs @@ -67,7 +67,7 @@ namespace BatCharging.Model /// /// 用户卡号/用户识别号(内容只能”0~9、A~Z、a~z 字符 ASCII 码,不够长度填’\0’) /// - public UInt32 value10 { get; set; } + public string value10 { get; set; } /// /// 断网充电标志 /// 0-不允许 diff --git a/BatCharging.Service/Common/ByteUtils.cs b/BatCharging.Service/Common/ByteUtils.cs index c991897..e9d6b3d 100644 --- a/BatCharging.Service/Common/ByteUtils.cs +++ b/BatCharging.Service/Common/ByteUtils.cs @@ -170,12 +170,12 @@ namespace BatCharging.Service { Array.Copy(byteArray, 0, bytes, 0, byteArray.Length); } - else if (byteArray.Length > leng) - { - // 长度超过32字节,可以截断或者抛出异常 - Array.Copy(byteArray, 0, new byte[leng], 0, leng); // 截断数组到32字节 - } - return byteArray; + //else if (byteArray.Length > leng) + //{ + // // 长度超过32字节,可以截断或者抛出异常 + // Array.Copy(byteArray, 0, new byte[leng], 0, leng); // 截断数组到32字节 + //} + return bytes; } /// diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs index 6e0bfe6..4d497d5 100644 --- a/BatCharging.Service/发送方法/ChargerSendCMD.cs +++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs @@ -50,9 +50,9 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD1.value1)); lstContent.AddRange(BitConverter.GetBytes(CMD1.value2)); lstContent.Add(CMD1.value3); - lstContent.AddRange(BitConverter.GetBytes(CMD1.value4)); - lstContent.Add(CMD1.value5); - lstContent.AddRange(BitConverter.GetBytes(CMD1.value6)); + lstContent.AddRange(BitConverter.GetBytes(CMD1.value4));//起始地址 + lstContent.Add(CMD1.value5);//查询个数 + lstContent.AddRange(BitConverter.GetBytes(CMD1.value6));//参数字节数 if (CMD1.value3 == 1) { lstContent.AddRange(CMD1.value7); @@ -199,19 +199,20 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); + lstContent.Add(CMD.value03); lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); lstContent.AddRange(BitConverter.GetBytes(CMD.value05)); + lstContent.AddRange(BitConverter.GetBytes(CMD.value06)); lstContent.AddRange(BitConverter.GetBytes(CMD.value07)); lstContent.AddRange(BitConverter.GetBytes(CMD.value08)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value09)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value10)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value11)); + lstContent.Add(CMD.value09); + lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value10, 32)); + lstContent.Add(CMD.value11); lstContent.AddRange(BitConverter.GetBytes(CMD.value12)); lstContent.AddRange(ByteUtils.ToByteByHexStr32(CMD.value13, 32)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value14)); + lstContent.Add(CMD.value14); lstContent.AddRange(BitConverter.GetBytes(CMD.value15)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value16)); + lstContent.Add(CMD.value16); results = lstContent.ToArray(); } return results; @@ -356,8 +357,8 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); + lstContent.Add(CMD.value03); + lstContent.Add(Convert.ToByte(CMD.value04)); results = lstContent.ToArray(); } @@ -571,8 +572,6 @@ namespace BatCharging.Service model.CMD = 113; model.checksumDomain = 0x01; - - model.dataDomain = GetRCMD113DataInfo(CMD); //数据域 model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度 @@ -598,8 +597,8 @@ namespace BatCharging.Service lstContent.AddRange(BitConverter.GetBytes(CMD.value01)); lstContent.AddRange(BitConverter.GetBytes(CMD.value02)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value03)); - lstContent.AddRange(BitConverter.GetBytes(CMD.value04)); + lstContent.Add(CMD.value03); + lstContent.Add(Convert.ToByte(CMD.value04)); results = lstContent.ToArray(); } @@ -1436,7 +1435,7 @@ namespace BatCharging.Service public byte[] SendRCMD1103(out APDUModel APDUModel, CMD1103 CMD) { - byte[] result = null; + byte[] result; APDUModel model = new APDUModel(); model.OriginDomain1 = 0xAA; diff --git a/Monitor.ChargeTest/FrmChargeResult.cs b/Monitor.ChargeTest/FrmChargeResult.cs index 61e0603..e87c919 100644 --- a/Monitor.ChargeTest/FrmChargeResult.cs +++ b/Monitor.ChargeTest/FrmChargeResult.cs @@ -226,7 +226,7 @@ namespace Monitor.ChargeTest { byte type = 1;//类型 0-查询/1-设置 uint startAddress = 2;//设置/查询参数起始地址 - byte num = 3;//设置/查询个数 + byte num = 2;//设置/查询个数 byte[] setData = new byte[8];//设置数据 setData[0] = 0; setData[1] = 1; @@ -265,10 +265,18 @@ namespace Monitor.ChargeTest /// private void button16_Click(object sender, EventArgs e) { - byte type = 0; - uint startAddress = 9; - byte num = 10; - byte[] setData = null; + byte type = 1;//充电枪口 + uint startAddress = 1;//启始命令地址 + byte num = 2;//命令个数 + byte[] setData = new byte[8];//命令参数 + setData[0] = 0; + setData[1] = 1; + setData[2] = 2; + setData[3] = 3; + setData[4] = 4; + setData[5] = 5; + setData[6] = 6; + setData[7] = 7; CmnChargerParam._CHR00TCPCLIENT.Send5(type, startAddress, num, setData); } #endregion @@ -449,9 +457,6 @@ namespace Monitor.ChargeTest /// private void button1_Click(object sender, EventArgs e) { - - - CmnChargerParam._CHR00TCPCLIENT.Send1101(); } /// @@ -462,8 +467,23 @@ namespace Monitor.ChargeTest private void button2_Click(object sender, EventArgs e) { CMD1103 cMD1103 = new CMD1103(); - - + cMD1103.startHour1 = 00; + cMD1103.startMinute1 = 00; + cMD1103.startHour1 = 10; + cMD1103.endHour1 = 30; + cMD1103.rate1 = 120; + + cMD1103.startHour2 = 10; + cMD1103.startMinute2 = 30; + cMD1103.startHour2 = 20; + cMD1103.endHour2 = 00; + cMD1103.rate2 = 100; + + cMD1103.startHour3 = 20; + cMD1103.startMinute3 = 00; + cMD1103.startHour3 = 24; + cMD1103.endHour3 = 00; + cMD1103.rate3 = 160; CmnChargerParam._CHR00TCPCLIENT.Send1103(cMD1103); } @@ -579,7 +599,7 @@ namespace Monitor.ChargeTest CMD.value07 = 5; CMD.value08 = 6; CMD.value09 = 7; - CMD.value10 = 8; + CMD.value10 = "123456789"; CMD.value11 = 9; CMD.value12 = 10; CMD.value13 = "12345678";