revert e30f1f0f35
revert Merge branch 'main' of https://git.skbkit.ru/CPL/Simulator
This commit is contained in:
@ -17,6 +17,8 @@ namespace DroneSimulator
|
||||
NetServerClients netServerClient = new NetServerClients();
|
||||
NetServerVisual netServerVisual = new NetServerVisual();
|
||||
|
||||
List<Drone> AllDrones = new List<Drone>();
|
||||
|
||||
public Form_Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -49,24 +51,20 @@ namespace DroneSimulator
|
||||
|
||||
screen2D.CreateDrone(Color.Red, data.ID);
|
||||
|
||||
lock (Drone.AllDrones) Drone.AllDrones.Add(drone);
|
||||
AllDrones.Add(drone);
|
||||
}
|
||||
else
|
||||
{
|
||||
Drone? d = null;
|
||||
|
||||
lock (Drone.AllDrones)
|
||||
foreach (Drone drone in AllDrones)
|
||||
{
|
||||
foreach (Drone drone in Drone.AllDrones)
|
||||
{
|
||||
if (drone.ID != data.ID) continue;
|
||||
d = drone;
|
||||
Drone.AllDrones.Remove(drone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (drone.ID != data.ID) continue;
|
||||
drone.Close();
|
||||
|
||||
if (d != null) screen2D.RemoveDrone(d.ID);
|
||||
screen2D.RemoveDrone(data.ID);
|
||||
|
||||
AllDrones.Remove(drone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,14 +74,11 @@ namespace DroneSimulator
|
||||
|
||||
Drone? drone = null;
|
||||
|
||||
lock (Drone.AllDrones)
|
||||
foreach (Drone d in AllDrones)
|
||||
{
|
||||
foreach (Drone d in Drone.AllDrones)
|
||||
{
|
||||
if (d.ID != data.ID) continue;
|
||||
drone = d;
|
||||
break;
|
||||
}
|
||||
if (d.ID != data.ID) continue;
|
||||
drone = d;
|
||||
break;
|
||||
}
|
||||
|
||||
if (drone == null) return;
|
||||
@ -128,8 +123,6 @@ namespace DroneSimulator
|
||||
|
||||
if (done != NetServerClients.ServerState.Start) return;
|
||||
|
||||
Drone.StartThread();
|
||||
|
||||
pictureBox_2D.Image = null;
|
||||
|
||||
screen2D = new Screen2D(DrawCallback);
|
||||
@ -162,25 +155,23 @@ namespace DroneSimulator
|
||||
|
||||
try
|
||||
{
|
||||
lock (Drone.AllDrones)
|
||||
foreach (Drone d in AllDrones)
|
||||
{
|
||||
foreach (Drone d in Drone.AllDrones)
|
||||
{
|
||||
screen2D.Move(d.ID, d.PosXYZ, d.GetOrientation());
|
||||
screen2D.Move(d.ID, d.PosXYZ, d.GetOrientation());
|
||||
|
||||
string line = "ID:" + d.ID.ToString() + " Pitch:" + ((int)d.Orientation.X).ToString() + " Roll:" + ((int)d.Orientation.Y).ToString() + " Yaw:" + ((int)d.Orientation.Z).ToString();
|
||||
string line = "ID:" + d.ID.ToString() + " Pitch:" + ((int)d.Orientation.X).ToString() + " Roll:" + ((int)d.Orientation.Y).ToString() + " Yaw:" + ((int)d.Orientation.Z).ToString();
|
||||
|
||||
listBox_Drones.Items.Add(line);
|
||||
}
|
||||
listBox_Drones.Items.Add(line);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
label_Timing.Text = Drone.Timing.ToString() + " Hz";
|
||||
label_Timing_Lag.Text = Drone.Lag.ToString();
|
||||
|
||||
screen2D.DrawScene();
|
||||
}
|
||||
private void Form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
foreach (Drone d in AllDrones) d.Close();
|
||||
}
|
||||
|
||||
private void VisualConnectionCallback(object o)
|
||||
{
|
||||
@ -207,15 +198,12 @@ namespace DroneSimulator
|
||||
|
||||
int index = 0;
|
||||
|
||||
lock (Drone.AllDrones)
|
||||
foreach (Drone d in AllDrones)
|
||||
{
|
||||
foreach (Drone d in Drone.AllDrones)
|
||||
{
|
||||
VisualData.VisualDrone v = d.GetVisual(Drone.AllDrones.Count, index++);
|
||||
VisualData.VisualDrone v = d.GetVisual(AllDrones.Count, index++);
|
||||
|
||||
try { data.Client.Send(Drone.getBytes(v)); }
|
||||
catch { }
|
||||
}
|
||||
try { data.Client.Send(Drone.getBytes(v)); }
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,8 +306,11 @@ namespace DroneSimulator
|
||||
RealMode.OpticalFlow.Lateness = (float)numericUpDown_OF_Laten.Value;
|
||||
RealMode.OpticalFlow.Enable = checkBox_OF_Enable.Checked;
|
||||
|
||||
RealMode.OpticalFlow.Lens = (uint)numericUpDown_OF_Lens.Value;
|
||||
RealMode.OpticalFlow.Lens = (uint)numericUpDown_OF_Lens.Value * 10;
|
||||
RealMode.OpticalFlow.MaxHeight = (float)numericUpDown_OF_Len.Value;
|
||||
|
||||
RealMode.OpticalFlow.Error = (float)numericUpDown_OF_Error.Value * 10;
|
||||
RealMode.OpticalFlow.Wait = (uint)numericUpDown_OF_Wait.Value * 1000;
|
||||
}
|
||||
|
||||
private void checkBox_Area_Freeze_CheckedChanged(object sender, EventArgs e)
|
||||
@ -361,16 +352,5 @@ namespace DroneSimulator
|
||||
Drone.Physics.Length = (float)numericUpDown_Physics_Length.Value;
|
||||
Drone.Physics.MaxPower = (float)numericUpDown_Physics_Power.Value;
|
||||
}
|
||||
|
||||
private void Form_Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Drone.StopThread();
|
||||
}
|
||||
|
||||
private void numericUpDown_Timing_Freq_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
Drone.Freq = (long)numericUpDown_Timing_Freq.Value;
|
||||
Drone.Boost = checkBox_Freq_Boost.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user