/// <summary>
 ///     Write an event data line.
 /// </summary>
 /// <param name="writer">An event writer</param>
 /// <param name="eventTemplate">An event template</param>
 /// <param name="eventData">Event data</param>
 static async Task WriteEventDataLine(
     EventStreamWriter writer,
     EventElement eventTemplate,
     string eventData)
 {
     await WriteEventData(
         writer,
         eventTemplate,
         eventData + Environment.NewLine);
 }
Пример #2
0
 /// <summary>
 ///     Write an event data line.
 /// </summary>
 /// <param name="writer">An event writer</param>
 /// <param name="eventTemplate">An event template</param>
 /// <param name="eventData">Event data</param>
 private static void WriteEventDataLine(
     EventStreamWriter writer,
     EventElement eventTemplate,
     string eventData)
 {
     WriteEventData(
         writer,
         eventTemplate,
         eventData + Environment.NewLine);
 }
        public void SetAttachableEvent_TreeValidator(object o)
        {
            EventElement eventElement = ((EventElement)o);
            int          fireCount    = eventElement.TapEventCount;

            AttachedEventHolder.RaiseTapEvent(eventElement);
            if (eventElement.TapEventCount != fireCount + 1)
            {
                throw new Exception("Tap event did not fire");
            }
        }
        public void SetEventToMarkupExtensionWhichReturnsAMatchingDelegate_TreeValidator(object o)
        {
            EventElement eventElement = ((EventElement)o);
            int          fireCount    = eventElement.TapEventCount;

            eventElement.RaiseTapEvent();
            if (eventElement.TapEventCount != fireCount + 1)
            {
                throw new Exception("Tap event did not fire");
            }
        }
Пример #5
0
        public override void ProcessActivity(Activity activity, IBaseElement baseElement)
        {
            EventElement eventElement = GetType <EventElement>(baseElement);
            Event        @event       = new Event();
            Type         xpdlType     = XpdlTypeAttribute.GetCorrespondingType(eventElement.Type);

            if (xpdlType != null)
            {
                @event.Item = Activator.CreateInstance(xpdlType);
            }
            activity.Item = @event;
        }
        /// <summary>
        ///     Write events using EventStreamWriter
        /// </summary>
        // This method can be used by manual testing thus is public
        public static async Task WriteEvents()
        {
            using (var writer = new EventStreamWriter())
            {
                var eventTemplate = new EventElement
                {
                    Index      = "sdk-tests2",
                    Host       = "test host",
                    SourceType = "test sourcetype",
                    Source     = "test source",
                };

                await WriteEventData(
                    writer,
                    eventTemplate,
                    "Event with all default fields set");

                await WriteEventData(
                    writer,
                    eventTemplate,
                    "Letter O with double acute: \u0150");

                eventTemplate.Unbroken = true;

                await WriteEventData(
                    writer,
                    eventTemplate,
                    "Part 1 of an unbroken event ");

                await WriteEventData(
                    writer,
                    eventTemplate,
                    "Part 2 of an unbroken event ending with newline" + Environment.NewLine);

                await WriteEventDone(
                    writer,
                    eventTemplate);

                eventTemplate.Unbroken = false;

                await WriteEventData(
                    writer,
                    eventTemplate,
                    "Event after done key");

                var timedEvent = eventTemplate;
                timedEvent.Time = new DateTime(2013, 1, 1, 0, 0, 0, 1, DateTimeKind.Utc);
                timedEvent.Data = "Event with fixed time";
                await writer.WriteEventAsync(timedEvent);

                await WriteMultiplex(writer);
            }
        }
Пример #7
0
 public EventElement <TEventArg> this[TKey key]
 {
     get
     {
         EventElement <TEventArg> eventElement;
         if (!_eventElements.TryGetValue(key, out eventElement))
         {
             eventElement = new EventElement <TEventArg>();
             _eventElements.Add(key, eventElement);
         }
         return(eventElement);
     }
     set
     {
         _eventElements[key] = value;
     }
 }
Пример #8
0
        public void InitializationForImpossibleProbabilityTest()
        {
            var input = new List <string> {
                "0%"
            };
            var element = new EventElement(null, new List <int>()
            {
                1
            }, input);

            var state = new StateModel {
                Variables = new Dictionary <string, decimal> {
                }
            };

            element.Execute(state);
            Assert.Equal(0, element.NextElementIds.Count);
        }
Пример #9
0
        public void InitializationForCertainProbabilityTest()
        {
            var input = new List <string> {
                "101%"
            };
            var element = new EventElement(null, new List <int>()
            {
                1
            }, input);

            var state = new StateModel {
                Variables = new Dictionary <string, decimal> {
                }
            };

            element.Execute(state);
            Assert.Contains(1, element.NextElementIds);
        }
