diff --git a/DroneSimulator/Drone.cs b/DroneSimulator/Drone.cs index 6095c97..dcc303e 100644 --- a/DroneSimulator/Drone.cs +++ b/DroneSimulator/Drone.cs @@ -155,13 +155,14 @@ namespace DroneSimulator if (drone.StepTime > 0) { uint tick = Tick(); - uint step = drone.Timer + drone.StepTime; + uint prev = drone.Timer; + uint step = prev + drone.StepTime; if (TimeLimit && (step > tick)) step = tick; drone.Action(step); drone.StepTime = 0; - drone.SendStep(step); + drone.SendStep(step, prev); break; } } @@ -377,16 +378,17 @@ namespace DroneSimulator AccPRY.Z = ((ul + dr) - (dl + ur)) / 4; } - private void SendStep(uint time) + private void SendStep(uint time, uint prev) { DroneData.Step step = new DroneData.Step(); - step.Head.Size = Marshal.SizeOf(typeof(DroneData.DataAcc)); + step.Head.Size = Marshal.SizeOf(typeof(DroneData.Step)); step.Head.Mode = DroneData.DataMode.Response; step.Head.Type = DroneData.DataType.Step; step.Head.Time = Tick(); step.StepTime = time; + step.PrevTime = prev; byte[] bytes = getBytes(step); diff --git a/DroneSimulator/DroneData.cs b/DroneSimulator/DroneData.cs index d6b1f94..a9689f2 100644 --- a/DroneSimulator/DroneData.cs +++ b/DroneSimulator/DroneData.cs @@ -1,5 +1,4 @@ -using System.Net; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace DroneData { @@ -9,8 +8,8 @@ namespace DroneData }; public enum DataType : ushort - { - Ping = 0, Step = 1, + { + None = 0, Ping = 1, Step = 2, // Output DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005, DataBar = 1006, DataOF = 1007, DataGPS = 1008, @@ -39,8 +38,9 @@ namespace DroneData public DataHead Head; public uint StepTime; // ms, запрос: шаг работы симулятора; ответ: Последнее время изменения данных + public uint PrevTime; // ms, ответ: Предпоследнее время изменения данных - static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataAcc)); + static public int StrLen = Marshal.SizeOf(typeof(DroneData.Step)); } public struct XYZ { public float X, Y, Z; }