Commit 39eb8a552d1ca7d4f446fedddaeae53c94f79a13
1 parent
45b02a76
Exists in
develop
handOver注释
Showing
1 changed file
with
8 additions
and
12 deletions
Show diff stats
src/main/java/com/example/mina/client/experiment/HandoverExperiment.java
@@ -31,24 +31,24 @@ public class HandoverExperiment extends Experiment { | @@ -31,24 +31,24 @@ public class HandoverExperiment extends Experiment { | ||
31 | if (one == null || one.getInList() == null) { | 31 | if (one == null || one.getInList() == null) { |
32 | return; | 32 | return; |
33 | } | 33 | } |
34 | - // 输入端口的个数 | 34 | + // in port count |
35 | int inSize = one.getInList().size(); | 35 | int inSize = one.getInList().size(); |
36 | if (inSize < 2) { | 36 | if (inSize < 2) { |
37 | return; | 37 | return; |
38 | } | 38 | } |
39 | - // 循环次数 | 39 | + // circle count |
40 | Integer count = options.getMaxIterCount(); | 40 | Integer count = options.getMaxIterCount(); |
41 | if (count == null || count < 1) { | 41 | if (count == null || count < 1) { |
42 | return; | 42 | return; |
43 | } | 43 | } |
44 | Integer step = options.getStep(); | 44 | Integer step = options.getStep(); |
45 | Integer endAttenuation = options.getEndAttenuation(); | 45 | Integer endAttenuation = options.getEndAttenuation(); |
46 | - int dynamicCont = endAttenuation / step; | ||
47 | if (step == null || step <= 0) { | 46 | if (step == null || step <= 0) { |
48 | return; | 47 | return; |
49 | } | 48 | } |
49 | + int dynamicCont = endAttenuation / step; | ||
50 | for (int i = 0; i < count; i++) { | 50 | for (int i = 0; i < count; i++) { |
51 | - // 输入端口只有 2 个 | 51 | + // in port count == 2 |
52 | if (inSize == 2) { | 52 | if (inSize == 2) { |
53 | for (int k = 0; k <= dynamicCont; k++) { | 53 | for (int k = 0; k <= dynamicCont; k++) { |
54 | int dynamic = step * k; | 54 | int dynamic = step * k; |
@@ -73,15 +73,14 @@ public class HandoverExperiment extends Experiment { | @@ -73,15 +73,14 @@ public class HandoverExperiment extends Experiment { | ||
73 | } | 73 | } |
74 | } | 74 | } |
75 | } else { | 75 | } else { |
76 | - // 输入端口大于 2 | ||
77 | - // 行数 | 76 | + // in port count > 2 |
78 | int rowCount = 1 + inSize * dynamicCont; | 77 | int rowCount = 1 + inSize * dynamicCont; |
79 | - // 动态衰减值 矩阵 | 78 | + // dynamic attenuation matrix |
80 | int[][] attenuation = new int[rowCount][inSize]; | 79 | int[][] attenuation = new int[rowCount][inSize]; |
81 | - // 当前动态输入端口指针 | 80 | + // current dynamic in port index |
82 | int current = 0; | 81 | int current = 0; |
83 | for (int k = 0; k < rowCount; k++) { | 82 | for (int k = 0; k < rowCount; k++) { |
84 | - // 动态衰减值 | 83 | + // dynamic value |
85 | int dynamic = step * (k != 0 && k % dynamicCont == 0 ? dynamicCont : k % dynamicCont); | 84 | int dynamic = step * (k != 0 && k % dynamicCont == 0 ? dynamicCont : k % dynamicCont); |
86 | for (int j = 0; j < inSize; j++) { | 85 | for (int j = 0; j < inSize; j++) { |
87 | if (j == current && j != inSize - 1) { | 86 | if (j == current && j != inSize - 1) { |
@@ -94,13 +93,11 @@ public class HandoverExperiment extends Experiment { | @@ -94,13 +93,11 @@ public class HandoverExperiment extends Experiment { | ||
94 | attenuation[k][j] = endAttenuation; | 93 | attenuation[k][j] = endAttenuation; |
95 | } | 94 | } |
96 | } | 95 | } |
97 | - // 一轮衰减完成后,当前动态输入端口指针 加 1 | ||
98 | if (k != 0 && k % dynamicCont == 0) { | 96 | if (k != 0 && k % dynamicCont == 0) { |
99 | current++; | 97 | current++; |
100 | } | 98 | } |
101 | } | 99 | } |
102 | for (int x = 0; x < rowCount; x++) { | 100 | for (int x = 0; x < rowCount; x++) { |
103 | - // 当前行 --> 时间点,需要发送的 命令 | ||
104 | List<MatrixCommand> commandList = new ArrayList<>(); | 101 | List<MatrixCommand> commandList = new ArrayList<>(); |
105 | for (int y = 0; y < inSize; y++) { | 102 | for (int y = 0; y < inSize; y++) { |
106 | int att = attenuation[x][y]; | 103 | int att = attenuation[x][y]; |
@@ -112,7 +109,6 @@ public class HandoverExperiment extends Experiment { | @@ -112,7 +109,6 @@ public class HandoverExperiment extends Experiment { | ||
112 | } | 109 | } |
113 | } | 110 | } |
114 | commandList.forEach(this::sendCommand); | 111 | commandList.forEach(this::sendCommand); |
115 | - // 发送完成后,清空集合。 | ||
116 | commandList.clear(); | 112 | commandList.clear(); |
117 | try { | 113 | try { |
118 | Thread.sleep(options.getPeriod() * 1000); | 114 | Thread.sleep(options.getPeriod() * 1000); |