コード例 #1
0
 public void Start()
 {
     KSPit.AddToDeviceHandler(AltitudeProvider);
     altitudeChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.Altitude);
     KSPit.AddToDeviceHandler(ApsidesProvider);
     apsidesChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.Apsides);
     KSPit.AddToDeviceHandler(ApsidesTimeProvider);
     apsidesTimeChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.ApsidesTime);
     KSPit.AddToDeviceHandler(OrbitInfoProvider);
     ortbitInfoChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.OrbitInfo);
     KSPit.AddToDeviceHandler(VelocityProvider);
     maneuverChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.ManeuverData);
     KSPit.AddToDeviceHandler(ManeuverProvider);
     velocityChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.Velocities);
     KSPit.AddToDeviceHandler(RotationProvider);
     rotationChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.RotationData);
     KSPit.AddToDeviceHandler(DeltaVProvider);
     deltaVChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.DeltaV);
     KSPit.AddToDeviceHandler(DeltaVEnvProvider);
     deltaVEnvChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.DeltaVEnv);
     KSPit.AddToDeviceHandler(BurnTimeProvider);
     burnTimeChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.BurnTime);
     // We fire one SoI packet when SoI changes. So no need to use the
     // periodic DeviceHandler infrastructure.
     CurrentSoI = "";
     soiChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.SoIName);
     //When SOIName channel is subscribed to, we need to resend the SOI name.
     GameEvents.FindEvent <EventData <byte, object> >("onSerialChannelSubscribed" + OutboundPackets.SoIName).Add(resendSOI);
     KSPit.AddToDeviceHandler(AirspeedProvider);
     airspeedChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.Airspeed);
     KSPit.AddToDeviceHandler(TempLimitProvider);
     tempLimitChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.TempLimit);
 }
コード例 #2
0
 public void OnDestroy()
 {
     KSPit.RemoveToDeviceHandler(ResourceProvider);
     KSPit.RemoveToDeviceHandler(WasteProvider);
     KSPit.RemoveToDeviceHandler(Custom1Provider);
     KSPit.RemoveToDeviceHandler(Custom2Provider);
 }
コード例 #3
0
        public void Start()
        {
            ProviderActive = false;

            KSPit.AddToDeviceHandler(TargetProvider);
            targetChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial25");
        }
コード例 #4
0
        public void OnDestroy()
        {
            if (RotationChannel != null)
            {
                RotationChannel.Remove(vesselRotationCallback);
            }
            if (TranslationChannel != null)
            {
                TranslationChannel.Remove(vesselTranslationCallback);
            }
            if (WheelChannel != null)
            {
                WheelChannel.Remove(wheelCallback);
            }
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Remove(throttleCallback);
            }
            if (CustomAxisChannel != null)
            {
                CustomAxisChannel.Remove(customAxisCallback);
            }
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Remove(autopilotModeCallback);
            }

            KSPit.RemoveToDeviceHandler(SASInfoProvider);

            lastActiveVessel.OnPostAutopilotUpdate -= AutopilotUpdater;
            GameEvents.onVesselChange.Remove(OnVesselChange);
        }
コード例 #5
0
 public void EchoRequestCallback(byte ID, object Data)
 {
     if (KSPit.Config.Verbose)
     {
         Debug.Log(String.Format("KerbalSimpit: Echo request on port {0}. Replying.", ID));
     }
     KSPit.SendToSerialPort(ID, CommonPackets.EchoResponse, Data);
 }
コード例 #6
0
 public void OnDestroy()
 {
     KSPit.RemoveToDeviceHandler(AltitudeProvider);
     KSPit.RemoveToDeviceHandler(ApsidesProvider);
     KSPit.RemoveToDeviceHandler(ApsidesTimeProvider);
     KSPit.RemoveToDeviceHandler(VelocityProvider);
     KSPit.RemoveToDeviceHandler(AirspeedProvider);
 }
