Esempio n. 1
0
        public static DataValue XMLDeserialize(string xml)
        {
            Match m = typeregex.Match(xml);

            if (m.Success)
            {
                Group g = m.Groups[1];

                string dataType = g.ToString();
                switch (dataType)
                {
                case "StringType":
                    StringValue sv = new StringValue();
                    sv.FromXML(xml);
                    return(sv);

                case "DoubleType":
                    DoubleValue dv = new DoubleValue();
                    dv.FromXML(xml);
                    return(dv);

                case "IntegerType":
                    IntegerValue iv = new IntegerValue();
                    iv.FromXML(xml);
                    return(iv);

                case "LocationType":
                    LocationValue lv = new LocationValue();
                    lv.FromXML(xml);
                    return(lv);

                case "VelocityType":
                    VelocityValue vv = new VelocityValue();
                    vv.FromXML(xml);
                    return(vv);

                case "AttributeCollectionType":
                    AttributeCollectionValue av = new AttributeCollectionValue();
                    av.FromXML(xml);
                    return(av);

                default:
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static DataValue XMLDeserialize(string xml)
        {
            Match m = typeregex.Match(xml);
            if (m.Success)
            {
                Group g = m.Groups[1];
                
                string dataType = g.ToString();
                switch (dataType)
                {
                    case "StringType":
                        StringValue sv = new StringValue();
                        sv.FromXML(xml);
                        return sv;
                    case "DoubleType":
                        DoubleValue dv = new DoubleValue();
                        dv.FromXML(xml);
                        return dv;
                    case "IntegerType":
                        IntegerValue iv = new IntegerValue();
                        iv.FromXML(xml);
                        return iv;
                    case "LocationType":
                        LocationValue lv = new LocationValue();
                        lv.FromXML(xml);
                        return lv;
                    case "VelocityType":
                        VelocityValue vv = new VelocityValue();
                        vv.FromXML(xml);
                        return vv;
                    case "AttributeCollectionType":
                        AttributeCollectionValue av = new AttributeCollectionValue();
                        av.FromXML(xml);
                        return av;
                    default:
                        return null;
                }
            }
            else
            {
                return null;
            }

        }
Esempio n. 3
0
        private static SimulationEvent populateQueue3()
        {
            SimulationEvent ee = new SimulationEvent();
            Dictionary<string, DataValue> myAtt = new Dictionary<string, DataValue>();

            ee.eventType = "NewObject";
            DataValue myDV = new StringValue();
            ((StringValue)(myDV)).value = "PhysicalObject";
            ee.parameters.Add("ObjectType", myDV);


            // START OF ATTRIBUTE DEFINITIONS //
            myDV = new IntegerValue();
            ((IntegerValue)(myDV)).value = 1;
            myAtt.Add("ID", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "Second Object";
            myAtt.Add("ObjectName", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "flying";
            myAtt.Add("ObjectState", myDV);

            myDV = new StringValue();
            ((StringValue)(myDV)).value = "NoClassesYet";
            myAtt.Add("ClassName", myDV);

            myDV = new LocationValue();
            ((LocationValue)(myDV)).X = 100;
            ((LocationValue)(myDV)).Y = 100;
            ((LocationValue)(myDV)).Z = 0;
            myAtt.Add("Location", myDV);

            myDV = new VelocityValue();
            ((VelocityValue)(myDV)).VX = 0;
            ((VelocityValue)(myDV)).VY = 0;
            ((VelocityValue)(myDV)).VZ = 0;
            myAtt.Add("Velocity", myDV);

            myDV = new DoubleValue();
            ((DoubleValue)(myDV)).value = 1;
            myAtt.Add("MaximumSpeed", myDV);

            myDV = new DoubleValue();
            ((DoubleValue)(myDV)).value = 0.0;
            myAtt.Add("Throttle", myDV);

            myDV = new LocationValue();
            ((LocationValue)(myDV)).X = 0;
            ((LocationValue)(myDV)).Y = 0;
            ((LocationValue)(myDV)).Z = 0;
            myAtt.Add("DestinationLocation", myDV);

            // END OF ATTRIBUTE DEFINITIONS //

            myDV = new AttributeCollectionValue();
            ((AttributeCollectionValue)(myDV)).attributes = myAtt;
            ee.parameters.Add("Attributes", myDV);

            myDV = new IntegerValue();
            ((IntegerValue)(myDV)).value = 5000;
            ee.parameters.Add("Time", myDV);

            return ee;

        }