From ddc5e8ff392ff18583e5afa861d8c142d985bc2c Mon Sep 17 00:00:00 2001 From: gunther82 Date: Thu, 9 Jun 2022 17:38:08 +0200 Subject: [PATCH] Add project files. --- .DS_Store | Bin 0 -> 6148 bytes dummy_drone.sln | 25 ++ dummy_drone/.DS_Store | Bin 0 -> 6148 bytes dummy_drone/App.xaml | 16 ++ dummy_drone/App.xaml.cs | 17 ++ dummy_drone/AssemblyInfo.cs | 10 + dummy_drone/MainWindow.xaml | 406 +++++++++++++++++++++++++++++++++ dummy_drone/MainWindow.xaml.cs | 192 ++++++++++++++++ dummy_drone/dummy_drone.csproj | 25 ++ 9 files changed, 691 insertions(+) create mode 100644 .DS_Store create mode 100644 dummy_drone.sln create mode 100644 dummy_drone/.DS_Store create mode 100644 dummy_drone/App.xaml create mode 100644 dummy_drone/App.xaml.cs create mode 100644 dummy_drone/AssemblyInfo.cs create mode 100644 dummy_drone/MainWindow.xaml create mode 100644 dummy_drone/MainWindow.xaml.cs create mode 100644 dummy_drone/dummy_drone.csproj diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..98f23bdfb3fd3888e6da6857bd721a967ebbf19e GIT binary patch literal 6148 zcmeHK%}T>S5S~qYh!mtpkBi_{=&9FOqAyVJs?Kprf~a?*GT_=l^<=-5CSM zz*aHfy6HF_;gLdbZ9E+JS`R&kvT$6fxJto9S}|g|74JbsVD~%$CIL%DSRnQzAT-!u I4E!qtU*$hGtd`09V%%Q` zdG-O7bWMx-W&8P8pAA#RqA2IFgeNn2ru~sRRHH;ZBCJ)DjXC40FR;5e$qq6sVzWB?fCa{K3}chP9%G6I=1YmU&&g zaLSJTLt0LpD|+t=xB^`T209(d{eOs0rnkuNhWN}Ca0ULE0z53H#RM;9ck9OM$z2=J uPSM0 + + + + + + + + + diff --git a/dummy_drone/App.xaml.cs b/dummy_drone/App.xaml.cs new file mode 100644 index 0000000..f478bbd --- /dev/null +++ b/dummy_drone/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace dummy_drone +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/dummy_drone/AssemblyInfo.cs b/dummy_drone/AssemblyInfo.cs new file mode 100644 index 0000000..8b5504e --- /dev/null +++ b/dummy_drone/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/dummy_drone/MainWindow.xaml b/dummy_drone/MainWindow.xaml new file mode 100644 index 0000000..084f0b0 --- /dev/null +++ b/dummy_drone/MainWindow.xaml @@ -0,0 +1,406 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dummy_drone/MainWindow.xaml.cs b/dummy_drone/MainWindow.xaml.cs new file mode 100644 index 0000000..f43891c --- /dev/null +++ b/dummy_drone/MainWindow.xaml.cs @@ -0,0 +1,192 @@ +using NadLibrary; +using System; +using System.Windows; +using System.Collections.Generic; +using System.Windows.Threading; +using System.Threading; + +namespace dummy_drone +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + + } + + DispatcherTimer timer = new DispatcherTimer(); + NadSystem nad = new NadSystem(); + + List remoteIp = null; + double latitude_f = 43.719259015524976; + double longitude_f = 10.421048893480233; + double latitude_up; + double longitude_up; + int altitude; + double a = (Math.PI / 180.0) * 45.0; + Random r = new Random(); + + public void initializeTimer() + { + timer.Interval = TimeSpan.FromSeconds(10); + timer.Tick += timer_Tick; + timer.Start(); + } + + private void timer_Tick(object sender, EventArgs e) + { + + double lat0 = Math.Cos(Math.PI / 180.0 * latitude_f); + + latitude_up = latitude_f + (180.0 / Math.PI) * (10.0 / 6378137.0) * Math.Sin(a); + longitude_up = longitude_f + (180 / Math.PI) * (10.0 / 6378137.0) / Math.Cos(lat0) * Math.Cos(a); + altitude = r.Next(10, 60); + + latitude_f = latitude_up; + longitude_f = longitude_up; + showmsg(); + nad.NADPopulateListCoordinate(latitude_f.ToString(), longitude_f.ToString(), altitude.ToString()); + + //nad.NADUpdateShipCoord(latitude_f.ToString(), longitude_f.ToString()); + + } + + private void btnStart_Click(object sender, RoutedEventArgs e) + { + nad.NADOpenConnection(IPTextBox.Text, PortTextBox.Text); + nad.NADPopulateListCoordinate("43.71967438461098", "10.420797021964137", "40"); + nad.NADPopulateListCoordinate("43.71968213866057", "10.421413929976033", "30"); + nad.NADPopulateListCoordinate("43.72014350280539", "10.4228730515346", "20"); + nad.NADPopulateListCoordinate("43.720825039296045", "10.424706602137107", "20"); + nad.NADPopulateListCoordinate("43.72266628185771", "10.422610492949717", "20"); + //initializeTimer(); + //showmsg(); + //Thread thread = new Thread(showmsg); + //thread.IsBackground = true; + //thread.Start(); + } + + private void btnStop_Click(object sender, RoutedEventArgs e) + { + //showmsg(MSGTextBox.Text); + //nad.Send_tcp_msg(MSGTextBox.Text + "\r\n"); + //nad.NADGetDroneStatus(); + nad.NADCloseConnection(); + + } + + private void btnSend_ConfigWP(object sender, RoutedEventArgs e) + { + //showmsg(MSGSetSpeed.Text); + //nad.NADUpdateShip(MSGSetSpeed.Text); + nad.NADSetSpeed(MSGSetSpeed.Text); + + } + + private void btnSend_CreateWP(object sender, RoutedEventArgs e) + { + //nad.NADSendCoordinate(SetLatitudeWP.Text, SetLongitudeWP.Text, SetAltitudeWP.Text); + //nad.NADSendListCoord(); + } + + private void btnSend_UploadWP(object sender, RoutedEventArgs e) + { + //nad.NADUploadMobMission(); + } + + private void btnSend_startWP(object sender, RoutedEventArgs e) + { + nad.NADStartMobMission(); + + + } + + private void btnGet_Info(object sender, RoutedEventArgs e) + { + string msg = nad.NADGetDroneStatus(); + System.Diagnostics.Trace.WriteLine("Message from client " + msg); + } + + private void btnSend_pauseWP(object sender, RoutedEventArgs e) + { + nad.NADPauseMobMission(); + } + + private void btnSend_resumeWP(object sender, RoutedEventArgs e) + { + nad.NADResumeMobMission(); + } + + private void btnSend_stopWP(object sender, RoutedEventArgs e) + { + nad.NADStopMobMission(); + } + + private void btnSend_delWP(object sender, RoutedEventArgs e) + { + nad.NADDelPos(); + } + + private void btnSend_startHP(object sender, RoutedEventArgs e) + { + nad.NADSearchAtPos(SetLatitudeHP.Text, SetLongitudeHP.Text, SetAltitudeHP.Text, SetRadiusHP.Text); + } + + private void btnSend_pauseHP(object sender, RoutedEventArgs e) + { + nad.NADPauseSearchAt(); + } + + private void btnSend_resumeHP(object sender, RoutedEventArgs e) + { + nad.NADResumeSearchAt(); + } + + private void btnSend_stopHP(object sender, RoutedEventArgs e) + { + nad.NADStopSearchAt(); + } + + private void btnSend_startFM(object sender, RoutedEventArgs e) + { + + latitude_f = double.Parse(SetLatitudeFM.Text, System.Globalization.CultureInfo.InvariantCulture); + longitude_f = double.Parse(SetLongitudeFM.Text, System.Globalization.CultureInfo.InvariantCulture); + System.Diagnostics.Trace.WriteLine("Longitude init " + longitude_f); + System.Diagnostics.Trace.WriteLine("Latitude init " + latitude_f); + nad.NADFollowShip(SetLatitudeFM.Text, SetLongitudeFM.Text, SetAltitudeFM.Text); + initializeTimer(); + } + + private void btnSend_stopFM(object sender, RoutedEventArgs e) + { + timer.Stop(); + nad.NADStopFollowShip(); + } + + + private void showmsg() + { + string p = nad.GetMSG(); + System.Diagnostics.Trace.WriteLine("Message from client " + p); + if (string.IsNullOrEmpty(p)) + { + p = "Nessun messaggio"; + } + System.Diagnostics.Trace.WriteLine("Message from client " + p); + + + Dispatcher.BeginInvoke(new Action(() => + { + //rtbx.AppendText(p + "\r\n"); + MSGTextBox.Text = p; + })); + + + } + } +} \ No newline at end of file diff --git a/dummy_drone/dummy_drone.csproj b/dummy_drone/dummy_drone.csproj new file mode 100644 index 0000000..4a25a20 --- /dev/null +++ b/dummy_drone/dummy_drone.csproj @@ -0,0 +1,25 @@ + + + + WinExe + net5.0-windows + true + + + + + + + + + + + + + + + bin\Debug\net5.0-windows\NadLibrary.dll + + + +