public SkyIslandMapChunkStorePopulator(
            IChunkStore <ChunkOverheadKey, SerializedSkyIslandMapChunk> store,
            IChunkPersister <ISkyIslandMapChunk, SerializedSkyIslandMapChunk> persister,
            IChunkPopulator <ISkyIslandMapChunk> fallback)
        {
            Contracts.Requires.That(store != null);
            Contracts.Requires.That(persister != null);
            Contracts.Requires.That(fallback != null);

            this.store     = store;
            this.persister = persister;
            this.fallback  = fallback;
        }
        public VoxelGridChunkStorePopulator(
            IChunkStore <ChunkKey, SerializedVoxelGridChunk> store,
            IChunkPersister <IVoxelGridChunk, SerializedVoxelGridChunk> persister,
            IChunkPopulator <IVoxelGridChunk> fallback)
        {
            Contracts.Requires.That(store != null);
            Contracts.Requires.That(persister != null);
            Contracts.Requires.That(fallback != null);

            this.store     = store;
            this.persister = persister;
            this.fallback  = fallback;
        }
        public ChunkedBatchingPhase(
            IStageIdentity stageIdentity,
            IGenerationPhaseIdentity phaseIdentity,
            IReadOnlyLargeCollection <TKey> chunkKeys,
            IAsyncFactory <TKey, TPersistable> chunkFactory,
            IChunkStore <TKey, TPersistable> chunkStore,
            int maxBatchedChunks,
            BatchGenerationOptions options = null)
            : base(options?.CancellationToken ?? DefaultCancellationToken)
        {
            Contracts.Requires.That(stageIdentity != null);
            Contracts.Requires.That(phaseIdentity != null);
            Contracts.Requires.That(chunkKeys != null);
            Contracts.Requires.That(chunkFactory != null);
            Contracts.Requires.That(chunkStore != null);
            Contracts.Requires.That(maxBatchedChunks > 0);

            this.StageIdentity = stageIdentity;
            this.PhaseIdentity = phaseIdentity;
            this.chunkKeys     = chunkKeys;
            this.chunkFactory  = chunkFactory;
            this.chunkStore    = chunkStore;

            this.Progress = this.progress.AsObservable();

            var dataflowOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism,
                BoundedCapacity        = maxBatchedChunks,
                CancellationToken      = this.CancellationToken,
            };

            this.generateChunks = new TransformBlock <TKey, TPersistable>(
                chunkIndex => this.chunkFactory.CreateAsync(chunkIndex), dataflowOptions);

            this.saveChunks = BatchActionBlock.Create <TPersistable>(
                this.SaveChunks,
                maxBatchedChunks,
                options?.Batching ?? DefaultBatching,
                dataflowOptions);

            var linkOptions = new DataflowLinkOptions()
            {
                PropagateCompletion = true
            };

            this.generateChunks.LinkTo(this.saveChunks, linkOptions);

            this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount);
        }
