package com.pwt.netty.common.plc;


import HslCommunication.Core.Transfer.IByteTransform;
import HslCommunication.Core.Transfer.ReverseBytesTransform;
import HslCommunication.Core.Types.IDataTransfer;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

public class PlcHolderState implements IDataTransfer {

    private final IByteTransform byteTransform = new ReverseBytesTransform( );

    private static final int MAX_HOLDER_COUNT = 16;


    @Getter
    @Setter
    private LocalDateTime dateTime;

    @Getter
    @Setter
    private boolean[] batteryExists;

    @Override
    public short getReadCount() {
        return MAX_HOLDER_COUNT;
    }

    @Override
    public void ParseSource(byte[] bytes) {
          batteryExists = byteTransform.TransBool(bytes, 0, MAX_HOLDER_COUNT);
//        batteryExists1 = byteTransform.TransBool(bytes, 0); // buffer[0] 的第0位
//        batteryExists2 = byteTransform.TransBool(bytes, 1);
//        batteryExists3 = byteTransform.TransBool(bytes, 2);
//        batteryExists4 = byteTransform.TransBool(bytes, 3);
//        batteryExists5 = byteTransform.TransBool(bytes, 4);
//        batteryExists6 = byteTransform.TransBool(bytes, 5);
//        batteryExists7 = byteTransform.TransBool(bytes, 6);
//        batteryExists8 = byteTransform.TransBool(bytes, 7);
//        batteryExists9 = byteTransform.TransBool(bytes, 8); // buffer[1] 的第0位
//        batteryExists10 = byteTransform.TransBool(bytes, 9); // buffer[1] 的第1位
//        batteryExists11 = byteTransform.TransBool(bytes, 10);
//        batteryExists12 = byteTransform.TransBool(bytes, 11);
    }

    @Override
    public byte[] ToSource() {
        return new byte[0];
    }
}
