|
|
|
@ -506,23 +506,24 @@ namespace SocketExample
|
|
|
|
|
MessageBox.Show("数值不可为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string setPowerString = "AA 55 14 42 ";
|
|
|
|
|
string setPowerString = "AA 55 14 42 ";//设置命令开头
|
|
|
|
|
int[] powers = new int[8] {int.Parse(_port1readtext),int.Parse(_port2readtext), int.Parse(_port3readtext), int.Parse(_port4readtext),
|
|
|
|
|
int.Parse(_port1writetext),int.Parse(_port2writetext),int.Parse(_port3writetext),int.Parse(_port4writetext)};
|
|
|
|
|
for (int i = 0; i < powers.Length/2; i++) {
|
|
|
|
|
setPowerString += $"0{i+1} {(powers[i]*100).ToString("X").PadLeft(4,'0').Insert(2," ")} {(powers[i+4] * 100).ToString("X").PadLeft(4, '0').Insert(2, " ")} ";
|
|
|
|
|
}
|
|
|
|
|
setPowerString += "52 0D";
|
|
|
|
|
}//功率设置时为两位数,乘100后再转换为16进制字符串,再填满左侧保证4位数,最后两位两位隔开
|
|
|
|
|
setPowerString += "52 0D";//命令结尾
|
|
|
|
|
byte[] data = strToToHexByte(setPowerString);
|
|
|
|
|
client.Send(data);
|
|
|
|
|
byte[] confirmdata1 = strToToHexByte("AA 55 05 5F ");
|
|
|
|
|
|
|
|
|
|
byte[] confirmdata1 = strToToHexByte("AA 55 05 5F ");//保存命令
|
|
|
|
|
byte[] confirmdata2 = System.Text.Encoding.UTF8.GetBytes("\"SAVE\" ");
|
|
|
|
|
byte[] confirmdata3 = strToToHexByte("01 5A 0D");
|
|
|
|
|
|
|
|
|
|
byte[] confirmdata = new byte[confirmdata1.Length+ confirmdata2.Length+ confirmdata3.Length];
|
|
|
|
|
confirmdata1.CopyTo(confirmdata,0);
|
|
|
|
|
confirmdata2.CopyTo(confirmdata,confirmdata1.Length);
|
|
|
|
|
confirmdata3.CopyTo(confirmdata,confirmdata1.Length+ confirmdata2.Length);
|
|
|
|
|
confirmdata3.CopyTo(confirmdata,confirmdata1.Length+ confirmdata2.Length);//保存命令拼接
|
|
|
|
|
client.Send(confirmdata);
|
|
|
|
|
data = strToToHexByte("AA 55 00 72 72 0D");//获取功率
|
|
|
|
|
client.Send(data);
|
|
|
|
|