-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2232b0
commit 2770b6d
Showing
10 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/net/shibadogs/prcm/process/calculate/status.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.shibadogs.prcm.process.calculate | ||
|
||
import net.shibadogs.prcm.server.statusList | ||
|
||
fun percent(): MutableMap<Int, Int> { | ||
val result: MutableMap<Int, Int> = mutableMapOf() | ||
for (i in statusList) { | ||
var runs = 0 | ||
if (i.value.isEmpty()) { | ||
result[i.key] = 0 | ||
continue | ||
} | ||
for (ck in i.value) { | ||
if (ck) { | ||
runs += 1 | ||
} | ||
} | ||
if (runs == 0) { | ||
result[i.key] = 0 | ||
continue | ||
} | ||
if (runs == i.value.size) { | ||
result[i.key] = 100 | ||
continue | ||
} | ||
result[i.key] = (runs.toDouble() / i.value.size * 100).toInt() | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.shibadogs.prcm.process.flow | ||
|
||
import net.shibadogs.prcm.save.loadxml | ||
import net.shibadogs.prcm.server.nodeList | ||
import net.shibadogs.prcm.server.statusList | ||
|
||
fun nodeStatus() { | ||
val loadConfigs = loadxml("configs.xml") | ||
for (i in loadConfigs) { | ||
if (statusList.getOrElse(i.value.id) { null } == null) { | ||
statusList[i.value.id] = MutableList(60) {false} | ||
} | ||
if (nodeList.getOrElse(i.value.id) { null } == null) { | ||
statusList[i.value.id]?.add(false) | ||
} else { | ||
statusList[i.value.id]?.add(true) | ||
} | ||
if (statusList[i.value.id]?.size ?: 0 >= 60) { | ||
statusList[i.value.id]?.subList(0, statusList[i.value.id]!!.size - 60)?.clear() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters