Exemple #1
0
        private LinkRouterBase <T> GetLinkFromProducerType <T>(ProducerType type)
        {
            switch (type)
            {
            case ProducerType.Broadcaster:
                return(new LinkBroadcasterRouter <T>());

            case ProducerType.Dispatcher:
                return(new LinkDispatcherRouter <T>());

            default:
                throw new Exception("Unknown producer type specified. Cannot create router.");
            }
        }
        public static Factories.AbstractFactory GetFactory(ProducerType producerType)
        {
            switch (producerType)
            {
            case ProducerType.Shape:
                return(new ShapeFactory());

            case ProducerType.Color:
                return(new ColorFactory());

            default:
                throw new ArgumentOutOfRangeException(nameof(producerType), producerType, null);
            }
        }
Exemple #3
0
    /// <summary>
    /// Create a new Ring Buffer with the specified producer type (SINGLE or MULTI)
    /// </summary>
    /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
    /// <param name="factory">used to create the events within the ring buffer.</param>
    /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
    /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
    /// <returns>a constructed ring buffer.</returns>
    /// <exception cref="ArgumentOutOfRangeException">if the producer type is invalid</exception>
    /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
    public static RingBuffer <T> Create(ProducerType producerType, Func <T> factory, int bufferSize, IWaitStrategy waitStrategy)
    {
        switch (producerType)
        {
        case ProducerType.Single:
            return(CreateSingleProducer(factory, bufferSize, waitStrategy));

        case ProducerType.Multi:
            return(CreateMultiProducer(factory, bufferSize, waitStrategy));

        default:
            throw new ArgumentOutOfRangeException(producerType.ToString());
        }
    }
        private ISequencer newProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.SINGLE:
                return(new SingleProducerSequencer(bufferSize, waitStrategy));

            case ProducerType.MULTI:
                return(new MultiProducerSequencer(bufferSize, waitStrategy));

            default:
                throw new ArgumentException(producerType.ToString());
            }
        }
        private ISequencer NewProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.Single:
                return(new SingleProducerSequencer(bufferSize, waitStrategy));

            case ProducerType.Multi:
                return(new MultiProducerSequencer(bufferSize, waitStrategy));

            default:
                throw new ArgumentOutOfRangeException(nameof(producerType), producerType, null);
            }
        }
    /// <summary>
    /// Create a new sequencer with the specified producer type.
    /// </summary>
    /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
    /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
    /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
    /// <returns>a constructed ring buffer.</returns>
    /// <exception cref="ArgumentOutOfRangeException">if the producer type is invalid</exception>
    /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
    public static ISequencer Create(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
    {
        switch (producerType)
        {
        case ProducerType.Single:
            return(new SingleProducerSequencer(bufferSize, waitStrategy));

        case ProducerType.Multi:
            return(new MultiProducerSequencer(bufferSize, waitStrategy));

        default:
            throw new ArgumentOutOfRangeException(producerType.ToString());
        }
    }
        public static void UpdateProducerType(this ProducerType computerType, ProducerTypeViewModel computerTypeVm)
        {
            computerType.ProducerTypeId          = computerTypeVm.ProducerTypeId;
            computerType.ProducerTypeCode        = computerTypeVm.ProducerTypeCode;
            computerType.ProducerTypeName        = computerTypeVm.ProducerTypeName;
            computerType.ProducerTypeDescription = computerTypeVm.ProducerTypeDescription;

            computerType.CreatedDate     = computerTypeVm.CreatedDate;
            computerType.CreatedBy       = computerTypeVm.CreatedBy;
            computerType.UpdatedDate     = computerTypeVm.UpdatedDate;
            computerType.UpdatedBy       = computerTypeVm.UpdatedBy;
            computerType.MetaKeyword     = computerTypeVm.MetaKeyword;
            computerType.MetaDescription = computerTypeVm.MetaDescription;
            computerType.Status          = computerTypeVm.Status;
        }
Exemple #8
0
        /// <summary>
        /// Create a new Ring Buffer with the specified producer type (SINGLE or MULTI).
        /// </summary>
        /// <param name="producerType">producer type to use <see cref="ProducerType"/>.</param>
        /// <param name="factory">used to create events within the ring buffer.</param>
        /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
        /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
        /// <returns>a constructed ring buffer.</returns>
        /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
        public static RingBuffer <TEvent> Create(
            ProducerType producerType,
            IEventFactory <TEvent> factory,
            int bufferSize,
            IWaitStrategy waitStrategy)
        {
            switch (producerType)
            {
            case ProducerType.Single:
                return(CreateSingleProducer(factory, bufferSize, waitStrategy));

            case ProducerType.Multi:
                return(CreateMultiProducer(factory, bufferSize, waitStrategy));

            default:
                throw new IllegalStateException(producerType.ToString());
            }
        }
        // Input parameter configuration (with default value)
        // Please refer to OpenPose documentation for parameter explanation
        public static void OPConfigureInput(
            ProducerType producerType   = ProducerType.None, string producerString = "-1",
            ulong frameFirst            = 0, ulong frameStep    = 1, ulong frameLast = ulong.MaxValue,
            bool realTimeProcessing     = false, bool frameFlip = false,
            int frameRotate             = 0, bool framesRepeat  = false,
            Vector2Int?cameraResolution = null, string cameraParameterPath = null,
            bool undistortImage         = false, int numberViews = -1)
        {
            // Other default values
            Vector2Int _cameraResolution = cameraResolution ?? new Vector2Int(-1, -1);

            cameraParameterPath = cameraParameterPath ?? Environment.CurrentDirectory + "/models/cameraParameters/";

            Bind._OPConfigureInput(
                (byte)producerType, producerString,                 // ProducerType and string
                frameFirst, frameStep, frameLast,
                realTimeProcessing, frameFlip, frameRotate, framesRepeat,
                _cameraResolution.x, _cameraResolution.y,                 // Point
                cameraParameterPath, undistortImage, numberViews
                );
        }
Exemple #10
0
        public static StdSharedPtr <Producer> CreateProducer(ProducerType type,
                                                             Point <int> cameraResolution,
                                                             string producerString      = "",
                                                             string cameraParameterPath = "models/cameraParameters/",
                                                             bool undistortImage        = true,
                                                             int numberViews            = -1)
        {
            var producerStringBytes      = Encoding.UTF8.GetBytes(producerString ?? "");
            var cameraParameterPathBytes = Encoding.UTF8.GetBytes(cameraParameterPath ?? "");

            using (var resolution = cameraResolution.ToNative())
            {
                var ret = Native.op_createProducer(type,
                                                   producerStringBytes,
                                                   resolution.NativePtr,
                                                   cameraParameterPathBytes,
                                                   undistortImage,
                                                   numberViews);
                return(new StdSharedPtr <Producer>(ret));
            }
        }
        public HttpResponseMessage Post(HttpRequestMessage request, ProducerTypeViewModel producerTypeVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.Values.FirstOrDefault()?.Errors.FirstOrDefault()?.ErrorMessage);
                }
                else
                {
                    var newProducerType = new ProducerType();
                    newProducerType.UpdateProducerType(producerTypeVm);

                    var producerType = _producerTypeService.Add(newProducerType);
                    _producerTypeService.Save();

                    response = request.CreateResponse(HttpStatusCode.Created, producerType);
                }
                return response;
            }));
        }