コード例 #7
0
 void Start()
 {
     UpdateGUIState();
     simpitInstance = (KSPit)FindObjectOfType(typeof(KSPit));
     if (simpitInstance == null)
     {
         Debug.Log("Simpit : the GUI could not locate the KSPit instance. GUI will not work");
     }
 }
コード例 #8
0
        public void Start()
        {
            ARPWrapper.InitKSPARPWrapper();
            if (ARPWrapper.APIReady)
            {
                ARPPresent = true;
                KSPit.AddToDeviceHandler(LFProvider);
                LFChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial10");
                KSPit.AddToDeviceHandler(LFStageProvider);
                LFStageChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial11");
                KSPit.AddToDeviceHandler(OxProvider);
                OxChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial12");
                KSPit.AddToDeviceHandler(OxStageProvider);
                OxStageChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial13");
                KSPit.AddToDeviceHandler(SFProvider);
                SFChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial14");
                KSPit.AddToDeviceHandler(SFStageProvider);
                SFStageChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial15");
                KSPit.AddToDeviceHandler(MonoProvider);
                MonoChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial16");
                KSPit.AddToDeviceHandler(ElectricProvider);
                ElectricChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial17");
                KSPit.AddToDeviceHandler(EvaProvider);
                EvaChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial18");
                KSPit.AddToDeviceHandler(OreProvider);
                OreChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial19");
                KSPit.AddToDeviceHandler(AbProvider);
                AbChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial20");
                KSPit.AddToDeviceHandler(AbStageProvider);
                AbStageChannel =
                    GameEvents.FindEvent <EventData <byte, object> >("toSerial21");

                ScanForResources();
            }
            else
            {
                ARPPresent = false;
                Debug.Log("KerbalSimpit: AlternateResourcePanel not found. Resource providers WILL NOT WORK.");
            }
        }
コード例 #9
0
 public void OnDestroy()
 {
     KSPit.RemoveToDeviceHandler(LFProvider);
     KSPit.RemoveToDeviceHandler(LFStageProvider);
     KSPit.RemoveToDeviceHandler(OxProvider);
     KSPit.RemoveToDeviceHandler(OxStageProvider);
     KSPit.RemoveToDeviceHandler(SFProvider);
     KSPit.RemoveToDeviceHandler(SFStageProvider);
     KSPit.RemoveToDeviceHandler(MonoProvider);
     KSPit.RemoveToDeviceHandler(ElectricProvider);
     KSPit.RemoveToDeviceHandler(EvaProvider);
     KSPit.RemoveToDeviceHandler(OreProvider);
     KSPit.RemoveToDeviceHandler(AbProvider);
     KSPit.RemoveToDeviceHandler(AbStageProvider);
 }
コード例 #10
0
 public void OnDestroy()
 {
     KSPit.RemoveToDeviceHandler(AltitudeProvider);
     KSPit.RemoveToDeviceHandler(ApsidesProvider);
     KSPit.RemoveToDeviceHandler(ApsidesTimeProvider);
     KSPit.RemoveToDeviceHandler(OrbitInfoProvider);
     KSPit.RemoveToDeviceHandler(VelocityProvider);
     KSPit.RemoveToDeviceHandler(RotationProvider);
     KSPit.RemoveToDeviceHandler(AirspeedProvider);
     KSPit.RemoveToDeviceHandler(ManeuverProvider);
     KSPit.RemoveToDeviceHandler(DeltaVProvider);
     KSPit.RemoveToDeviceHandler(DeltaVEnvProvider);
     KSPit.RemoveToDeviceHandler(BurnTimeProvider);
     KSPit.RemoveToDeviceHandler(TempLimitProvider);
 }
