示例#1
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;
        }
示例#2
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);
            }
        }
示例#3
0
 public static void Connect()
 {
     connection = new Connection("KPSF");
     service    = connection.KRPC();
 }