+++
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net.Sockets;
|
||||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace DroneSimulator
|
||||
{
|
||||
@ -10,10 +9,12 @@ namespace DroneSimulator
|
||||
{
|
||||
public int ID;
|
||||
|
||||
public bool Active; // Живой?
|
||||
private Socket? Client = null;
|
||||
|
||||
public bool Active = false; // Живой?
|
||||
public const float Dynamic = 10; // Динамика вращения
|
||||
public Vector3 PosXYZ, SpdXYZ, AccXYZ; // Положение в пространстве: Позиция, Скорость, Ускорение
|
||||
public Quaternion Quat; // Основной кватернион
|
||||
public Vector3 PosXYZ = Vector3.Zero, SpdXYZ = Vector3.Zero, AccXYZ = Vector3.Zero; // Положение в пространстве: Позиция, Скорость, Ускорение
|
||||
public Quaternion Quat = Quaternion.Identity; // Основной кватернион
|
||||
public float Power = 0; // Тяга всех двигателей (0-1)
|
||||
|
||||
public Vector3 SpdPRY, AccPRY; // Поворот в пространстве: pitch roll yaw
|
||||
@ -23,8 +24,6 @@ namespace DroneSimulator
|
||||
|
||||
public Vector4 Orientation;
|
||||
|
||||
private uint DataTimer;
|
||||
|
||||
private const float Gravity = 9.8f;
|
||||
|
||||
private const float TO_GRAD = 180 / MathF.PI;
|
||||
@ -32,12 +31,13 @@ namespace DroneSimulator
|
||||
|
||||
public static List<Drone> AllDrones = new List<Drone>();
|
||||
private static Thread? DroneThread = null;
|
||||
public static long Timing = 0;
|
||||
public static long Lag = 0;
|
||||
public static long Freq = 1000;
|
||||
public static bool Boost = false;
|
||||
private uint StepTime = 0;
|
||||
|
||||
private uint Timer;
|
||||
public static Semaphore StepSemaphore = new Semaphore(0, 10);
|
||||
|
||||
private uint Timer = 0;
|
||||
|
||||
public static bool TimeLimit = false;
|
||||
|
||||
private Vector2 MoveOF = Vector2.Zero;
|
||||
private uint CountOF = 0;
|
||||
@ -56,6 +56,11 @@ namespace DroneSimulator
|
||||
private RealMode.Range RealRange = new RealMode.Range();
|
||||
private RealMode.OpticalFlow RealOF = new RealMode.OpticalFlow();
|
||||
|
||||
private static uint Tick()
|
||||
{
|
||||
return (uint)(Stopwatch.GetTimestamp() / Stopwatch.Frequency / 1000);
|
||||
}
|
||||
|
||||
public static byte[] getBytes(object data)
|
||||
{
|
||||
int size = Marshal.SizeOf(data);
|
||||
@ -139,42 +144,37 @@ namespace DroneSimulator
|
||||
|
||||
private static void ThreadFunction()
|
||||
{
|
||||
long last = Stopwatch.GetTimestamp();
|
||||
long prev = Stopwatch.GetTimestamp();
|
||||
|
||||
while (DroneThread != null)
|
||||
{
|
||||
if(!Boost) Thread.Yield();
|
||||
|
||||
long tick = Stopwatch.GetTimestamp();
|
||||
|
||||
if (tick == prev) continue;
|
||||
|
||||
Timing = Stopwatch.Frequency / (tick - prev);
|
||||
prev = tick;
|
||||
|
||||
long quant = Stopwatch.Frequency / Freq;
|
||||
|
||||
if (tick < last + quant) continue;
|
||||
|
||||
if (tick > (last + quant) + quant * 0.1) Lag++;
|
||||
|
||||
last = tick;
|
||||
|
||||
if (StepSemaphore.WaitOne(1))
|
||||
{
|
||||
lock (AllDrones)
|
||||
{
|
||||
foreach (Drone drone in AllDrones)
|
||||
drone.Action((uint)(tick / (Stopwatch.Frequency / 1000)));
|
||||
{
|
||||
if (drone.StepTime > 0)
|
||||
{
|
||||
uint tick = Tick();
|
||||
uint step = drone.Timer + drone.StepTime;
|
||||
|
||||
if (TimeLimit && (step > tick)) step = tick;
|
||||
|
||||
drone.Action(step);
|
||||
drone.StepTime = 0;
|
||||
drone.SendStep(step);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Drone(int id)
|
||||
public Drone(int id, Socket? client)
|
||||
{
|
||||
ID = id;
|
||||
Active = false;
|
||||
PosXYZ = Vector3.Zero;
|
||||
SpdXYZ = Vector3.Zero;
|
||||
AccXYZ = Vector3.Zero;
|
||||
Quat = Quaternion.Identity;
|
||||
Timer = Tick();
|
||||
Client = client;
|
||||
}
|
||||
|
||||
public int Create()
|
||||
@ -229,7 +229,7 @@ namespace DroneSimulator
|
||||
{
|
||||
uint period = tick - Timer;
|
||||
|
||||
if (period <= 0) return;
|
||||
if (period == 0) return;
|
||||
|
||||
float time = period / 1000.0f;
|
||||
Timer = tick;
|
||||
@ -356,9 +356,6 @@ namespace DroneSimulator
|
||||
MoveOF += RealOF.result;
|
||||
CountOF += 1;
|
||||
}
|
||||
|
||||
|
||||
DataTimer = tick;
|
||||
}
|
||||
|
||||
private float Range(float pow)
|
||||
@ -380,6 +377,31 @@ namespace DroneSimulator
|
||||
AccPRY.Z = ((ul + dr) - (dl + ur)) / 4;
|
||||
}
|
||||
|
||||
private void SendStep(uint time)
|
||||
{
|
||||
DroneData.Step step = new DroneData.Step();
|
||||
|
||||
step.Head.Size = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
||||
step.Head.Mode = DroneData.DataMode.Response;
|
||||
step.Head.Type = DroneData.DataType.Step;
|
||||
step.Head.Time = Tick();
|
||||
|
||||
step.StepTime = time;
|
||||
|
||||
byte[] bytes = getBytes(step);
|
||||
|
||||
try { Client?.Send(bytes); } catch { }
|
||||
}
|
||||
|
||||
private void RecvStep(byte[] data)
|
||||
{
|
||||
DroneData.Step step = (DroneData.Step)fromBytes(data, typeof(DroneData.Step));
|
||||
|
||||
StepTime = step.StepTime;
|
||||
|
||||
StepSemaphore.Release();
|
||||
}
|
||||
|
||||
private void RecvDataMotor4(byte[] data)
|
||||
{
|
||||
DroneData.DataMotor4 mot = (DroneData.DataMotor4)fromBytes(data, typeof(DroneData.DataMotor4));
|
||||
@ -394,7 +416,7 @@ namespace DroneSimulator
|
||||
acc.Head.Size = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
||||
acc.Head.Mode = DroneData.DataMode.Response;
|
||||
acc.Head.Type = DroneData.DataType.DataAcc;
|
||||
acc.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
acc.Head.Time = Tick();
|
||||
|
||||
acc.Acc.X = RealAcc.result.X; acc.Acc.Y = RealAcc.result.Y; acc.Acc.Z = RealAcc.result.Z;
|
||||
acc.Time = RealAcc.timer;
|
||||
@ -409,7 +431,7 @@ namespace DroneSimulator
|
||||
gyr.Head.Size = Marshal.SizeOf(typeof(DroneData.DataGyr));
|
||||
gyr.Head.Mode = DroneData.DataMode.Response;
|
||||
gyr.Head.Type = DroneData.DataType.DataGyr;
|
||||
gyr.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
gyr.Head.Time = Tick();
|
||||
|
||||
gyr.Gyr.X = RealGyr.result.X; gyr.Gyr.Y = RealGyr.result.Y; gyr.Gyr.Z = RealGyr.result.Z;
|
||||
gyr.Time = RealGyr.timer;
|
||||
@ -424,10 +446,10 @@ namespace DroneSimulator
|
||||
mag.Head.Size = Marshal.SizeOf(typeof(DroneData.DataMag));
|
||||
mag.Head.Mode = DroneData.DataMode.Response;
|
||||
mag.Head.Type = DroneData.DataType.DataMag;
|
||||
mag.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
mag.Head.Time = Tick();
|
||||
|
||||
mag.Mag.X = 0; mag.Mag.Y = 0; mag.Mag.Z = 0;
|
||||
mag.Time = DataTimer;
|
||||
mag.Time = Timer;
|
||||
|
||||
return getBytes(mag);
|
||||
}
|
||||
@ -439,7 +461,7 @@ namespace DroneSimulator
|
||||
range.Head.Size = Marshal.SizeOf(typeof(DroneData.DataRange));
|
||||
range.Head.Mode = DroneData.DataMode.Response;
|
||||
range.Head.Type = DroneData.DataType.DataRange;
|
||||
range.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
range.Head.Time = Tick();
|
||||
|
||||
range.LiDAR = RealRange.result;
|
||||
range.Time = RealRange.timer;
|
||||
@ -454,7 +476,7 @@ namespace DroneSimulator
|
||||
local.Head.Size = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
||||
local.Head.Mode = DroneData.DataMode.Response;
|
||||
local.Head.Type = DroneData.DataType.DataLocal;
|
||||
local.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
local.Head.Time = Tick();
|
||||
|
||||
local.Local.X = RealPos.result.X; local.Local.Y = RealPos.result.Y; local.Local.Z = RealPos.result.Z;
|
||||
local.Time = RealPos.timer;
|
||||
@ -469,7 +491,7 @@ namespace DroneSimulator
|
||||
bar.Head.Size = Marshal.SizeOf(typeof(DroneData.DataBar));
|
||||
bar.Head.Mode = DroneData.DataMode.Response;
|
||||
bar.Head.Type = DroneData.DataType.DataBar;
|
||||
bar.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
bar.Head.Time = Tick();
|
||||
|
||||
bar.Pressure = RealBar.result;
|
||||
bar.Time = RealBar.timer;
|
||||
@ -484,7 +506,7 @@ namespace DroneSimulator
|
||||
of.Head.Size = Marshal.SizeOf(typeof(DroneData.DataOF));
|
||||
of.Head.Mode = DroneData.DataMode.Response;
|
||||
of.Head.Type = DroneData.DataType.DataOF;
|
||||
of.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
of.Head.Time = Tick();
|
||||
|
||||
lock (this)
|
||||
{
|
||||
@ -506,7 +528,7 @@ namespace DroneSimulator
|
||||
gps.Head.Size = Marshal.SizeOf(typeof(DroneData.DataGPS));
|
||||
gps.Head.Mode = DroneData.DataMode.Response;
|
||||
gps.Head.Type = DroneData.DataType.DataGPS;
|
||||
gps.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
gps.Head.Time = Tick();
|
||||
|
||||
GPS.Point p = new GPS.Point();
|
||||
p.x = RealPos.result.Y; p.y= RealPos.result.X;
|
||||
@ -544,7 +566,7 @@ namespace DroneSimulator
|
||||
quat.Head.Size = Marshal.SizeOf(typeof(DroneData.DataQuat));
|
||||
quat.Head.Mode = DroneData.DataMode.Response;
|
||||
quat.Head.Type = DroneData.DataType.DataQuat;
|
||||
quat.Head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
quat.Head.Time = Tick();
|
||||
|
||||
quat.X = Quat.X; quat.Y = Quat.Y; quat.Z = Quat.Z; quat.W = Quat.W;
|
||||
|
||||
@ -557,8 +579,8 @@ namespace DroneSimulator
|
||||
|
||||
head.Size = Marshal.SizeOf(typeof(DroneData.DataHead));
|
||||
head.Mode = DroneData.DataMode.Response;
|
||||
head.Type = DroneData.DataType.None;
|
||||
head.Time = (uint)(Stopwatch.GetTimestamp() / (Stopwatch.Frequency / 1000));
|
||||
head.Type = DroneData.DataType.Ping;
|
||||
head.Time = Tick();
|
||||
|
||||
return getBytes(head);
|
||||
}
|
||||
@ -569,6 +591,8 @@ namespace DroneSimulator
|
||||
|
||||
switch (head.Type)
|
||||
{
|
||||
case DroneData.DataType.Step: if (head.Mode == DroneData.DataMode.Request) RecvStep(body); return zero;
|
||||
|
||||
case DroneData.DataType.DataAcc:
|
||||
{
|
||||
if (head.Mode == DroneData.DataMode.Request)
|
||||
@ -603,7 +627,7 @@ namespace DroneSimulator
|
||||
|
||||
case DroneData.DataType.DataMotor4: if (head.Mode == DroneData.DataMode.Response) RecvDataMotor4(body); return zero;
|
||||
|
||||
case DroneData.DataType.None: if (head.Mode == DroneData.DataMode.Request) return SendPingPong(); else return zero;
|
||||
case DroneData.DataType.Ping: if (head.Mode == DroneData.DataMode.Request) return SendPingPong(); else return zero;
|
||||
}
|
||||
|
||||
return zero;
|
||||
@ -612,7 +636,7 @@ namespace DroneSimulator
|
||||
private const int DroneStreamCount = 512;
|
||||
private byte[] DroneStreamData = new byte[DroneStreamCount];
|
||||
private int DroneStreamIndex = 0;
|
||||
private DroneData.DataHead DroneStreamHead = new DroneData.DataHead() { Mode = DroneData.DataMode.None, Size = 0, Type = DroneData.DataType.None };
|
||||
private DroneData.DataHead DroneStreamHead = new DroneData.DataHead() { Mode = DroneData.DataMode.None, Size = 0, Type = DroneData.DataType.Ping };
|
||||
|
||||
public List<byte[]?>? DataStream(byte[]? data, int size)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace DroneData
|
||||
|
||||
public enum DataType : ushort
|
||||
{
|
||||
None = 0, Head = 1,
|
||||
Ping = 0, Step = 1,
|
||||
|
||||
// Output
|
||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005, DataBar = 1006, DataOF = 1007, DataGPS = 1008,
|
||||
@ -29,17 +29,26 @@ namespace DroneData
|
||||
public DataMode Mode;
|
||||
public DataType Type;
|
||||
|
||||
public uint Time; // Общее время
|
||||
public uint Time; // ответ: Общее время на симуляторе
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
||||
}
|
||||
|
||||
public struct Step
|
||||
{
|
||||
public DataHead Head;
|
||||
|
||||
public uint StepTime; // ms, запрос: шаг работы симулятора; ответ: Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
||||
}
|
||||
|
||||
public struct XYZ { public float X, Y, Z; }
|
||||
|
||||
public struct DataAcc
|
||||
{
|
||||
public DataHead Head;
|
||||
public XYZ Acc;
|
||||
public XYZ Acc; // G, ускорения по осям
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -49,7 +58,7 @@ namespace DroneData
|
||||
public struct DataGyr
|
||||
{
|
||||
public DataHead Head;
|
||||
public XYZ Gyr;
|
||||
public XYZ Gyr; // dps, угловые скорости
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -69,7 +78,7 @@ namespace DroneData
|
||||
public struct DataRange
|
||||
{
|
||||
public DataHead Head;
|
||||
public float LiDAR; // Датчик посадки
|
||||
public float LiDAR; // m, Датчик посадки
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -79,7 +88,7 @@ namespace DroneData
|
||||
public struct DataLocal
|
||||
{
|
||||
public DataHead Head;
|
||||
public XYZ Local; // Локальные координаты
|
||||
public XYZ Local; // m, Локальные координаты
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -89,7 +98,7 @@ namespace DroneData
|
||||
public struct DataBar
|
||||
{
|
||||
public DataHead Head;
|
||||
public float Pressure; // Давление
|
||||
public float Pressure; // Pa, Давление
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -99,7 +108,7 @@ namespace DroneData
|
||||
public struct DataOF
|
||||
{
|
||||
public DataHead Head;
|
||||
public float X, Y; // Угловой сдвиг
|
||||
public float X, Y; // degree, Угловой сдвиг
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
@ -129,7 +138,7 @@ namespace DroneData
|
||||
public struct DataMotor4
|
||||
{
|
||||
public DataHead Head;
|
||||
public float UL, UR, DL, DR;
|
||||
public float UL, UR, DL, DR; // тяга 0.0 - 1.0
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor4));
|
||||
}
|
||||
@ -137,7 +146,7 @@ namespace DroneData
|
||||
public struct DataMotor6
|
||||
{
|
||||
public DataHead Head;
|
||||
public float UL, UR, LL, RR, DL, DR;
|
||||
public float UL, UR, LL, RR, DL, DR; // тяга 0.0 - 1.0
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMotor6));
|
||||
}
|
||||
@ -145,7 +154,7 @@ namespace DroneData
|
||||
public struct DataQuat
|
||||
{
|
||||
public DataHead Head;
|
||||
public float X, Y, Z, W;
|
||||
public float X, Y, Z, W; // Кватернион дрона
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataQuat));
|
||||
}
|
||||
|
148
DroneSimulator/FormMain.Designer.cs
generated
148
DroneSimulator/FormMain.Designer.cs
generated
@ -34,13 +34,9 @@
|
||||
pictureBox_2D = new PictureBox();
|
||||
tabControl_Menu = new TabControl();
|
||||
tabPage_Main = new TabPage();
|
||||
groupBox6 = new GroupBox();
|
||||
checkBox_Freq_Boost = new CheckBox();
|
||||
label84 = new Label();
|
||||
numericUpDown_Timing_Freq = new NumericUpDown();
|
||||
label83 = new Label();
|
||||
label_Timing = new Label();
|
||||
label79 = new Label();
|
||||
groupBox_Lockstep = new GroupBox();
|
||||
label_Lockstep_Time = new Label();
|
||||
checkBox_Lockstep_Limit = new CheckBox();
|
||||
groupBox_Visual = new GroupBox();
|
||||
numericUpDown_Visual_Limit = new NumericUpDown();
|
||||
label1 = new Label();
|
||||
@ -219,14 +215,11 @@
|
||||
comboBox_Drone_Rotor = new ComboBox();
|
||||
comboBox_Drone = new ComboBox();
|
||||
timer_Test = new System.Windows.Forms.Timer(components);
|
||||
label37 = new Label();
|
||||
label_Timing_Lag = new Label();
|
||||
groupBox_Screen.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox_2D).BeginInit();
|
||||
tabControl_Menu.SuspendLayout();
|
||||
tabPage_Main.SuspendLayout();
|
||||
groupBox6.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Timing_Freq).BeginInit();
|
||||
groupBox_Lockstep.SuspendLayout();
|
||||
groupBox_Visual.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Visual_Limit).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Visual_Port).BeginInit();
|
||||
@ -338,7 +331,7 @@
|
||||
//
|
||||
// tabPage_Main
|
||||
//
|
||||
tabPage_Main.Controls.Add(groupBox6);
|
||||
tabPage_Main.Controls.Add(groupBox_Lockstep);
|
||||
tabPage_Main.Controls.Add(groupBox_Visual);
|
||||
tabPage_Main.Controls.Add(groupBox_Clients);
|
||||
tabPage_Main.Location = new Point(4, 24);
|
||||
@ -350,81 +343,37 @@
|
||||
tabPage_Main.Text = "Main";
|
||||
tabPage_Main.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox6
|
||||
// groupBox_Lockstep
|
||||
//
|
||||
groupBox6.Controls.Add(label_Timing_Lag);
|
||||
groupBox6.Controls.Add(numericUpDown_Timing_Freq);
|
||||
groupBox6.Controls.Add(label37);
|
||||
groupBox6.Controls.Add(checkBox_Freq_Boost);
|
||||
groupBox6.Controls.Add(label84);
|
||||
groupBox6.Controls.Add(label83);
|
||||
groupBox6.Controls.Add(label_Timing);
|
||||
groupBox6.Controls.Add(label79);
|
||||
groupBox6.Dock = DockStyle.Top;
|
||||
groupBox6.Location = new Point(3, 174);
|
||||
groupBox6.Name = "groupBox6";
|
||||
groupBox6.Size = new Size(204, 75);
|
||||
groupBox6.TabIndex = 3;
|
||||
groupBox6.TabStop = false;
|
||||
groupBox6.Text = "Frequency";
|
||||
groupBox_Lockstep.Controls.Add(label_Lockstep_Time);
|
||||
groupBox_Lockstep.Controls.Add(checkBox_Lockstep_Limit);
|
||||
groupBox_Lockstep.Dock = DockStyle.Top;
|
||||
groupBox_Lockstep.Location = new Point(3, 174);
|
||||
groupBox_Lockstep.Name = "groupBox_Lockstep";
|
||||
groupBox_Lockstep.Size = new Size(204, 51);
|
||||
groupBox_Lockstep.TabIndex = 3;
|
||||
groupBox_Lockstep.TabStop = false;
|
||||
groupBox_Lockstep.Text = "Lockstep";
|
||||
//
|
||||
// checkBox_Freq_Boost
|
||||
// label_Lockstep_Time
|
||||
//
|
||||
checkBox_Freq_Boost.AutoSize = true;
|
||||
checkBox_Freq_Boost.Location = new Point(148, 18);
|
||||
checkBox_Freq_Boost.Name = "checkBox_Freq_Boost";
|
||||
checkBox_Freq_Boost.Size = new Size(56, 19);
|
||||
checkBox_Freq_Boost.TabIndex = 11;
|
||||
checkBox_Freq_Boost.Text = "boost";
|
||||
checkBox_Freq_Boost.UseVisualStyleBackColor = true;
|
||||
checkBox_Freq_Boost.CheckedChanged += numericUpDown_Timing_Freq_ValueChanged;
|
||||
label_Lockstep_Time.AutoSize = true;
|
||||
label_Lockstep_Time.Location = new Point(6, 23);
|
||||
label_Lockstep_Time.Name = "label_Lockstep_Time";
|
||||
label_Lockstep_Time.Size = new Size(70, 15);
|
||||
label_Lockstep_Time.TabIndex = 1;
|
||||
label_Lockstep_Time.Text = "00:00:00.000";
|
||||
//
|
||||
// label84
|
||||
// checkBox_Lockstep_Limit
|
||||
//
|
||||
label84.AutoSize = true;
|
||||
label84.Location = new Point(116, 43);
|
||||
label84.Name = "label84";
|
||||
label84.Size = new Size(21, 15);
|
||||
label84.TabIndex = 10;
|
||||
label84.Text = "Hz";
|
||||
//
|
||||
// numericUpDown_Timing_Freq
|
||||
//
|
||||
numericUpDown_Timing_Freq.Location = new Point(64, 41);
|
||||
numericUpDown_Timing_Freq.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDown_Timing_Freq.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDown_Timing_Freq.Name = "numericUpDown_Timing_Freq";
|
||||
numericUpDown_Timing_Freq.Size = new Size(51, 23);
|
||||
numericUpDown_Timing_Freq.TabIndex = 9;
|
||||
numericUpDown_Timing_Freq.Value = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDown_Timing_Freq.ValueChanged += numericUpDown_Timing_Freq_ValueChanged;
|
||||
//
|
||||
// label83
|
||||
//
|
||||
label83.AutoSize = true;
|
||||
label83.Location = new Point(7, 43);
|
||||
label83.Name = "label83";
|
||||
label83.Size = new Size(57, 15);
|
||||
label83.TabIndex = 2;
|
||||
label83.Text = "Required:";
|
||||
//
|
||||
// label_Timing
|
||||
//
|
||||
label_Timing.AutoSize = true;
|
||||
label_Timing.Location = new Point(70, 19);
|
||||
label_Timing.Name = "label_Timing";
|
||||
label_Timing.Size = new Size(13, 15);
|
||||
label_Timing.TabIndex = 1;
|
||||
label_Timing.Text = "0";
|
||||
//
|
||||
// label79
|
||||
//
|
||||
label79.AutoSize = true;
|
||||
label79.Location = new Point(6, 19);
|
||||
label79.Name = "label79";
|
||||
label79.Size = new Size(58, 15);
|
||||
label79.TabIndex = 0;
|
||||
label79.Text = "Available:";
|
||||
checkBox_Lockstep_Limit.AutoSize = true;
|
||||
checkBox_Lockstep_Limit.Location = new Point(96, 22);
|
||||
checkBox_Lockstep_Limit.Name = "checkBox_Lockstep_Limit";
|
||||
checkBox_Lockstep_Limit.Size = new Size(102, 19);
|
||||
checkBox_Lockstep_Limit.TabIndex = 0;
|
||||
checkBox_Lockstep_Limit.Text = "Real time limit";
|
||||
checkBox_Lockstep_Limit.UseVisualStyleBackColor = true;
|
||||
checkBox_Lockstep_Limit.CheckedChanged += checkBox_Lockstep_Limit_CheckedChanged;
|
||||
//
|
||||
// groupBox_Visual
|
||||
//
|
||||
@ -2396,24 +2345,6 @@
|
||||
timer_Test.Interval = 10;
|
||||
timer_Test.Tick += timer_Test_Tick;
|
||||
//
|
||||
// label37
|
||||
//
|
||||
label37.AutoSize = true;
|
||||
label37.Location = new Point(143, 43);
|
||||
label37.Name = "label37";
|
||||
label37.Size = new Size(29, 15);
|
||||
label37.TabIndex = 12;
|
||||
label37.Text = "Lag:";
|
||||
//
|
||||
// label_Timing_Lag
|
||||
//
|
||||
label_Timing_Lag.AutoSize = true;
|
||||
label_Timing_Lag.Location = new Point(168, 43);
|
||||
label_Timing_Lag.Name = "label_Timing_Lag";
|
||||
label_Timing_Lag.Size = new Size(13, 15);
|
||||
label_Timing_Lag.TabIndex = 13;
|
||||
label_Timing_Lag.Text = "0";
|
||||
//
|
||||
// Form_Main
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@ -2431,9 +2362,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox_2D).EndInit();
|
||||
tabControl_Menu.ResumeLayout(false);
|
||||
tabPage_Main.ResumeLayout(false);
|
||||
groupBox6.ResumeLayout(false);
|
||||
groupBox6.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Timing_Freq).EndInit();
|
||||
groupBox_Lockstep.ResumeLayout(false);
|
||||
groupBox_Lockstep.PerformLayout();
|
||||
groupBox_Visual.ResumeLayout(false);
|
||||
groupBox_Visual.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Visual_Limit).EndInit();
|
||||
@ -2706,14 +2636,8 @@
|
||||
private Label label78;
|
||||
private NumericUpDown numericUpDown_Physics_Power;
|
||||
private Label label77;
|
||||
private GroupBox groupBox6;
|
||||
private Label label_Timing;
|
||||
private Label label79;
|
||||
private Label label84;
|
||||
private NumericUpDown numericUpDown_Timing_Freq;
|
||||
private Label label83;
|
||||
private CheckBox checkBox_Freq_Boost;
|
||||
private Label label_Timing_Lag;
|
||||
private Label label37;
|
||||
private GroupBox groupBox_Lockstep;
|
||||
private Label label_Lockstep_Time;
|
||||
private CheckBox checkBox_Lockstep_Limit;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace DroneSimulator
|
||||
|
||||
if (data.Connect)
|
||||
{
|
||||
Drone drone = new Drone(data.ID);
|
||||
Drone drone = new Drone(data.ID, data.Client);
|
||||
drone.Create();
|
||||
|
||||
screen2D.CreateDrone(Color.Red, data.ID);
|
||||
@ -115,6 +115,9 @@ namespace DroneSimulator
|
||||
{
|
||||
button_Client_Start.Text = "Stop";
|
||||
button_Client_Start.BackColor = Color.LimeGreen;
|
||||
numericUpDown_Clients_Limit.Enabled = false;
|
||||
numericUpDown_Clients_Port.Enabled = false;
|
||||
checkBox_Lockstep_Limit.Enabled = false;
|
||||
break;
|
||||
}
|
||||
case NetServerClients.ServerState.Stop:
|
||||
@ -122,6 +125,9 @@ namespace DroneSimulator
|
||||
label_Clients_Num.Text = "0";
|
||||
button_Client_Start.Text = "Start";
|
||||
button_Client_Start.BackColor = Color.Transparent;
|
||||
numericUpDown_Clients_Limit.Enabled = true;
|
||||
numericUpDown_Clients_Port.Enabled = true;
|
||||
checkBox_Lockstep_Limit.Enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -151,10 +157,9 @@ namespace DroneSimulator
|
||||
|
||||
private void timer_Test_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DateTime test = DateTime.Now;
|
||||
|
||||
int tim = test.Second + test.Minute * 100 + test.Hour * 10000;
|
||||
DateTime time = DateTime.Now;
|
||||
|
||||
label_Lockstep_Time.Text = time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + ":" + time.Second.ToString("D2") + "." + time.Millisecond.ToString("D3");
|
||||
|
||||
if (screen2D == null) return;
|
||||
|
||||
@ -176,9 +181,6 @@ namespace DroneSimulator
|
||||
}
|
||||
catch { }
|
||||
|
||||
label_Timing.Text = Drone.Timing.ToString() + " Hz";
|
||||
label_Timing_Lag.Text = Drone.Lag.ToString();
|
||||
|
||||
screen2D.DrawScene();
|
||||
}
|
||||
|
||||
@ -367,10 +369,9 @@ namespace DroneSimulator
|
||||
Drone.StopThread();
|
||||
}
|
||||
|
||||
private void numericUpDown_Timing_Freq_ValueChanged(object sender, EventArgs e)
|
||||
private void checkBox_Lockstep_Limit_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Drone.Freq = (long)numericUpDown_Timing_Freq.Value;
|
||||
Drone.Boost = checkBox_Freq_Boost.Checked;
|
||||
Drone.TimeLimit = checkBox_Lockstep_Limit.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user