コード例 #11
0
 public void Start()
 {
     KSPit.AddToDeviceHandler(AltitudeProvider);
     altitudeChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial8");
     KSPit.AddToDeviceHandler(ApsidesProvider);
     apsidesChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial9");
     KSPit.AddToDeviceHandler(ApsidesTimeProvider);
     apsidesTimeChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial24");
     KSPit.AddToDeviceHandler(VelocityProvider);
     velocityChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial22");
     // We fire one SoI packet when SoI changes. So no need to use the
     // periodic DeviceHandler infrastructure.
     CurrentSoI = "";
     soiChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial26");
     KSPit.AddToDeviceHandler(AirspeedProvider);
     airspeedChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial27");
 }
コード例 #12
0
        public void Start()
        {
            RotationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselRotation);
            if (RotationChannel != null)
            {
                RotationChannel.Add(vesselRotationCallback);
            }
            TranslationChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselTranslation);
            if (TranslationChannel != null)
            {
                TranslationChannel.Add(vesselTranslationCallback);
            }
            WheelChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.WheelControl);
            if (WheelChannel != null)
            {
                WheelChannel.Add(wheelCallback);
            }
            ThrottleChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselThrottle);
            if (ThrottleChannel != null)
            {
                ThrottleChannel.Add(throttleCallback);
            }
            CustomAxisChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.VesselCustomAxis);
            if (CustomAxisChannel != null)
            {
                CustomAxisChannel.Add(customAxisCallback);
            }
            AutopilotChannel = GameEvents.FindEvent <EventData <byte, object> >("onSerialReceived" + InboundPackets.AutopilotMode);
            if (AutopilotChannel != null)
            {
                AutopilotChannel.Add(autopilotModeCallback);
            }

            SASInfoChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.SASInfo);
            KSPit.AddToDeviceHandler(SASInfoProvider);
            mySASInfo.currentSASMode      = 255; // value for not enabled
            mySASInfo.SASModeAvailability = 0;

            lastActiveVessel = FlightGlobals.ActiveVessel;
            FlightGlobals.ActiveVessel.OnPostAutopilotUpdate += AutopilotUpdater;
            GameEvents.onVesselChange.Add(OnVesselChange);
        }
コード例 #13
0
        public KSPSerialPort(KSPit k_simpit, string pn, int br, byte idx, bool vb)
        {
            this.k_simpit = k_simpit;
            PortName      = pn;
            BaudRate      = br;
            ID            = idx;
            portStatus    = ConnectionStatus.CLOSED;

            DoSerial = false;

            Port = new SerialPort(PortName, BaudRate, Parity.None,
                                  8, StopBits.One);

            // To allow communication from a Pi Pico, the DTR seems to be mandatory to allow the connection
            // This does not seem to prevent communication from Arduino.
            Port.DtrEnable = true;

            if (KSPit.Config.Verbose)
            {
                Debug.Log(String.Format("KerbalSimpit: Using serial polling thread for {0}", pn));
            }
        }
コード例 #14
0
 public void Update()
 {
     // We only need to register as a device handler if
     // there's an active target. So we keep a watch on
     // targets and add/remove ourselves as required.
     if (FlightGlobals.fetch.VesselTarget != null)
     {
         if (!ProviderActive)
         {
             KSPit.AddToDeviceHandler(TargetProvider);
             ProviderActive = true;
         }
     }
     else
     {
         if (ProviderActive)
         {
             KSPit.RemoveToDeviceHandler(TargetProvider);
             ProviderActive = false;
         }
     }
 }
コード例 #15
0
 public void OnDestroy()
 {
     KSPit.RemoveToDeviceHandler(MsgProvider);
 }
コード例 #16
0
 public void Start()
 {
     KSPit.AddToDeviceHandler(MsgProvider);
     _msgChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + _channelID);
     GameEvents.FindEvent <EventData <byte, object> >("onSerialChannelSubscribed" + _channelID).Add(forceSending);
 }
コード例 #17
0
 public KSPSerialPort(KSPit k_simpit, string pn, int br, byte idx) : this(k_simpit, pn, br, idx, false)
 {
 }
