Пример #1
0
        private static void FuzzLocationValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double stdDev = targetDV.stdDev;
            double X      = ((LocationValue)((DetectedAttributeValue)targetDV).value).X;
            double Y      = ((LocationValue)((DetectedAttributeValue)targetDV).value).Y;
            double Z      = ((LocationValue)((DetectedAttributeValue)targetDV).value).Z;

            double r = random.NextDouble();// in [0,1]
            double x = ZInverse.FindZ(r);

            r = random.NextDouble();// in [0,1]
            double y = ZInverse.FindZ(r);

            r = random.NextDouble();// in [0,1]
            double z = ZInverse.FindZ(r);



            //obfuscate X
            ((LocationValue)((DetectedAttributeValue)targetDV).value).X = (double)(x * stdDev + X);
            //obfuscate Y
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Y = (double)(y * stdDev + Y);
            //obfuscate Z
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Z = (double)(z * stdDev + Z);
            //exit
            // No: let smaller confidence be what chooses a value in ViewPro   targetDV.stdDev = GetConfidence(Y) * 100;
        }
Пример #2
0
        private static void FuzzVelocityValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double stdDev = targetDV.stdDev;

            double VX = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX;
            double VY = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY;
            double VZ = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ;
            double r  = random.NextDouble();// in [0,1]
            double vx = ZInverse.FindZ(r);

            r = random.NextDouble();
            double vy = ZInverse.FindZ(r);

            r = random.NextDouble();
            double vz = ZInverse.FindZ(r);


            //add noise to  VX
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX = (double)(vx * stdDev + VX);
            //add noise toe VY
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY = (double)(vy * stdDev + VY);
            //add noise to VZ
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ = (double)(vz * stdDev + VZ);
            //exit
            //No: let smaller confidence be what chooses a value in ViewProtargetDV.confidence= 1/stdDev;
        }
Пример #3
0
        private static void FuzzStringValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            // the input is the probability that a single character of the string will be transformed.
            //if transformed, it can become any character of the extended set with equal probability
            // in addition every nth (n=3) character might be preceded by a randomly
            // chosen character
            int    growthFactor = 3;
            string characters   = "abcdefghijklmnopqrstuvwxyz"
                                  +
                                  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                  +
                                  "0123456789"
                                  +
                                  "!@#$%^&*()?<>~";

            char[] cArray      = characters.ToCharArray();
            double probability = targetDV.probability;

            if ((0 >= probability) || (probability > 1))
            {
                return;// what do do about confidence here?
            }
            string strVal    = ((StringValue)((DetectedAttributeValue)targetDV).value).value;
            int    strLen    = strVal.Length;
            int    newStrLen = strLen + (int)((strLen + growthFactor) / growthFactor);

            StringBuilder newBuiltString = new StringBuilder(strLen, newStrLen);

            char[] strToChar = strVal.ToCharArray();
            for (int i = 0; i < strLen; i++)
            {
                if (0 == i % growthFactor)
                {
                    // insert a character?
                    if (random.NextDouble() < probability)
                    {
                        newBuiltString.Append(cArray[(int)random.Next(cArray.Length - 1)]);
                    }
                }
                if (random.NextDouble() >= probability)
                {
                    newBuiltString.Append(strToChar[i]);
                }
                else
                {
                    newBuiltString.Append(cArray[(int)random.Next(cArray.Length - 1)]);
                }
            }

            ((StringValue)((DetectedAttributeValue)targetDV).value).value = newBuiltString.ToString();
            // No: let smaller confidence be what chooses a value in ViewPro targetDV.confidence = 1 / probability;
        }
Пример #4
0
 /// <summary>
 /// Given a detected value and an attribute collection, the detected value will be added to the collection only
 /// if the attribute is already not-existant within the collection, or if its confidence is higher.
 /// </summary>
 /// <param name="ACV"></param>
 /// <param name="attributeName"></param>
 /// <param name="dav"></param>
 private void AddAttributeToACV(ref AttributeCollectionValue ACV, string attributeName, DetectedAttributeValue dav)
 {
     if (ACV.attributes.ContainsKey(attributeName))
     {
         if (((DetectedAttributeValue)dav).stdDev > ((DetectedAttributeValue)ACV[attributeName]).stdDev)
         {
             ACV[attributeName] = dav;
         }
     }
     else
     {
         ACV.attributes.Add(attributeName, dav);
     }
 }
