Example #1
0
        public PrtDequeueReturnStatus PrtDequeueEvent(bool hasNullTransition)
        {
            if (eventQueue.DequeueEvent(this))
            {
                if (currentStatus == PrtMachineStatus.Blocked)
                {
                    throw new PrtInternalException("Internal error: Tyring to execute blocked machine");
                }

                stateImpl.TraceLine(
                    "<DequeueLog> Dequeued Event <{0},{1}> at Machine {2}-{3}",
                    (currentTrigger as PrtEventValue).evt.name, currentPayload.ToString(), Name, instanceNumber);
                stateImpl.DequeueCallback?.Invoke(this, (currentTrigger as PrtEventValue).evt.name, currentTriggerSenderInfo.Item1, currentTriggerSenderInfo.Item2);

                receiveSet = new HashSet <PrtValue>();
                return(PrtDequeueReturnStatus.SUCCESS);
            }
            else if (hasNullTransition || receiveSet.Contains(PrtValue.@null))
            {
                if (currentStatus == PrtMachineStatus.Blocked)
                {
                    throw new PrtInternalException("Internal error: Tyring to execute blocked machine");
                }
                stateImpl.TraceLine(
                    "<NullTransLog> Null transition taken by Machine {0}-{1}",
                    Name, instanceNumber);
                currentPayload = PrtValue.@null;
                currentTrigger = PrtValue.@null;
                receiveSet     = new HashSet <PrtValue>();
                return(PrtDequeueReturnStatus.NULL);
            }
            else if (CurrentActionSet.Contains(PrtValue.@null))
            {
                if (currentStatus == PrtMachineStatus.Blocked)
                {
                    throw new PrtInternalException("Internal error: Tyring to execute blocked machine");
                }
                stateImpl.TraceLine(
                    "<NullActionLog> Null action taken by Machine {0}-{1}",
                    Name, instanceNumber);
                currentPayload = PrtValue.@null;
                currentTrigger = PrtValue.@null;
                receiveSet     = new HashSet <PrtValue>();
                return(PrtDequeueReturnStatus.NULL);
            }
            else
            {
                if (currentStatus == PrtMachineStatus.Blocked)
                {
                    throw new PrtAssumeFailureException();
                }
                currentStatus = PrtMachineStatus.Blocked;
                if (stateImpl.Deadlock)
                {
                    throw new PrtDeadlockException("Deadlock detected");
                }
                return(PrtDequeueReturnStatus.BLOCKED);
            }
        }
Example #2
0
 public bool PrtIsActionInstalled(PrtValue ev)
 {
     return(CurrentActionSet.Contains(ev));
 }