Пример #1
0
    public static void Start(bool consoleToGUI = true, dynamic consoleBoxGUI = null, IProgress <string> _progress = null)
    {
        progress = _progress;
        // Redirect Console.WriteLine to GUI.
        if (consoleToGUI && consoleBoxGUI != null)
        {
            Console.SetOut(new KSPScripts.App.GUIConsoleWriter(consoleBoxGUI));
        }

        conn = Utilities.Connect("Horizon");
        if (conn == null)
        {
            progress.Report("Couldn't connect to the kRPC server. Exiting...");
            return;
        }

        // Getting variables and streams
        spaceCenter = conn.SpaceCenter();
        vessel      = spaceCenter.ActiveVessel;
        // Use surface reference frame as we are still on Kerbin
        flight = vessel.Flight(vessel.SurfaceReferenceFrame);
        orbitBodyReferenceFrame = vessel.Orbit.Body.ReferenceFrame;

        // Setting up streams here so that it will be easier to refer to them later on.
        positionStream          = conn.AddStream(() => vessel.Position(orbitBodyReferenceFrame));
        solidFuelStream         = conn.AddStream(() => vessel.Resources.Amount("SolidFuel"));
        meanAltitudeStream      = conn.AddStream(() => flight.MeanAltitude);
        apoapsisAltitudeStream  = conn.AddStream(() => vessel.Orbit.ApoapsisAltitude);
        periapsisAltitudeStream = conn.AddStream(() => vessel.Orbit.PeriapsisAltitude);
        surfaceAltitudeStream   = conn.AddStream(() => flight.SurfaceAltitude);
        verticalSpeedStream     = conn.AddStream(() => vessel.Flight(orbitBodyReferenceFrame).VerticalSpeed);

        // Start landing.
        Land();
    }
Пример #2
0
    // TODO: Rewrite whole script to use adaptive throttling.
    /// <summary>
    ///
    /// </summary>
    public static void Start(double orbitApoapsisAlt = 72000, double orbitPeriapsisAlt = 72000, bool consoleToGUI = true, dynamic consoleBoxGUI = null, IProgress <string> _progress = null)
    {
        OrbitApoapsisAlt  = orbitApoapsisAlt;
        OrbitPeriapsisAlt = orbitPeriapsisAlt;
        progress          = _progress;

        // Redirect Console.WriteLine to GUI.
        if (consoleToGUI && consoleBoxGUI != null)
        {
            Console.SetOut(new KSPScripts.App.GUIConsoleWriter(consoleBoxGUI));
        }
        // Check if given options are appropriate.
        if (OrbitApoapsisAlt < 70000 || OrbitPeriapsisAlt < 70000)
        {
            progress.Report("Given orbit altitudes are incorrect, as they are below 70000 meters.");
            return;
        }

        conn = Utilities.Connect("Serpent");
        if (conn == null)
        {
            progress.Report("Couldn't connect to the kRPC server. Exiting...");
            return;
        }

        // Getting variables and streams
        spaceCenter = conn.SpaceCenter();
        vessel      = spaceCenter.ActiveVessel;
        // Use surface reference frame as we are still on Kerbin
        flight = vessel.Flight(vessel.SurfaceReferenceFrame);
        orbitBodyReferenceFrame = vessel.Orbit.Body.ReferenceFrame;

        // Setting up streams here so that it will be easier to refer to them later on.
        positionStream          = conn.AddStream(() => vessel.Position(orbitBodyReferenceFrame));
        solidFuelStream         = conn.AddStream(() => vessel.Resources.Amount("SolidFuel"));
        meanAltitudeStream      = conn.AddStream(() => flight.MeanAltitude);
        apoapsisAltitudeStream  = conn.AddStream(() => vessel.Orbit.ApoapsisAltitude);
        periapsisAltitudeStream = conn.AddStream(() => vessel.Orbit.PeriapsisAltitude);
        surfaceAltitudeStream   = conn.AddStream(() => flight.SurfaceAltitude);
        verticalSpeedStream     = conn.AddStream(() => vessel.Flight(orbitBodyReferenceFrame).VerticalSpeed);

        // Setup events
        // When going down vertically call landing stage.
        var        verticalSpeedCall = Connection.GetCall(() => vessel.Flight(orbitBodyReferenceFrame).VerticalSpeed);
        Expression expr = Expression.LessThan(conn, Expression.Call(conn, verticalSpeedCall), Expression.ConstantDouble(conn, 0));

        landingFailsafeEvent = conn.KRPC().AddEvent(expr);
        landingFailsafeEvent.AddCallback(LandingStageLoop);

        // Start sequence
        Utilities.Countdown(5, progress);
        LaunchStageLoop();
        SuborbitalStageLoop();
        progress.Report("Launch stage concluded.");
    }