Пример #5
0
        private static void FuzzDoubleValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            // not called if stdDev=0
            double stdDev = targetDV.stdDev;
            double dblVal = ((DoubleValue)((DetectedAttributeValue)targetDV).value).value;
            double r      = random.NextDouble();// in [0,1]
            double z      = ZInverse.FindZ(r);


            //add noise to double
            ((DoubleValue)((DetectedAttributeValue)targetDV).value).value = (double)(z * stdDev + dblVal);
            //exit
            // No: let smaller confidence be what chooses a value in ViewPro targetDV.confidence = 1 / stdDev;
        }
Пример #6
0
        /// <summary>
        /// This method retrieves all sensable attributes from the target proxy into the referenced attribute collection value.
        /// </summary>
        /// <param name="ACV">Current collection to add attributes into.</param>
        /// <param name="targetProxy">SimulationProxy to retrieve attributes from.</param>
        private void SenseAllAttributes(ref AttributeCollectionValue singleObjectACV, SimulationObjectProxy targetProxy)
        {
            //for the target object, go through each observable attribute, and add to the view with full confidence.
            string targetObjectID = ((StringValue)targetProxy["ID"].GetDataValue()).value;
            string objectType     = targetProxy.GetObjectType();
            DetectedAttributeValue dav;
            List <string>          keys = targetProxy.GetKeys();

            foreach (string att in simModel.objectModel.objects[objectType].attributes.Keys)
            {
                if (simModel.objectModel.objects[objectType].attributes[att].otherObservable)
                {
                    if (keys.Contains(att))
                    {
                        dav = new DetectedAttributeValue();

                        if (att == "CustomAttributes")
                        {
                            DataValue t = targetProxy[att].GetDataValue();
                            if (t.dataType == "CustomAttributesType")
                            {
                                Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                t = new CustomAttributesValue();
                                ((CustomAttributesValue)t).attributes = copiedDict;
                            }

                            dav        = new DetectedAttributeValue();
                            dav.stdDev = 100;
                            dav.value  = DataValueFactory.BuildFromDataValue(t);
                            //AddAttributeToACV(ref singleAttributeCollection, simModelAtt.Key, detectedAttribute);
                        }
                        else
                        {
                            dav.value  = DataValueFactory.BuildFromDataValue(targetProxy[att].GetDataValue());
                            dav.stdDev = 100;
                        }
                        if (((AttributeCollectionValue)singleObjectACV).attributes.ContainsKey(att))
                        {
                            ((AttributeCollectionValue)singleObjectACV)[att] = dav;
                        }
                        else
                        {
                            ((AttributeCollectionValue)singleObjectACV).attributes.Add(att, dav);
                        }
                    }
                }
            }
        }
Пример #7
0
        private static void ObfuscateDoubleValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double dblVal     = ((DoubleValue)((DetectedAttributeValue)targetDV).value).value;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //double area = (double)(random.Next((int)(Z * 10), (int)(Z * -10)) / 10.0);


            //obfuscate int
            ((DoubleValue)((DetectedAttributeValue)targetDV).value).value = (double)(Z * confidence + dblVal);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Пример #8
