private void load() { var space = new Dictionary <SpaceId, List <int> >(); for (int i = 0; i < DataSet.Count; i++) { var position = DataSet[i].Position; var x = (int)(position.x / NodeSize); var y = (int)(position.y / NodeSize); var z = (int)(position.z / NodeSize); var spaceId = new SpaceId(x, y, z); if (!space.ContainsKey(spaceId)) { space[spaceId] = new List <int>(); } space[spaceId].Add(i); } _offset.x = -space.Min(pair => pair.Key.x); _len.x = space.Max(pair => pair.Key.x) + _offset.x; _offset.y = -space.Min(pair => pair.Key.y); _len.y = space.Max(pair => pair.Key.y) + _offset.y; _offset.z = -space.Min(pair => pair.Key.z); _len.z = space.Max(pair => pair.Key.z) + _offset.z; _space = new List <int> [_len.x + 1, _len.y + 1, _len.z + 1]; foreach (var spaceKey in space) { var x = spaceKey.Key.x + _offset.x; var y = spaceKey.Key.y + _offset.y; var z = spaceKey.Key.z + _offset.z; try { _space[x, y, z] = spaceKey.Value; } catch (IndexOutOfRangeException) { Debug.LogError("error add node at space, x:" + x + "/" + _len.x + " y:" + y + " / " + _len.y + " z:" + z + "/" + _len.z); } } _isLoaded = true; }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); UserDefinedFunction refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetUDFFromCache(memoryCache, Id); if (refInCache != null) { if (Name != null && !Name.Equals(refInCache.Name)) { changes.Add("Name", Name); refInCache.Name = Name; } if (!SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); refInCache.SpaceId = SpaceId; } if (MatchersHasChanged) { changes.Add("Matchers", GetMatchersIds()); refInCache.Matchers = Matchers; } } else { refInCache = this; if (Name != null) { changes.Add("Name", Name); } if (SpaceId != null && SpaceId != Guid.Empty) { changes.Add("SpaceId", SpaceId); } if (MatchersHasChanged) { changes.Add("Matchers", GetMatchersIds()); } } } updatedElement = refInCache; return(changes); }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); Matcher refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetMatcherFromCache(memoryCache, Id); if (refInCache != null) { changes.Add("Name", Name); if (!SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); } changes.Add("Conditions", Conditions); //if (!Conditions.Equals(refInCache.Conditions)) changes.Add("Conditions", Conditions); if (UserDefinedFunctions != null && UserDefinedFunctions.Equals(refInCache.UserDefinedFunctions)) { changes.Add("UserDefinedFunctions", UserDefinedFunctions); } } else { refInCache = this; if (Name != null) { changes.Add("Name", Name); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } if (Conditions != null) { changes.Add("Conditions", Conditions); } if (UserDefinedFunctions != null) { changes.Add("UserDefinedFunctions", UserDefinedFunctions); } } } updatedElement = refInCache; return(changes); }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); Device refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetDeviceFromCache(memoryCache, Id); if (refInCache != null) { if (Name != null && !Name.Equals(refInCache.Name)) { changes.Add("Name", Name); refInCache.Name = Name; } if (HardwareId != null && !HardwareId.Equals(refInCache.HardwareId)) { changes.Add("HardwareId", HardwareId); refInCache.HardwareId = HardwareId; } if (SpaceId != null && !SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); refInCache.SpaceId = SpaceId; } if (Type != null && !Type.Equals(refInCache.Type)) { changes.Add("Type", Type); refInCache.Type = Type; } if (SubType != null && !SubType.Equals(refInCache.SubType)) { changes.Add("SubType", SubType); refInCache.SubType = SubType; } } else { refInCache = this; if (Name != null) { changes.Add("Name", Name); } if (HardwareId != null) { changes.Add("HardwareId", HardwareId); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } if (Type != null) { changes.Add("Type", Type); } if (SubType != null) { changes.Add("SubType", SubType); } } } updatedElement = refInCache; return(changes); }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); PropertyKey refInCache = null; if (Id != string.Empty) { refInCache = CacheHelper.GetPropertyKeyFromCache(memoryCache, Id); if (refInCache != null) { if (!Name.Equals(refInCache.Name)) { changes.Add("Name", Name); } if (!PrimitiveDataType.Equals(refInCache.PrimitiveDataType)) { changes.Add("PrimitiveDataType", this.PrimitiveDataType.ToString()); } if (!Category.Equals(refInCache.Category)) { changes.Add("Category", Category); } if (!Description.Equals(refInCache.Description)) { changes.Add("Description", Description); } if (!SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); } if (!Scope.Equals(refInCache.Scope)) { changes.Add("Scope", Scope.ToString()); } if (!ValidationData.Equals(refInCache.ValidationData)) { changes.Add("ValidationData", ValidationData); } if (!Min.Equals(refInCache.Min)) { changes.Add("Min", Min); } if (!Max.Equals(refInCache.Max)) { changes.Add("Max", Max); } } else { refInCache = this; if (Name != null) { changes.Add("Name", Name); } changes.Add("PrimitiveDataType", this.PrimitiveDataType.ToString()); if (Category != null) { changes.Add("Category", Category); } if (Description != null) { changes.Add("Description", Description); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } changes.Add("Scope", Scope.ToString()); if (ValidationData != null) { changes.Add("ValidationData", ValidationData); } if (Min != null) { changes.Add("Min", Min); } if (Max != null) { changes.Add("Max", Max); } } } updatedElement = refInCache; return(changes); }
public override Dictionary <string, object> ToUpdate(IMemoryCache memoryCache, out BaseModel updatedElement) { Dictionary <string, object> changes = new Dictionary <string, object>(); Sensor refInCache = null; if (Id != Guid.Empty) { refInCache = CacheHelper.GetSensorFromCache(memoryCache, Id); if (refInCache != null) { if (!DeviceId.Equals(refInCache.DeviceId)) { changes.Add("DeviceId", DeviceId); refInCache.DeviceId = DeviceId; } if (HardwareId != null && !HardwareId.Equals(refInCache.HardwareId)) { changes.Add("HardwareId", HardwareId); refInCache.HardwareId = HardwareId; } if (SpaceId != null && !SpaceId.Equals(refInCache.SpaceId)) { changes.Add("SpaceId", SpaceId); refInCache.SpaceId = SpaceId; } if (!PollRate.Equals(refInCache.PollRate)) { changes.Add("PollRate", PollRate); refInCache.PollRate = PollRate; } if (PortType != null && !PortType.Equals(refInCache.PortType)) { changes.Add("PortType", PortType); refInCache.PortType = PortType; } if (DataType != null && !DataType.Equals(refInCache.DataType)) { changes.Add("DataType", DataType); refInCache.DataType = DataType; } if (DataUnitType != null && !DataUnitType.Equals(refInCache.DataUnitType)) { changes.Add("DataUnitType", DataUnitType); refInCache.DataUnitType = DataUnitType; } if (DataSubtype != null && !DataSubtype.Equals(refInCache.DataSubtype)) { changes.Add("DataSubtype", DataSubtype); refInCache.DataSubtype = DataSubtype; } } else { refInCache = this; if (DeviceId != null) { changes.Add("DeviceId", DeviceId); } if (HardwareId != null) { changes.Add("HardwareId", HardwareId); } if (SpaceId != null) { changes.Add("SpaceId", SpaceId); } if (PollRate != 0) { changes.Add("PollRate", PollRate); } if (PortType != null) { changes.Add("PortType", PortType); } if (DataType != null) { changes.Add("DataType", DataType); } if (DataUnitType != null) { changes.Add("DataUnitType", DataUnitType); } if (DataSubtype != null) { changes.Add("DataSubTypeId", DataSubTypeId); } } } updatedElement = refInCache; return(changes); }