Пример #10
0
        private EventElement CreateEventGUI(VisualElement root, EventRow @event)
        {
            var eventElem = new EventElement {
                text = @event.Id
            };

            var stagesContainer = new StagesContainer();

            eventElem.Content.Add(new InvokeTypeElement {
                value = @event.InvokeType.ToKeyword()
            });
            eventElem.Content.Add(stagesContainer);

            foreach (var stage in @event.Stages)
            {
                var stageContainer = new StageContainer();
                stagesContainer.Add(stageContainer);

                stageContainer.Add(new StageElement {
                    value = $"{stage.Index}"
                });

                if (stage.MaxConstraint >= 0)
                {
                    stageContainer.Add(new StageElement {
                        value = $"<{stage.MaxConstraint}>"
                    });
                }

                var commandContainer = new CommandContainer();
                stageContainer.Add(commandContainer);

                foreach (var command in stage.Commands)
                {
                    commandContainer.Add(new CommandElement {
                        value = command.Id
                    });
                }
            }

            root.Add(eventElem);
            return(eventElem);
        }
        public void WriteValueOfEventAsDelegate()
        {
            XamlSchemaContext xsc = new XamlSchemaContext();
            XamlObjectWriter  ow  = new XamlObjectWriter(xsc);

            XamlType eventElementXT = xsc.GetXamlType(typeof(EventElement));

            ow.WriteStartObject(eventElementXT);
            ow.WriteStartMember(eventElementXT.GetMember("Tap"));
            EventElement.TapDelegate tapDelegate = new EventElement.TapDelegate(methodToCall);
            ow.WriteValue(tapDelegate);
            ow.WriteEndMember();
            ow.WriteEndObject();

            EventElement eventElement = ((EventElement)ow.Result);

            tapEventFired = false;
            eventElement.RaiseTapEvent();
            if (!tapEventFired)
            {
                throw new Exception("Tap event did not fire");
            }
        }
Пример #12
0
        /// <summary>
        /// Processes an event element.
        /// </summary>
        /// <param name="element">Event code element.</param>
        public override void VisitEventElement(EventElement element)
        {
            this.WriteComments(element.HeaderComments);
            this.WriteAttributes(element);

            WriteAccess(element.Access);

            WriteMemberAttributes(
                element.MemberModifiers,
                element[VBExtendedProperties.Overloads] is bool && (bool)element[VBExtendedProperties.Overloads]);

            bool isCustom = false;

            if (element.BodyText != null && element.BodyText.Trim().Length > 0)
            {
                isCustom = true;
                Writer.Write(VBKeyword.Custom);
                Writer.Write(' ');
            }

            Writer.Write(VBKeyword.Event);
            Writer.Write(' ');

            Writer.Write(element.Name);

            if (element.Parameters != null)
            {
                WriteParameterList(element.Parameters);
            }
            WriteReturnType(element.Type);
            WriteImplements(element.Implements);

            if (isCustom)
            {
                WriteBody(element);
            }
        }
Пример #13
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Timing;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (EventElement != null)
            {
                dest.EventElement = new List <Hl7.Fhir.Model.FhirDateTime>(EventElement.DeepCopy());
            }
            if (Repeat != null)
            {
                dest.Repeat = (Hl7.Fhir.Model.Timing.RepeatComponent)Repeat.DeepCopy();
            }
            if (Code != null)
            {
                dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy();
            }
            return(dest);
        }
Пример #14
0
 private void InitializeListEvents()
 {
     if (_listEventElements == null)
     {
         DataManager.instance.EventDAO.GetAllEvents((List <EventVO> p_listEventVO) =>
         {
             try
             {
                 _layoutGroup.GetComponent <RectTransform>().sizeDelta = new Vector2(_layoutGroup.GetComponent <RectTransform>().sizeDelta.x, 1550 * p_listEventVO.Count);
                 _listEventElements = new List <EventElement>();
                 for (int i = 0; i < p_listEventVO.Count; i++)
                 {
                     EventElement __eventElement = Instantiate(EventElementPrefab, _layoutGroup).GetComponent <EventElement>();
                     __eventElement.SetEventElement(p_listEventVO[i]);
                     _listEventElements.Add(__eventElement);
                 }
             }
             catch (Exception e)
             {
                 Debug.Log(e);
             }
         });
     }
 }
        public void WriteEventWithAMarkupExtensionReturingADelegate()
        {
            XamlSchemaContext xsc = new XamlSchemaContext();
            XamlObjectWriter  ow  = new XamlObjectWriter(xsc);

            XamlType eventElementXT       = xsc.GetXamlType(typeof(EventElement));
            XamlType delegateCreatingMeXT = xsc.GetXamlType(typeof(DelegateCreatingME));

            ow.WriteStartObject(eventElementXT);
            ow.WriteStartMember(eventElementXT.GetMember("Tap"));
            ow.WriteStartObject(delegateCreatingMeXT);
            ow.WriteEndObject();
            ow.WriteEndMember();
            ow.WriteEndObject();

            EventElement eventElement = ((EventElement)ow.Result);
            int          fireCount    = eventElement.TapEventCount;

            eventElement.RaiseTapEvent();
            if (eventElement.TapEventCount != fireCount + 1)
            {
                throw new Exception("Tap event did not fire");
            }
        }
