package org.ts.ddcs.itemdatatemplate.szy;

import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.common.util.BytesHelp;
import org.ts.ddcs.itemdatatemplate.DataItemTemplate;

import java.util.List;
import java.util.Map;

/**
 * 0xF0
 * 由 5 字节组成 格式 ssmmHHDD 秒分时日
 * 观测时间
 */
public class DataItemTemplateSzyTT extends DataItemTemplate {

    @Override
    public int stream(byte[] data, int index) {
        this.macth = true;
        int count = 0;
        byte[] tm = BytesHelp.subBytes(data, index+count, 4);
        byte tmp = tm[0];
        tm[0] = tm[3];
        tm[3] = tmp;
        tmp = tm[1];
        tm[1] = tm[2];
        tm[2] = tmp;
        this.varcharValue = BytesHelp.byte2HexStr(tm);
        count += 5;
        return count;
    }

    @Override
    public int stream(byte[] data, int index, int batchSize) {
        return 0;
    }


    @Override
    public String getStringValue() {
        return this.varcharValue;
    }

    @Override
    public void saveValue(Map<String, List<Map<String,Object>>> keyStore) {
        this.saveVarcharValues(keyStore);
    }

}
