/// <summary> Assert from the right side is always going to be from an Alpha node.
        ///
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this);

            rightmem.Put(rfact, rfact);
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);
            IEnumerator itr = leftmem.Values.GetEnumerator();

            while (itr.MoveNext())
            {
                IBetaMemory bmem = (IBetaMemory)itr.Current;
                if (evaluate(bmem.LeftFacts, rfact, engine))
                {
                    // now we propogate
                    bmem.addMatch(rfact);
                    propogateAssert(bmem.Index.add(rfact), engine, mem);
                }
            }
        }
Beispiel #2
0
        /// <summary> Assert from the right side is always going to be from an
        /// Alpha node.
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            // we only proceed if the fact hasn't already entered
            // the join node
            Index linx = new Index(new IFact[0]);
            IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this);

            rightmem.Put(rfact, rfact);
            // now that we've added the facts to the list, we
            // proceed with evaluating the fact
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);
            IEnumerator itr = leftmem.Values.GetEnumerator();

            while (itr.MoveNext())
            {
                IBetaMemory bmem      = (IBetaMemory)itr.Current;
                int         prevCount = bmem.matchCount();
                if (evaluate(linx.Facts, rfact, engine))
                {
                    bmem.addMatch(rfact);
                }
                // When facts are asserted from the right, it can only
                // increase the match count, so basically it will never
                // need to propogate to successor nodes.
                if (prevCount == 0 && bmem.matchCount() != 0)
                {
                    linx = new Index(new IFact[0]);
                    // we have to retract
                    try
                    {
                        propogateRetract(linx, engine, mem);
                    }
                    catch (RetractException e)
                    {
                        throw new AssertException("NotJion - " + e.Message);
                    }
                }
            }
        }