Exemple #12
0
        public WrapperStructInput(ProducerType producerType    = ProducerType.None,
                                  string producerString        = "",
                                  ulong frameFirst             = 0,
                                  ulong frameStep              = 1,
                                  ulong frameLast              = ulong.MaxValue,
                                  bool realTimeProcessing      = false,
                                  bool frameFlip               = false,
                                  int frameRotate              = 0,
                                  bool framesRepeat            = false,
                                  Point <int> cameraResolution = default(Point <int>),
                                  string cameraParameterPath   = "models/cameraParameters/",
                                  bool undistortImage          = true,
                                  int numberViews              = -1)
        {
            if (cameraParameterPath == null)
            {
                throw new ArgumentNullException(nameof(cameraParameterPath));
            }

            var producerStringBytes      = Encoding.UTF8.GetBytes(producerString ?? "");
            var cameraParameterPathBytes = Encoding.UTF8.GetBytes(cameraParameterPath);

            using (var native = cameraResolution.ToNative())
                this.NativePtr = Native.op_wrapperStructInput_new(producerType,
                                                                  producerStringBytes,
                                                                  frameFirst,
                                                                  frameStep,
                                                                  frameLast,
                                                                  realTimeProcessing,
                                                                  frameFlip,
                                                                  frameRotate,
                                                                  framesRepeat,
                                                                  native.NativePtr,
                                                                  cameraParameterPathBytes,
                                                                  undistortImage,
                                                                  numberViews);
        }
 public SequencerTests(ProducerType producerType)
 {
     _producerType = producerType;
 }
