diff --git a/.idea/.idea.Tello Drone/.idea/contentModel.xml b/.idea/.idea.Tello Drone/.idea/contentModel.xml
index cf6a0f4..aab3155 100644
--- a/.idea/.idea.Tello Drone/.idea/contentModel.xml
+++ b/.idea/.idea.Tello Drone/.idea/contentModel.xml
@@ -26,11 +26,19 @@
+
+
-
+
+
+
+
+
+
+
@@ -40,6 +48,7 @@
+
diff --git a/Tello Drone/ConsoleClient.cs b/Tello Drone/ConsoleClient.cs
index 06491f0..fb82d98 100644
--- a/Tello Drone/ConsoleClient.cs
+++ b/Tello Drone/ConsoleClient.cs
@@ -5,14 +5,15 @@ namespace Tello_Drone
public class ConsoleClient
{
- private readonly IMissions _missions;
+ private readonly IMissionList _missionList;
private readonly IConsoleLogger _consoleLogger;
+ private readonly IMissionCommander _missionCommander;
- public ConsoleClient(IMissions missions, IConsoleLogger consoleLogger)
+ public ConsoleClient(IMissionList missionList, IConsoleLogger consoleLogger, IMissionCommander missionCommander)
{
- _missions = missions;
+ _missionCommander = missionCommander;
+ _missionList = missionList;
_consoleLogger = consoleLogger;
- _missions.SetUpDrone();
}
public void Run()
@@ -20,27 +21,17 @@ namespace Tello_Drone
while (true)
{
_consoleLogger.Log("Choose a mission to run.");
- _consoleLogger.Log("1: Mission 1");
- _consoleLogger.Log("2: Mission 2");
- _consoleLogger.Log("3: Mission 3");
-
- var userInput = Console.ReadLine();
-
- switch (userInput)
+ for (int x = 0; x < _missionList.GetMissionList().Count; x++)
{
- case "1":
- _missions.RunMission1();
- break;
- case "2":
- _missions.RunMission2();
- break;
- case "exit":
- return;
- default:
- _consoleLogger.Log("Not A Valid Entry...Try Again");
- Run();
- break;
+ var currentMission = _missionList.GetMissionList()[x];
+ _consoleLogger.Log($"{x+1}: {currentMission.Item1}");
}
+
+
+ var userInput = Convert.ToInt16(Console.ReadLine());
+ _missionCommander.RunMission(_missionList.GetMissionList()[userInput-1].Item2);
+
+
}
}
diff --git a/Tello Drone/CoreModule.cs b/Tello Drone/CoreModule.cs
index 4877330..3882ffd 100644
--- a/Tello Drone/CoreModule.cs
+++ b/Tello Drone/CoreModule.cs
@@ -8,8 +8,11 @@ namespace Tello_Drone
{
container.Register(Reuse.Singleton);
container.Register(Reuse.Singleton);
- container.Register(Reuse.Singleton);
+ //container.Register(Reuse.Singleton);
+ container.Register(Reuse.Singleton);
+ container.Register(Reuse.Singleton);
container.Register(Reuse.Singleton);
+ container.Register(Reuse.Singleton);
}
public void Resolve(IContainer container)
diff --git a/Tello Drone/DroneComands.cs b/Tello Drone/DroneComands.cs
index 5686a01..92203ec 100644
--- a/Tello Drone/DroneComands.cs
+++ b/Tello Drone/DroneComands.cs
@@ -1,5 +1,3 @@
-
-
namespace Tello_Drone
{
public class DroneComands : IDroneCommands
diff --git a/Tello Drone/IMissionCommander.cs b/Tello Drone/IMissionCommander.cs
new file mode 100644
index 0000000..3318ddd
--- /dev/null
+++ b/Tello Drone/IMissionCommander.cs
@@ -0,0 +1,7 @@
+namespace Tello_Drone
+{
+ public interface IMissionCommander
+ {
+ void RunMission(IMissions missions);
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/IMissionList.cs b/Tello Drone/IMissionList.cs
new file mode 100644
index 0000000..b183301
--- /dev/null
+++ b/Tello Drone/IMissionList.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Tello_Drone
+{
+ public interface IMissionList
+ {
+ List<(string, IMissions)> GetMissionList();
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/IMissions.cs b/Tello Drone/IMissions.cs
index cc738da..0a35231 100644
--- a/Tello Drone/IMissions.cs
+++ b/Tello Drone/IMissions.cs
@@ -2,8 +2,6 @@ namespace Tello_Drone
{
public interface IMissions
{
- void SetUpDrone();
- void RunMission1();
- void RunMission2();
+ void Run(Drone drone);
}
}
\ No newline at end of file
diff --git a/Tello Drone/MissionCommander.cs b/Tello Drone/MissionCommander.cs
new file mode 100644
index 0000000..02275bc
--- /dev/null
+++ b/Tello Drone/MissionCommander.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Linq;
+using System.Security.Authentication.ExtendedProtection;
+
+namespace Tello_Drone
+{
+ public class MissionCommander : IMissionCommander
+ {
+ private readonly Drone _drone;
+
+ public MissionCommander(IDroneFactory droneFactory)
+ {
+ _drone = droneFactory.CreateDrone;
+ }
+
+ public void RunMission(IMissions mission)
+ {
+ SetUpDrone(3);
+ mission.Run(_drone);
+ TearDownDrone();
+ }
+
+ private void SetUpDrone(int retryCount)
+ {
+ var inCommandMode = false;
+ while (inCommandMode != true && retryCount > 0)
+ {
+ inCommandMode = _drone.Command();
+ retryCount--;
+ }
+ _drone.TakeOff();
+ }
+
+ private void TearDownDrone()
+ {
+ _drone.Land();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/MissionList.cs b/Tello Drone/MissionList.cs
new file mode 100644
index 0000000..871f5ac
--- /dev/null
+++ b/Tello Drone/MissionList.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Dynamic;
+using System.Linq;
+using System.Reflection;
+using FastExpressionCompiler.LightExpression;
+using ImTools;
+using Tello_Drone.Missions;
+
+namespace Tello_Drone
+{
+ public class MissionList : IMissionList
+ {
+ public List<(string, IMissions)> GetMissionList( )
+ {
+ var list = new List<(string, IMissions)>();
+
+ list.Add(("Mission 1", new Mission1()));
+ list.Add(("Mission 2", new Mission2()));
+ list.Add(("Mission 3", new Mission3()));
+
+ return list;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/Missions.cs b/Tello Drone/Missions.cs
deleted file mode 100644
index ef61a48..0000000
--- a/Tello Drone/Missions.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-namespace Tello_Drone
-{
- public class Missions : IMissions
- {
- private Drone _drone;
- private int _setupRetry;
-
-
- public Missions( IDroneFactory droneFactory)
- {
- _drone = droneFactory.CreateDrone;
- }
-
- public void SetUpDrone()
- {
- var inCommandMode = false;
- while (inCommandMode != true && _setupRetry < 3)
- {
- inCommandMode = _drone.Command();
- _setupRetry++;
- }
- }
- public void RunMission1()
- {
- MissionSetup();
- _drone.Up(20);
- _drone.Down(20);
- MissionTeardown();
- }
-
- public void RunMission2()
- {
- MissionSetup();
- _drone.BackFlip();
- _drone.FrontFlip();
- _drone.Reverse(300);
- _drone.Forward(66);
- _drone.Up(20);
- MissionTeardown();
- }
-
- private void MissionSetup()
- {
-
-
- if (!_drone.InitialTakeOff())
- _drone.InitialTakeOff();
- }
-
- private void MissionTeardown()
- {
- _drone.Land();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Tello Drone/Missions/Mission1.cs b/Tello Drone/Missions/Mission1.cs
new file mode 100644
index 0000000..e3c5222
--- /dev/null
+++ b/Tello Drone/Missions/Mission1.cs
@@ -0,0 +1,12 @@
+namespace Tello_Drone.Missions
+{
+ public class Mission1 : IMissions
+ {
+
+ public void Run(Drone drone)
+ {
+ drone.Up(20);
+ drone.Land();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/Missions/Mission2.cs b/Tello Drone/Missions/Mission2.cs
new file mode 100644
index 0000000..b7c783d
--- /dev/null
+++ b/Tello Drone/Missions/Mission2.cs
@@ -0,0 +1,12 @@
+namespace Tello_Drone.Missions
+{
+ [TestNameAttributes("Mission 2")]
+ public class Mission2: IMissions
+ {
+ public void Run(Drone drone)
+ {
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Tello Drone/Missions/Mission3.cs b/Tello Drone/Missions/Mission3.cs
new file mode 100644
index 0000000..24462a3
--- /dev/null
+++ b/Tello Drone/Missions/Mission3.cs
@@ -0,0 +1,14 @@
+namespace Tello_Drone.Missions
+{
+ public class Mission3 : IMissions
+ {
+ public void Run(Drone drone)
+ {
+ drone.Up(20);
+ drone.FrontFlip();
+ drone.BackFlip();
+ drone.Left(20);
+ drone.Right(20);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tello Drone/Program.cs b/Tello Drone/Program.cs
index 946dc80..bc91d43 100644
--- a/Tello Drone/Program.cs
+++ b/Tello Drone/Program.cs
@@ -5,9 +5,10 @@
static void Main(string[] args)
{
var bootstrapper = BootStrapper.BootstrapSystem(new CoreModule());
- var missions = bootstrapper.Resolve();
+ var missionList = bootstrapper.Resolve();
+ var missionCommander = bootstrapper.Resolve();
var consoleLogger = bootstrapper.Resolve();
- var consoleClient = new ConsoleClient(missions, consoleLogger);
+ var consoleClient = new ConsoleClient(missionList, consoleLogger, missionCommander);
consoleClient.Run();
}
}
diff --git a/Tello Drone/TestNameAttributes.cs b/Tello Drone/TestNameAttributes.cs
new file mode 100644
index 0000000..94b1173
--- /dev/null
+++ b/Tello Drone/TestNameAttributes.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Dynamic;
+using System.Security.Cryptography;
+
+namespace Tello_Drone
+{
+ [AttributeUsage(AttributeTargets.Class)]
+ public class TestNameAttributes : Attribute
+ {
+ public TestNameAttributes(string name)
+ {
+ Name = name;
+ }
+
+ public string Name { get; }
+ }
+}
\ No newline at end of file