public static RequestMessage Build(bool full, ModelFilter filter = null, IList <ObserverDefinition> observerRequests = null) { var builder = new FlatBufferBuilder(RequestMessageBuilder.BufferInitialSize); Offset <Filter>?filterOffset = null; if (filter != null) { var boxes = new Offset <Box3D> [filter.Boxes.Count]; filter.Boxes.EachWithIndex((i, box) => { boxes[i] = Box3D.CreateBox3D(builder, box.LowerBound.X, box.LowerBound.Y, box.LowerBound.Z, box.Size.X, box.Size.Y, box.Size.Z); }); VectorOffset boxesOffset = Filter.CreateBoxesVector(builder, boxes); filterOffset = Filter.CreateFilter(builder, boxesOffset); } VectorOffset?observersVectorOffset = null; if (observerRequests != null) { var observerOffsets = new Offset <Observer> [observerRequests.Count()]; observerRequests.EachWithIndex((i, definition) => { Offset <NeuronId> neuronId = NeuronId.CreateNeuronId(builder, definition.NeuronIndex, definition.RegionIndex); StringOffset observerType = builder.CreateString(definition.Type); observerOffsets[i] = Observer.CreateObserver(builder, neuronId, observerType); }); observersVectorOffset = GetModelRequest.CreateObserversVector(builder, observerOffsets); } GetModelRequest.StartGetModelRequest(builder); GetModelRequest.AddFull(builder, full); if (filterOffset.HasValue) { GetModelRequest.AddFilter(builder, filterOffset.Value); } if (observersVectorOffset.HasValue) { GetModelRequest.AddObservers(builder, observersVectorOffset.Value); } Offset <GetModelRequest> requestOffset = GetModelRequest.EndGetModelRequest(builder); return(RequestMessageBuilder.Build(builder, Request.GetModelRequest, requestOffset)); }
public static Offset <GetModelRequest> CreateGetModelRequest(FlatBufferBuilder builder, bool full = false, Offset <Filter> filterOffset = default(Offset <Filter>), VectorOffset observersOffset = default(VectorOffset)) { builder.StartObject(3); GetModelRequest.AddObservers(builder, observersOffset); GetModelRequest.AddFilter(builder, filterOffset); GetModelRequest.AddFull(builder, full); return(GetModelRequest.EndGetModelRequest(builder)); }