diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..98f23bd Binary files /dev/null and b/.DS_Store differ diff --git a/dummy_drone.sln b/dummy_drone.sln new file mode 100644 index 0000000..b405f37 --- /dev/null +++ b/dummy_drone.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31702.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dummy_drone", "dummy_drone\dummy_drone.csproj", "{3A1775D1-D2DC-464A-88D0-01B93C142357}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A1775D1-D2DC-464A-88D0-01B93C142357}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A1775D1-D2DC-464A-88D0-01B93C142357}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A1775D1-D2DC-464A-88D0-01B93C142357}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A1775D1-D2DC-464A-88D0-01B93C142357}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {880CC511-2400-485E-B5B5-502D09454F75} + EndGlobalSection +EndGlobal diff --git a/dummy_drone/.DS_Store b/dummy_drone/.DS_Store new file mode 100644 index 0000000..a8416b6 Binary files /dev/null and b/dummy_drone/.DS_Store differ diff --git a/dummy_drone/App.xaml b/dummy_drone/App.xaml new file mode 100644 index 0000000..1abe857 --- /dev/null +++ b/dummy_drone/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + 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 + + + +