Пример #16
0
        private void SetupProcessElements(InputProcessModel inputModel)
        {
            ProcessElements = new Dictionary <int, IProcessElement>();
            foreach (var processModel in inputModel.Elements)
            {
                IProcessElement element = null;
                switch (processModel.ElementType)
                {
                case ElementType.Block:
                    element = new BlockElement(processModel.PreviousElementIds, processModel.NextElementIds, processModel.Actions);
                    break;

                case ElementType.Condition:
                    element = new ConditionElement(processModel.PreviousElementIds, processModel.Actions);
                    break;

                case ElementType.Event:
                    element = new EventElement(processModel.PreviousElementIds, processModel.NextElementIds, processModel.Actions);
                    break;
                }

                ProcessElements[processModel.Id] = element;
            }
        }
Пример #17
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the element with the interface member state copied.</returns>
        protected override InterfaceMemberElement DoInterfaceMemberClone()
        {
            EventElement clone = new EventElement();
            clone._params = _params;

            return clone;
        }
Пример #18
0
        public override ErrorList Validate()
        {
            var result = new ErrorList();

            result.AddRange(base.Validate());

            if (IdentifierElement != null)
            {
                result.AddRange(IdentifierElement.Validate());
            }
            if (TimestampElement != null)
            {
                result.AddRange(TimestampElement.Validate());
            }
            if (EventElement != null)
            {
                result.AddRange(EventElement.Validate());
            }
            if (Response != null)
            {
                result.AddRange(Response.Validate());
            }
            if (Source != null)
            {
                result.AddRange(Source.Validate());
            }
            if (Destination != null)
            {
                result.AddRange(Destination.Validate());
            }
            if (Enterer != null)
            {
                result.AddRange(Enterer.Validate());
            }
            if (Author != null)
            {
                result.AddRange(Author.Validate());
            }
            if (Receiver != null)
            {
                result.AddRange(Receiver.Validate());
            }
            if (Responsible != null)
            {
                result.AddRange(Responsible.Validate());
            }
            if (Effective != null)
            {
                result.AddRange(Effective.Validate());
            }
            if (Reason != null)
            {
                result.AddRange(Reason.Validate());
            }
            if (Data != null)
            {
                Data.ForEach(elem => result.AddRange(elem.Validate()));
            }

            return(result);
        }
Пример #19
0
 protected override VisualElement CreateElement()
 {
     _eventElement = new EventElement();
     return(_eventElement);
 }
Пример #20
0
 /// <summary>
 /// Processes a event element.
 /// </summary>
 /// <param name="element">Event code element.</param>
 public abstract void VisitEventElement(EventElement element);
