return commandFrame;
}
public Buffer buildBinaryControlCommand(byte operateMode, int index,
byte controlCode, int timeOn, int timeOff) {
Buffer commandFrame = appSnd
.buildRequestMsg(operateMode, BINARY_OUTPUT_COMMAND, (byte) 1,
new int[] { index }, WITH_DATA);
// int previous_marker = commandFrame.length();
commandFrame.writeByte(toBytes(index, 1)[0]);
commandFrame.setMarker(7);
commandFrame.writeByte(controlCode);
// commandFrame.setMarker(previous_marker);
byte[] timeOnBytes = toBytes(timeOn, 4);
commandFrame.setMarker(9);
commandFrame.writeByte(timeOnBytes[0]);
commandFrame.setMarker(10);
commandFrame.writeByte(timeOnBytes[1]);
commandFrame.setMarker(11);
commandFrame.writeByte(timeOnBytes[2]);
commandFrame.setMarker(12);
commandFrame.writeByte(timeOnBytes[3]);
byte[] timeOffBytes = toBytes(timeOff, 4);
commandFrame.setMarker(13);
commandFrame.writeByte(timeOffBytes[0]);
commandFrame.setMarker(14);
commandFrame.writeByte(timeOffBytes[1]);
commandFrame.setMarker(15);
commandFrame.writeByte(timeOffBytes[2]);
commandFrame.setMarker(16);
commandFrame.writeByte(timeOffBytes[3]);
commandFrame.writeByte((byte) 0x00);
// commandFrame.setMarker(previous_marker);
return commandFrame;
}