public DisjunctiveNormalDecorator(ITruthTable table) { _data = table; _argumentManager = new ArgumentsManager(); _names = table.GetOperator().GetArguments(); StartCalculating(); }
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()); }
/// <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); }
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); }
/// <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); } }
/// <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); }
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)); }
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; }
public static CubesComplex GetCubesComplex(ITruthTable truthTable) { return(GetCubesComplex(GetNullCoverage(truthTable))); }