Пример #21
0
    /// <summary>
    /// Apply the subdivisions based on which particles need subdividing this frame.
    ///
    /// This happens in two Compute Shader steps:
    ///
    ///   - The first takes all particles to be subdived and calculates the details of which particles will be created
    ///
    ///   - The second takes all the newly created particles and adds them to the total pool of Wave Particles
    ///     It also creates a buffer of data that can be used to calculate future subdivision events that will occur
    ///     as a result of the new wave particles.
    ///
    /// </summary>
    /// <param name="currentFrame"></param>
    public void calculateSubdivisions(int currentFrame)
    {
        // Commit all pending particles that are stored in CPU memory to the GPU.
        commitParticles();

        ///
        /// Count the number of subdivisions that will applied this frame.
        ///
        int numSubdivisions = 0;

        {
            int particleIndex = _subdivisionEvents[currentFrame];
            while (particleIndex != _NullParticleIndex)
            {
                numSubdivisions++;
                particleIndex = _particleEvents[particleIndex].frontIndex;
            }
        }

        // If no subdivisions are required, return
        if (numSubdivisions == 0)
        {
            return;
        }

        ///
        /// Get the indices of all the particles that will be subdivided this frame.
        ///
        int[] particleIndicesToSubdivide = new int[numSubdivisions];
        {
            int particleIndex = _subdivisionEvents[currentFrame];
            for (int i = 0; i < particleIndicesToSubdivide.Length; i++)
            {
                particleIndicesToSubdivide[i] = particleIndex;
                particleIndex = _particleEvents[particleIndex].frontIndex;
                _particleEvents[particleIndicesToSubdivide[i]] = EventElement.getDeadEvent();
            }
            _subdivisionEvents[currentFrame] = _NullParticleIndex;
        }

        ///
        /// Create buffers for storing particles to be subdivided and the resulting subdivisions.
        ///
        ComputeBuffer particleIndicesToSubdivideBuffer = new ComputeBuffer(numSubdivisions, sizeof(int));

        particleIndicesToSubdivideBuffer.SetData(particleIndicesToSubdivide);
        // Create an append buffer for the newly created particles
        ComputeBuffer particlesToAddBuffer = new ComputeBuffer(numSubdivisions * 3, WaveParticle.STRIDE, ComputeBufferType.Append);

        particlesToAddBuffer.SetCounterValue(0);

        // Load particles to be subdivided into this buffer, and copy it out to get future subdivision details???
        _gpuSubdivideParticles.SetInt(NUM_SUBDIVISIONS, numSubdivisions);
        _gpuSubdivideParticles.SetFloat(KILL_THRESHOLD, _waveParticleKillThreshold);
        _gpuSubdivideParticles.SetBuffer(kernel_SubdivideParticles, PARTICLE_INDICES_TO_SUBDIVIDE_BUFFER, particleIndicesToSubdivideBuffer);
        _gpuSubdivideParticles.SetBuffer(kernel_SubdivideParticles, WAVE_PARTICLE_BUFFER, _waveParticlesBuffer);
        _gpuSubdivideParticles.SetBuffer(kernel_SubdivideParticles, PARTICLES_TO_ADD_APPEND_BUFFER, particlesToAddBuffer);
        _gpuSubdivideParticles.Dispatch(kernel_SubdivideParticles, (numSubdivisions + THREAD_GROUPS_X) / THREAD_GROUPS_X, 1, 1);

        int           numParticlesToAdd     = particlesToAddBuffer.count;
        ComputeBuffer subdivisionDataBuffer = new ComputeBuffer(numParticlesToAdd, sizeof(int) * 2);

        _gpuSubdivideParticles.SetInt(CURRENT_HEAD, _currentHead);
        _gpuSubdivideParticles.SetInt(PARTICLE_CONTAINER_SIZE, _particleContainerSize);
        _gpuSubdivideParticles.SetInt(FRAME_CYCLE_LENGTH, WaveParticle.FRAME_CYCLE_LENGTH);
        _gpuSubdivideParticles.SetInt(NUM_PARTICLES_TO_ADD, numParticlesToAdd);
        _gpuSubdivideParticles.SetFloat(WAVE_PARTICLE_RADIUS, WaveParticle.RADIUS);
        _gpuSubdivideParticles.SetFloat(FIXED_DELTA_TIME, Time.fixedDeltaTime);
        _gpuSubdivideParticles.SetFloat(PARTICLE_SPEED, WaveParticle.PARTICLE_SPEED);

        _gpuSubdivideParticles.SetBuffer(kernel_AddSubdividedParticles, PARTICLES_TO_ADD_CONSUME_BUFFER, particlesToAddBuffer);
        _gpuSubdivideParticles.SetBuffer(kernel_AddSubdividedParticles, SUBDIVISION_DATA, subdivisionDataBuffer);
        _gpuSubdivideParticles.SetBuffer(kernel_AddSubdividedParticles, WAVE_PARTICLE_BUFFER, _waveParticlesBuffer);

        _gpuSubdivideParticles.Dispatch(kernel_AddSubdividedParticles, (numParticlesToAdd + THREAD_GROUPS_X) / THREAD_GROUPS_X, 1, 1);

        _currentHead           = (_currentHead + numParticlesToAdd) % _particleContainerSize;
        int[,] subdivisionData = new int[numParticlesToAdd, 2];
        subdivisionDataBuffer.GetData(subdivisionData);
        for (int i = 0; i < numParticlesToAdd; i++)
        {
            int particleIndex    = subdivisionData[i, 0];
            int subdivisionFrame = subdivisionData[i, 1];
            addSubdivisionEvent(particleIndex, subdivisionFrame);
        }

        subdivisionDataBuffer.Release();
        particlesToAddBuffer.Release();
        particleIndicesToSubdivideBuffer.Release();
    }