package com.example.mina.server.util; import java.nio.charset.StandardCharsets; public class RmasmCommandHelper { /*public static byte[] genReadAllAttenuation(HardwareConfig hardwareConfig) { int maxInput = hardwareConfig.getInputNumber(); int maxOutput = hardwareConfig.getOutputNumber(); int maxIndex = getIndex(maxInput, maxOutput, maxOutput); return String.format("RA 1-%d\r\n", maxIndex).getBytes(StandardCharsets.UTF_8); } public static byte[] genSetAttenuation(int input, int output, int atten, HardwareConfig hardwareConfig) { int index = getIndex(input, output, hardwareConfig.getOutputNumber()); String command = String.format("SA %d %d\r\n", index, atten); return command.getBytes(StandardCharsets.UTF_8); }*/ public static byte[] genReadPowermeter(int index) { String command = String.format("RP %d\r\n", index); return command.getBytes(StandardCharsets.UTF_8); } public static int getInput(int index, int maxOutput) { return ((index - 1) / maxOutput) + 1; } public static int getOutput(int index, int maxOutput) { return ((index - 1) % maxOutput) + 1; } public static int getIndex(int input, int output, int maxOutput) { return (input - 1) * maxOutput + output; } }