コード例 #18
0
 // Constructors:
 // pn: port number
 // br: baud rate
 // idx: a unique identifier for this port
 public KSPSerialPort(KSPit k_simpit, string pn, int br) : this(k_simpit, pn, br, 37, false)
 {
 }
コード例 #19
0
        public void Start()
        {
            ARPWrapper.InitKSPARPWrapper();

            if (ARPWrapper.APIReady)
            {
                Config.KerbalSimpitConfig config = new Config.KerbalSimpitConfig();

                if (config.CustomResourceMessages.Count >= 2)
                {
                    custom11ID = GetResourceID(config.CustomResourceMessages[0].resourceName1);
                    custom12ID = GetResourceID(config.CustomResourceMessages[0].resourceName2);
                    custom13ID = GetResourceID(config.CustomResourceMessages[0].resourceName3);
                    custom14ID = GetResourceID(config.CustomResourceMessages[0].resourceName4);

                    custom21ID = GetResourceID(config.CustomResourceMessages[1].resourceName1);
                    custom22ID = GetResourceID(config.CustomResourceMessages[1].resourceName2);
                    custom23ID = GetResourceID(config.CustomResourceMessages[1].resourceName3);
                    custom24ID = GetResourceID(config.CustomResourceMessages[1].resourceName4);
                }
                else
                {
                    custom11ID = custom12ID = custom13ID = custom14ID = null;
                    custom21ID = custom22ID = custom23ID = custom24ID = null;
                }

                FoodID        = GetResourceID("Food");
                WaterID       = GetResourceID("Water");
                OxygenID      = GetResourceID("Oxygen");
                WasteID       = GetResourceID("Waste");
                LiquidWasteID = GetResourceID("WasteWater");
                CO2ID         = GetResourceID("CarbonDioxide");

                if (FoodID != null && WaterID != null && OxygenID != null && WasteID != null && LiquidWasteID != null && CO2ID != null)
                {
                    KSPit.AddToDeviceHandler(ResourceProvider);
                    resourceChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.TACLSResource);
                    KSPit.AddToDeviceHandler(WasteProvider);
                    wasteChannel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.TACLSWaste);

                    TACLSFound = true;
                    Debug.Log("KerbalSimpit: TACLS resources found. You can subscribe to the TACLS channels.");
                }
                else
                {
                    Debug.Log("KerbalSimpit: TACLS resources not found. I assume TACLS is not installed.");
                    TACLSFound = false;
                }

                if (custom11ID != null || custom12ID != null || custom13ID != null || custom14ID != null)
                {
                    KSPit.AddToDeviceHandler(Custom1Provider);
                    custom1Channel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.CustomResource1);
                    custom1Found   = true;
                    Debug.Log("KerbalSimpit: Custom1 resources available.");
                }
                else
                {
                    Debug.Log("KerbalSimpit: Custom1 resources not available as no resources were found.");
                    custom1Found = false;
                }

                if (custom21ID != null || custom22ID != null || custom23ID != null || custom24ID != null)
                {
                    KSPit.AddToDeviceHandler(Custom2Provider);
                    custom2Channel = GameEvents.FindEvent <EventData <byte, object> >("toSerial" + OutboundPackets.CustomResource2);
                    custom2Found   = true;
                    Debug.Log("KerbalSimpit: Custom2 resources available.");
                }
                else
                {
                    Debug.Log("KerbalSimpit: Custom2 resources not available as no resources were found.");
                    custom2Found = false;
                }
            }
            else
            {
                TACLSFound = false;
            }
        }
コード例 #20
0
 public KerbalSimpitConsole(KSPit k_simpit)
 {
     this.k_simpit = k_simpit;
 }
コード例 #21
0
 // Command constructor
 public KerbalSimpitConsole_SerialCommand(KSPit k_simpit) : base(SERIAL_COMMAND, SERIAL_HELP, SERIAL_USAGE)
 {
     this.k_simpit = k_simpit;
 }