Skip to main content
Sign in
Snippets Groups Projects
Commit 1c0040d7 authored by jr4234s's avatar jr4234s
Browse files

Implement method so as to switch the connection style to dashed, if the errors are too big.

parent 8336735e
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -44,14 +44,18 @@ export class Connection{
constructor(startNode, endNode){
this.startNode = startNode;
this.endNode = endNode;
this.delivered = 0;
this.deliveredFile = 0;
this.crcError = 0;
this.dropped = 0;
this.droppedError = 0;
this.wrongId = 0;
this.broken = false;
this.crcErrorBound = 300;
this.wrongIdBound = 300;
}
print(){
console.log("Output: "+this.startNode+", Input: "+this.endNode+"\nDelivered: "+this.delivered+", CRC_Error: "+this.crcError+", Dropped: "+this.dropped+", Wrong_ID: "+this.wrongId);
console.log("Output: "+this.startNode+", Input: "+this.endNode+"\nDelivered: "+this.deliveredFile+", CRC_Error: "+this.crcError+", Dropped: "+this.dropped+", Wrong_ID: "+this.wrongId);
}
isEquals(element){
......@@ -66,22 +70,61 @@ export class Connection{
return ".c-"+this.startNode+".c-"+this.endNode;
}
set deliverRate(value){
set delivered(value){
if(!Number.isInteger(value)){
throw "Value is not a Integer";
}
if(value != this.delivered){
this.delivered = value;
this.updateConnectionColor();
if(value != this.deliveredFile){
this.deliveredFile = value;
this.updateColor();
}
}
set dropped(drop){
this.droppedError = drop;
}
set CRC_Error(err){
if((this.crcError < this.crcErrorBound && err >= this.crcErrorBound) || (this.crcError >= this.crcErrorBound && err < this.crcErrorBound)){
this.checkErrorRate();
}
this.crcError = err;
}
set wrongID(wrong){
if((this.wrongId < this.wrongIdBound && wrong >= this.wrongIdBound) || (this.wrongId >= this.wrongIdBound && wrong < this.wrongIdBound)){
this.checkErrorRate();
}
this.wrongId = wrong;
this.checkErrorRate();
}
checkErrorRate(){
if(this.crcError >= this.crcErrorBound || this.wrongId >= this.wrongIdBound){
let connections = document.querySelectorAll(this.getSelector());
for (let connection of connections) {
connection.style.zIndex = String(101);
if (connection.getAttribute("class").split(" ")[1] === "c-"+this.startNode) {
connection.style.borderStyle = "dashed";
}
}
} else{
let connections = document.querySelectorAll(this.getSelector());
for (let connection of connections) {
connection.style.zIndex = String(Math.floor(this.deliveredFile/1300*100));
if (connection.getAttribute("class").split(" ")[1] === "c-"+this.startNode) {
connection.style.borderStyle = "solid"
}
}
}
}
updateConnectionColor(){
updateColor(){
let connections = document.querySelectorAll(this.getSelector());
for (let connection of connections) {
connection.style.zIndex = String(this.delivered);
connection.style.zIndex = String(Math.floor(this.deliveredFile/1300*100));
if (connection.getAttribute("class").split(" ")[1] === "c-"+this.startNode) {
connection.style.borderColor = calculateColorScale(this.delivered/1300*100);
connection.style.borderColor = calculateColorScale(this.deliveredFile/1300*100);
}
}
}
......
......
......@@ -515,10 +515,10 @@ async function updateConnections() {
elementList = elementList.split("|");
let conn = connectionList.getConnection("0-1 "+elementList[0]+"-"+elementList[1]);
conn.deliverRate = parseInt(data[element][0]);
conn.crcError = parseInt(data[element][1]);
conn.delivered = parseInt(data[element][0]);
conn.CRC_Error = parseInt(data[element][1]);
conn.dropped = parseInt(data[element][2]);
conn.wrongId = parseInt(data[element][3]);
conn.wrongID = parseInt(data[element][3]);
conn.print();
}
}
......
......
......@@ -80,7 +80,7 @@ def get_connections_infomations(request):
# continue
# ret.setdefault(line[startIndex], [infos[startIndex+1].rstrip(",").strip(), infos[startIndex+2].rstrip(",").strip(), infos[startIndex+3].rstrip(",").strip(), infos[startIndex+4].rstrip(",").strip()])
ret.setdefault("(2|2)", ["1274", "0", "0", "0"])
ret.setdefault("(2|2)", ["1274", "0", "0", "299"])
return HttpResponse(json.dumps(ret, indent=4));
return HttpResponse(False)
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment