var inputSample = 5;
var dataSample=[['01---','11110','01---','00000'],['01110','1-1-1','----0'],['01---','11110','01110','1-1-1','0---0'],['----1']];
var sampleInputListNames=["A", "B"];
var sampleOutputListNames=["X"];
createCombinationalAnalysisPrompt=function(scope=globalScope){
//console.log("Ya");
scheduleBackup();
$('#combinationalAnalysis').empty();
$('#combinationalAnalysis').append("
Enter Input names separated by commas:
");
$('#combinationalAnalysis').append("
Enter Output names separated by commas:
");
$('#combinationalAnalysis').append("
Do you need a decimal column?
");
$('#combinationalAnalysis').dialog({
width:"auto",
buttons: [
{
text: "Next",
click: function() {
var inputList = $("#inputNameList").val().split(',');
var outputList = $("#outputNameList").val().split(',');
inputList = inputList.map(x => x.trim());
inputList = inputList.filter(e => e);
outputList = outputList.map(x => x.trim());
outputList = outputList.filter(e => e);
if(inputList.length > 0 && outputList.length > 0){
$(this).dialog("close");
createBooleanPrompt(inputList,outputList,scope);
}
else{
alert("Enter Input / Output Variable(s) !");
}
},
}
]
});
}
function createBooleanPrompt(inputListNames,outputListNames,scope=globalScope){
inputListNames=inputListNames||(prompt("Enter inputs separated by commas").split(','));
outputListNames=outputListNames||(prompt("Enter outputs separated by commas").split(','));
outputListNamesInteger=[];
for (var i = 0; i < outputListNames.length; i++)
outputListNamesInteger[i] = 7*i + 13;//assigning an integer to the value, 7*i + 13 is random
var s='
';
var matrix = [];
for(var i=0; i';
if($("#decimalColumnBox").is(":checked"))
s+='
'+j+'
';
for(var i=0;i'+matrix[i][j]+'';
}
for(var i=0;i'+'x'+'';
//using hash values as they'll be used in the generateBooleanTableData function
}
s+='';
}
s+='';
s+='
';
//console.log(s)
$('#combinationalAnalysis').empty()
$('#combinationalAnalysis').append(s)
$('#combinationalAnalysis').dialog({
width:"auto",
buttons: [
{
text: "Generate Circuit",
click: function() {
$( this ).dialog( "close" );
var data = generateBooleanTableData(outputListNamesInteger);
//passing the hash values to avoid spaces being passed which is causing a problem
minmizedCircuit = [];
for(let output in data){
let temp = new BooleanMinimize(
inputListNames.length,
data[output][1].map(Number),
data[output]['x'].map(Number)
)
minmizedCircuit.push(temp.result);
}
// //console.log(dataSample);
drawCombinationalAnalysis(minmizedCircuit,inputListNames,outputListNames,scope)
},
},
{
text: "Print Truth Table",
click: function() {
var sTable = document.getElementById('combinationalAnalysis').innerHTML;
var style = "";
var win = window.open('', '', 'height=700,width=700');
win.document.write('');
win.document.write('Boolean Logic Table');
win.document.write(style);
win.document.write('');
win.document.write('');
win.document.write('
'+sTable+'
');
win.document.write('');
win.document.close();
win.print();
},
},
]
});
$('.output').click(function (){
var v=$(this).html();
if(v==0)v=$(this).html(1);
else if(v==1)v=$(this).html('x');
else if(v=='x')v=$(this).html(0);
})
}
function generateBooleanTableData(outputListNames){
var data={};
for(var i=0;i1){
var andGate=new AndGate(andPosX, currentPosY, scope, "RIGHT", c, 1);
andGateNodes.push(andGate.output1);
var misses=0;
for(var k=0;k1){
var o=new OrGate(orPosX,orGatePosY,scope,"RIGHT",andGateCount,1);
if(andGateCount%2==1)andGateNodes[midWay].connect(o.inp[midWay]);
for(var j=0;j