0
        //detection
        public static DetectedAttributeValue Detection(LocationValue sensingLocation,
                                                       LocationValue emittingLocation,
                                                       DataValue emittingObjectAttribute,
                                                       List <ConeValue> sensingCones,
                                                       Dictionary <string, double> emitters,
                                                       List <SimulationObjectProxy> obstructions,
                                                       ref Random random)
        {
            DetectedAttributeValue returnDAV = new DetectedAttributeValue();
            Vec3D  sensingPoint                 = new Vec3D(sensingLocation);
            Vec3D  emittingPoint                = new Vec3D(emittingLocation);
            Vec3D  sensingDirection             = new Vec3D(sensingPoint); //can't set to blank, just ignore.
            double coneAngle                    = 0.0;
            double angleBetweenSensorAndEmitter = 0.0;

            foreach (ConeValue cone in sensingCones)
            {
                sensingDirection.Set(cone.direction);
                Vec3D closestPoint = FindClosestPoint(sensingPoint, sensingDirection, emittingPoint);
                if (cone.extent > sensingPoint.ScalerDistanceTo(closestPoint))
                {                                            //p* is within the cone's extent.
                    //determine if emitting point is within the spread of the cone.
                    coneAngle = cone.spread * Math.PI / 180; // System.Math.Atan(emittingPoint.ScalerDistanceTo(closestPoint) / sensingPoint.ScalerDistanceTo(closestPoint));//should be cone.spread
                    angleBetweenSensorAndEmitter = System.Math.Atan(emittingPoint.ScalerDistanceTo(closestPoint) / sensingPoint.ScalerDistanceTo(closestPoint));

                    if (coneAngle < angleBetweenSensorAndEmitter)
                    {
                        continue; //should go to next cone.
                    }
                    if (emitters.ContainsKey(cone.level))
                    {//emitter has an emission at the same level as the cone.
                        //returnDAV = (DetectedAttributeValue)ObfuscateAttributeValue(emittingObjectAttribute, emitters[cone.level], ref random);
                        returnDAV = (DetectedAttributeValue)FuzzAttributeValue(emittingObjectAttribute, emitters[cone.level], ref random);

                        return(returnDAV);
                    }
                    else
                    { //emitter does not emit the same level as the cone.
                      //should this find next best, or just move on?
                    }
                }
            }

            return(null);
        }
Пример #9
0
// If an attribute is fixed to integers, it is either ordinal or a count (probably)
        // Normal distribution doesn't apply
        private static void FuzzIntegerValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double probability = targetDV.stdDev;
            int    intVal      = ((IntegerValue)((DetectedAttributeValue)targetDV).value).value;

            int newInt = intVal;

            if (probability < random.NextDouble())
            {
                newInt = random.Next(2 * intVal);// 2* is "random" in the other sense
            }
            if (intVal < 0)
            {
                newInt = -newInt;
            }
            //obfuscate int
            ((IntegerValue)((DetectedAttributeValue)targetDV).value).value = newInt;
            //exit
        }
Пример #10
0
        private static void ObfuscateLocationValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double x          = ((LocationValue)((DetectedAttributeValue)targetDV).value).X;
            double y          = ((LocationValue)((DetectedAttributeValue)targetDV).value).Y;
            double z          = ((LocationValue)((DetectedAttributeValue)targetDV).value).Z;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //obfuscate X
            ((LocationValue)((DetectedAttributeValue)targetDV).value).X = (double)(Z * confidence + x);
            //obfuscate Y
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Y = (double)(Z * confidence + y);
            //obfuscate Z
            ((LocationValue)((DetectedAttributeValue)targetDV).value).Z = (double)(Z * confidence + z);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Пример #11
0
        private static void ObfuscateVelocityValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            double vx         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX;
            double vy         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY;
            double vz         = ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);

            //double area = (double)(random.Next((int)(Z * 10), (int)(Z * -10)) / 10.0);

            //obfuscate VX
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VX = (double)(Z * confidence + vx);
            //obfuscate VY
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VY = (double)(Z * confidence + vy);
            //obfuscate VZ
            ((VelocityValue)((DetectedAttributeValue)targetDV).value).VZ = (double)(Z * confidence + vz);
            //exit
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Пример #12
0
/* *************************************************************** */
        private static DataValue FuzzAttributeValue(DataValue dv, double confidence, ref Random random)
        { //maybe pass level as well, have a sim model def of how each model affects clarity?
            DetectedAttributeValue returnValue = new DetectedAttributeValue();

            ((DetectedAttributeValue)returnValue).value  = dv;
            ((DetectedAttributeValue)returnValue).stdDev = confidence;
            //check data type
            string attributeType = dv.dataType;

            //switch statement
            switch (attributeType)
            {
            case "LocationType":
                FuzzLocationValue(ref returnValue, ref random);
                break;

            case "VelocityType":
                FuzzVelocityValue(ref returnValue, ref random);
                break;

            case "IntegerType":
                FuzzIntegerValue(ref returnValue, ref random);
                break;

            case "DoubleType":
                FuzzDoubleValue(ref returnValue, ref random);
                break;

            case "StringType":
                FuzzStringValue(ref returnValue, ref random);
                break;

            default:
                break;
            }

            return(returnValue as DataValue);
        }
