Example #1
0
        /// <summary>
        /// Notify all interested nodes in the immutable grid a site model has changed attributes
        /// </summary>
        public void ModelAttributesChanged(SiteModelNotificationEventGridMutability targetGrids,
                                           Guid siteModelID,
                                           bool existenceMapChanged = false,
                                           ISubGridTreeBitMask existenceMapChangeMask = null,
                                           bool designsChanged             = false,
                                           bool surveyedSurfacesChanged    = false,
                                           bool csibChanged                = false,
                                           bool machinesChanged            = false,
                                           bool machineTargetValuesChanged = false,
                                           bool machineDesignsModified     = false,
                                           bool proofingRunsModified       = false,
                                           bool alignmentsChanged          = false,
                                           bool siteModelMarkedForDeletion = false)
        {
            var gridFactory = DIContext.Obtain <ITRexGridFactory>();

            var evt = new SiteModelAttributesChangedEvent
            {
                SiteModelID                 = siteModelID,
                ExistenceMapModified        = existenceMapChanged,
                ExistenceMapChangeMask      = existenceMapChangeMask?.ToBytes(),
                CsibModified                = csibChanged,
                DesignsModified             = designsChanged,
                SurveyedSurfacesModified    = surveyedSurfacesChanged,
                MachinesModified            = machinesChanged,
                MachineTargetValuesModified = machineTargetValuesChanged,
                MachineDesignsModified      = machineDesignsModified,
                ProofingRunsModified        = proofingRunsModified,
                AlignmentsModified          = alignmentsChanged,
                SiteModelMarkedForDeletion  = siteModelMarkedForDeletion,
                ChangeEventUid              = Guid.NewGuid(),
                TimeSentUtc                 = DateTime.UtcNow
            };

            /*
             * if ((targetGrids & SiteModelNotificationEventGridMutability.NotifyImmutable) != 0)
             * gridFactory.Grid(StorageMutability.Immutable).GetMessaging().SendOrdered(evt, MESSAGE_TOPIC_NAME, _messageSendTimeout);
             *
             * if ((targetGrids & SiteModelNotificationEventGridMutability.NotifyMutable) != 0)
             * gridFactory.Grid(StorageMutability.Mutable).GetMessaging().SendOrdered(evt, MESSAGE_TOPIC_NAME, _messageSendTimeout);
             */

            if ((targetGrids & SiteModelNotificationEventGridMutability.NotifyImmutable) != 0)
            {
                evt.SourceNodeUid = gridFactory.Grid(StorageMutability.Immutable).GetCluster().GetLocalNode().Id;
                SendInvokeStyleMessage("Immutable", evt);
            }

            if ((targetGrids & SiteModelNotificationEventGridMutability.NotifyMutable) != 0)
            {
                evt.SourceNodeUid = gridFactory.Grid(StorageMutability.Mutable).GetCluster().GetLocalNode().Id;
                SendInvokeStyleMessage("Mutable", evt);
            }
        }
Example #2
0
        /// <summary>
        /// Creates a change map buffer queue item and places it in to the cache for the service processor to collect
        /// </summary>
        public void Notify(Guid projectUid, DateTime insertUtc, ISubGridTreeBitMask changeMap, SiteModelChangeMapOrigin origin, SiteModelChangeMapOperation operation)
        {
            try
            {
                _log.LogInformation($"Adding site model change map notification for project {projectUid}");

                _queueCache.Put(new SiteModelChangeBufferQueueKey(projectUid, insertUtc),
                                new SiteModelChangeBufferQueueItem
                {
                    ProjectUID = projectUid,
                    InsertUTC  = insertUtc,
                    Operation  = operation,
                    Origin     = origin,
                    Content    = changeMap?.ToBytes()
                });
            }
            catch (Exception e)
            {
                _log.LogError(e, "Exception notifying site model change map");
            }
        }
Example #3
0
        private void TestSiteModelAndChangeMap_Ingest(ISiteModel siteModel, ISubGridTreeBitMask changeMap, int finalBitCount)
        {
            var insertUtc = DateTime.UtcNow;
            var key       = new SiteModelChangeBufferQueueKey(siteModel.ID, insertUtc);
            var value     = new SiteModelChangeBufferQueueItem
            {
                ProjectUID = siteModel.ID,
                MachineUid = siteModel.Machines.First().ID,
                InsertUTC  = insertUtc,
                Operation  = SiteModelChangeMapOperation.AddSpatialChanges,
                Origin     = SiteModelChangeMapOrigin.Ingest,
                Content    = changeMap.ToBytes()
            };

            PerformProcessEvent(key, value);

            // Check there is now a change map item for the site model with the given content
            var changeMapProxy  = new SiteModelChangeMapProxy();
            var resultChangeMap = changeMapProxy.Get(key.ProjectUID, value.MachineUid);

            resultChangeMap.Should().NotBeNull();
            resultChangeMap.CountBits().Should().Be(finalBitCount);
        }