コード例 #1
0
        private static void PopulateHeavyUAV(XmlDocument xmlDoc, XmlNode parentNode, HeavyUAVConfig c)
        {
            // Create "HeavyUAV" node and append to parentNode
            XmlNode node = xmlDoc.CreateElement("HeavyUAV");

            parentNode.AppendChild(node);

            // Add attributes
            AddAttribute(xmlDoc, node, "x_km", c.x_km.ToString());
            AddAttribute(xmlDoc, node, "y_km", c.y_km.ToString());
            AddAttribute(xmlDoc, node, "z_km", c.z_km.ToString());
            AddAttribute(xmlDoc, node, "id", c.id.ToString());
            AddOptionalAttribute(xmlDoc, node, "sensorBeamwidth_deg", c.sensorBeamwidth_deg);
            AddOptionalAttribute(xmlDoc, node, "commsRange_km", c.commsRange_km);
            AddOptionalAttribute(xmlDoc, node, "fuelTankSize_s", c.fuelTankSize_s);
            AddOptionalAttribute(xmlDoc, node, "numStorageSlots", c.numStorageSlots);

            // Add perception override (if specified)
            AddPerceptionOverride(xmlDoc, node, c);
        }
コード例 #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
        }