コード例 #1
0
ファイル: Vec2D.cs プロジェクト: wshanshan/DDD
 public VelocityValue ToVelocityValue()
 {
     VelocityValue v = new VelocityValue();
     v.VX = X;
     v.VY = Y;
     v.VZ = 0;
     return v;
 }
コード例 #2
0
ファイル: BehaviorTools.cs プロジェクト: wshanshan/DDD
        static public bool VelocityIsEqual(VelocityValue vel1, VelocityValue vel2, Double threshhold)
        {
            if (Math.Abs(vel1.VX - vel2.VX) > threshhold)
            {
                return false;
            }
            else if (Math.Abs(vel1.VY - vel2.VY) > threshhold)
            {
                return false;
            }
            else if (Math.Abs(vel1.VZ - vel2.VZ) > threshhold)
            {
                return false;
            }
            else
            {
                return true;
            }


        }
コード例 #3
0
ファイル: Vec2D.cs プロジェクト: wshanshan/DDD
 public void Set(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
 }
コード例 #4
0
ファイル: Vec2D.cs プロジェクト: wshanshan/DDD
 public Vec2D(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
 }
コード例 #5
0
ファイル: Vec3D.cs プロジェクト: wshanshan/DDD
 public Vec3D(VelocityValue v)
 {
     X = v.VX;
     Y = v.VY;
     Z = v.VZ;
 }
コード例 #6
0
ファイル: MotionSim.cs プロジェクト: wshanshan/DDD
 private void ChangeObjectVelocity(VelocityValue newVelocity, string objectID)
 { 
 
 }
コード例 #7
0
ファイル: DataValues.cs プロジェクト: wshanshan/DDD
        /// <summary>
        /// Takes an xml string, and returns a DataValue object.
        /// Returns null if the xml doesn't represent a DataValue.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        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 "BooleanType":
                        BooleanValue bv = new BooleanValue();
                        bv.FromXML(xml);
                        return bv;
                    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;
                    case "CustomAttributesType":
                        CustomAttributesValue cav = new CustomAttributesValue();
                        cav.FromXML(xml);
                        return cav;
                    case "StringListType":
                        StringListValue slv = new StringListValue();
                        slv.FromXML(xml);
                        return slv;
                    case "PolygonType":
                        PolygonValue polyv = new PolygonValue();
                        polyv.FromXML(xml);
                        return polyv;
                    case "StateTableType":
                        StateTableValue stv = new StateTableValue();
                        stv.FromXML(xml);
                        return stv;
                    case "CapabilityType":
                        CapabilityValue cv = new CapabilityValue();
                        cv.FromXML(xml);
                        return cv;
                    case "VulnerabilityType":
                        VulnerabilityValue vv2 = new VulnerabilityValue();
                        vv2.FromXML(xml);
                        return vv2;
                    case "ConeType":
                        ConeValue cv2 = new ConeValue();
                        cv2.FromXML(xml);
                        return cv2;
                    case "SensorType":
                        SensorValue sv2 = new SensorValue();
                        sv2.FromXML(xml);
                        return sv2;
                    case "SensorArrayType":
                        SensorArrayValue sav = new SensorArrayValue();
                        sav.FromXML(xml);
                        return sav;
                    case "EmitterType":
                        EmitterValue ev = new EmitterValue();
                        ev.FromXML(xml);
                        return ev;
                    case "RangeRingDisplayType":
                        RangeRingDisplayValue rrdv = new RangeRingDisplayValue();
                        rrdv.FromXML(xml);
                        return rrdv;
                    case "AttackCollectionType":
                        AttackCollectionValue attCV = new AttackCollectionValue();
                        attCV.FromXML(xml);
                        return attCV;
                    case "WrapperType":
                        WrapperValue wrapper = new WrapperValue();
                        wrapper.FromXML(xml);
                        return wrapper;
                    case "ClassificationDisplayRulesType":
                        ClassificationDisplayRulesValue cdrv = new ClassificationDisplayRulesValue();
                        cdrv.FromXML(xml);
                        return cdrv;
                    default:
                        return null;
                }
            }
            else
            {
                return null;
            }

        }
コード例 #8
0
ファイル: SimObject.cs プロジェクト: wshanshan/DDD
 /// <summary>
 /// The constructor for the SimObject.
 /// </summary>
 /// <param name="id"></param>
 public SimObject(String id)
 {
     m_id = id;
     m_velocity = new VelocityValue();
     m_location = new LocationValue();
     m_destination = new LocationValue();
     m_vulnerabilityList = new List<string>();
     m_capabilityList = new List<string>();
     m_dockedObjects = new List<string>();
     m_dockedWeapons = new List<string>();
     m_childObjects = new List<string>();
     m_agent = new ObjectControlAgent();
     m_agent.simObject = this;
     m_inActiveRegions = new List<string>();
 }
コード例 #9
0
ファイル: EventCommunicator.cs プロジェクト: wshanshan/DDD
 /// <summary>
 /// Given a VelocityType (ScenCon defined object), a new DataValue is created, and assigned as a 
 /// VelocityValue.  This LocationValue's coordinate settings are set to the input
 /// VelocityType, and then the VelocityType is returned as a DataValue.
 /// </summary>
 /// <param name="input">
 /// A VelocityType object, whose coordinates are assigned to a VelocityValue.
 /// </param>
 /// <returns>
 ///</returns>
 private static DataValue ConvertVelocity(VelocityType input)
 {//Replaced by method in DataValueFactory...
     DataValue dv = new VelocityValue();
     ((VelocityValue)dv).VX = input.VX;
     ((VelocityValue)dv).VY = input.VY;
     ((VelocityValue)dv).VZ = input.VZ;
     return dv;
 }