Пример #3
0
 public VesselController(KRPC.Client.Services.SpaceCenter.Service spaceCenter, Flight flight, Vessel vessel)
 {
     Flight              = flight;
     Vessel              = vessel;
     Orbit               = Vessel.Orbit;
     SpaceCenter         = spaceCenter;
     refFrame            = Orbit.Body.ReferenceFrame;
     nonRotatingRefFrame = Orbit.Body.NonRotatingReferenceFrame;
     Body         = Orbit.Body;
     BodyPosition = tupleToVec3(Body.Position(refFrame));
     thrustLimit  = 1.0f;
 }
Пример #4
0
        public MissionViewModel(Mission mission)
        {
            this.mission = mission;
            var ksc = mission.SpaceCenter;

            this.krpc          = mission.Connection.KRPC();
            this.spaceCenter   = ksc;
            this.universalTime = mission.Streams.UseStream <double>(() => ksc.UT);
            this.universalTime.UnderlyingStream.AddCallback(this.Tick);
            this.universalTime.UnderlyingStream.Rate = 1;
            this.universalTime.UnderlyingStream.Start(false);

            this.scene = this.mission.Streams.UseStream <GameScene>(() => krpc.CurrentGameScene);
            this.scene.UnderlyingStream.AddCallback(this.SceneChanged);
            this.scene.UnderlyingStream.Start(false);
            this.scene.UnderlyingStream.Rate = 2;
        }
