Example #1
0
        void Element_OnVocationCreated(Element sender, Element rec, Vocation vocation)
        {
            if (sender == this.sender)
            {
                if (this.vocation != null)
                {
                    Debug.WriteLine("ssssppp");
                }
                this.vocation = vocation;


                if (((Processor)this.reciever).IsBusy)
                {
                    if (currentCapacity >= capacity)
                    {
                        isBusy = true;
                    }

                    if (!isBusy)
                    {
                        currentCapacity++;
                    }
                }
                else
                {
                    OnVocationCreated?.Invoke(this, this.reciever, vocation);

                    this.vocation = null;

                    if (counter != null)
                    {
                        counter.Increment();
                    }
                }
            }
        }
Example #2
0
        public override void ProcessTick(bool isFreeNextElement)
        {
            base.ProcessTick(isFreeNextElement);

            VocationLiveTimeIncrement();

            isFreeNextElement = true;

            if (reciever != null)
            {
                isFreeNextElement = !reciever.IsBusy;
            }

            if (isFreeNextElement && currentCapacity > 0)
            {
                currentCapacity--;

                OnVocationCreated?.Invoke(this, reciever, vocation);
                this.vocation = null;


                if (counter != null)
                {
                    counter.Increment();
                }
            }

            if (currentCapacity == capacity)
            {
                isBusy = true;
            }
            else
            {
                isBusy = false;
            }
        }
        public override void ProcessTick(bool isFreeNextElement)
        {
            base.ProcessTick(isFreeNextElement);
            isFreeNextElement = true;



            VocationLiveTimeIncrement();

            if (reciever != null)
            {
                isFreeNextElement = !reciever.IsBusy;
            }

            if (isBusy)
            {
                if (isBLocked && isFreeNextElement)
                {
                    isBLocked = false;
                    isBusy    = false;

                    OnVocationCreated?.Invoke(this, reciever, vocation);
                    vocation = null;


                    IsProcessed = true;
                    return;
                }

                if (!isBLocked)
                {
                    if (IsVocationProcessed())
                    {
                        if (!isFreeNextElement)
                        {
                            isBLocked = true;
                        }
                        else
                        {
                            isBusy = false;

                            OnVocationCreated?.Invoke(this, reciever, vocation);
                            vocation = null;

                            if (counter != null)
                            {
                                counter.Increment();
                            }
                        }
                    }
                    else
                    {
                        if (sender != null && OnBlockPrevious != null)
                        {
                            OnBlockPrevious(this, sender);
                        }
                    }
                }
            }
            else
            {
                //isBusy = true;
            }

            IsProcessed = true;
        }
 public void SendVocation()
 {
     OnVocationCreated?.Invoke(this, reciever, new Helper.Vocation());
     currentTickCount = period;
     //Debug.WriteLine("VOCATION SEND");
 }