Пример #13
0
        private static void ObfuscateStringValue(ref DetectedAttributeValue targetDV, ref Random random)
        {
            double confidence = targetDV.stdDev;
            string strVal     = ((StringValue)((DetectedAttributeValue)targetDV).value).value;
            double X          = random.NextDouble();
            double Y          = .5 - (X / 2);
            double Z          = ZTransformer.ZTransformGivenProbability(Y);
            int    strLen     = strVal.Length;

            strLen = (int)Math.Round((Z * confidence) + strLen, 0);
            char[] str;
            if (strLen <= strVal.Length)
            {
                str = strVal.ToCharArray(0, strLen);
            }
            else
            {
                for (int b = strVal.Length; b < strLen; b++)
                {
                    strVal += Convert.ToChar(random.Next(49, 122));
                }
                str = strVal.ToCharArray();
            }
            StringBuilder sb = new StringBuilder();

            for (int a = 0; a < strLen; a++)
            {
                int asciiVal = Convert.ToInt32(str[a]);
                asciiVal = (int)Math.Round((ZTransformer.ZTransformGivenProbability(.5 - (random.NextDouble() / 2)) * confidence) + asciiVal, 0);
                //str[a] = Convert.ToChar(asciiVal);
                sb.Append(Convert.ToChar(asciiVal));
            }
            //((StringValue)((DetectedAttributeValue)targetDV).attribute).value = str.ToString();
            ((StringValue)((DetectedAttributeValue)targetDV).value).value = sb.ToString();
            targetDV.stdDev = GetConfidence(Y) * 100;
        }