Пример #5
0
        private void addStream(DataType type)
        {
            // Some much used variables
            spaceCenter = connection.SpaceCenter();

            vessel          = connection.SpaceCenter().ActiveVessel;
            control         = connection.SpaceCenter().ActiveVessel.Control;
            orbit           = connection.SpaceCenter().ActiveVessel.Orbit;
            resources       = connection.SpaceCenter().ActiveVessel.Resources;
            resources_stage = connection.SpaceCenter().ActiveVessel.ResourcesInDecoupleStage(stage, false);

            inertialRefFrame = orbit.Body.NonRotatingReferenceFrame;
            surfaceRefFrame  = vessel.SurfaceReferenceFrame;
            mapRefFrame      = orbit.Body.ReferenceFrame;

            inertFlight = connection.SpaceCenter().ActiveVessel.Flight(inertialRefFrame);
            flight      = connection.SpaceCenter().ActiveVessel.Flight(surfaceRefFrame);
            mapFlight   = connection.SpaceCenter().ActiveVessel.Flight(mapRefFrame);


            Kstream stream;

            switch (type)
            {
            ///// BODY DATA /////
            case DataType.body_radius:
                stream = new floatStream(connection.AddStream(() => orbit.Body.EquatorialRadius));
                break;

            case DataType.body_gravityParameter:
                stream = new floatStream(connection.AddStream(() => orbit.Body.GravitationalParameter));
                break;

            case DataType.body_rotSpeed:
                stream = new floatStream(connection.AddStream(() => orbit.Body.RotationalSpeed));
                break;

            case DataType.body_name:
                stream = new stringStream(connection.AddStream(() => orbit.Body.Name));
                break;

            case DataType.body_mass:
                stream = new floatStream(connection.AddStream(() => orbit.Body.Mass));
                break;

            case DataType.body_rotPeriod:
                stream = new floatStream(connection.AddStream(() => orbit.Body.RotationalPeriod));
                break;

            case DataType.body_nonRotatingReferenceFrame:
                stream = new referenceFrameStream(connection.AddStream(() => orbit.Body.NonRotatingReferenceFrame));
                break;

            ///// CONTROL DATA /////

            case DataType.control_SAS:
                stream = new boolStream(connection.AddStream(() => control.SAS));
                break;

            case DataType.control_SASmode:
                stream = new sasModeStream(connection.AddStream(() => control.SASMode));
                break;

            case DataType.control_RCS:
                stream = new boolStream(connection.AddStream(() => control.RCS));
                break;

            case DataType.control_gear:
                stream = new boolStream(connection.AddStream(() => control.Gear));
                break;

            case DataType.control_brakes:
                stream = new boolStream(connection.AddStream(() => control.Brakes));
                break;

            case DataType.control_lights:
                stream = new boolStream(connection.AddStream(() => control.Lights));
                break;

            case DataType.control_abort:
                stream = new boolStream(connection.AddStream(() => control.Abort));
                break;

            case DataType.control_actionGroup0:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(0)));
                break;

            case DataType.control_actionGroup1:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(1)));
                break;

            case DataType.control_actionGroup2:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(2)));
                break;

            case DataType.control_actionGroup3:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(3)));
                break;

            case DataType.control_actionGroup4:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(4)));
                break;

            case DataType.control_actionGroup5:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(5)));
                break;

            case DataType.control_actionGroup6:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(6)));
                break;

            case DataType.control_actionGroup7:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(7)));
                break;

            case DataType.control_actionGroup8:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(8)));
                break;

            case DataType.control_actionGroup9:
                stream = new boolStream(connection.AddStream(() => control.GetActionGroup(9)));
                break;

            case DataType.control_throttle:
                stream = new floatStream(connection.AddStream(() => control.Throttle));
                break;

            case DataType.control_currentStage:
                stream = new intStream(connection.AddStream(() => control.CurrentStage));
                break;

            case DataType.control_nodes:
                stream = new IListNodeStream(connection.AddStream(() => control.Nodes));
                break;

            ///// FLIGHT DATA /////

            case DataType.flight_gForce:
                stream = new floatStream(connection.AddStream(() => flight.GForce));
                break;

            case DataType.flight_angleOfAttack:
                stream = new floatStream(connection.AddStream(() => flight.AngleOfAttack));
                break;

            case DataType.flight_meanAltitude:
                stream = new doubleStream(connection.AddStream(() => flight.MeanAltitude));
                break;

            case DataType.flight_surfaceAltitude:
                stream = new doubleStream(connection.AddStream(() => flight.SurfaceAltitude));
                break;

            case DataType.flight_bedrockAltitude:
                stream = new doubleStream(connection.AddStream(() => flight.BedrockAltitude));
                break;

            case DataType.flight_elevation:
                stream = new doubleStream(connection.AddStream(() => flight.Elevation));
                break;

            case DataType.flight_latitude:
                stream = new doubleStream(connection.AddStream(() => flight.Latitude));
                break;

            case DataType.flight_longitude:
                stream = new doubleStream(connection.AddStream(() => flight.Longitude));
                break;

            case DataType.flight_map_latitude:
                stream = new doubleStream(connection.AddStream(() => mapFlight.Latitude));
                break;

            case DataType.flight_map_longitude:
                stream = new doubleStream(connection.AddStream(() => mapFlight.Longitude));
                break;

            case DataType.flight_velocity:
                stream = new tuple3Stream(connection.AddStream(() => flight.Velocity));
                break;

            case DataType.flight_speed:
                stream = new doubleStream(connection.AddStream(() => flight.Speed));
                break;

            case DataType.flight_horizontalSpeed:
                stream = new doubleStream(connection.AddStream(() => flight.HorizontalSpeed));
                break;

            case DataType.flight_verticalSpeed:
                stream = new doubleStream(connection.AddStream(() => flight.VerticalSpeed));
                break;

            case DataType.flight_centerOfMass:
                stream = new tuple3Stream(connection.AddStream(() => flight.CenterOfMass));
                break;

            case DataType.flight_rotation:
                stream = new tuple4Stream(connection.AddStream(() => flight.Rotation));
                break;

            case DataType.flight_direction:
                stream = new tuple3Stream(connection.AddStream(() => flight.Direction));
                break;

            case DataType.flight_pitch:
                stream = new floatStream(connection.AddStream(() => flight.Pitch));
                break;

            case DataType.flight_heading:
                stream = new floatStream(connection.AddStream(() => flight.Heading));
                break;

            case DataType.flight_roll:
                stream = new floatStream(connection.AddStream(() => flight.Roll));
                break;

            case DataType.flight_atmosphereDensity:
                stream = new floatStream(connection.AddStream(() => flight.AtmosphereDensity));
                break;

            case DataType.flight_dynamicPressure:
                stream = new floatStream(connection.AddStream(() => flight.DynamicPressure));
                break;

            case DataType.flight_staticPressure:
                stream = new floatStream(connection.AddStream(() => flight.StaticPressure));
                break;

            case DataType.flight_prograde:
                stream = new tuple3Stream(connection.AddStream(() => flight.Prograde));
                break;

            case DataType.flight_retrograde:
                stream = new tuple3Stream(connection.AddStream(() => flight.Retrograde));
                break;

            case DataType.flight_radial:
                stream = new tuple3Stream(connection.AddStream(() => flight.Radial));
                break;

            case DataType.flight_antiRadial:
                stream = new tuple3Stream(connection.AddStream(() => flight.AntiRadial));
                break;

            case DataType.flight_normal:
                stream = new tuple3Stream(connection.AddStream(() => flight.Normal));
                break;

            case DataType.flight_antiNormal:
                stream = new tuple3Stream(connection.AddStream(() => flight.AntiNormal));
                break;


            ///// INERTIAL FLIGHT DATA /////

            case DataType.flight_inertial_roll:
                stream = new floatStream(connection.AddStream(() => inertFlight.Roll));
                break;

            case DataType.flight_inertial_pitch:
                stream = new floatStream(connection.AddStream(() => inertFlight.Pitch));
                break;

            case DataType.flight_inertial_yaw:
                stream = new floatStream(connection.AddStream(() => inertFlight.Heading));
                break;

            case DataType.flight_inertial_direction:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Direction));
                break;

            case DataType.flight_inertial_rotation:
                stream = new tuple4Stream(connection.AddStream(() => inertFlight.Rotation));
                break;

            case DataType.flight_inertial_velocity:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Velocity));
                break;

            case DataType.flight_inertial_prograde:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Prograde));
                break;

            case DataType.flight_inertial_retrograde:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Retrograde));
                break;

            case DataType.flight_inertial_radial:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Radial));
                break;

            case DataType.flight_inertial_antiRadial:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.AntiRadial));
                break;

            case DataType.flight_inertial_normal:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.Normal));
                break;

            case DataType.flight_inertial_antiNormal:
                stream = new tuple3Stream(connection.AddStream(() => inertFlight.AntiNormal));
                break;


            ///// ORBIT DATA /////

            case DataType.orbit_apoapsisAltitude:
                stream = new doubleStream(connection.AddStream(() => orbit.ApoapsisAltitude));
                break;

            case DataType.orbit_apoapsis:
                stream = new doubleStream(connection.AddStream(() => orbit.Apoapsis));
                break;

            case DataType.orbit_periapsisAltitude:
                stream = new doubleStream(connection.AddStream(() => orbit.PeriapsisAltitude));
                break;

            case DataType.orbit_periapsis:
                stream = new doubleStream(connection.AddStream(() => orbit.Periapsis));
                break;

            case DataType.orbit_radius:
                stream = new doubleStream(connection.AddStream(() => orbit.Radius));
                break;

            case DataType.orbit_speed:
                stream = new doubleStream(connection.AddStream(() => orbit.Speed));
                break;

            case DataType.orbit_celestialBody:
                stream = new celestialBodyStream(connection.AddStream(() => orbit.Body));
                break;

            case DataType.orbit_semiMajorAxis:
                stream = new doubleStream(connection.AddStream(() => orbit.SemiMajorAxis));
                break;

            case DataType.orbit_semiMinorAxis:
                stream = new doubleStream(connection.AddStream(() => orbit.SemiMinorAxis));
                break;

            case DataType.orbit_argumentOfPeriapsis:
                stream = new doubleStream(connection.AddStream(() => orbit.ArgumentOfPeriapsis));
                break;

            case DataType.orbit_longitudeOfAscendingNode:
                stream = new doubleStream(connection.AddStream(() => orbit.LongitudeOfAscendingNode));
                break;

            case DataType.orbit_eccentricity:
                stream = new doubleStream(connection.AddStream(() => orbit.Eccentricity));
                break;

            case DataType.orbit_inclination:
                stream = new doubleStream(connection.AddStream(() => orbit.Inclination));
                break;

            case DataType.orbit_trueAnomaly:
                stream = new doubleStream(connection.AddStream(() => orbit.TrueAnomaly));
                break;

            case DataType.orbit_timeToApoapsis:
                stream = new doubleStream(connection.AddStream(() => orbit.TimeToApoapsis));
                break;

            case DataType.orbit_timeToPeriapsis:
                stream = new doubleStream(connection.AddStream(() => orbit.TimeToPeriapsis));
                break;

            case DataType.orbit_period:
                stream = new doubleStream(connection.AddStream(() => orbit.Period));
                break;

            case DataType.orbit_timeToSOIChange:
                stream = new doubleStream(connection.AddStream(() => orbit.TimeToSOIChange));
                break;



            ///// RESOURCE DATA /////

            case DataType.resource_total_max_electricCharge:
                stream = new floatStream(connection.AddStream(() => resources.Max("ElectricCharge")));
                break;

            case DataType.resource_total_amount_electricCharge:
                stream = new floatStream(connection.AddStream(() => resources.Amount("ElectricCharge")));
                break;

            case DataType.resource_stage_max_electricCharge:
                stream = new floatStream(connection.AddStream(() => resources_stage.Max("ElectricCharge")));
                break;

            case DataType.resource_stage_amount_electricCharge:
                stream = new floatStream(connection.AddStream(() => resources_stage.Amount("ElectricCharge")));
                break;


            case DataType.resource_total_max_monoPropellant:
                stream = new floatStream(connection.AddStream(() => resources.Max("MonoPropellant")));
                break;

            case DataType.resource_total_amount_monoPropellant:
                stream = new floatStream(connection.AddStream(() => resources.Amount("MonoPropellant")));
                break;

            case DataType.resource_stage_max_monoPropellant:
                stream = new floatStream(connection.AddStream(() => resources_stage.Max("MonoPropellant")));
                break;

            case DataType.resource_stage_amount_monoPropellant:
                stream = new floatStream(connection.AddStream(() => resources_stage.Amount("MonoPropellant")));
                break;


            case DataType.resource_total_max_liquidFuel:
                stream = new floatStream(connection.AddStream(() => resources.Max("LiquidFuel")));
                break;

            case DataType.resource_total_amount_liquidFuel:
                stream = new floatStream(connection.AddStream(() => resources.Amount("LiquidFuel")));
                break;

            case DataType.resource_stage_max_liquidFuel:
                stream = new floatStream(connection.AddStream(() => resources_stage.Max("LiquidFuel")));
                break;

            case DataType.resource_stage_amount_liquidFuel:
                stream = new floatStream(connection.AddStream(() => resources_stage.Amount("LiquidFuel")));
                break;


            case DataType.resource_stage_max_oxidizer:
                stream = new floatStream(connection.AddStream(() => resources_stage.Max("Oxidizer")));
                break;

            case DataType.resource_stage_amount_oxidizer:
                stream = new floatStream(connection.AddStream(() => resources_stage.Amount("Oxidizer")));
                break;

            case DataType.resource_total_max_oxidizer:
                stream = new floatStream(connection.AddStream(() => resources.Max("Oxidizer")));
                break;

            case DataType.resource_total_amount_oxidizer:
                stream = new floatStream(connection.AddStream(() => resources.Amount("Oxidizer")));
                break;


            ///// SPACECENTER DATA /////
            case DataType.spacecenter_universial_time:
                stream = new doubleStream(connection.AddStream(() => spaceCenter.UT));
                break;


            ///// VESSEL DATA /////
            case DataType.vessel_MET:
                stream = new doubleStream(connection.AddStream(() => vessel.MET));
                break;

            case DataType.vessel_type:
                stream = new vesselTypeStream(connection.AddStream(() => vessel.Type));
                break;

            case DataType.vessel_mass:
                stream = new floatStream(connection.AddStream(() => vessel.Mass));
                break;

            case DataType.vessel_dryMass:
                stream = new floatStream(connection.AddStream(() => vessel.DryMass));
                break;

            case DataType.vessel_position:
                stream = new tuple3Stream(connection.AddStream(() => vessel.Position(vessel.Orbit.Body.NonRotatingReferenceFrame)));
                break;

            case DataType.vessel_velocity:
                stream = new tuple3Stream(connection.AddStream(() => vessel.Velocity(vessel.Orbit.Body.NonRotatingReferenceFrame)));
                break;

            case DataType.vessel_parts:
                stream = new vesselPartsStream(connection.AddStream(() => vessel.Parts));
                break;

            case DataType.vessel_referenceFrame:
                stream = new referenceFrameStream(connection.AddStream(() => vessel.ReferenceFrame));
                break;

            case DataType.vessel_orbit:
                stream = new OrbitStream(connection.AddStream(() => vessel.Orbit));
                break;

            case DataType.vessel_autoPilot:
                stream = new AutoPilotStream(connection.AddStream(() => vessel.AutoPilot));
                break;

            case DataType.vessel_surfaceReferenceFrame:
                stream = new referenceFrameStream(connection.AddStream(() => vessel.SurfaceReferenceFrame));
                break;


            default:
                throw (new Exception("DataType: " + type.ToString() + " not supported"));
            }

            // Safety check if type already exists in streams
            if (!streams.ContainsKey(type))
            {
                streams.Add(type, stream);
            }
        }
