Commit 075c6b410cceca3b63649d21876df710bc14d47f

Authored by 林本磊
1 parent 9b4524d9
Exists in develop

fix: 修改抽象client

src/main/java/com/example/mina/client/base/AbstractClient.java
... ... @@ -54,24 +54,29 @@ public abstract class AbstractClient {
54 54 // 等待建立连接
55 55 connectFuture.awaitUninterruptibly();
56 56 // 获取连接会话
  57 + int a = getAttenuation(3);
  58 +
57 59 this.ioSession = connectFuture.getSession();
58   - setAttenuation(clientDTO);
59   - }
60 60  
61   - public boolean isConnected() {
62   - return false;
  61 + //setAttenuation(clientDTO);
  62 +
  63 + int b = getAttenuation(3);
63 64 }
64 65  
65   - public void close() {
  66 + abstract public int getAttenuation(int col);
66 67  
67   - }
  68 + /*public boolean isConnected() {
  69 + return false;
  70 + }*/
  71 +
  72 + //public void close() {}
68 73  
69 74 abstract public void setAttenuation(ClientDTO clientDTO);
70 75  
71   - //abstract public int getAttenuation(int row, int col);
72 76  
73   - abstract public Boolean reset();
74 77  
75   - abstract public int[][] getAll();
  78 + //abstract public Boolean reset();
  79 +
  80 + //abstract public int[][] getAll();
76 81  
77 82 }
... ...
src/main/java/com/example/mina/client/base/AbstractVirtualBoxClientHandler.java
... ... @@ -34,7 +34,7 @@ public abstract class AbstractVirtualBoxClientHandler extends IoHandlerAdapter {
34 34  
35 35 @Override
36 36 public void messageReceived(IoSession session, Object message) {
37   - handleCommandResponse(clientMessage.getCommands().get(1).getBytes(), (byte[]) message, ((byte[]) message).length);
  37 + //handleCommandResponse(clientMessage.getCommands().get(1).getBytes(), (byte[]) message, ((byte[]) message).length);
38 38 System.out.println("客户端messageReceived被调用!");
39 39 System.out.println("client端接收信息:" + new String((byte[])message, StandardCharsets.UTF_8));
40 40 LogUtils.println("client端接收信息hex:",(byte[])message);
... ...
src/main/java/com/example/mina/client/box/aeroflex/AeroflexClient.java
... ... @@ -36,7 +36,7 @@ public class AeroflexClient extends AbstractClient {
36 36 @Override
37 37 public int getAttenuation(int row, int col) {
38 38 return 0;
39   - }*/
  39 + }
40 40  
41 41 @Override
42 42 public Boolean reset() {
... ... @@ -46,6 +46,10 @@ public class AeroflexClient extends AbstractClient {
46 46 @Override
47 47 public int[][] getAll() {
48 48 return new int[0][];
49   - }
  49 + }*/
50 50  
  51 + @Override
  52 + public int getAttenuation(int col) {
  53 + return 0;
  54 + }
51 55 }
... ...
src/main/java/com/example/mina/client/box/lte3000/Lte3000Client.java
... ... @@ -5,6 +5,7 @@ import com.example.mina.client.entity.ClientDTO;
5 5 import com.example.mina.client.entity.Command;
6 6 import com.example.mina.client.entity.Lte3000Message;
7 7 import com.example.mina.client.entity.ServerMessage;
  8 +import com.example.mina.server.entity.Entry;
8 9 import com.example.mina.server.entity.Lte3000DataBuffer;
9 10 import com.example.mina.server.util.Lte3000CommandHelper;
10 11  
... ... @@ -45,11 +46,28 @@ public class Lte3000Client extends AbstractClient {
45 46 ioSession.write(cmd);
46 47 }
47 48  
  49 + public boolean isCrossPointOn(int row, int col) {
  50 + return hardwareDataBuffer.getAttenuation(row, col) >= 1;
  51 + }
  52 +
  53 + @Override
48 54 public int getAttenuation(int col) {
49 55 return hardwareDataBuffer.getOffset(col);
50 56 }
51 57  
52   - @Override
  58 + public byte[] genCloseCommand(){
  59 + return Lte3000CommandHelper.genCommandGetCross(1);
  60 + }
  61 +
  62 + public Entry[][] getMatrix(){
  63 + return hardwareDataBuffer.getMatrixData();
  64 + }
  65 +
  66 + public Entry[] getOffsetData(){
  67 + return hardwareDataBuffer.getOffsetData();
  68 + }
  69 +
  70 + /*@Override
53 71 public Boolean reset() {
54 72 return null;
55 73 }
... ... @@ -57,6 +75,6 @@ public class Lte3000Client extends AbstractClient {
57 75 @Override
58 76 public int[][] getAll() {
59 77 return new int[0][];
60   - }
  78 + }*/
61 79  
62 80 }
... ...
src/main/java/com/example/mina/client/test/MinaClient.java
... ... @@ -31,7 +31,7 @@ public class MinaClient {
31 31 // cf.getSession().getCloseFuture().awaitUninterruptibly();
32 32 //
33 33 // connector.dispose();
34   - new Lte3000Client().start(ClientDTO.builder().row(32).col(32).maxAttn(30).build());
  34 + new Lte3000Client().start(ClientDTO.builder().row(0).col(3).maxAttn(5).build());
35 35  
36 36  
37 37 }
... ...
src/main/java/com/example/mina/server/box/lte3000/Lte3000VirtualBoxHandler.java
No preview for this file type