Exemplo n.º 1
0
 public void AddTerrain(R_Landblock landblock)
 {
     if (CurrentBatch == null || !CurrentBatch.CanAdd(landblock))
     {
         CurrentBatch = new TerrainBatchDraw(OverlayAtlasChain, AlphaAtlasChain);
         Batches.Add(CurrentBatch);
     }
     CurrentBatch.AddTerrain(landblock);
 }
Exemplo n.º 2
0
 public void XmlRead(XmlReader reader)
 {
     reader.ReadStartElement(nameof(BatchList));
     NextBatchId = reader.ReadElementContentAsInt(nameof(NextBatchId), "");
     while (reader.IsStartElement(nameof(Batch)))
     {
         Batches.Add(new Batch());
         Batches.Last().XmlRead(reader);
     }
 }
Exemplo n.º 3
0
        //Draws the pendulum bobs.
        public override void Draw(State state)
        {
            //Sets width and height to canvas height and width propeties depending on
            //if the canvas is initialised.
            var width  = Canvas.ActualWidth > 0 ? Canvas.ActualWidth : Canvas.Width;
            var height = Canvas.ActualHeight > 0 ? Canvas.ActualHeight : Canvas.Height;

            //Calaculate bob position.
            BobPosition.X = Length * Math.Sin(state.Displacement);
            BobPosition.Y = Length * Math.Cos(state.Displacement);

            PivotPosition = new Vec2
            {
                X = width / 2,
                Y = height / 2
            };

            Batches.Add(DrawingMethods.FilledCircle(PivotPosition, 4, Brushes.Black));

            //Calculate bob position relative to the canvas coordinates.
            BobPosCanvas.X = PivotPosition.X + BobPosition.X * PixelsPerMeter;
            BobPosCanvas.Y = PivotPosition.Y + BobPosition.Y * PixelsPerMeter;


            //Create line objects for pendulum arm.
            var arm = new LightLine
            {
                X1 = PivotPosition.X,
                Y1 = PivotPosition.Y,
                X2 = BobPosCanvas.X - BobRadius * Math.Sin(state.Displacement),
                Y2 = BobPosCanvas.Y - BobRadius * Math.Cos(state.Displacement)
            };

            var armLineBatch = new LineBatch {
                LineThickness = 2
            };

            armLineBatch.Add(arm);
            Batches.Add(armLineBatch);

            //Draw origin circles depending on whether interaction is taking place.
            Batches.Add(IsInteracting
                ? DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Red)
                : DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Blue));

            //Render the batches.
            foreach (var batch in Batches)
            {
                batch.Render(Canvas);
                batch.Clear();
            }

            Batches.Clear();
        }