Пример #6
0
        public void ConnectToServer(object sender, EventArgs e)
        {
            if (!connected)
            {
                Console.WriteLine("You pressed the 'Connect'-button, you clever you... :-)");
                pySSSMQStatus.Text = "PySSSMQ: CONNECTING";
                kRPCStatus.Text    = "   kRPC: CONNECTING";

                try
                {
                    IPAddress[]          connectionAdrs = Dns.GetHostAddresses(ipAddr.Text);
                    System.Net.IPAddress IP             = connectionAdrs[0];         // IPv4

                    // Store connection IP
                    this.connectionIP = IP.ToString();

                    connectionName = name.Text;

                    connection = new Connection(name: connectionName, address: IP);

                    krpc        = connection.KRPC();
                    spaceCenter = connection.SpaceCenter();

                    streamCollection.setConnection(connection);

                    // Setup graphable data
                    setupChartData(streamCollection);

                    kRPCStatus.Text = "   kRPC: CONNECTED";
                    connected       = true;
                }
                catch (System.Net.Sockets.SocketException)
                {
                    MessageBox.Show("KRPC SERVER NOT RESPONDING");
                    kRPCStatus.Text = "   kRPC: NOT CONNECTED";
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("NOT A VALID IP-ADDRESS");
                    kRPCStatus.Text = "   kRPC: NOT CONNECTED";
                }
                catch (System.IO.IOException)
                {
                    MessageBox.Show("IO ERROR");
                    kRPCStatus.Text = "   kRPC: NOT CONNECTED";
                }

                // Connect to pySSMQ
                try
                {
                    pySSSMQ.Connect(connectionIP);
                    pySSSMQ.AttachReceiveEvent(pySSSMQ_handler.receive);
                    if (pySSSMQ.IsConnected())
                    {
                        pySSSMQStatus.Text = "PySSSMQ: CONNECTED";
                        dataStorage.Pull();
                    }
                    else
                    {
                        pySSSMQStatus.Text = "PySSSMQ: NOT CONNECTED";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.GetType() + ":" + ex.Message);
                    pySSSMQStatus.Text = "PySSSMQ: NOT CONNECTED";
                }
            }
            else
            {
                MessageBox.Show("Already Connected", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #7
0
 public KRPC.Client.Stream <KRPC.Client.Services.SpaceCenter.Vessel> getVesselStream(Connection con, KRPC.Client.Services.SpaceCenter.Service sc)
 {
     return(con.AddStream(() => sc.ActiveVessel));
 }
 private void Poll()
 {
     while (_shouldPoll)
     {
         try
         {
             UpdateFromRPC(_spaceCenter.ActiveVessel);
         }
         catch (Exception e)
         {
             _shouldPoll = false;
             _connection = null;
             _spaceCenter = null;
             Notifications.LastErrorMessage = string.Format("Error on update: {0}", e.Message);
             ConnectedAndViewsVisbilityChanged();
         }
         Thread.Sleep(100);
     }
 }
        public void SetConnectionAndStartPolling(KRPC.Client.Connection connection)
        {
            _connection = connection;
            _spaceCenter = _connection.SpaceCenter();

            _shouldPoll = true;
            _pollingThread = new Thread(Poll);
            _pollingThread.Start();
            ConnectedAndViewsVisbilityChanged();
        }