//package com.example.mina.box.rbm3000; // //import com.example.mina.base.AbstractVirtualBoxHandler; //import com.example.mina.util.CommandHelper; //import com.example.mina.entity.AeroflexDataBuffer; //import com.example.mina.entity.Entry; //import lombok.extern.slf4j.Slf4j; //import org.apache.mina.core.buffer.IoBuffer; //import org.apache.mina.core.session.IoSession; // ///** // * @author dy // * @date 2021/3/5 // */ //@Slf4j //public class Rbm3000VirtualBoxHander extends AbstractVirtualBoxHandler { // // private AeroflexDataBuffer dataBuffer; // // public Rbm3000VirtualBoxHander() { // this.initMatrix(); // } // // @Override // protected void initMatrix() { // // int row = 6; // int col = 8; // int maxAtten = 222; // // dataBuffer = new AeroflexDataBuffer(row, maxAtten); // } // // @Override // protected byte[] handleMessage(byte[] cmd, int len) { // return new byte[0]; // } // // @Override // public void messageReceived(IoSession session, Object message) { // // IoBuffer ioBuffer = (IoBuffer) message; // byte[] bytes = new byte[ioBuffer.limit()]; // ioBuffer.get(bytes, ioBuffer.position(), ioBuffer.limit()); // // byte[] result = handleCommand(bytes, bytes.length); // // session.write(IoBuffer.wrap(result)); // } // // @Override // public void sessionCreated(IoSession session) { // // log.info("---server session created"); // } // // @Override // public void sessionOpened(IoSession session) { // // log.info("---server session Opened"); // } // // @Override // public void sessionClosed(IoSession session) { // // log.info("---server session Closed"); // } // // @Override // public void messageSent(IoSession session, Object message) { // // log.info("---发送数据成功了。。。{}", message); // } // // protected byte[] handleCommand(byte[] cmd, int len) { // // byte[] buffer; // Entry[][] entries = dataBuffer.getMatrixData(); // // if (len == 8) { // switch (cmd[0]) { // case 0x30: // int row = CommandHelper.BCD_REV[cmd[3]]; // int col = CommandHelper.BCD_REV[cmd[4]]; // // int rowCol = 0; // int colRow = 0; // // for (int i = 0; i < dataBuffer.getMaxCol(); i++) { // if (entries[row - 1][i].getValue() == 1) { // rowCol = i + 1; // break; // } // } // for (int i = 0; i < dataBuffer.getMaxRow(); i++) { // if (entries[i][col - 1].getValue() == 1) { // colRow = i + 1; // } // } // // dataBuffer.setAttenuation(row, rowCol, 0); // dataBuffer.setAttenuation(row, col, 1); // dataBuffer.setAttenuation(colRow, col, 0); // dataBuffer.setAttenuation(colRow, rowCol, 1); // // buffer = new byte[8]; // buffer[0] = cmd[0]; // buffer[1] = cmd[1]; // buffer[2] = cmd[2]; // buffer[3] = cmd[3]; // buffer[4] = cmd[4]; // buffer[5] = CommandHelper.BCD[colRow]; // buffer[6] = CommandHelper.BCD[rowCol]; // buffer[7] = (byte) 0x03; // // return buffer; // case 0x68: // boolean isA = (cmd[3] == (byte) 0x0A); // int callPort = CommandHelper.BCD_REV[cmd[4]]; // int returnPort = 0; // // if (isA) { // for (int i = 0; i < dataBuffer.getMaxCol(); i++) { // if (entries[callPort - 1][i].getValue() == 1) { // returnPort = i + 1; // break; // } // } // } else { // for (int i = 0; i < dataBuffer.getMaxRow(); i++) { // if (entries[i][callPort - 1].getValue() == 1) { // returnPort = i + 1; // } // } // } // // buffer = new byte[8]; // buffer[0] = cmd[0]; // buffer[1] = cmd[1]; // buffer[2] = cmd[2]; // if (isA) { // buffer[3] = 0x0B; // } else { // buffer[3] = 0x0A; // } // buffer[4] = CommandHelper.BCD[returnPort]; // buffer[5] = 0x00; // buffer[6] = 0x06; // buffer[7] = (byte) 0x03; // // return buffer; // case 0x62: // buffer = new byte[8]; // buffer[0] = cmd[0]; // buffer[1] = cmd[1]; // buffer[2] = cmd[2]; // buffer[3] = cmd[3]; // buffer[4] = cmd[4]; // buffer[5] = cmd[5]; // buffer[6] = cmd[6]; // buffer[7] = (byte) 0x03; // // return buffer; // default: // break; // } // } // // buffer = new byte[len + 2]; // buffer[0] = (byte) 0xFE; // buffer[1] = (byte) 0xFE; // System.arraycopy(cmd, 0, buffer, 2, len); // // return buffer; // } //}