Ejemplo n.º 1
0
        /// <summary>
        /// The terminal nodes doesn't have a memory, so the method
        /// does nothing.
        /// </summary>
        /// <param name="mem"></param>
        public override void clear(IWorkingMemory mem)
        {
            IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);

            if (tmem != null)
            {
                tmem.Clear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retracts the facts.
        /// </summary>
        /// <param name="inx">The inx.</param>
        /// <param name="engine">The engine.</param>
        /// <param name="mem">The mem.</param>
        public override void retractFacts(Index inx, Rete engine, IWorkingMemory mem)
        {
            IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);
            LinkedActivation             act  = (LinkedActivation)tmem.RemoveWithReturn(inx);

            if (act != null)
            {
                engine.Agenda.removeActivation(act);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Asserts the facts.
        /// </summary>
        /// <param name="inx">The inx.</param>
        /// <param name="engine">The engine.</param>
        /// <param name="mem">The mem.</param>
        public override void assertFacts(Index inx, Rete engine, IWorkingMemory mem)
        {
            LinkedActivation act = new LinkedActivation(theRule, inx);

            act.TerminalNode = this;
            IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);

            tmem.Put(inx, act);
            // Add the activation to the current module's activation list.
            engine.Agenda.addActivation(act);
        }
Ejemplo n.º 4
0
 /// <summary> The implementation checks to see if the rule is active before it tries to
 /// assert the fact. It checks in the following order.
 /// 1. is the expiration date greater than zero
 /// 2. is the current time > the effective date
 /// 3. is the current time the expiration date
 /// </summary>
 /// <param name="">facts
 /// </param>
 /// <param name="">engine
 /// 
 /// </param>
 public override void assertFacts(Index inx, Rete engine, IWorkingMemory mem)
 {
     long time = (DateTime.Now.Ticks - 621355968000000000)/10000;
     if (theRule.ExpirationDate > 0 && time > theRule.EffectiveDate && time < theRule.ExpirationDate)
     {
         LinkedActivation act = new LinkedActivation(theRule, inx);
         act.TerminalNode = this;
         IGenericMap<Object, Object> tmem = (IGenericMap<Object, Object>) mem.getTerminalMemory(this);
         tmem.Put(act.Index, act);
         // Add the activation to the current module's activation list.
         engine.Agenda.addActivation(act);
     }
 }
Ejemplo n.º 5
0
        /// <summary> The implementation checks to see if the rule is active before it tries to
        /// retract the fact. It checks in the following order.
        /// 1. is the expiration date greater than zero
        /// 2. is the current time > the effective date
        /// 3. is the current time the expiration date
        /// </summary>
        /// <param name="">facts
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void retractFacts(Index inx, Rete engine, IWorkingMemory mem)
        {
            long time = (DateTime.Now.Ticks - 621355968000000000) / 10000;

            if (theRule.ExpirationDate > 0 && time > theRule.EffectiveDate && time < theRule.ExpirationDate)
            {
                IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);
                LinkedActivation             act  = (LinkedActivation)tmem.RemoveWithReturn(inx);
                if (act != null)
                {
                    engine.Agenda.removeActivation(act);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary> The implementation checks to see if the rule is active before it tries to
        /// assert the fact. It checks in the following order.
        /// 1. is the expiration date greater than zero
        /// 2. is the current time > the effective date
        /// 3. is the current time the expiration date
        /// </summary>
        /// <param name="">facts
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertFacts(Index inx, Rete engine, IWorkingMemory mem)
        {
            long time = (DateTime.Now.Ticks - 621355968000000000) / 10000;

            if (theRule.ExpirationDate > 0 && time > theRule.EffectiveDate && time < theRule.ExpirationDate)
            {
                LinkedActivation act = new LinkedActivation(theRule, inx);
                act.TerminalNode = this;
                IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);
                tmem.Put(act.Index, act);
                // Add the activation to the current module's activation list.
                engine.Agenda.addActivation(act);
            }
        }
Ejemplo n.º 7
0
 /// <summary> Method will call checkFacts() first to make sure none of the facts have
 /// expired. An activation is only created if the facts are valid.
 /// </summary>
 /// <param name="">facts
 /// </param>
 /// <param name="">engine
 /// 
 /// </param>
 public override void assertFacts(Index inx, Rete engine, IWorkingMemory mem)
 {
     // first check the facts and make sure they didn't expire
     if (checkFacts(inx, engine, mem))
     {
         LinkedActivation act = new LinkedActivation(theRule, inx);
         act.TerminalNode = this;
         if (temporal)
         {
             engine.fireActivation(act);
         }
         else
         {
             IGenericMap<Object, Object> tmem = (IGenericMap<Object, Object>) mem.getTerminalMemory(this);
             tmem.Put(inx, act);
             // Add the activation to the current module's activation list.
             engine.Agenda.addActivation(act);
         }
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Remove the LinkedActivation from TerminalNode2. This is necessary
        /// when the activation is fired and the actions executed.
        /// </summary>
        /// <param name="mem">The mem.</param>
        /// <param name="activation">The activation.</param>
        public virtual void removeActivation(IWorkingMemory mem, LinkedActivation activation)
        {
            IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);

            tmem.Remove(activation.Index);
        }
Ejemplo n.º 9
0
 /// <summary> Method will call checkFacts() first to make sure none of the facts have
 /// expired. An activation is only created if the facts are valid.
 /// </summary>
 /// <param name="">facts
 /// </param>
 /// <param name="">engine
 ///
 /// </param>
 public override void assertFacts(Index inx, Rete engine, IWorkingMemory mem)
 {
     // first check the facts and make sure they didn't expire
     if (checkFacts(inx, engine, mem))
     {
         LinkedActivation act = new LinkedActivation(theRule, inx);
         act.TerminalNode = this;
         if (temporal)
         {
             engine.fireActivation(act);
         }
         else
         {
             IGenericMap <Object, Object> tmem = (IGenericMap <Object, Object>)mem.getTerminalMemory(this);
             tmem.Put(inx, act);
             // Add the activation to the current module's activation list.
             engine.Agenda.addActivation(act);
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary> The implementation checks to see if the rule is active before it tries to
 /// retract the fact. It checks in the following order.
 /// 1. is the expiration date greater than zero
 /// 2. is the current time > the effective date
 /// 3. is the current time the expiration date
 /// </summary>
 /// <param name="">facts
 /// </param>
 /// <param name="">engine
 /// 
 /// </param>
 public override void retractFacts(Index inx, Rete engine, IWorkingMemory mem)
 {
     long time = (DateTime.Now.Ticks - 621355968000000000)/10000;
     if (theRule.ExpirationDate > 0 && time > theRule.EffectiveDate && time < theRule.ExpirationDate)
     {
         IGenericMap<Object, Object> tmem = (IGenericMap<Object, Object>) mem.getTerminalMemory(this);
         LinkedActivation act = (LinkedActivation) tmem.RemoveWithReturn(inx);
         if (act != null)
         {
             engine.Agenda.removeActivation(act);
         }
     }
 }