コード例 #1
0
        private static void AddPerceptionOverride(XmlDocument xmlDoc, XmlNode parentNode, PlatformConfig c)
        {
            // Add sensor if overridden
            if (!c.GetUseDefaultSensorModalities())
            {
                XmlNode childNode = xmlDoc.CreateElement("Sensor");
                parentNode.AppendChild(childNode);
                PopulatePerceptionModes(xmlDoc, childNode, c.GetSensorModalities());
            }

            // Add classifier if overridden
            if (!c.GetUseDefaultClassifierModalities())
            {
                XmlNode childNode = xmlDoc.CreateElement("Classifier");
                parentNode.AppendChild(childNode);
                PopulatePerceptionModes(xmlDoc, childNode, c.GetClassifierModalities());
            }
        }
コード例 #2
0
        // Remote platform category parsing
        private static void ParseRemote(XmlNode node, SoaConfig soaConfig)
        {
            PlatformConfig newConfig = null; // Dummy value
            bool           newConfigValid;

            // Go through each child node
            foreach (XmlNode c in node.ChildNodes)
            {
                newConfigValid = true;

                try
                {
                    switch (c.Name)
                    {
                    case "HeavyUAV":
                    {
                        newConfig = new HeavyUAVConfig(
                            GetFloatAttribute(c, "x_km", 0),
                            GetFloatAttribute(c, "y_km", 0),
                            GetFloatAttribute(c, "z_km", 0),
                            GetIntAttribute(c, "id", -1),         // Default -1 means runtime determined id field
                            GetOptionalFloatAttribute(c, "sensorBeamwidth_deg"),
                            GetOptionalFloatAttribute(c, "commsRange_km"),
                            GetOptionalFloatAttribute(c, "fuelTankSize_s"),
                            GetOptionalIntAttribute(c, "numStorageSlots")
                            );
                    }
                    break;

                    case "SmallUAV":
                    {
                        newConfig = new SmallUAVConfig(
                            GetFloatAttribute(c, "x_km", 0),
                            GetFloatAttribute(c, "y_km", 0),
                            GetFloatAttribute(c, "z_km", 0),
                            GetIntAttribute(c, "id", -1),         // Default -1 means runtime determined id field
                            GetOptionalFloatAttribute(c, "sensorBeamwidth_deg"),
                            GetOptionalFloatAttribute(c, "commsRange_km"),
                            GetOptionalFloatAttribute(c, "fuelTankSize_s")
                            );
                    }
                    break;

                    case "BlueBalloon":
                    {
                        // Get list of waypoints
                        List <PrimitivePair <float, float> > waypoints_km = new List <PrimitivePair <float, float> >();
                        foreach (XmlNode g in c.ChildNodes)
                        {
                            switch (g.Name)
                            {
                            case "Waypoint":
                                waypoints_km.Add(new PrimitivePair <float, float>(GetFloatAttribute(g, "x_km", 0), GetFloatAttribute(g, "z_km", 0)));
                                break;
                            }
                        }

                        // Create a Blue Balloon config
                        newConfig = new BlueBalloonConfig(
                            GetIntAttribute(c, "id", -1),         // Default -1 means runtime determined id field
                            GetOptionalFloatAttribute(c, "sensorBeamwidth_deg"),
                            waypoints_km,
                            GetBooleanAttribute(c, "teleportLoop", true)
                            );
                    }
                    break;

                    default:
                        newConfigValid = false;
                        if (c.Name != "#comment")
                        {
                            Debug.LogWarning("SoaConfigXMLReader::ParseRemote(): Unrecognized node " + c.Name);
                        }
                        break;
                    }
                }
                catch (Exception)
                {
                    Debug.LogError("SoaConfigXMLReader::ParseRemote(): Error parsing " + c.Name);
                } // End try-catch

                // Handle and add the new config if it is valid
                if (newConfigValid)
                {
                    // Parse any sensor/classifier override modalities specified
                    foreach (XmlNode g in c.ChildNodes)
                    {
                        switch (g.Name)
                        {
                        case "Sensor":
                            newConfig.SetSensorModalities(ParseModalities(g));
                            break;

                        case "Classifier":
                            newConfig.SetClassifierModalities(ParseModalities(g));
                            break;
                        }
                    }

                    // Add to list of remote platforms
                    soaConfig.remotePlatforms.Add(newConfig);
                } // End if new config valid
            }     // End foreach
        }