Exemplo n.º 4
0
        private void AddBatches(IEnumerable <Batch> batches)
        {
            if (Batches == null)
            {
                Batches = new List <ObservationBatch>();
            }

            foreach (var batch in batches)
            {
                Batches.Add(new ObservationBatch(batch));
            }
        }
        private void CreateDefaultConfiguration()
        {
            Client = new BlazorClient()
            {
                DefaultLatencyTimeout = DefaultLatencyTimeout
            };
            Client.RenderBatchReceived += (id, data) => Batches.Add(new Batch(id, data));
            Client.OnCircuitError      += (error) => Errors.Add(error);

            _        = _serverFixture.RootUri; // this is needed for the side-effects of getting the URI.
            TestSink = _serverFixture.Host.Services.GetRequiredService <TestSink>();
            TestSink.MessageLogged += LogMessages;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Called when [get diagnostics batches completed].
 /// </summary>
 /// <param name="items">The items.</param>
 /// <remarks></remarks>
 public void OnGetDiagnosticsBatchesCompleted(DiagnosticsBatchViewItem[] items)
 {
     IsEmpty = true;
     IsBusy  = false;
     if (items == null)
     {
         return;
     }
     IsEmpty = (items.Count() == 0);
     Batches.Clear();
     foreach (var diagnosticsBatchViewItem in items)
     {
         Batches.Add(diagnosticsBatchViewItem);
     }
     RaisePropertyChanged(Property.Batches);
 }
        public void LoadNextBatchSet()
        {
            if (_currentEpoch >= 0)
            {
                for (int setIdx = 0; setIdx < Constants.BATCHES_PER_SET; setIdx++)
                {
                    DataBatch batch;
                    if ((Batches == null) || (Batches.Count < (Constants.BATCHES_PER_SET)))
                    {
                        batch = new DataBatch(Constants.TOTAL_VALUE_COUNT, 1, sparse: true);
                        Batches.Add(batch);
                    }
                    else
                    {
                        batch = Batches[setIdx];
                    }

                    for (var minibatchIdx = 0; minibatchIdx < Constants.MINIBATCH_SIZE; minibatchIdx++)
                    {
                        OneHotRecordReadOnly rec = _records[_recNo];
                        rec.CopyDataToSparseArray(batch.SparseIndices, batch.SparseValues, minibatchIdx);
                        batch.Labels[minibatchIdx] = rec.Label;
                        _recNo++;
                        if (_recNo >= _records.Count)
                        {
                            _recNo = 0;
                            if (_totalBatchCount == 0)
                            {
                                _totalBatchCount = _batchesRead;
                            }
                            _batchesRead = 0;
                            _currentEpoch++;
                            CurrentEpochBatch = 0;
                            if (_shuffle)
                            {
                                _records.Shuffle();
                            }
                        }
                        _batchesRead++;
                    }
                }
            }

            _currentBatch = 0;
            CurrentSet++;
            _loaded = true;
        }
Exemplo n.º 8
0
        public RemoteRendererBufferLimitTest(AspNetSiteServerFixture serverFixture)
        {
            serverFixture.BuildWebHostMethod = TestServer.Program.BuildWebHost;
            _serverFixture = serverFixture;

            // Needed here for side-effects
            _ = _serverFixture.RootUri;

            Client = new BlazorClient()
            {
                DefaultLatencyTimeout = DefaultLatencyTimeout
            };
            Client.RenderBatchReceived += (id, data) => Batches.Add(new Batch(id, data));

            Sink = _serverFixture.Host.Services.GetRequiredService <TestSink>();
            Sink.MessageLogged += LogMessages;
        }
Exemplo n.º 9
0
        private void CreateDefaultConfiguration()
        {
            Client = new BlazorClient()
            {
                DefaultLatencyTimeout = DefaultLatencyTimeout
            };
            Client.RenderBatchReceived += (id, data) => Batches.Add(new Batch(id, data));
            Client.OnCircuitError      += (error) => Errors.Add(error);
            Client.LoggerProvider       = new XunitLoggerProvider(Output);
            Client.FormatError          = (error) =>
            {
                var logs = string.Join(Environment.NewLine, Logs);
                return(new Exception(error + Environment.NewLine + logs));
            };

            _        = _serverFixture.RootUri; // this is needed for the side-effects of getting the URI.
            TestSink = _serverFixture.Host.Services.GetRequiredService <TestSink>();
            TestSink.MessageLogged += LogMessages;
        }
Exemplo n.º 10
0
        public Task EmitBatchAsync(IEnumerable <LogEvent> events)
        {
            lock (_stateLock)
            {
                if (_stopped)
                {
                    return(Task.FromResult(0));
                }

                if (IsDisposed)
                {
                    WasCalledAfterDisposal = true;
                }

                Thread.Sleep(_batchEmitDelay);
                Batches.Add(events.ToList());
            }

            return(Task.FromResult(0));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Aggregate the input range into a single batch.
        /// </summary>
        /// <param name="totalSz"></param>
        /// <param name="lo"></param>
        /// <param name="hi"></param>
        private void Create <VertexType>(int totalSz, int lo, int hi) where VertexType : struct
        {
            if (totalSz > 0)
            {
                int totalNumVerts = BytesToCount(totalSz);

                var localVerts = CheckLocalVerts <VertexType>(totalNumVerts);

                int accumSz = 0;
                int iVerts  = 0;
                _boundsScratch.Set(_bufferScratch[lo].Bounds);
                for (int i = lo; i <= hi; ++i)
                {
                    _boundsScratch.Union(_bufferScratch[i].Bounds);

                    int numVerts = _bufferScratch[i].Buffer.VertexCount;

                    _bufferScratch[i].Buffer.GetData <VertexType>(localVerts, iVerts, numVerts);

                    iVerts += numVerts;

                    // TODO (****) Do we really need this in bytes?  Can we simplify?
                    accumSz += _bufferScratch[i].Buffer.VertexCount * _bufferScratch[i].Buffer.VertexDeclaration.VertexStride;

                    _bufferScratch[i].Dispose();
                }

                Debug.Assert(accumSz == totalSz);

                GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;
                VertexBuffer   vbuf   = new VertexBuffer(device, typeof(VertexType), totalNumVerts, BufferUsage.WriteOnly);
                vbuf.SetData <VertexType>(localVerts, 0, totalNumVerts);

                Batch batch = new Batch(new BoundVBuf(_boundsScratch, vbuf, Stride));

                Batches.Add(batch);

                CheckIndexBuffer(totalNumVerts);
            }
        }
 protected override Task WriteMessagesAsync(IEnumerable <LogMessage> messages, CancellationToken token)
 {
     Batches.Add(messages.ToArray());
     return(Task.CompletedTask);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Add a DocumentBatchGet object to the multi-table batch request.
 /// </summary>
 /// <param name="batch">DocumentBatchGet to add.</param>
 public void AddBatch(DocumentBatchGet batch)
 {
     Batches.Add(batch);
 }
Exemplo n.º 14
0
        //Draws the pendulum bobs.
        public override void Draw(State state)
        {
            var springLength = (Length + state.Displacement) * PixelsPerMeter - ConnectorLength * 2;
            var coilSpan     = springLength / NumberOfCoils;
            var multiplier   = -1;


            //Sets width and height to canvas height and width propeties depending on
            //if the canvas is initialised.
            var width  = Canvas.ActualWidth > 0 ? Canvas.ActualWidth : Canvas.Width;
            var height = Canvas.ActualHeight > 0 ? Canvas.ActualHeight : Canvas.Height;

            BobPosition.Y = Length + state.Displacement;

            PivotPosition = new Vec2
            {
                X = width / 2,
                Y = 10
            };
            Batches.Add(DrawingMethods.FilledCircle(PivotPosition, 4, Brushes.Black));

            //Calaculate bob position.
            BobPosCanvas.X = PivotPosition.X;
            BobPosCanvas.Y = PivotPosition.Y + BobPosition.Y * PixelsPerMeter + BobRadius;

            #region DrawSpring

            var springlineBatch = new LineBatch();
            var springPivotLine = new LightLine()
            {
                X1 = PivotPosition.X,
                Y1 = PivotPosition.Y,
                X2 = PivotPosition.X,
                Y2 = PivotPosition.Y + ConnectorLength
            };
            springlineBatch.Add(springPivotLine);

            var theta = Math.Asin(coilSpan / 2 / CoilDiameter);
            var x     = (CoilDiameter * Math.Cos(theta) / 2);

            var startLine = new LightLine()
            {
                X1 = PivotPosition.X,
                Y1 = PivotPosition.Y + ConnectorLength,
                X2 = PivotPosition.X + x,
                Y2 = PivotPosition.Y + ConnectorLength + coilSpan / 2
            };
            springlineBatch.Add(startLine);
            var tempLine = startLine;


            for (int i = 0; i < (NumberOfCoils - 1) * 2; i++)
            {
                var coilLine = new LightLine()
                {
                    X1 = tempLine.X2,
                    Y1 = tempLine.Y2,
                    X2 = tempLine.X2 + 2 * x * multiplier,
                    Y2 = tempLine.Y2 + coilSpan / 2,
                };

                springlineBatch.Add(coilLine);
                tempLine    = coilLine;
                multiplier *= -1;
            }

            var endLine = new LightLine()
            {
                X1 = tempLine.X2,
                Y1 = tempLine.Y2,
                X2 = tempLine.X2 + x * multiplier,
                Y2 = tempLine.Y2 + coilSpan / 2
            };
            springlineBatch.Add(endLine);

            var springBobLine = new LightLine()
            {
                X1 = endLine.X2,
                Y1 = endLine.Y2,
                X2 = endLine.X2,
                Y2 = endLine.Y2 + ConnectorLength
            };
            springlineBatch.Add(springBobLine);

            #endregion

            springlineBatch.LineThickness = 2;
            Batches.Add(springlineBatch);

            //Draw origin circles depending on whether interaction is taking place.
            Batches.Add(IsInteracting
                ? DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Red)
                : DrawingMethods.FilledCircle(BobPosCanvas, (int)BobRadius, Brushes.Blue));


            //Render the batches.
            foreach (var batch in Batches)
            {
                batch.Render(Canvas);
                batch.Clear();
            }

            Batches.Clear();
        }