public DisjunctiveNormalDecorator(ITruthTable table)
 {
     _data            = table;
     _argumentManager = new ArgumentsManager();
     _names           = table.GetOperator().GetArguments();
     StartCalculating();
 }
Ejemplo n.º 2
0
 public void BuildTruthTable()
 {
     if (this.ExpressionTree == null)
     {
         throw new NullReferenceException("The expression Tree has to be build in order the truth table to be created!");
     }
     this.TruthTable = this.ExpressionTree.BuildTruthTable(this.ToString());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets called when the parent model element of the current model element is about to change
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanging(IModelElement newParent, IModelElement oldParent)
        {
            ITruthTable           oldOwner = ModelHelper.CastAs <ITruthTable>(oldParent);
            ITruthTable           newOwner = ModelHelper.CastAs <ITruthTable>(newParent);
            ValueChangedEventArgs e        = new ValueChangedEventArgs(oldOwner, newOwner);

            this.OnOwnerChanging(e);
            this.OnPropertyChanging("Owner", e, _ownerReference);
        }
Ejemplo n.º 4
0
        private static byte GetSgnfcntCornersCnt(ITruthTable truthTable)
        {
            byte sgnfcntCubeCornersCnt = 0;

            for (byte i = 0; i < truthTable.GetRowCount(); i++)
            {
                if (truthTable[i, truthTable.ArgCount])
                {
                    sgnfcntCubeCornersCnt++;
                }
            }
            return(sgnfcntCubeCornersCnt);
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Owner == null))
                {
                    ITruthTable ownerCasted = item.As <ITruthTable>();
                    if ((ownerCasted != null))
                    {
                        this._parent.Owner = ownerCasted;
                        return;
                    }
                }
                ICell cellsCasted = item.As <ICell>();

                if ((cellsCasted != null))
                {
                    this._parent.Cells.Add(cellsCasted);
                }
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets called when the parent model element of the current model element changes
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent)
        {
            ITruthTable oldOwner = ModelHelper.CastAs <ITruthTable>(oldParent);
            ITruthTable newOwner = ModelHelper.CastAs <ITruthTable>(newParent);

            if ((oldOwner != null))
            {
                oldOwner.Rows.Remove(this);
            }
            if ((newOwner != null))
            {
                newOwner.Rows.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldOwner, newOwner);

            this.OnOwnerChanged(e);
            this.OnPropertyChanged("Owner", e, _ownerReference);
            base.OnParentChanged(newParent, oldParent);
        }
Ejemplo n.º 7
0
        public static Coverage GetNullCoverage(ITruthTable truthTable)
        {
            var cubes = new ICube[GetSgnfcntCornersCnt(truthTable)];

            for (byte i = 0, cubesI = 0; i < truthTable.GetRowCount(); i++)
            {
                if (!truthTable[i, truthTable.ArgCount])
                {
                    continue;
                }
                var row = new State[truthTable.ArgCount];
                for (byte j = 0; j < truthTable.ArgCount; j++)
                {
                    row[j] = truthTable[i, j];
                }
                cubes[cubesI] = new Cube(row);
                cubesI++;
            }
            return(new Coverage(cubes));
        }
Ejemplo n.º 8
0
 public static ITruthTable<T1, T2, T3, T4> Row<T1, T2, T3, T4>(this ITruthTable<T1, T2, T3, T4> table, bool v1, bool v2, bool v3, bool v4, bool result)
 {
     (table as IMutableTable).AddRow(v1, v2, v3, v4, result);
     return table;
 }
Ejemplo n.º 9
0
 public static CubesComplex GetCubesComplex(ITruthTable truthTable)
 {
     return(GetCubesComplex(GetNullCoverage(truthTable)));
 }