public FlightSimulatorModel(ITelnetClient telnetC) { initializeModel(); telnetClient = telnetC; status = "Disconnected"; initializeDashboard(); }
/// <summary> /// Initializes a new instance of the <see cref="DummyServerTCPHandler"/> class. /// </summary> /// <param name="client">The client.</param> private DummyServerTCPHandler(ITelnetClient client) { this.client = new DummyTelnetClient(); this.threadsList = new List <Thread>(); this.parsingQueue = new Queue <string>(); this.initializeParametersMap(); }
/// <summary> /// connecting the telnet client to a server. /// </summary> /// <param name="ip">the ip address of the server.</param> /// <param name="port">the port number of the server.</param> public void connect(string ip, int port) { StrException = "trying to connect...\npleast wait"; bool tryToConnect = false; for (int i = 0; i < 2; i++) { try { this.stopRunning = false; this.telnetClient.connect(ip, port); StrException = "connected to the server succesfuly"; this.start(); tryToConnect = true; break; } catch { StrException = "trying to connect...\npleast wait"; Console.WriteLine("can't connect to the serverXXX"); } } if (!tryToConnect) { StrException = "can't connect to the server"; stopRunning = true; this.telnetClient = new MyTelnetClient(); } }
/** * FlyModel constructor update variables. * get ITelnetClient. */ public FlyModel(ITelnetClient telClient) { //Read value valueMap = new Dictionary <string, FlyData>(); valueMap.Add("longitude", new FlyData("/position/longitude-deg", 34.888781)); valueMap.Add("latitude", new FlyData("/position/latitude-deg", 32.002644)); valueMap.Add("indicatedSpeed", new FlyData("/instrumentation/airspeed-indicator/indicated-speed-kt", 0.0)); valueMap.Add("gpsAltitude", new FlyData("/instrumentation/gps/indicated-altitude-ft", 0.0)); valueMap.Add("internalRoll", new FlyData("/instrumentation/attitude-indicator/internal-roll-deg", 0.0)); valueMap.Add("internalPitch", new FlyData("/instrumentation/attitude-indicator/internal-pitch-deg", 0.0)); valueMap.Add("altimeterAltitude", new FlyData("/instrumentation/altimeter/indicated-altitude-ft", 0.0)); valueMap.Add("headingDeg", new FlyData("/instrumentation/heading-indicator/indicated-heading-deg", 0.0)); valueMap.Add("groundSpeed", new FlyData("/instrumentation/gps/indicated-ground-speed-kt", 0.0)); valueMap.Add("verticalSpeed", new FlyData("/instrumentation/gps/indicated-vertical-speed", 0.0)); // Write value valueMap.Add("throttle", new FlyData("/controls/engines/current-engine/throttle", 0.0)); valueMap.Add("aileron", new FlyData("/controls/flight/aileron", 0.0)); valueMap.Add("elevator", new FlyData("/controls/flight/elevator", 0.0)); valueMap.Add("rudder", new FlyData("/controls/flight/rudder", 0.0)); this.dashBoardError = new List <string>(); this.stop = false; this.telnetClient = telClient; sendToSimQueue = new Queue <string>(); this.generalErrList = new List <string>(); }
/// <summary> /// disconnecting from the server. /// </summary> public void disconnect() { this.stopRunning = true; this.telnetClient.disconnect(); this.telnetClient = new MyTelnetClient(); StrException = "disconnected"; }
//constroctor. public CommandManager(ITelnetClient telnetClient, IConfiguration configuration) { this.telnetClient = telnetClient; this.configuration = configuration; this.queue = new BlockingCollection <AsyncCommand>(); stop = true; Start(); }
// Initialize the model class private void initialize(ITelnetClient client) { this.client = client; this.playing = false; this.PlaybackSpeed = 1; this.Time = DateTime.MinValue; this.currentLine = 0; }
/// <summary> /// a static functoin that creates an object of FGModelImp /// </summary> /// <param name="telnetClient">telnet client to initialize</param> public static void CreateModel(ITelnetClient telnetClient) { if (fgModel != null) { throw new Exception("FGModel was created"); } fgModel = new FGModelImp(telnetClient); }
public void createClient(string ip, int port) { ITelnetClient telnetClient = new MyTelnetClient(); this.telnetClient = telnetClient; telnetClient.connect(ip, port); }
// CTOR public ConnectionManager(CommandManager commandManager) { this.ip = commandManager.IP; this.port = commandManager.PORT; _queue = new BlockingCollection <AsyncCommand>(); this.telnetClientHandler = new MyTelnetClient(); this.isConnected = false; this.Start(); }
public void Run(string ip, int port) { // Set ip and port. this.telnetClient = new Telnet(ip, port); // Connect to the simulator. this.Connect(); // Set time out to 10 seconds. this.telnetClient.SetTimeOutRead(10000); }
//A setter for telnet client. public IFlightSimulatorModel SetTelnetClient(ITelnetClient telnet) { //set it only once because this is a singleton. if (!isTelnetSet) { tc = telnet; } return(this); }
/// <summary> /// connecting to the simulator (client and server) and starting to read from the server /// </summary> public void Connect() { ISettingsModel settings = ApplicationSettingsModel.Instance; ITelnetServer server = DataReaderServer.Instance; ITelnetClient client = FlightTelnetClient.Instance; server.Connect(settings.FlightServerIP, settings.FlightInfoPort); client.connect(settings.FlightServerIP, settings.FlightCommandPort); FlightBoardModel.Instance.ReadFromServer(); }
/// <summary> /// this is the constructor of this class. /// </summary> /// <param name="_planeLocations"></param> /// <param name="_plotter"></param> public FlightBoardModel(ObservableDataSource <Point> _planeLocations, ChartPlotter _plotter) { planeLocations = _planeLocations; plotter = _plotter; ts = new TelnetServer(planeLocations, plotter); mtc = new MyTelnetClient(); ip = (string)Settings.Default["IP"]; clientPort = Int32.Parse((string)Settings.Default["PortClient"]); serverPort = Int32.Parse((string)Settings.Default["PortServer"]); }
public ConnectionViewModel(ITelnetClient model) { IP = System.Configuration.ConfigurationManager.AppSettings["ip"]; Port = System.Configuration.ConfigurationManager.AppSettings["port"]; this.model = model; model.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { NotifyPropertyChanged("Vm" + e.PropertyName); }; }
public CommandManager(ITelnetClient telnetClient) { this.telnetClient = telnetClient; try { telnetClient.connect("127.0.0.1", 5402); } catch { } }
public static void CheckTelnetClient(ITelnetClient telnet) { if (telnet == null) { throw new NullReferenceException(); } if (!telnet.Connected) { throw new System.Net.Sockets.SocketException((int)System.Net.Sockets.SocketError.NotConnected); } }
// MyMapModel Ctor public MyMapModel(ITelnetClient tc) { this.tc = tc; Latitude = System.Configuration.ConfigurationManager.AppSettings["startLatitude"]; Longitude = System.Configuration.ConfigurationManager.AppSettings["startLongitude"]; LatitudeError = ""; LongitudeError = ""; this.oldLatitude = Latitude; this.oldLongtitude = Longitude; StartReadingFlightData(); }
public static void SendTime(ITelnetClient telnet, TimeInfo timeInfo) { TelnetException.CheckTelnetClient(telnet); var minute = Math.Ceiling(timeInfo.Minute * 16.666666666666666666666666666667); //16.66666666667 ≒ 50.0f ÷ 3.0f var stTime = (timeInfo.Day - 1) * 24000 + (timeInfo.Hour * 1000) + (int)minute; //(Day - 1) * 24000 + (Hour * 1000) + (Minute * 16.666666666666666666666666666667) telnet.WriteLine("st " + stTime.ToString()); }
public MyFlight(ITelnetClient tc) { this.myTelnetClient = tc; stop = false; timer = new System.Timers.Timer(10000); timer.Elapsed += HandleTimer; timer.AutoReset = false; timer.Enabled = true; InitializeObjects(); }
public static TimeInfo GetTimeFromTelnet(ITelnetClient telnet) { TelnetException.CheckTelnetClient(telnet); telnet.DestructionEvent = true; telnet.WriteLine("gt"); System.Threading.Thread.Sleep(200); var log = telnet.Read().TrimEnd('\0'); telnet.DestructionEvent = false; return(ConvertTime(log)); }
private string getValuesFromServer(string ip, int port, List <string> vars) { IModel model = MyModel.Instance; model.connectClient(ip, port); ICollection <string> elemetsWithGet = addGetAndNewLineToStrings(vars); ITelnetClient c = model.getClient(); string strings = c.read(elemetsWithGet); model.disconnectClient(); return(strings); }
public MyFlightGearModel(ITelnetClient telnetClient) { this.telnetClient = telnetClient; this.isStopped = true; this.isPaused = false; this.simulatorspeed = 1.00; createProperties(); SetUpGraphOfCurrent(); SetUpGraphOfCorrelated(); SetUpGraphOfRegression(); this.currerntChoice = null; this.correlatedChoice = null; this.assembly = null; }
public void addClient(Tuple <String, int> key) { mutex.WaitOne(); try { ITelnetClient client = clientsFactory.New(); client.Connect(key.Item1, key.Item2); clients[key] = new ManagableClient(client, Timeout); } finally { mutex.ReleaseMutex(); } }
/// <summary> /// this function disconnect the socket. /// </summary> private void disconnectSockets() { Connector connector = Connector.getInstance(); ITelnetClient tc = connector.getClient(); TelnetServer ts = connector.getServer(); if (tc != null) { tc.disconnect(); } if (ts != null) { ts.closeServer(); } }
public void setValue(ITelnetClient myTelnetClient, string property, double value) { ITelnetClient telnetClient = myTelnetClient; string set = null; if (property.Equals("throttle")) { set = "set /controls/engines/current-engine/" + property + " " + value + "\r\n"; } else { set = "set /controls/flight/" + property + " " + value + "\r\n"; } telnetClient.write(set); }
//Connection to server. public void Connect(string ip, int port) { client = new MyTelnetClient(); try { client.Connect(ip, port); MessageInd = true; Message = "Connected to server."; Connected = true; } catch (Exception) { MessageInd = true; Connected = false; Message = "Unable to connect to server."; } }
// Constructor public MyAirplaneModel() { this.client = new MyTelnetClient(); this.stop = false; this.simVars = this.CreateSimVarsArr(); this.commands = new Queue <string>(); this.syncLock = new object(); this.stopWatch = new Stopwatch(); this.timer = new DispatcherTimer(); // Set the timer to perform the function repeatedly within 2 seconds. this.timer.Interval = TimeSpan.FromSeconds(2); this.timer.Tick += TimerTick; // Default IP and port. Ip = ConfigurationManager.AppSettings["ip"]; Port = ConfigurationManager.AppSettings["port"]; }
public static List <PlayerInfo> SetPlayerInfo(ITelnetClient telnet) { TelnetException.CheckTelnetClient(telnet); telnet.DestructionEvent = true; var players = new List <PlayerInfo>(); telnet.WriteLine("lp"); System.Threading.Thread.Sleep(200); string log = telnet.Read().TrimEnd('\0'); telnet.DestructionEvent = false; players.Add(log); return(players); }
public string checkSet(ITelnetClient myTelnetClient, string property, double value) { ITelnetClient telnetClient = myTelnetClient; string get = null; if (property.Equals("throttle")) { get = "get /controls/engines/current-engine/" + property + "\r\n"; } else { get = "get /controls/flight/" + property + "\r\n"; } telnetClient.write(get); string retValue = telnetClient.read(); Console.WriteLine(retValue); string s; double newRet = Convert.ToDouble(retValue); if (retValue.ToString().Length > 7) { s = retValue.ToString().Substring(0, 7); newRet = Convert.ToDouble(s); } double newVal = value; if (value.ToString().Length > 7) { s = value.ToString().Substring(0, 7); newVal = Convert.ToDouble(s); } if (newRet == newVal) { return("Ok"); } else { return("NotOk"); } }