update
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
using System.Diagnostics.Metrics;
|
||||
using DroneData;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DroneClient
|
||||
@ -15,6 +17,8 @@ namespace DroneClient
|
||||
public float LaserRange;
|
||||
public uint TimeRange;
|
||||
|
||||
public Vector2 OF = Vector2.Zero;
|
||||
|
||||
public float MotorUL, MotorUR, MotorDL, MotorDR;
|
||||
|
||||
public static byte[] getBytes(object data)
|
||||
@ -116,6 +120,16 @@ namespace DroneClient
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
private byte[]? RecvDataOF(byte[] data)
|
||||
{
|
||||
DroneData.DataOF of = (DroneData.DataOF)fromBytes(data, typeof(DroneData.DataOF));
|
||||
|
||||
OF.X = of.X;
|
||||
OF.Y = of.Y;
|
||||
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
private byte[]? ClientRequestResponse(DroneData.DataHead head, byte[] body)
|
||||
{
|
||||
byte[] zero = new byte[0];
|
||||
@ -186,6 +200,22 @@ namespace DroneClient
|
||||
}
|
||||
}
|
||||
|
||||
case DroneData.DataType.DataOF:
|
||||
{
|
||||
if (head.Mode == DroneData.DataMode.Request)
|
||||
{
|
||||
// Запрос данных
|
||||
// ... //
|
||||
//
|
||||
return zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Пришли данные
|
||||
return RecvDataOF(body);
|
||||
}
|
||||
}
|
||||
|
||||
case DroneData.DataType.DataMotor4:
|
||||
{
|
||||
if (head.Mode == DroneData.DataMode.Request)
|
||||
@ -271,12 +301,18 @@ namespace DroneClient
|
||||
local.Mode = DroneData.DataMode.Request;
|
||||
local.Type = DroneData.DataType.DataLocal;
|
||||
|
||||
DroneData.DataHead of = new DroneData.DataHead();
|
||||
of.Size = DroneData.DataHead.StrLen;
|
||||
of.Mode = DroneData.DataMode.Request;
|
||||
of.Type = DroneData.DataType.DataOF;
|
||||
|
||||
List<byte[]> list = new List<byte[]>();
|
||||
|
||||
list.Add(getBytes(acc));
|
||||
list.Add(getBytes(gyr));
|
||||
list.Add(getBytes(range));
|
||||
list.Add(getBytes(local));
|
||||
list.Add(getBytes(of));
|
||||
list.Add(SendDataMotor4());
|
||||
|
||||
int count = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DroneData
|
||||
{
|
||||
@ -12,10 +12,13 @@ namespace DroneData
|
||||
None = 0, Head = 1,
|
||||
|
||||
// Output
|
||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005,
|
||||
DataAcc = 1001, DataGyr = 1002, DataMag = 1003, DataRange = 1004, DataLocal = 1005, DataBar = 1006, DataOF = 1007,
|
||||
|
||||
// Input
|
||||
DataMotor4 = 2001, DataMotor6 = 2002
|
||||
DataMotor4 = 2001, DataMotor6 = 2002,
|
||||
|
||||
// State
|
||||
DataQuat = 3001,
|
||||
};
|
||||
|
||||
public struct DataHead
|
||||
@ -25,7 +28,7 @@ namespace DroneData
|
||||
public DataMode Mode;
|
||||
public DataType Type;
|
||||
|
||||
public uint Time; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint Time; // Общее время
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataHead));
|
||||
}
|
||||
@ -37,7 +40,7 @@ namespace DroneData
|
||||
public DataHead Head;
|
||||
public XYZ Acc;
|
||||
|
||||
public uint Time; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataAcc));
|
||||
}
|
||||
@ -47,7 +50,7 @@ namespace DroneData
|
||||
public DataHead Head;
|
||||
public XYZ Gyr;
|
||||
|
||||
public uint Time; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataGyr));
|
||||
}
|
||||
@ -57,31 +60,51 @@ namespace DroneData
|
||||
public DataHead Head;
|
||||
public XYZ Mag;
|
||||
|
||||
public uint Time; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataMag));
|
||||
}
|
||||
|
||||
public struct DataLocal
|
||||
{
|
||||
public DataHead Head;
|
||||
public XYZ Local; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
public uint Time; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
||||
}
|
||||
|
||||
public struct DataRange
|
||||
{
|
||||
public DataHead Head;
|
||||
public float LiDAR; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public float LiDAR; // Датчик посадки
|
||||
|
||||
public uint Time; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataRange));
|
||||
}
|
||||
|
||||
public struct DataLocal
|
||||
{
|
||||
public DataHead Head;
|
||||
public XYZ Local; // Локальные координаты
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataLocal));
|
||||
}
|
||||
|
||||
public struct DataBar
|
||||
{
|
||||
public DataHead Head;
|
||||
public float Pressure; // Давление
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataBar));
|
||||
}
|
||||
|
||||
public struct DataOF
|
||||
{
|
||||
public DataHead Head;
|
||||
public float X, Y; // Угловой сдвиг
|
||||
|
||||
public uint Time; // Последнее время изменения данных
|
||||
|
||||
static public int StrLen = Marshal.SizeOf(typeof(DroneData.DataOF));
|
||||
}
|
||||
|
||||
public struct DataMotor4
|
||||
{
|
||||
public DataHead Head;
|
||||
|
131
DroneClient/FormMain.Designer.cs
generated
131
DroneClient/FormMain.Designer.cs
generated
@ -38,12 +38,14 @@
|
||||
label3 = new Label();
|
||||
label1 = new Label();
|
||||
groupBox2 = new GroupBox();
|
||||
label_time_acc = new Label();
|
||||
label_Acc_Z = new Label();
|
||||
label7 = new Label();
|
||||
label_Acc_Y = new Label();
|
||||
label5 = new Label();
|
||||
label_Acc_X = new Label();
|
||||
groupBox3 = new GroupBox();
|
||||
label_time_gyr = new Label();
|
||||
label_Gyr_Z = new Label();
|
||||
label9 = new Label();
|
||||
label_Gyr_Y = new Label();
|
||||
@ -51,6 +53,7 @@
|
||||
label_Gyr_X = new Label();
|
||||
label13 = new Label();
|
||||
groupBox4 = new GroupBox();
|
||||
label_time_range = new Label();
|
||||
label_Pos_L = new Label();
|
||||
label6 = new Label();
|
||||
label_Pos_Y = new Label();
|
||||
@ -65,15 +68,19 @@
|
||||
label_Pow = new Label();
|
||||
button_ML = new Button();
|
||||
button_MR = new Button();
|
||||
label_time_acc = new Label();
|
||||
label_time_range = new Label();
|
||||
label_time_gyr = new Label();
|
||||
groupBox5 = new GroupBox();
|
||||
label_time_of = new Label();
|
||||
label_OF_Y = new Label();
|
||||
label17 = new Label();
|
||||
label_OF_X = new Label();
|
||||
label19 = new Label();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown_Server_Port).BeginInit();
|
||||
groupBox2.SuspendLayout();
|
||||
groupBox3.SuspendLayout();
|
||||
groupBox4.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBar_Power).BeginInit();
|
||||
groupBox5.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// timer_Test
|
||||
@ -92,7 +99,7 @@
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(0, 0);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(275, 80);
|
||||
groupBox1.Size = new Size(357, 80);
|
||||
groupBox1.TabIndex = 3;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Tag = "";
|
||||
@ -173,6 +180,15 @@
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Acc";
|
||||
//
|
||||
// label_time_acc
|
||||
//
|
||||
label_time_acc.AutoSize = true;
|
||||
label_time_acc.Location = new Point(6, 100);
|
||||
label_time_acc.Name = "label_time_acc";
|
||||
label_time_acc.Size = new Size(13, 15);
|
||||
label_time_acc.TabIndex = 25;
|
||||
label_time_acc.Text = "0";
|
||||
//
|
||||
// label_Acc_Z
|
||||
//
|
||||
label_Acc_Z.AutoSize = true;
|
||||
@ -227,13 +243,22 @@
|
||||
groupBox3.Controls.Add(label11);
|
||||
groupBox3.Controls.Add(label_Gyr_X);
|
||||
groupBox3.Controls.Add(label13);
|
||||
groupBox3.Location = new Point(95, 86);
|
||||
groupBox3.Location = new Point(94, 86);
|
||||
groupBox3.Name = "groupBox3";
|
||||
groupBox3.Size = new Size(78, 118);
|
||||
groupBox3.TabIndex = 6;
|
||||
groupBox3.TabStop = false;
|
||||
groupBox3.Text = "Gyr";
|
||||
//
|
||||
// label_time_gyr
|
||||
//
|
||||
label_time_gyr.AutoSize = true;
|
||||
label_time_gyr.Location = new Point(3, 100);
|
||||
label_time_gyr.Name = "label_time_gyr";
|
||||
label_time_gyr.Size = new Size(13, 15);
|
||||
label_time_gyr.TabIndex = 26;
|
||||
label_time_gyr.Text = "0";
|
||||
//
|
||||
// label_Gyr_Z
|
||||
//
|
||||
label_Gyr_Z.AutoSize = true;
|
||||
@ -297,13 +322,22 @@
|
||||
groupBox4.Controls.Add(label10);
|
||||
groupBox4.Controls.Add(label_Pos_X);
|
||||
groupBox4.Controls.Add(label14);
|
||||
groupBox4.Location = new Point(188, 86);
|
||||
groupBox4.Location = new Point(182, 86);
|
||||
groupBox4.Name = "groupBox4";
|
||||
groupBox4.Size = new Size(78, 118);
|
||||
groupBox4.TabIndex = 7;
|
||||
groupBox4.TabStop = false;
|
||||
groupBox4.Text = "Pos";
|
||||
//
|
||||
// label_time_range
|
||||
//
|
||||
label_time_range.AutoSize = true;
|
||||
label_time_range.Location = new Point(6, 100);
|
||||
label_time_range.Name = "label_time_range";
|
||||
label_time_range.Size = new Size(13, 15);
|
||||
label_time_range.TabIndex = 27;
|
||||
label_time_range.Text = "0";
|
||||
//
|
||||
// label_Pos_L
|
||||
//
|
||||
label_Pos_L.AutoSize = true;
|
||||
@ -443,38 +477,71 @@
|
||||
button_MR.MouseDown += button_UU_MouseDown;
|
||||
button_MR.MouseUp += button_UU_MouseUp;
|
||||
//
|
||||
// label_time_acc
|
||||
// groupBox5
|
||||
//
|
||||
label_time_acc.AutoSize = true;
|
||||
label_time_acc.Location = new Point(6, 100);
|
||||
label_time_acc.Name = "label_time_acc";
|
||||
label_time_acc.Size = new Size(13, 15);
|
||||
label_time_acc.TabIndex = 25;
|
||||
label_time_acc.Text = "0";
|
||||
groupBox5.Controls.Add(label_time_of);
|
||||
groupBox5.Controls.Add(label_OF_Y);
|
||||
groupBox5.Controls.Add(label17);
|
||||
groupBox5.Controls.Add(label_OF_X);
|
||||
groupBox5.Controls.Add(label19);
|
||||
groupBox5.Location = new Point(270, 86);
|
||||
groupBox5.Name = "groupBox5";
|
||||
groupBox5.Size = new Size(78, 118);
|
||||
groupBox5.TabIndex = 24;
|
||||
groupBox5.TabStop = false;
|
||||
groupBox5.Text = "OF";
|
||||
//
|
||||
// label_time_range
|
||||
// label_time_of
|
||||
//
|
||||
label_time_range.AutoSize = true;
|
||||
label_time_range.Location = new Point(6, 100);
|
||||
label_time_range.Name = "label_time_range";
|
||||
label_time_range.Size = new Size(13, 15);
|
||||
label_time_range.TabIndex = 27;
|
||||
label_time_range.Text = "0";
|
||||
label_time_of.AutoSize = true;
|
||||
label_time_of.Location = new Point(6, 100);
|
||||
label_time_of.Name = "label_time_of";
|
||||
label_time_of.Size = new Size(13, 15);
|
||||
label_time_of.TabIndex = 27;
|
||||
label_time_of.Text = "0";
|
||||
//
|
||||
// label_time_gyr
|
||||
// label_OF_Y
|
||||
//
|
||||
label_time_gyr.AutoSize = true;
|
||||
label_time_gyr.Location = new Point(3, 100);
|
||||
label_time_gyr.Name = "label_time_gyr";
|
||||
label_time_gyr.Size = new Size(13, 15);
|
||||
label_time_gyr.TabIndex = 26;
|
||||
label_time_gyr.Text = "0";
|
||||
label_OF_Y.AutoSize = true;
|
||||
label_OF_Y.Location = new Point(19, 45);
|
||||
label_OF_Y.Name = "label_OF_Y";
|
||||
label_OF_Y.Size = new Size(13, 15);
|
||||
label_OF_Y.TabIndex = 7;
|
||||
label_OF_Y.Text = "0";
|
||||
//
|
||||
// label17
|
||||
//
|
||||
label17.AutoSize = true;
|
||||
label17.Location = new Point(6, 45);
|
||||
label17.Name = "label17";
|
||||
label17.Size = new Size(17, 15);
|
||||
label17.TabIndex = 6;
|
||||
label17.Text = "Y:";
|
||||
//
|
||||
// label_OF_X
|
||||
//
|
||||
label_OF_X.AutoSize = true;
|
||||
label_OF_X.Location = new Point(19, 19);
|
||||
label_OF_X.Name = "label_OF_X";
|
||||
label_OF_X.Size = new Size(13, 15);
|
||||
label_OF_X.TabIndex = 5;
|
||||
label_OF_X.Text = "0";
|
||||
//
|
||||
// label19
|
||||
//
|
||||
label19.AutoSize = true;
|
||||
label19.Location = new Point(6, 19);
|
||||
label19.Name = "label19";
|
||||
label19.Size = new Size(17, 15);
|
||||
label19.TabIndex = 4;
|
||||
label19.Text = "X:";
|
||||
//
|
||||
// Form_Main
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(275, 447);
|
||||
ClientSize = new Size(357, 447);
|
||||
Controls.Add(groupBox5);
|
||||
Controls.Add(button_MR);
|
||||
Controls.Add(button_ML);
|
||||
Controls.Add(label_Pow);
|
||||
@ -501,6 +568,8 @@
|
||||
groupBox4.ResumeLayout(false);
|
||||
groupBox4.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBar_Power).EndInit();
|
||||
groupBox5.ResumeLayout(false);
|
||||
groupBox5.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -546,5 +615,11 @@
|
||||
private Label label_time_acc;
|
||||
private Label label_time_range;
|
||||
private Label label_time_gyr;
|
||||
private GroupBox groupBox5;
|
||||
private Label label_time_of;
|
||||
private Label label_OF_Y;
|
||||
private Label label17;
|
||||
private Label label_OF_X;
|
||||
private Label label19;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using System.Numerics;
|
||||
using System.Windows.Forms;
|
||||
using static DroneSimulator.NetClient;
|
||||
@ -109,6 +109,11 @@ namespace DroneSimulator
|
||||
|
||||
label_time_range.Text = dataDrone.TimeRange.ToString();
|
||||
|
||||
label_OF_X.Text = dataDrone.OF.X.ToString();
|
||||
label_OF_Y.Text = dataDrone.OF.Y.ToString();
|
||||
|
||||
label_time_of.Text = dataDrone.TimeRange.ToString();
|
||||
|
||||
netClient.SendData(dataDrone.SendReqest());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user