add temp1, temp2

This commit is contained in:
chi
2025-06-20 11:56:34 +09:00
parent 0ae0faf050
commit f7615396d5
22 changed files with 1800 additions and 802 deletions

View File

@@ -14,12 +14,16 @@ namespace AGVEmulator
public float Remain { get; set; }
public int CurA { get; set; }
public int MaxA { get; set; }
public UInt16 Temp1 { get; set; }
public UInt16 Temp2 { get; set; }
public RequestBatteryDataArgs()
{
this.Volt = 25;
this.Remain = 79f;
this.CurA = 40;
this.MaxA = 80;
Temp1 = 0;
Temp2 = 0;
}
}
public class RequestVoltageDataArgs : EventArgs
@@ -52,8 +56,8 @@ namespace AGVEmulator
var barrFD77 = sampleFD77.Split(' ').ToList().Select(t => Convert.ToByte(t, 16)).ToArray(); //normal
if (data.First() != 0xDD || data.Last() != 0x77)
{
RaiseMessage(MessageType.Error, "stx,etx error");
{
RaiseMessage(MessageType.Error, $"stx,etx error data={data.HexString()}");
return false;
}
var sts = data[1];
@@ -89,6 +93,14 @@ namespace AGVEmulator
var perc = (byte)(int)p.Remain;
Array.Copy(new byte[] { perc }, 0, basic_payload, 19, 1);
//temp1
var temp1 = BitConverter.GetBytes((UInt16)(p.Temp1 + 2731)).Reverse().ToArray();
Array.Copy(temp1, 0, basic_payload, 23,2);
//temp2
var temp2 = BitConverter.GetBytes((UInt16)(p.Temp2 + 2731)).Reverse().ToArray();
Array.Copy(temp2, 0, basic_payload, 25, 2);
var datalen = (byte)basic_payload.Length;
var payload_cs = new List<byte>();
payload_cs.Add(datalen);
@@ -115,7 +127,7 @@ namespace AGVEmulator
//Array.Copy(BitConverter.GetBytes(chksum).Reverse().ToArray(), 0, barrFD77, 20, 2);
RaiseMessage(MessageType.Normal, $"Volt:{p.Volt}v,Remain:{p.Remain}%");
RaiseMessage(MessageType.Normal, $"Volt:{p.Volt}v,Remain:{p.Remain}%,temp1:{p.Temp1/10f},Temp2:{p.Temp2/10f}");
var sendstr = System.Text.Encoding.Default.GetString(barr0D);
RaiseMessage(MessageType.Normal, "Tx:" + barr0D.HexString());
@@ -137,7 +149,7 @@ namespace AGVEmulator
{
var volt = p.cellVolt[i];
var arr_cellvolt = BitConverter.GetBytes(volt).Reverse().ToArray();
Array.Copy(arr_cellvolt, 0, payload, ( i * 2), arr_cellvolt.Length);
Array.Copy(arr_cellvolt, 0, payload, (i * 2), arr_cellvolt.Length);
}
//makechecksum