Ejemplo n.º 4
0
        public ContourPhase(
            IStageIdentity stageIdentity,
            IStageBounds stageBounds,
            IRasterChunkConfig <Index3D> voxelChunkConfig,
            IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory,
            IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer,
            IChunkStore <ChunkKey, SerializedMeshChunk> meshChunkStore,
            int maxBufferedChunks,
            BatchSerializeGenerationOptions options = null)
        {
            Contracts.Requires.That(stageIdentity != null);
            Contracts.Requires.That(stageBounds != null);
            Contracts.Requires.That(voxelChunkConfig != null);
            Contracts.Requires.That(voxelChunkFactory != null);
            Contracts.Requires.That(contourer != null);
            Contracts.Requires.That(meshChunkStore != null);
            Contracts.Requires.That(maxBufferedChunks > 0);

            var phaseIdentity = new GenerationPhaseIdentity(nameof(ContourPhase <TSurfaceData>));
            var chunkKeys     = new ChunkKeyCollection(stageBounds);

            var poolOptions = new PoolOptions <IMutableDivisibleMesh <NormalColorTextureVertex> >()
            {
                ResetAction = mesh => mesh.Clear(),
            };

            this.pool = Pool.WithFactory.New(
                Factory.From <IMutableDivisibleMesh <NormalColorTextureVertex> >(
                    () => new MutableDivisibleMesh <NormalColorTextureVertex>()),
                poolOptions);

            var chunkFactory = new ContourMeshFactory <TSurfaceData>(
                voxelChunkConfig, voxelChunkFactory, this.pool, contourer);
            var serializer = DivisibleMeshSerializer.NormalColorTextureVertices.WithColorAlpha[
                options?.SerializationEndianness ?? DefaultSerializationEndianness];
            var persistableFactory = new SerializeMeshChunkFactory(chunkFactory, serializer);

            this.Phase = new ChunkedBatchingPhase <ChunkKey, SerializedMeshChunk>(
                stageIdentity,
                phaseIdentity,
                chunkKeys,
                persistableFactory,
                meshChunkStore,
                maxBufferedChunks,
                options);

            this.Completion = this.CompleteAsync();
        }
        public SkyIslandMapAbsolutePhase(
            IStageIdentity stageIdentity,
            IStageBounds stageBounds,
            IRasterChunkConfig <Index2D> chunkConfig,
            IAsyncChunkPopulator <ISkyIslandMapChunk> chunkPopulator,
            IChunkStore <ChunkOverheadKey, SerializedSkyIslandMapChunk> chunkStore,
            int maxBufferedChunks,
            BatchSerializeGenerationOptions options = null)
        {
            Contracts.Requires.That(stageIdentity != null);
            Contracts.Requires.That(stageBounds != null);
            Contracts.Requires.That(chunkConfig != null);
            Contracts.Requires.That(chunkPopulator != null);
            Contracts.Requires.That(chunkStore != null);
            Contracts.Requires.That(maxBufferedChunks > 0);

            var phaseIdentity = new GenerationPhaseIdentity(nameof(SkyIslandMapAbsolutePhase));
            var chunkKeys     = new ChunkOverheadKeyCollection(stageBounds);

            var poolOptions = new PoolOptions <SkyIslandMapChunkResources>()
            {
            };

            this.pool = Pool.WithFactory.New(new SkyIslandMapChunkResourcesFactory(chunkConfig), poolOptions);

            var chunkFactory = new SkyIslandMapChunkPoolingFactory(this.pool, chunkPopulator);
            var serializer   = new SkyIslandMapChunkResourcesSerializer(
                SkyIslandMapsSerializer.Get[options?.SerializationEndianness ?? DefaultSerializationEndianness],
                chunkConfig);
            var persister          = new SkyIslandMapChunkPersister(serializer);
            var persistableFactory = ChunkFactory.Persister.Create(chunkFactory, persister);

            this.Phase = new ChunkedBatchingPhase <ChunkOverheadKey, SerializedSkyIslandMapChunk>(
                stageIdentity,
                phaseIdentity,
                chunkKeys,
                persistableFactory,
                chunkStore,
                maxBufferedChunks,
                options);

            this.Completion = this.CompleteAsync();
        }
Ejemplo n.º 6
0
        public Pv2ServerDeviceBase(IMavlinkV2Connection connection, IConfiguration cfgSvc,
                                   IEnumerable <Pv2ParamType> paramList, Pv2DeviceClass @class, IEnumerable <IWorkModeFactory> workModes,
                                   IChunkStore rttStore,
                                   IEnumerable <Pv2RttRecordDesc> rttRecords,
                                   IEnumerable <Pv2RttFieldDesc> rttFields, string configSuffix = "PV2")
        {
            var systemId    = (byte)Pv2DeviceParams.SystemId.ReadFromConfigValue(cfgSvc, configSuffix);
            var componentId = (byte)Pv2DeviceParams.ComponentId.ReadFromConfigValue(cfgSvc, configSuffix);
            var networkId   = (byte)Pv2DeviceParams.NetworkId.ReadFromConfigValue(cfgSvc, configSuffix);

            Seq = new PacketSequenceCalculator();
            var mavlinkServer = new MavlinkServerBase(connection, new MavlinkServerIdentity
            {
                ComponentId = componentId,
                SystemId    = systemId
            }, Seq).DisposeItWith(Disposable);

            _payloadServer = new PayloadV2Server(mavlinkServer, networkId).DisposeItWith(Disposable);

            var defaultParamsList =
                Pv2DeviceParams.Params.Concat(paramList)
                .Concat(Pv2BaseInterface.Params)
                .Concat(Pv2PowerInterface.Params)
                .Concat(Pv2RttInterface.Params)
                .Concat(Pv2MissionInterface.Params);

            _params = new Pv2ServerParamsInterface(_payloadServer, cfgSvc, defaultParamsList, configSuffix)
                      .DisposeItWith(Disposable);

            _base = new Pv2ServerBaseInterface(_payloadServer, @class, workModes).DisposeItWith(Disposable);

            _power = new Pv2ServerPowerInterface(_payloadServer, _params).DisposeItWith(Disposable);

            _rtt = new Pv2ServerRttInterface(_payloadServer, _base, _params, rttStore, rttRecords, rttFields)
                   .DisposeItWith(Disposable);

            _mission = new Pv2ServerMissionInterface(_payloadServer, _rtt, _base).DisposeItWith(Disposable);

            _base.OnLogMessage.Merge(_params.OnLogMessage).Merge(_power.OnLogMessage).Merge(_mission.OnLogMessage)
            .Subscribe(_ => Server.Server.StatusText.Log(_)).DisposeItWith(Disposable);
        }
Ejemplo n.º 7
0
 public ChunkConsumer(IChunkStore store)
 {
     _store = store;
 }