Skip to content

Commit

Permalink
fixed linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Medrek authored and Jack Medrek committed Jan 9, 2024
1 parent 39a4960 commit 928fce8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/core/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ export class NetworkHub {
for (const n of this.Nodes.value) {
if (n.id == 0) continue

let neighbors: any = []
const neighbors: any = []

switch (n.type) {
// 5G UE connects to one 5G tower and multiple wired end systems
case NODE_TYPE.FIVE_G_UE:
case NODE_TYPE.FIVE_G_UE: {
const ueBsNeighbors = this.kdTree.FindKNearest(n.pos, 1, 20)
const validUeBs = ueBsNeighbors.find(nn => this.Nodes.value[nn].type === NODE_TYPE.FIVE_G_GNB)
if (validUeBs !== undefined) neighbors.push(validUeBs)
Expand All @@ -218,9 +218,9 @@ export class NetworkHub {
if (validUeEnd !== undefined) neighbors.push(validUeEnd)

break

}
// 5G GNB connects to a TSN, an end system, and multiple 5G UEs
case NODE_TYPE.FIVE_G_GNB:
case NODE_TYPE.FIVE_G_GNB: {
const bsNeighbors = this.kdTree.FindKNearest(n.pos, 1, 20)
const validGnbTsn = bsNeighbors.find(nn => this.Nodes.value[nn].type === NODE_TYPE.TSN)
const validBsEnd = bsNeighbors.find(nn => this.Nodes.value[nn].type >= NODE_TYPE.END_SYSTEM_SERVER)
Expand All @@ -232,18 +232,18 @@ export class NetworkHub {
neighbors.push(...validUes)

break

}
// TSCH node connects to multiple other TSCH nodes and wired end systems
case NODE_TYPE.TSCH:
case NODE_TYPE.TSCH: {
const tschNeighbors = this.kdTree.FindKNearest(n.pos, 1000, 20)
const validTsch = tschNeighbors.filter(nn => this.Nodes.value[nn].type === NODE_TYPE.TSCH)
const validTschEnd = tschNeighbors.find(nn => this.Nodes.value[nn].type >= NODE_TYPE.END_SYSTEM_SERVER)
neighbors.push(...validTsch)
if (validTschEnd !== undefined) neighbors.push(validTschEnd)
break

}
// TSN bridge connects multiple TSN bridges, 5G tower and end systems
case NODE_TYPE.TSN:
case NODE_TYPE.TSN: {
const tsnNeighbors = this.kdTree.FindKNearest(n.pos, 1000, 20)
const validTsn = tsnNeighbors.filter(nn => this.Nodes.value[nn].type === NODE_TYPE.TSN)
const validTsnGnb = tsnNeighbors.find(nn => this.Nodes.value[nn].type === NODE_TYPE.FIVE_G_GNB)
Expand All @@ -253,16 +253,17 @@ export class NetworkHub {
if (validTsnEnd !== undefined) neighbors.push(validTsnEnd)

break

}
// end system connects to one network node
default:
default: {
const networkNeighbors = this.kdTree.FindKNearest(n.pos, 1, 20)
const validNetwork = networkNeighbors.find(nn =>
this.Nodes.value[nn].type === NODE_TYPE.TSN ||
this.Nodes.value[nn].type === NODE_TYPE.TSCH ||
this.Nodes.value[nn].type === NODE_TYPE.FIVE_G_UE)
if (validNetwork !== undefined) neighbors.push(validNetwork)
break
}
}

n.neighbors = neighbors
Expand Down

0 comments on commit 928fce8

Please sign in to comment.