Exemple #14
0
 private static IValueRingBuffer <StubValueEvent> CreateRingBuffer(int size, ProducerType producerType)
 {
     return(new ValueRingBuffer <StubValueEvent>(() => new StubValueEvent(-1), SequencerFactory.Create(producerType, size)));
 }
 /// <summary>
 /// Create a new ValueDisruptor.
 /// </summary>
 /// <param name="eventFactory">the factory to create events in the ring buffer</param>
 /// <param name="ringBufferSize">the size of the ring buffer, must be power of 2</param>
 /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param>
 /// <param name="producerType">the claim strategy to use for the ring buffer</param>
 /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param>
 public ValueDisruptor(Func <T> eventFactory, int ringBufferSize, TaskScheduler taskScheduler, ProducerType producerType, IWaitStrategy waitStrategy)
     : this(new ValueRingBuffer <T>(eventFactory, SequencerFactory.Create(producerType, ringBufferSize, waitStrategy)), taskScheduler)
 {
 }
Exemple #16
0
 protected abstract IValueRingBuffer <T> CreateRingBuffer(int size, ProducerType producerType);
 public SequencerTests(ProducerType producerType)
 {
     _producerType = producerType;
 }
Exemple #18
0
 public Producer(GameObject _object, ProducerType _type)
 {
     Object = _object;
     Type   = _type;
 }
 public void Update(ProducerType producerType)
 {
     producerType.UpdatedDate = DateTime.Now;
     //producerType.UpdatedBy = ad //Todo: Add CreatedBy
     _producerTypeRepository.Update(producerType);
 }
Exemple #20
0
 /// <summary>
 /// Create a new UnmanagedDisruptor.
 ///
 /// The <see cref="UnmanagedRingBufferMemory"/> is not owned by the disruptor and should be disposed after shutdown.
 /// </summary>
 /// <param name="memory">block of memory that will store the events</param>
 /// <param name="producerType">the claim strategy to use for the ring buffer</param>
 /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param>
 public UnmanagedDisruptor(UnmanagedRingBufferMemory memory, ProducerType producerType, IWaitStrategy waitStrategy)
     : this(new UnmanagedRingBuffer <T>(memory, producerType, waitStrategy), TaskScheduler.Default)
 {
 }
Exemple #21
0
 /// <summary>
 /// Create a new sequencer with the specified producer type and <see cref="BlockingWaitStrategy"/>.
 /// </summary>
 /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
 /// <param name="bufferSize">number of elements to create within the ring buffer.</param>
 /// <returns>a constructed ring buffer.</returns>
 /// <exception cref="ArgumentOutOfRangeException">if the producer type is invalid</exception>
 /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
 public static ISequencer Create(ProducerType producerType, int bufferSize)
 {
     return(Create(producerType, bufferSize, DefaultWaitStrategy()));
 }
Exemple #22
0
 public FlowBatcherSettings(ProducerType producerType, int maxBatchSize, TimeSpan maxBatchTimeout, int capacity, object context = null, uint parallelismInstances = 1) : base(capacity, context, parallelismInstances)
 {
     ProducerType    = producerType;
     MaxBatchSize    = maxBatchSize;
     MaxBatchTimeout = maxBatchTimeout;
 }
 public FlowWaiterSettings(ProducerType producerType, int capacity, object context = null, uint parallelismInstances = 1) : base(capacity, context, parallelismInstances)
 {
     ProducerType = producerType;
 }
Exemple #24
0
 internal FluentWaiterDefinition(ProducerType producerType)
 {
     _producerType = producerType;
 }
 public SequencerTest(ProducerType producerType /*, IWaitStrategy waitStrategy*/)
 {
     this.producerType = producerType;
 }
