diff --git a/BatCharging.Service/Common/ByteUtils.cs b/BatCharging.Service/Common/ByteUtils.cs
index c3c3848..c991897 100644
--- a/BatCharging.Service/Common/ByteUtils.cs
+++ b/BatCharging.Service/Common/ByteUtils.cs
@@ -116,6 +116,25 @@ namespace BatCharging.Service
return bytesResult;
}
+ ///
+ /// 32进制数高地位对调
+ ///
+ ///
+ ///
+ public static byte[] Int32ToByteArray(Int32 value) //16进制数高地位对调
+ {
+ byte[] bytesResult = new byte[4];
+ byte[] temp = new byte[4];
+
+ BitConverter.GetBytes(Convert.ToInt32(value)).CopyTo(temp, 0);
+
+ bytesResult[0] = temp[3];
+ bytesResult[1] = temp[2];
+ bytesResult[2] = temp[1];
+ bytesResult[3] = temp[0];
+
+ return bytesResult;
+ }
///
/// 获取16进制字符串的字节数组
diff --git a/BatCharging.Service/发送方法/ChargerSendCMD.cs b/BatCharging.Service/发送方法/ChargerSendCMD.cs
index a992436..8635f78 100644
--- a/BatCharging.Service/发送方法/ChargerSendCMD.cs
+++ b/BatCharging.Service/发送方法/ChargerSendCMD.cs
@@ -10,7 +10,7 @@ namespace BatCharging.Service
public class ChargerSendCMD
{
#region 协议格式
- public byte[] SendRCMD1(out APDUModel APDUModel, CMD1 t)
+ public byte[] SendRCMD1(out APDUModel APDUModel, CMD1 CMD)
{
byte[] result = null;
@@ -24,7 +24,7 @@ namespace BatCharging.Service
model.checksumDomain = 0x01;
- model.dataDomain = GetRCMD1DataInfo(t); //数据域
+ model.dataDomain = GetRCMD1DataInfo(CMD); //数据域
model.LengthDomain = Convert.ToUInt16(9 + model.dataDomain.Length); //报文长度
List lstResult = new List();
@@ -47,15 +47,15 @@ namespace BatCharging.Service
{
List lstContent = new List();
- lstContent.AddRange(BitConverter.GetBytes(CMD1.value1));
- lstContent.AddRange(BitConverter.GetBytes(CMD1.value2));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD1.value1));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD1.value2));
lstContent.Add(CMD1.value3);
- lstContent.AddRange(BitConverter.GetBytes(CMD1.value4));
+ lstContent.AddRange(ByteUtils.Int32ToByteArray((int)CMD1.value4));
if (CMD1.value3 == 1)
{
lstContent.Add(CMD1.value5);
- lstContent.AddRange(BitConverter.GetBytes(CMD1.value6));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD1.value6));
lstContent.AddRange(CMD1.value7);
}
else
@@ -104,13 +104,13 @@ namespace BatCharging.Service
{
List lstContent = new List();
- lstContent.AddRange(BitConverter.GetBytes(CMD.value1));
- lstContent.AddRange(BitConverter.GetBytes(CMD.value2));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD.value1));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD.value2));
lstContent.Add(CMD.value3);
- lstContent.AddRange(BitConverter.GetBytes(CMD.value4));
+ lstContent.AddRange(ByteUtils.Int32ToByteArray((int)CMD.value4));
if (CMD.value3 == 1)
{
- lstContent.AddRange(BitConverter.GetBytes(CMD.value5));
+ lstContent.AddRange(ByteUtils.Int16ToByteArray((short)CMD.value5));
lstContent.AddRange(CMD.value6);
}
else
diff --git a/Monitor.ChargeTest/FrmChargeResult.cs b/Monitor.ChargeTest/FrmChargeResult.cs
index c0bd048..f385dbd 100644
--- a/Monitor.ChargeTest/FrmChargeResult.cs
+++ b/Monitor.ChargeTest/FrmChargeResult.cs
@@ -224,10 +224,18 @@ namespace Monitor.ChargeTest
///
private void button14_Click(object sender, EventArgs e)
{
- byte type = 0;
- uint startAddress = 2;
- byte num = 3;
- byte[] setData = null;
+ byte type = 1;//类型 0-查询/1-设置
+ uint startAddress = 2;//设置/查询参数起始地址
+ byte num = 3;//设置/查询个数
+ 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.Send1(type, startAddress, num, setData);
}
///
@@ -237,9 +245,17 @@ namespace Monitor.ChargeTest
///
private void button15_Click(object sender, EventArgs e)
{
- byte type = 0;
- uint startAddress = 1;
- byte[] setData = null;
+ byte type = 0;//0-查询 1-设置
+ uint startAddress = 1;//设置/查询参数启始地址
+ 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.Send3(type, startAddress, setData);
}
///