Add real mode (bar)

This commit is contained in:
2025-04-15 01:23:54 +03:00
parent 376ce81a8a
commit cdf8c18d9b
5 changed files with 525 additions and 159 deletions

View File

@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using System.Numerics;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
@ -22,6 +22,9 @@ namespace DroneSimulator
public Form_Main()
{
InitializeComponent();
RealMode.RealSimulation = checkBox_Mode_Real.Checked;
numericUpDown_Bar_Update(null, null);
}
private void ClientConnectionCallback(object o)
@ -38,15 +41,6 @@ namespace DroneSimulator
Drone drone = new Drone(data.ID);
drone.Create(1.0f, 0.5f, 1.0f);
//
drone.dataBarometer.Pressure = 102258;
drone.dataBarometer.Accuracy = (float)numericUpDown_Bar_Accur.Value;
drone.dataBarometer.Frequency = (int)numericUpDown_Bar_Freq.Value;
try { drone.dataBarometer.Pressure = int.Parse(textBox_Bar_Pressure.Text); }
catch { MessageBox.Show("Pressure invalid format", "Barometer error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
//
screen2D.CreateDrone(Color.Red, data.ID);
AllDrones.Add(drone);
@ -84,7 +78,7 @@ namespace DroneSimulator
List<byte[]?>? send = drone.DataStream(data.Buffer, data.Size);
if (send == null) return;
try
try
{
foreach (byte[]? b in send)
{
@ -108,7 +102,6 @@ namespace DroneSimulator
{
button_Client_Start.Text = "Stop";
button_Client_Start.BackColor = Color.LimeGreen;
panel_Menu_Model.Enabled = false;
break;
}
case NetServerClients.ServerState.Stop:
@ -116,7 +109,6 @@ namespace DroneSimulator
label_Clients_Num.Text = "0";
button_Client_Start.Text = "Start";
button_Client_Start.BackColor = Color.Transparent;
panel_Menu_Model.Enabled = true;
break;
}
}
@ -215,5 +207,26 @@ namespace DroneSimulator
}
}
}
private void numericUpDown_Bar_Update(object sender, EventArgs e)
{
try { RealMode.Barometer.Pressure = uint.Parse(textBox_Bar_Pressure.Text); }
catch
{
RealMode.Barometer.Pressure = 102258;
MessageBox.Show("Pressure invalid format", "Barometer error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
RealMode.Barometer.Freq = (uint)numericUpDown_Bar_Freq.Value;
RealMode.Barometer.Noise = (float)numericUpDown_Bar_Noise.Value;
RealMode.Barometer.Lateness = (float)numericUpDown_Bar_Laten.Value;
RealMode.Barometer.Enable = checkBox_Bar_Enable.Checked;
}
private void checkBox_Mode_Real_CheckedChanged(object sender, EventArgs e)
{
RealMode.RealSimulation = checkBox_Mode_Real.Checked;
}
}
}