// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //get the ip and port configuration string ip = Configuration["Ip"]; // get the ip from appsettings.json int port = Int32.Parse(Configuration["Port"]); // get the port from appsettings.json //Add the TelnetClient ITelnetClient tlc = new MyTelnetClient(ip, port); services.AddSingleton <ITelnetClient>(tlc); //Add singleton FlightGearClient IFlightGearClient fgc = new FlightGearClient(tlc); services.AddSingleton <IFlightGearClient>(fgc); //Strting going over the blocking queue fgc.Start(); }
/// <summary> /// this is the constructor of this class. /// </summary> public Joystick() { InitializeComponent(); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; string ip = (string)Settings.Default["IP"]; int portClient = Int32.Parse((string)Settings.Default["PortClient"]); // create the telnetClient with defult ip and port. MyTelnetClient mtc = new MyTelnetClient(); //mtc.connect(ip, portClient); // the model for this viewModel MyJoystickModel joystickModel = new MyJoystickModel(mtc); Connector connector = Connector.getInstance(); // give this joystickModel to the connector connector.setJoystickModel(joystickModel); // give this telnetClient to the connector connector.setClient(mtc); joystickViewModel = new JoystickViewModel(joystickModel); this.DataContext = joystickViewModel; }
public View(string port, string ip) { int tempPort; // Connect settings - client and server. telnetClient = new MyTelnetClient(); Application.Current.Properties["model"] = new MySimulatorModel(telnetClient); mySimulator = (MySimulatorModel)Application.Current.Properties["model"]; // Define all controls in the view window. joystickViewModel = new JoystickViewModel(mySimulator); dashboardViewModel = new DashboardViewModel(mySimulator); errorViewModel = new ErrorViewModel(mySimulator); mapViewModel = new MapViewModel(mySimulator); // Checks the reseve port. try { tempPort = int.Parse(port); } catch { Console.WriteLine("Error - worng formt of port"); tempPort = 0; } if (mySimulator.connect(ip, tempPort) == 0) { mySimulator.start(); } InitializeComponent(); Joystick.DataContext = joystickViewModel; dash.DataContext = dashboardViewModel; error.DataContext = errorViewModel; map.DataContext = mapViewModel; disconnect.DataContext = mapViewModel; }
public screenshotController(IConfiguration configuration, MyTelnetClient telenet) { this.configuration = configuration; this.telenet = telenet; }
public commandController(MyTelnetClient telenet) { this.telenet = telenet; }