Пример #1
0
        // TODO: Implement Refuse Mode
        public override void Action()
        {
            // O: Required
            if (this.O_RelationalOp == null || this.O_RelationalOp.Value == null)
            {
                throw new ModelingException("TEST: Operand O is required conditional operand!");
            }
            string relationalOp = this.O_RelationalOp.Value;

            // A: Required.
            if (this.A_LValue == null)
            {
                throw new ModelingException("TEST: Operand A is required operand!");
            }
            double lValue = this.A_LValue.GetValue();

            // B: Required.
            if (this.B_RValue == null)
            {
                throw new ModelingException("TEST: Operand B is required operand!");
            }
            double rValue = this.B_RValue.GetValue();

            // C: Required. The operand must be PosInteger. Optional in refuse mode.
            if (this.C_DestBlockNo == null)
            {
                throw new ModelingException("TEST: Operand C is required operand!");
            }
            int consumerOnFalseBlockId = (int)C_DestBlockNo.GetValue();

            if (consumerOnFalseBlockId <= 0)
            {
                throw new ModelingException("TEST: Operand C must be PosInteger!");
            }


            Transaction transaction = this.Simulation.ActiveTransaction;

            this.EntryCount++;

            Console.WriteLine("Tested  \tTime: " + this.Simulation.Clock + transaction, ConsoleColor.DarkGreen);
            Console.WriteLine("\ttrue");

            AnyBlock consumerOnFalse = this.Simulation.Blocks[consumerOnFalseBlockId];

            if (this.Compare(relationalOp, lValue, rValue))
            {
                transaction.ChangeOwner(this);
                this.NextSequentialBlock.PassTransaction(transaction);
            }
            else
            {
                transaction.ChangeOwner(this);
                consumerOnFalse.PassTransaction(transaction);
            }

            this.Simulation.CurrentEventChain.AddAhead(transaction);
        }
Пример #2
0
        public override void Action()
        {
            // A: Required.
            if (this.A_TimeToWait == null)
            {
                throw new ModelingException("VOLATILE: Operand A is required operand!");
            }
            double timeToWait = this.A_TimeToWait.GetValue();

            if (timeToWait <= 0)
            {
                throw new ModelingException("VOLATILE: Negative time span!");
            }

            // B: Required. The operand must be PosInteger.
            int destBlockNo = (int)this.B_DestBlockNo.GetValue();

            if (destBlockNo <= 0)
            {
                throw new ModelingException("VOLATILE: Operand B must be PosInteger!");
            }

            Transaction transaction = this.Simulation.ActiveTransaction;

            this.EntryCount++;

            transaction.ChangeOwner(this);

            // Pass to NSB
            this.NextSequentialBlock.PassTransaction(transaction);
            this.Simulation.CurrentEventChain.AddAhead(transaction);

            // Pass Clone to Label
            Transaction transactionClone  = transaction.Split(this.Simulation.NumbersManager.NextFreeTransactionNo);
            AnyBlock    consumerOnTimeEnd = this.Simulation.Blocks[destBlockNo];

            transactionClone.NextEventTime = this.Simulation.Clock + timeToWait;
            consumerOnTimeEnd.PassTransaction(transactionClone); //transactionClone.SetNextOwner(consumerOnTimeEnd);
            this.Simulation.FutureEventChain.Add(transactionClone);

            clones.Add(transaction, transactionClone);
        }