|
|
|
@ -190,17 +190,48 @@ function changeLineColor(idLine) {
|
|
|
|
|
line.stroke(colorline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeLineState(idLine) {
|
|
|
|
|
let line = null;
|
|
|
|
|
lines.forEach(function (element) {
|
|
|
|
|
if (element.id === idLine) line = element;
|
|
|
|
|
});
|
|
|
|
|
var stateLine = line.state == true ? false : true;
|
|
|
|
|
line.state = stateLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setLineStateTrue(lineId) {
|
|
|
|
|
lines.forEach(function (line) {
|
|
|
|
|
if (line.id == lineId) line.state = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setLineStateFalse(lineId) {
|
|
|
|
|
lines.forEach(function (line) {
|
|
|
|
|
if (line.id == lineId) line.state = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLineState(lineId) {
|
|
|
|
|
var state = null;
|
|
|
|
|
lines.forEach(function (line) {
|
|
|
|
|
if (line.id == lineId) state = line.state;
|
|
|
|
|
});
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeLineColorInput(idLine, color) {
|
|
|
|
|
let line = stage.findOne("#" + idLine);
|
|
|
|
|
line.stroke(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeLineColorBlack(idLine) {
|
|
|
|
|
setLineStateFalse(idLine);
|
|
|
|
|
let line = stage.findOne("#" + idLine);
|
|
|
|
|
line.stroke(colorLineInnactive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeLineColorYellow(idLine) {
|
|
|
|
|
setLineStateTrue(idLine);
|
|
|
|
|
let line = stage.findOne("#" + idLine);
|
|
|
|
|
line.stroke(colorLineActive);
|
|
|
|
|
}
|
|
|
|
@ -314,24 +345,26 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
|
let line1State, line2State;
|
|
|
|
|
let id1Color = stage.findOne("#" + element.id1).stroke();
|
|
|
|
|
if (element.type !== "inv") {
|
|
|
|
|
let id2Color = stage.findOne("#" + element.id2).stroke();
|
|
|
|
|
line2State = getLineState(element.id2);
|
|
|
|
|
/*let id2Color = stage.findOne("#" + element.id2).stroke();
|
|
|
|
|
if (id2Color == colorLineInnactive) {
|
|
|
|
|
line2State = false;
|
|
|
|
|
} else {
|
|
|
|
|
line2State = true;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id1Color == colorLineInnactive) {
|
|
|
|
|
line1State = getLineState(element.id1);
|
|
|
|
|
/*if (id1Color == colorLineInnactive) {
|
|
|
|
|
line1State = false;
|
|
|
|
|
} else {
|
|
|
|
|
line1State = true;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
switch (logique.type) {
|
|
|
|
|
case "et":
|
|
|
|
|
if (line1State == true && line2State == true) {
|
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
|
console.log("oui");
|
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
@ -412,6 +445,29 @@ function isLineCollapsing() {
|
|
|
|
|
return isCollapsing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLogiqueByLine(idLine) {
|
|
|
|
|
var logique = null;
|
|
|
|
|
logiques.forEach(function (element) {
|
|
|
|
|
if (element.id1 === idLine || element.id2 === idLine) logique = element;
|
|
|
|
|
});
|
|
|
|
|
return logique;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateLines(logique) {
|
|
|
|
|
if (logique !== null) {
|
|
|
|
|
checkSortieLogique(logique.name);
|
|
|
|
|
logique.id3.forEach(function (line) {
|
|
|
|
|
updateLines(getLogiqueByLine(line));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function lineUpdate(swithId) {
|
|
|
|
|
var lineId = getSwitchById(swithId).id3;
|
|
|
|
|
var currLogique = getLogiqueByLine(lineId[0]);
|
|
|
|
|
updateLines(currLogique);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRandomArbitrary(min, max) {
|
|
|
|
|
return Math.floor(Math.random() * (max - min) + min);
|
|
|
|
|
}
|
|
|
|
@ -431,11 +487,11 @@ function checkLineSwitch(switchId) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function activeSwitch(idSwitch) {
|
|
|
|
|
getSwitchById(idSwitch);
|
|
|
|
|
var switche = getSwitchById(idSwitch);
|
|
|
|
|
changeSwitchColor(switche.id);
|
|
|
|
|
switche.id3.forEach(function (element) {
|
|
|
|
|
changeLineColor(element);
|
|
|
|
|
changeLineState(element);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|