示例#1
0
 private static void SendWhiteboardClear(string userID, string targetUserID)
 {
     SimulationEvent sendingEvent = SimulationEventFactory.BuildEvent(ref simModelInfo, "WhiteboardClear");
     DataValue dv = new StringValue();
     ((StringValue)sendingEvent["UserID"]).value = userID;
     ((StringValue)sendingEvent["TargetUserID"]).value = targetUserID;
     server.PutEvent(sendingEvent);
 }
示例#2
0
 private static void SendTextChat(string userID, string targetUserID, string chatBody, int time)
 {
     SimulationEvent sendingEvent = SimulationEventFactory.BuildEvent(ref simModelInfo, "TextChat");
     DataValue dv = new StringValue();
     ((StringValue)sendingEvent["ChatBody"]).value = chatBody;
     ((StringValue)sendingEvent["UserID"]).value = userID;
     ((StringValue)sendingEvent["TargetUserID"]).value = targetUserID;
     ((IntegerValue)sendingEvent["Time"]).value = time;
     server.PutEvent(sendingEvent);        
 }
示例#3
0
 private static void SendWhiteboardLine(string object_ID, string userID, string targetUserID,
     int mode, LocationValue start, LocationValue end, double width, double originalScale, int color, string text)
 {
     SimulationEvent sendingEvent = SimulationEventFactory.BuildEvent(ref simModelInfo, "WhiteboardLine");
     DataValue dv = new StringValue();
     ((StringValue)sendingEvent["ObjectID"]).value = object_ID;
     ((StringValue)sendingEvent["UserID"]).value = userID;
     ((StringValue)sendingEvent["TargetUserID"]).value = targetUserID;
     ((IntegerValue)(sendingEvent["Mode"])).value = mode; 
     sendingEvent["StartLocation"] = start;
     sendingEvent["EndLocation"] = end;
     ((DoubleValue)(sendingEvent["Width"])).value = width;
     ((DoubleValue)(sendingEvent["OriginalScale"])).value = originalScale;
     ((IntegerValue)(sendingEvent["Color"])).value = color;
     ((StringValue)sendingEvent["Text"]).value = text;
     server.PutEvent(sendingEvent);        
 }
示例#4
0
 private void ChangeIntent(StringValue newIntent, string objectID)
 {
     SimulationObjectProxy obj = objectProxies[objectID];
     if (obj == null)
         return;
     obj["Intent"].SetDataValue(newIntent);
     
 }
示例#5
0
        /// <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;
            }

        }
示例#6
0
 private void ChangeObjectFuelDepleteState(StringValue newState, string objectID)
 {
     SimulationObjectProxy obj = objectProxies[objectID];
     if (obj == null)
         return;
     obj["FuelDepletionState"].SetDataValue(newState);
 }
示例#7
0
        private void StateChange(SimulationEvent e)
        {
            string id = ((StringValue)e["ObjectID"]).value;
            SimulationObjectProxy prox = null; // objectProxies[id];
            prox = GetObjectProxy(id);
            if (prox == null)
                return;

            string newState = ((StringValue)e["NewState"]).value;

            DataValue dv = prox["StateTable"].GetDataValue();
            if (((StateTableValue)dv).states.ContainsKey(newState))
            {
                DataValue dv2 = ((StateTableValue)dv).states[newState];
                //AD: Added state to attributes
                DataValue temp = new StringValue();
                ((StringValue)temp).value = newState;
                ((AttributeCollectionValue)dv2).attributes["State"] = temp;
                //AD
                foreach (string attname in ((AttributeCollectionValue)dv2).attributes.Keys)
                {
                    if (prox.GetKeys().Contains(attname) && prox[attname].IsOwner())
                    {
                        prox[attname].SetDataValue(((AttributeCollectionValue)dv2).attributes[attname]);
                        if (attname == "Sensors")
                        {
                            double maxSensor = -1.0;
                            SensorArrayValue sav = ((AttributeCollectionValue)dv2).attributes[attname] as SensorArrayValue;
                            foreach (SensorValue sv in sav.sensors)
                            {
                                maxSensor = Math.Max(maxSensor, sv.maxRange);
                            }
                            if (maxSensor >= 0)
                            {
                                ObjectDistances.UpdateObjectSensorRange(id, maxSensor);
                            }
                        }
                    }
                }
            }
            CustomAttributesValue cav = prox["CustomAttributes"].GetDataValue() as CustomAttributesValue;

            Dictionary<string, DataValue> x = new Dictionary<string, DataValue>();
            if (cav != null)
            {
                x = cav.attributes;
            }

            EmitterValue em = (EmitterValue)prox["Emitters"].GetDataValue();
            foreach (string attName in em.attIsEngram.Keys)
            {
                if (em.attIsEngram[attName])
                {
                    if (StateDB.engrams.ContainsKey(attName))
                    {
                        x[attName] = DataValueFactory.BuildString(StateDB.engrams[attName].engramValue);
                    }
                }
            }

            prox["CustomAttributes"].SetDataValue(DataValueFactory.BuildCustomAttributes(x));
        }
示例#8
0
 private void ChangeObjectIcon(StringValue newIconName, string objectID)
 {
     SimulationObjectProxy obj = objectProxies[objectID];
     if (obj == null)
         return;
     obj["IconName"].SetDataValue(newIconName);
 }
示例#9
0
        private void ChangeObjectState(StringValue newState, string objectID)
        {
            SimulationObjectProxy obj = objectProxies[objectID];
            if (obj == null)
                return;
            string newStateName = newState.value;
            StateTableValue currentStateTable = obj["StateTable"].GetDataValue() as StateTableValue;

            foreach (String stateName in currentStateTable.states.Keys)
            {
                if (stateName == newStateName)
                {
                    SendStateChangeEvent(objectID, newStateName);
                }
            }
        }
示例#10
0
 /// <summary>
 /// Given a string, a new DataValue is created, and assigned as a 
 /// StringValue.  This StringValue's value setting is set to the input
 /// string, and then the StringValue is returned as a DataValue.
 /// </summary>
 /// <param name="input">
 /// A string to be assigned to a StringValue.
 /// </param>
 /// <returns>
 ///Returns an abstract class DataValue, which is a StringValue containing 
 /// a given string for its "value" member.
 ///</returns>
 private static DataValue ConvertString(string input)
 {//Replaced by method in DataValueFactory...
     DataValue dv = new StringValue();
     ((StringValue)dv).value = input;
     return dv;
 }