package com.example.mina.client.box.lte3000; import com.example.mina.client.base.AbstractClient; import com.example.mina.client.entity.ClientDTO; import com.example.mina.client.entity.Command; import com.example.mina.client.entity.Lte3000Message; import com.example.mina.client.entity.ServerMessage; import com.example.mina.server.entity.Entry; import com.example.mina.server.entity.Lte3000DataBuffer; import com.example.mina.server.util.Lte3000CommandHelper; /** * @author dy * @date 2021/3/10 */ public class Lte3000Client extends AbstractClient { @Override protected void init() { ServerMessage serverMessage = serverService.getServerService(this.getClass().getSimpleName()); hardwareDataBuffer = new Lte3000DataBuffer(32, 32, 30); abstractClientMessage = new Lte3000Message(); abstractClientMessage.setServerMessage(serverMessage); for (int i = 0; i < this.hardwareDataBuffer.getMaxRow(); i++) { abstractClientMessage.getCommands().add(new Command("", Lte3000CommandHelper.genCommandGetCross(i + 1))); } // query attenuation // the LTE attenuation is bound to column for (int j = 0; j < this.hardwareDataBuffer.getMaxCol(); j++) { abstractClientMessage.getCommands().add(new Command("", Lte3000CommandHelper.genCommandGetAttn(j + 1))); } protocolCodecFactory = new Lte3000ByteFactory(); abstractVirtualBoxClientHandler = new Lte3000ClientHandler(abstractClientMessage, hardwareDataBuffer); } @Override public void setAttenuation(ClientDTO clientDTO) { byte[] cmd; if (clientDTO.getRow() == 0) { cmd = Lte3000CommandHelper.genCommandSetAttn(clientDTO.getCol(), clientDTO.getMaxAttn()); } else { cmd = Lte3000CommandHelper.genCommandSetCross(clientDTO.getRow(), clientDTO.getCol()); } ioSession.write(cmd); } public boolean isCrossPointOn(int row, int col) { return hardwareDataBuffer.getAttenuation(row, col) >= 1; } @Override public int getAttenuation(int col) { return hardwareDataBuffer.getOffset(col); } public byte[] genCloseCommand(){ return Lte3000CommandHelper.genCommandGetCross(1); } public Entry[][] getMatrix(){ return hardwareDataBuffer.getMatrixData(); } public Entry[] getOffsetData(){ return hardwareDataBuffer.getOffsetData(); } /*@Override public Boolean reset() { return null; } @Override public int[][] getAll() { return new int[0][]; }*/ }