Пример #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="allObjectViews"></param>
        private void SenseAllObjects(ref Dictionary <string, Dictionary <string, AttributeCollectionValue> > allObjectsViews)
        {
            SimulationObjectProxy sensingProxy        = null;
            SimulationObjectProxy targetProxy         = null;
            Vec3D                    sensingLocation  = null;
            Vec3D                    targetsLocation  = null;
            LocationValue            senLocation      = null;
            LocationValue            tarLocation      = null;
            double                   distance         = 0.0;
            SensorArrayValue         sav              = null;
            DataValue                targetsAttribute = null;
            string                   ownerID          = null;
            string                   objectType       = null;
            DetectedAttributeValue   detectedAttribute;
            AttributeCollectionValue singleAttributeCollection = null;
            bool isSensed = false;

            // The dictionary is constantly created in this method //
            Dictionary <string, AttributeCollectionValue> singleObjectView;

            //AD to improve this later:
            // for each object in the visible ObjectDistances collection
            //    for each object after the current index
            //       check for the index object's view of the nested object
            //       check for the nested object's view of the index object
            //Possible hangup is the "All" emitter.



            int x = 0;

            //Each object senses each other object
            //foreach (string sensorObjectID in listOfObjectIDs)
            foreach (KeyValuePair <string, List <string> > networks in networkRosters)
            {
                if (!activeSensorNetworks[networks.Key])
                {
                    continue;
                }
                foreach (string sensorObjectID in networkObjects[networks.Key])
                {
                    sensingProxy = objectProxies[sensorObjectID];
                    objectType   = sensingProxy.GetObjectType();
                    senLocation  = sensingProxy["Location"].GetDataValue() as LocationValue;
                    if (senLocation.exists)
                    {
                        ownerID          = ((StringValue)sensingProxy["OwnerID"].GetDataValue()).value;
                        singleObjectView = new Dictionary <string, AttributeCollectionValue>();
                        x++;
                        //foreach (string targetObjectID in listOfObjectIDs)
                        foreach (List <string> objects in networkObjects.Values)
                        {
                            if (objects.Contains(sensorObjectID))
                            {
                                if (((EmitterValue)sensingProxy["Emitters"].GetDataValue()).emitters.ContainsKey("Invisible"))
                                //OR if it's the "master" object for a region?? -lisa
                                {
                                    continue;
                                }
                                string target = sensorObjectID;

                                singleAttributeCollection = new AttributeCollectionValue();
                                foreach (KeyValuePair <string, AttributeInfo> simModelAtt in simModel.objectModel.objects[objectType].attributes)
                                {
                                    if (!simModelAtt.Value.ownerObservable == true)
                                    {
                                        continue;
                                    }
                                    //if (!sensingProxy.GetKeys().Contains(simModelAtt.Key))
                                    //    continue;
                                    DataValue t = sensingProxy[simModelAtt.Key].GetDataValue();
                                    if (t.dataType == "CustomAttributesType")
                                    {
                                        Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                        t = new CustomAttributesValue();
                                        ((CustomAttributesValue)t).attributes = copiedDict;
                                    }
                                    detectedAttribute        = new DetectedAttributeValue();
                                    detectedAttribute.stdDev = 100;
                                    detectedAttribute.value  = DataValueFactory.BuildFromDataValue(t);
                                    AddAttributeToACV(ref singleAttributeCollection, simModelAtt.Key, detectedAttribute);
                                }//end foreach sensable attribute

                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                {
                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                }
                                if (!objectViews.ContainsKey(sensorObjectID))
                                {
                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                }
                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                //to users.
                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(target, singleAttributeCollection);

                                //if (changedAttributes != null && selectedRangeRingLevel != RangeRingLevels.DISABLED)
                                //{
                                //    CalculateRangeRings(ref changedAttributes, ref sensingProxy);
                                //}

                                if (changedAttributes != null)
                                {
                                    allObjectsViews[sensorObjectID].Add(target, changedAttributes);
                                }
                                else//this is so there is at least the empty entry for the detected object so
                                //you still know it is detected.
                                {
                                    if (!allObjectsViews[sensorObjectID].ContainsKey(target))
                                    {
                                        allObjectsViews[sensorObjectID].Add(target, new AttributeCollectionValue());
                                    }
                                }
                            }
                            else
                            {
                                foreach (string targetObjectID in objects)
                                {//sensing and target objects are not the same
                                    targetProxy = objectProxies[targetObjectID];
                                    tarLocation = targetProxy["Location"].GetDataValue() as LocationValue;
                                    if (tarLocation.exists)
                                    {
                                        EmitterValue emitters = targetProxy["Emitters"].GetDataValue() as EmitterValue;
                                        if (emitters.emitters.ContainsKey("All"))
                                        {
                                            //if an object has an all emitter, retrieve all attributes without sensing algorithm
                                            AttributeCollectionValue atts = new AttributeCollectionValue();
                                            if (singleObjectView.ContainsKey(targetObjectID))
                                            {
                                                atts = singleObjectView[targetObjectID];
                                            }
                                            SenseAllAttributes(ref atts, targetProxy);
                                            singleObjectView[targetObjectID] = atts;
                                            isSensed = true;

                                            if (!allObjectsViews.ContainsKey(sensorObjectID))
                                            {
                                                allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                            }
                                            if (!objectViews.ContainsKey(sensorObjectID))
                                            {
                                                objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                            }
                                            //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                            //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                            //to users.
                                            AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, atts);

                                            //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                            //{//the only way to sense a "target" here is for FULL ring display
                                            //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                            //}

                                            if (changedAttributes != null)
                                            {
                                                allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                            }
                                            else//this is so there is at least the empty entry for the detected object so
                                            //you still know it is detected.
                                            {
                                                if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                }
                                            }
                                        }
                                        else if (emitters.emitters.ContainsKey("Invisible"))
                                        //or if object is "master" for moving region -lisa
                                        {
                                            continue;
                                        }
                                        else
                                        {//object does not have an all emitter, continue to check each emitter value
                                            AttributeCollectionValue atts = new AttributeCollectionValue();
                                            if (Omniscience)
                                            {
                                                if (singleObjectView.ContainsKey(targetObjectID))
                                                {
                                                    atts = singleObjectView[targetObjectID];
                                                }
                                                SenseAllAttributes(ref atts, targetProxy);
                                                singleObjectView[targetObjectID] = atts;
                                                isSensed = true;
                                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                                {
                                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                                }
                                                if (!objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                                }
                                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                                //to users.
                                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, atts);

                                                //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                                //{//the only way to sense a "target" here is for FULL ring display
                                                //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                                //}

                                                if (changedAttributes != null)
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                                }
                                                else//this is so there is at least the empty entry for the detected object so
                                                //you still know it is detected.
                                                {
                                                    if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                    {
                                                        allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                    }
                                                }
                                                continue;
                                            }

                                            sensingLocation = new Vec3D(senLocation);
                                            targetsLocation = new Vec3D(tarLocation);
                                            isSensed        = false;
                                            distance        = sensingLocation.ScalerDistanceTo(targetsLocation);
                                            sav             = sensingProxy["Sensors"].GetDataValue() as SensorArrayValue;

                                            foreach (SensorValue sv in sav.sensors)
                                            {
                                                if (distance < sv.maxRange)
                                                {
                                                    //Find obstructions
                                                    List <SimulationObjectProxy> obstructions = FindObstructions(sensingLocation, targetsLocation);

                                                    foreach (KeyValuePair <string, List <ConeValue> > kvp in sv.ranges)
                                                    { //Key is the attribute being sensed, value is a list of cones
                                                        if (kvp.Key == "All")
                                                        {
                                                            atts = new AttributeCollectionValue();
                                                            if (singleObjectView.ContainsKey(targetObjectID))
                                                            {
                                                                atts = singleObjectView[targetObjectID];
                                                            }
                                                            SenseAllAttributes(ref atts, targetProxy);
                                                            singleObjectView[targetObjectID] = atts;
                                                            isSensed = true;
                                                        }
                                                        else //not an All sensor, so run detection algorithm
                                                        {//Added in main-line
                                                            if (!emitters.emitters.ContainsKey(kvp.Key))
                                                            {
                                                                continue;
                                                            }
                                                            //Custom attributes fix:
                                                            DataValue currentDataValue;
                                                            try
                                                            {
                                                                currentDataValue = targetProxy[kvp.Key].GetDataValue();
                                                            }
                                                            catch
                                                            {
                                                                currentDataValue = targetProxy["CustomAttributes"].GetDataValue();
                                                                currentDataValue = ((CustomAttributesValue)currentDataValue)[kvp.Key];
                                                                //will throw an error here if object doesn't contain custom atts, or
                                                                //if it doesnt contain the specified custom att.
                                                            }

                                                            bool isObstructed = false;
                                                            foreach (SimulationObjectProxy reg in obstructions)
                                                            {
                                                                foreach (string attributeBlocked in ((StringListValue)reg["BlocksSensorTypes"].GetDataValue()).strings)
                                                                {
                                                                    if (kvp.Key == attributeBlocked)
                                                                    {
                                                                        isObstructed = true;
                                                                    }
                                                                }
                                                            }
                                                            if (isObstructed)
                                                            {
                                                                detectedAttribute            = new DetectedAttributeValue();
                                                                detectedAttribute.value      = DataValueFactory.BuildValue(currentDataValue.dataType);
                                                                detectedAttribute.confidence = 0;
                                                                //continue;
                                                            }
                                                            else
                                                            {
                                                                targetsAttribute = DataValueFactory.BuildFromDataValue(currentDataValue);
                                                                //ev is emitters
                                                                Dictionary <string, double> emitterCollection = emitters.emitters[kvp.Key];

                                                                detectedAttribute = new DetectedAttributeValue();
                                                                detectedAttribute = ObjectMath.Detection(senLocation, tarLocation, targetsAttribute, kvp.Value, emitterCollection, obstructions, ref randomGenerator);
                                                            }
                                                            if (detectedAttribute != null)
                                                            {
                                                                singleAttributeCollection = new AttributeCollectionValue();
                                                                if (singleObjectView.ContainsKey(targetObjectID))
                                                                {
                                                                    singleAttributeCollection = singleObjectView[targetObjectID];
                                                                }
                                                                AddAttributeToACV(ref singleAttributeCollection, kvp.Key, detectedAttribute);
                                                                isSensed = true;
                                                            }
                                                        }
                                                    }//end foreach attribute in sensor

                                                    //if the object has any attributes sensed, fill in some other info for the object's view.
                                                    if (isSensed)
                                                    {
                                                        detectedAttribute        = new DetectedAttributeValue();
                                                        detectedAttribute.stdDev = 100;
                                                        detectedAttribute.value  = targetProxy["ID"].GetDataValue();
                                                        if (singleAttributeCollection == null)
                                                        {
                                                            singleAttributeCollection = new AttributeCollectionValue();
                                                        }
                                                        if (!singleObjectView.ContainsKey(targetObjectID))
                                                        {
                                                            singleObjectView.Add(targetObjectID, singleAttributeCollection);
                                                        }
                                                        singleAttributeCollection = singleObjectView[targetObjectID];
                                                        AddAttributeToACV(ref singleAttributeCollection, "ID", detectedAttribute);

                                                        detectedAttribute        = new DetectedAttributeValue();
                                                        detectedAttribute.stdDev = 100;
                                                        detectedAttribute.value  = targetProxy["OwnerID"].GetDataValue();
                                                        AddAttributeToACV(ref singleAttributeCollection, "OwnerID", detectedAttribute);
                                                    } //end if isSensed.
                                                }
                                            }         //end foreach sensor in sensor array

                                            if (singleObjectView.ContainsKey(targetObjectID))
                                            {
                                                AttributeCollectionValue attr = singleObjectView[targetObjectID];
                                                if (!allObjectsViews.ContainsKey(sensorObjectID))
                                                {
                                                    allObjectsViews.Add(sensorObjectID, new Dictionary <string, AttributeCollectionValue>());
                                                }
                                                if (!objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    objectViews.Add(sensorObjectID, new ObjectsAttributeCollection());
                                                }

                                                if (attr.attributes.ContainsKey("CustomAttributes"))
                                                {
                                                    DataValue t    = ((DetectedAttributeValue)attr["CustomAttributes"]).value;
                                                    double    conf = ((DetectedAttributeValue)attr["CustomAttributes"]).confidence;
                                                    Dictionary <string, DataValue> copiedDict = CopyFromCustomAttributes(((CustomAttributesValue)t).attributes);
                                                    t = new CustomAttributesValue();
                                                    ((CustomAttributesValue)t).attributes = copiedDict;
                                                    attr.attributes.Remove("CustomAttributes");
                                                    attr.attributes.Add("CustomAttributes", DataValueFactory.BuildDetectedValue(t, Convert.ToInt32(conf)));
                                                }
                                                //update the global "allObjectViews".  The return from UpdateObject is the collection of attributes
                                                //that have changed.  These attributes are stored in allObjectsViews and then sent out
                                                //to users.
                                                AttributeCollectionValue changedAttributes = objectViews[sensorObjectID].UpdateObject(targetObjectID, attr);

                                                //if (changedAttributes != null && selectedRangeRingLevel == RangeRingLevels.FULL)
                                                //{//the only way to sense a "target" here is for FULL ring display
                                                //    CalculateRangeRings(ref changedAttributes, ref targetProxy);
                                                //}

                                                if (changedAttributes != null)
                                                {
                                                    allObjectsViews[sensorObjectID].Add(targetObjectID, changedAttributes);
                                                }
                                                else//this is so there is at least the empty entry for the detected object so
                                                //you still know it is detected.
                                                {
                                                    if (!allObjectsViews[sensorObjectID].ContainsKey(targetObjectID))
                                                    {
                                                        allObjectsViews[sensorObjectID].Add(targetObjectID, new AttributeCollectionValue());
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (objectViews.ContainsKey(sensorObjectID))
                                                {
                                                    if (objectViews[sensorObjectID].ContainsObject(targetObjectID))
                                                    {
                                                        objectViews[sensorObjectID].RemoveObject(targetObjectID);
                                                        //if you once knew of this object, and now don't, remove it from object's view.
                                                    }
                                                }
                                            }
                                        } //end emitter detection
                                    }     //end if target is visible
                                }
                            }
                        } //end foreach target object
                    }     //end if sensor is visible
                }         //end of foreach sensing object
            }             //end of Foreach sensor network
            if (x > 0)
            {
                //Console.Out.WriteLine("ViewPro: {0} objects were sensing at time {1}.", x, currentTick / 1000);
            }
        }