package com.hboxs.serialport.plc.frame;

import com.hboxs.serialport.plc.Command;

/**
 * 命令帧 - 写
 * 写的num必须偶数字节
 */
public class WriteCommandFrame extends CommandFrame {
    /**
     * 构造写命令
     * @param address 地址
     * @param binDataStr 二进制字符串
     */
    public WriteCommandFrame(String address, String binDataStr) {
        super(Command.CMD_WRITE, address, binDataStr);
    }

    public static void main(String[] args) {
//        System.out.println(Integer.parseInt("10000001", 2));
//        System.out.println(Integer.parseInt("81", 16));
//        System.out.println("10000001".substring(0, 8));
        CommandFrame commandFrame = new WriteCommandFrame("Y0", "10000001");
        System.out.print("{");
        for (byte b : commandFrame.getFrameData()) {
            System.out.print(Integer.toHexString(b));
            System.out.print(",");
        }
        System.out.println("}");
    }
}
