Пример #1
0
        public static string getMasterArm(GameObject vehicle)
        {
            bool masterArmState = false;

            try
            {
                foreach (VRLever lever in vehicle.GetComponentsInChildren <VRLever>())
                {
                    if (lever.gameObject.name == "masterArmSwitchInteractable")
                    {
                        if (lever.currentState == 1)
                        {
                            masterArmState = true;
                            break;
                        }
                        else
                        {
                            masterArmState = false;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("Error getting master arm state: " + ex.ToString());
            }
            return(masterArmState.ToString());
        }
Пример #2
0
        public void FixedUpdate()
        {
            if (iterator < 46)
            {
                iterator++;
            }
            else
            {
                iterator = 0;
                secondCount++;

                if (runlogger)
                {
                    if (SceneManager.GetActiveScene().buildIndex != 7 && SceneManager.GetActiveScene().buildIndex != 12)
                    {
                        ResetLogger();
                    }
                }
            }

            if (runlogger)
            {
                try
                {
                    dataGetter.GetData();
                }
                catch (Exception ex)
                {
                    Support.WriteErrorLog("Error getting data." + ex.ToString());
                }
            }
        }
Пример #3
0
        public static List <Dictionary <string, string> > getRWRContacts(GameObject vehicle)
        {
            List <Dictionary <string, string> > contacts = new List <Dictionary <string, string> >();

            try
            {
                ModuleRWR rwr = vehicle.GetComponentInChildren <ModuleRWR>();

                foreach (ModuleRWR.RWRContact contact in rwr.contacts)
                {
                    Dictionary <string, string> contactDict = new Dictionary <string, string>();
                    contactDict.Add("active", contact.active.ToString());
                    contactDict.Add("locked", contact.locked.ToString());
                    Actor radar_actor = contact.radarActor;
                    contactDict.Add("friendFoe", radar_actor.team.ToString());
                    contactDict.Add("name", radar_actor.name.ToString());
                    contactDict.Add("radarSymbol", contact.radarSymbol.ToString());
                    contactDict.Add("signalStrength", contact.signalStrength.ToString());

                    contacts.Add(contactDict);
                }
            }
            catch (NullReferenceException ex)
            {
                //I don't think this really matters here. It seems to work and I'm too lazy to debug it.
                //I think ModuleRWR only updates at a certain rate and does not exist otherwise.
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("Error getting RWR Contacts: " + ex);
            }
            return(contacts);
        }
Пример #4
0
 public static string GetBattery(GameObject vehicle)
 {
     try
     {
         Battery batteryCharge = vehicle.GetComponentInChildren <Battery>();
         string  battery       = batteryCharge.currentCharge.ToString();
         return(battery);
     }
     catch (Exception ex)
     {
         Support.WriteErrorLog("unable to get battery status: " + ex.ToString());
         return("False");
     }
 }
Пример #5
0
        public static Dictionary <string, string> getVehicleLights(GameObject vehicle)
        {
            Dictionary <string, string> lights = new Dictionary <string, string>();

            //this is BAD
            //Light landingLights = vehicle.transform.Find("LandingLight").GetComponent<Light>();


            try
            {
                bool landinglight = false;
                bool navlight     = false;
                bool strobelight  = false;

                foreach (Light light in vehicle.GetComponentsInChildren <Light>())
                {
                    if (light.gameObject.name == "LandingLight")
                    {
                        landinglight = true;
                    }
                    if (light.gameObject.name.ToString().Contains("StrobeLight"))
                    {
                        strobelight = true;
                    }
                    Support.WriteLog(light.ToString());
                }


                foreach (SpriteRenderer spriteish in vehicle.GetComponentsInChildren <SpriteRenderer>())
                {
                    if (spriteish.ToString().Contains("Nav"))
                    {
                        navlight = true;
                    }
                }

                lights.Add("LandingLights", landinglight.ToString());
                lights.Add("NavLights", navlight.ToString());
                lights.Add("StrobeLights", strobelight.ToString());

                return(lights);
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("Error getting lights " + ex.ToString());
                return(lights);
            }
        }
Пример #6
0
        public static string GetHook(GameObject vehicle)
        {
            try
            {
                Tailhook hook = vehicle.GetComponentInChildren <Tailhook>();

                //Nullable boolean allows it to get "stalling" if it doesn't exist? and sets it as false? I think.
                Boolean?deployed = Traverse.Create(hook).Field("deployed").GetValue() as Boolean?;

                return(deployed.ToString());
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("unable to get stall status: " + ex.ToString());
                return("False");
            }
        }
Пример #7
0
        public static string GetStall(GameObject vehicle)
        {
            try
            {
                HUDStallWarning warning = vehicle.GetComponentInChildren <HUDStallWarning>();

                //Nullable boolean allows it to get "stalling" if it doesn't exist? and sets it as false? I think.
                Boolean?stalling = Traverse.Create(warning).Field("stalling").GetValue() as Boolean?;

                return(stalling.ToString());
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("unable to get stall status: " + ex.ToString());
                return("False");
            }
        }
Пример #8
0
        public static bool GetMissileFiring(GameObject vehicle)
        {
            try
            {
                WeaponManager weaponManager = vehicle.GetComponentInChildren <WeaponManager>();

                if (weaponManager.availableWeaponTypes.aam || weaponManager.availableWeaponTypes.agm || weaponManager.availableWeaponTypes.antirad || weaponManager.availableWeaponTypes.antiShip)
                {
                    return(weaponManager.isFiring);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog("Unable to get weapon manager status: " + ex.ToString());
                return(false);
            }
        }
Пример #9
0
        public void GetData()
        {
            LogData f_info = new LogData();

            try
            {
                if (dataLogger.printOutput)
                {
                    Support.WriteLog("Collecting Data...");
                }
                Actor      playeractor    = FlightSceneManager.instance.playerActor;
                GameObject currentVehicle = VTOLAPI.instance.GetPlayersVehicleGameObject();

                f_info.unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

                f_info.Physics.XAccel   = Math.Round(playeractor.flightInfo.acceleration.x, 2).ToString();
                f_info.Physics.YAccel   = Math.Round(playeractor.flightInfo.acceleration.y, 2).ToString();
                f_info.Physics.ZAccel   = Math.Round(playeractor.flightInfo.acceleration.z, 2).ToString();
                f_info.Physics.PlayerGs = Math.Round(playeractor.flightInfo.playerGs, 2).ToString();

                f_info.Vehicle.VehicleName = currentVehicle.name;

                f_info.Vehicle.Heading       = Math.Round(playeractor.flightInfo.heading, 2).ToString();
                f_info.Vehicle.Pitch         = Math.Round(playeractor.flightInfo.pitch, 2).ToString();
                f_info.Vehicle.Roll          = Math.Round(playeractor.flightInfo.roll, 2).ToString();
                f_info.Vehicle.AoA           = Math.Round(playeractor.flightInfo.aoa, 2).ToString();
                f_info.Vehicle.Airspeed      = Math.Round(playeractor.flightInfo.airspeed, 2).ToString();
                f_info.Vehicle.VerticalSpeed = Math.Round(playeractor.flightInfo.verticalSpeed, 2).ToString();
                f_info.Vehicle.AltitudeASL   = Math.Round(playeractor.flightInfo.altitudeASL, 2).ToString();

                Health health = Traverse.Create(playeractor).Field("h").GetValue() as Health;
                f_info.Vehicle.Health = health.currentHealth.ToString();

                f_info.Vehicle.Drag     = Math.Round(playeractor.flightInfo.rb.drag, 2).ToString();
                f_info.Vehicle.Mass     = Math.Round(playeractor.flightInfo.rb.mass, 2).ToString();
                f_info.Vehicle.IsLanded = playeractor.flightInfo.isLanded.ToString();


                f_info.Vehicle.Fuel.FuelDensity  = DataGetters.getFuelDensity(currentVehicle);
                f_info.Vehicle.Fuel.FuelBurnRate = DataGetters.getFuelBurnRate(currentVehicle);
                f_info.Vehicle.Fuel.FuelLevel    = DataGetters.getFuelLevel(currentVehicle);

                f_info.Vehicle.BatteryLevel = DataGetters.GetBattery(currentVehicle);
                f_info.Vehicle.Engines      = DataGetters.GetEngineStats(currentVehicle);

                f_info.Vehicle.RadarCrossSection = DataGetters.getRadarCrossSection(currentVehicle);
                f_info.Vehicle.TailHook          = DataGetters.GetHook(currentVehicle);

                f_info.Vehicle.Lights = DataGetters.getVehicleLights(currentVehicle);

                f_info.Vehicle.Flaps = DataGetters.getFlaps(currentVehicle);

                f_info.Vehicle.Brakes        = DataGetters.getBrakes(currentVehicle);
                f_info.Vehicle.EjectionState = DataGetters.getEjectionState(currentVehicle);

                f_info.Vehicle.Avionics.RadarState      = DataGetters.getRadarState(currentVehicle);
                f_info.Vehicle.Avionics.RWRContacts     = DataGetters.getRWRContacts(currentVehicle);
                f_info.Vehicle.Avionics.MissileDetected = DataGetters.getMissileDetected(currentVehicle);
                f_info.Vehicle.Avionics.StallDetector   = DataGetters.GetStall(currentVehicle);

                f_info.Vehicle.Avionics.masterArm = DataGetters.getMasterArm(currentVehicle);

                // Dumps all components in the vehicle. Will freeze game, but useful to see what we get.
                //GetAllVehicleComponents(currentVehicle);


                if (dataLogger.printOutput)
                {
                    Support.WriteLog(f_info.ToCSV());
                }
            }
            catch (Exception ex)
            {
                Support.WriteErrorLog($"{Globals.projectName} - Error getting telemetry data " + ex.ToString());
            }


            if (dataLogger.csvEnabled == true)
            {
                if (dataLogger.printOutput)
                {
                    Support.WriteLog("Saving CSV");
                }

                if (!File.Exists(dataLogger.csv_path))
                {
                    using (StreamWriter sw = File.AppendText(dataLogger.csv_path))
                    {
                        sw.WriteLine(f_info.CSVHeaders());
                    }
                }

                using (StreamWriter sw = File.AppendText(dataLogger.csv_path))
                {
                    sw.WriteLine(f_info.ToCSV());
                }
            }

            if (dataLogger.jsonEnabled == true)
            {
                if (dataLogger.printOutput)
                {
                    Support.WriteLog("Saving JSON...");
                }

                using (StreamWriter sw = File.AppendText(dataLogger.json_path))
                {
                    sw.WriteLine(JsonConvert.SerializeObject(f_info) + "\n");
                }
            }

            if (dataLogger.udpEnabled == true)
            {
                if (dataLogger.printOutput)
                {
                    Support.WriteLog("Sending UDP Packet...");
                }
                try
                {
                    SendUdp(JsonConvert.SerializeObject(f_info));
                }
                catch (Exception ex)
                {
                    Debug.LogError($"{Globals.projectName} - Error sending UDP " + ex.ToString());
                }
            }
        }