/***************************************************************************/ public LogicSet toLogicSet(int _number, int _size) { LogicSet result = new LogicSet(); for (int i = 0; i < _size; ++i) { result.Add(LogicValue.Enum.Unknown); } for (int i = 0; i < _size; ++i) { int remainder = _number % 2; if (remainder == 1) { result[i] = LogicValue.Enum.High; } else { result[i] = LogicValue.Enum.Low; } _number /= 2; } return(result); }
public void simpleConvert() { LogicValuesNumbersConverter converter = new LogicValuesNumbersConverter(); LogicSet set1 = new LogicSet(); set1.Add(LogicValue.Enum.Low); set1.Add(LogicValue.Enum.Low); set1.Add(LogicValue.Enum.Low); //000 Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 0); //001 set1[0] = LogicValue.Enum.High; Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 1); //010 set1[1] = LogicValue.Enum.High; set1[0] = LogicValue.Enum.Low; Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 2); //011 set1[0] = LogicValue.Enum.High; Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 3); //100 set1[2] = LogicValue.Enum.High; set1[1] = LogicValue.Enum.Low; set1[0] = LogicValue.Enum.Low; Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 4); //101 set1[0] = LogicValue.Enum.High; Assert.AreEqual(converter.executeOnSimpleLogicSet(set1), 5); }
/***************************************************************************/ private LogicSet logicSetCopy(LogicSet _set) { LogicSet newSet = new LogicSet(); int count = _set.Count; for (int i = 0; i < count; ++i) { newSet.Add(_set[i]); } return(newSet); }
/***************************************************************************/ private LogicSet toLogicSet( ILineCollection _lines , int _firstIndex , int _lastIndex ) { LogicSet newSet = new LogicSet(); for (int i = _firstIndex; i <= _lastIndex; ++i) { newSet.Add(_lines[i].Value); } return(newSet); }