コード例 #10
0
ファイル: EventCommunicator.cs プロジェクト: wshanshan/DDD
        /// <summary>
        /// This method takes in a dictionary that represents the SimulationModel parameters, and a Dictionary
        /// that is to be used to populate a DataValue dictionary given the Simulation Model.  Foreach entry
        /// in the SimModel dictionary, if the same key (witch is converted from SimCoreKey to ScenConKey)
        /// exists in the given DataValue dictionary, then that value is used rather than a default DataValue.
        /// The newly created DataValue dictionary represents every member in the SimModel dictionary, and uses
        /// the available data from the given DataValue dictionary.
        /// </summary>
        /// <param name="objectAttributes">
        /// This Dictionary is indexed by a string that is the parameter name, and the value is an AttributeInfo
        /// object that contains the name and type of the parameter.
        /// </param>
        /// <param name="SendingEventAttributes">
        /// This dictionary contains attributes given from the ScenCon, to be passed on to the SimCore.  The 
        /// data is copied over to the correct entry in the resulting dictionary.
        /// </param>
        /// <returns></returns>
        private static Dictionary<string, DataValue> ParseAttributesList(Dictionary<string, AttributeInfo> objectAttributes, Dictionary<string, object> SendingEventAttributes)
        {
            Dictionary<string, DataValue> myAtt = new Dictionary<string, DataValue>();
            DataValue dv;
            string scenConKey,
                   simCoreKey,
                   attributeType;

            foreach (KeyValuePair<string, AttributeInfo> pair in objectAttributes)
            {
                if (!simModelIgnoreList.Contains(pair.Key))
                {
                    simCoreKey = pair.Key;
                    scenConKey = convertSimCoreToScenCon(simCoreKey);
                    if (SendingEventAttributes.ContainsKey(scenConKey))
                    {//Copy over the data 
                        attributeType = pair.Value.dataType;
                        switch (attributeType)
                        { //attribute type will be either the system defined name, or Dennis' type
                            case "StringType":

                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    myAtt.Add(simCoreKey, DataValueFactory.BuildString(Convert.ToString(SendingEventAttributes[scenConKey])));
                                }/*ConvertString(Convert.ToString(SendingEventAttributes[scenConKey])*/
                                else
                                {
                                    myAtt.Add(simCoreKey, DataValueFactory.BuildString(string.Empty));
                                }/*ConvertString(String.Empty)*/

                                break;
                            case "IntegerType":
                                dv = new IntegerValue();
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    dv = DataValueFactory.BuildInteger(Convert.ToInt32(SendingEventAttributes[scenConKey]));//ConvertInteger(Convert.ToInt32(SendingEventAttributes[scenConKey]));
                                }
                                myAtt.Add(simCoreKey, dv);
                                break;
                            case "BooleanType":
                                dv = new BooleanValue();
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    dv = DataValueFactory.BuildBoolean(Convert.ToBoolean(SendingEventAttributes[scenConKey]));//ConvertBoolean(Convert.ToBoolean(SendingEventAttributes[scenConKey]));
                                }
                                myAtt.Add(simCoreKey, dv);
                                break;
                            case "DoubleType":
                                dv = new DoubleValue();
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    dv = DataValueFactory.BuildDouble(Convert.ToDouble(SendingEventAttributes[scenConKey]));//ConvertDouble(Convert.ToDouble(SendingEventAttributes[scenConKey]));
                                }
                                myAtt.Add(simCoreKey, dv);
                                break;

                            case "LocationType":

                                dv = new LocationValue();
                                ((LocationValue)dv).exists = false;
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    LocationType lt = SendingEventAttributes[scenConKey] as LocationType;
                                    dv = DataValueFactory.BuildLocation(lt.X, lt.Y, lt.Z, true);//ConvertLocation((LocationType)SendingEventAttributes[scenConKey], true);
                                }
                                myAtt.Add(simCoreKey, dv);
                                break;
                            case "VelocityType":

                                dv = new VelocityValue();
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    VelocityType vt = SendingEventAttributes[scenConKey] as VelocityType;
                                    dv = DataValueFactory.BuildVelocity(vt.VX, vt.VY, vt.VZ);//ConvertVelocity((VelocityType)SendingEventAttributes[scenConKey]);
                                }
                                myAtt.Add(simCoreKey, dv);
                                break;

                            case "StringListType":
                                dv = new StringListValue();
                                if (SendingEventAttributes.ContainsKey(scenConKey))
                                {
                                    ((StringListValue)dv).strings = (List<string>)SendingEventAttributes[scenConKey];
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            return myAtt;
        }
コード例 #11
0
ファイル: BehaviorTools.cs プロジェクト: wshanshan/DDD
 static public bool VelocityIsEqual(VelocityValue vel1, VelocityValue vel2)
 {
     return VelocityIsEqual(vel1, vel2, 0.1);
 }