Exemple #26
0
 public FlowProducerSettings(ProducerType producerType, object context = null, uint parallelismInstances = 1)
     : base(context, parallelismInstances)
 {
     ProducerType = producerType;
 }
Exemple #27
0
 public Batching_Test(ProducerType producerType)
 {
     _producerType = producerType;
 }
Exemple #28
0
 /// <summary>
 /// Construct an UnmanagedRingBuffer with the full option set.
 /// The <see cref="UnmanagedRingBufferMemory"/> is not owned by the ring buffer and should be disposed after shutdown.
 /// </summary>
 /// <param name="memory">block of memory that will store the events</param>
 /// <param name="producerType">producer type to use <see cref="ProducerType" /></param>
 /// <param name="waitStrategy">used to determine how to wait for new elements to become available.</param>
 /// <exception cref="ArgumentException">if bufferSize is less than 1 or not a power of 2</exception>
 public UnmanagedRingBuffer(UnmanagedRingBufferMemory memory, ProducerType producerType, IWaitStrategy waitStrategy)
     : base(SequencerFactory.Create(producerType, memory.EventCount, waitStrategy), memory.PointerToFirstEvent, memory.EventSize)
 {
 }
Exemple #29
0
 public static extern IntPtr op_createProducer(ProducerType type,
                                               byte[] producerString,
                                               IntPtr cameraResolution,
                                               byte[] cameraParameterPath,
                                               bool undistortImage,
                                               int mNumberViews);
 private Sequencer NewProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
 {
     switch (producerType)
     {
         case ProducerType.Single:
             return new SingleProducerSequencer(bufferSize, waitStrategy);
         case ProducerType.Multi:
             return new MultiProducerSequencer(bufferSize, waitStrategy);
         default:
             throw new ArgumentOutOfRangeException(nameof(producerType), producerType, null);
     }
 }
Exemple #31
0
 /// <summary>
 /// Create a new UnmanagedDisruptor.
 /// </summary>
 /// <param name="pointer">pointer to the first event of the buffer</param>
 /// <param name="eventSize">size of each event</param>
 /// <param name="ringBufferSize">the number of events of the ring buffer, must be power of 2</param>
 /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param>
 /// <param name="producerType">the claim strategy to use for the ring buffer</param>
 /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param>
 public UnmanagedDisruptor(IntPtr pointer, int eventSize, int ringBufferSize, TaskScheduler taskScheduler, ProducerType producerType, IWaitStrategy waitStrategy)
     : this(new UnmanagedRingBuffer <T>(pointer, eventSize, SequencerFactory.Create(producerType, ringBufferSize, waitStrategy)), taskScheduler)
 {
 }
 public SequencerTest(ProducerType producerType/*, IWaitStrategy waitStrategy*/)
 {
     this.producerType = producerType;
           
 }
 /// <summary>
 /// Create a new ValueDisruptor.
 /// </summary>
 /// <param name="eventFactory">the factory to create events in the ring buffer</param>
 /// <param name="ringBufferSize">the size of the ring buffer, must be power of 2</param>
 /// <param name="taskScheduler">a <see cref="TaskScheduler"/> to create threads for processors</param>
 /// <param name="producerType">the claim strategy to use for the ring buffer</param>
 /// <param name="waitStrategy">the wait strategy to use for the ring buffer</param>
 public ValueDisruptor(Func <T> eventFactory, int ringBufferSize, TaskScheduler taskScheduler, ProducerType producerType, IWaitStrategy waitStrategy)
     : this(ValueRingBuffer <T> .Create(producerType, eventFactory, ringBufferSize, waitStrategy), new BasicExecutor(taskScheduler))
 {
 }
 private ISequencer newProducer(ProducerType producerType, int bufferSize, IWaitStrategy waitStrategy)
 {
     switch (producerType)
     {
         case ProducerType.SINGLE:
             return new SingleProducerSequencer(bufferSize, waitStrategy);
         case ProducerType.MULTI:
             return new MultiProducerSequencer(bufferSize, waitStrategy);
         default:
             throw new ArgumentException(producerType.ToString());
     }
 }