/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2021/12/16
 */
package org.ts.ddcs.dataStream.processor.sw;


import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.ts.ddcs.common.util.BytesHelp;
import org.ts.ddcs.dataStream.*;
import org.ts.ddcs.datatemplate.TestState;

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

/***
 * Date:2021/12/16
 * Title:数据处理器模块
 * Description： 未定义报文处理器
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Slf4j
public class DataStreamSwUnknownProcessor extends DataStreamProcessor {

    private DataStreamCache dataStreamCache;

    @Override
    public void init(DataStreamLineManager context) {
        this.context = context;
        this.dataStreamCache = context.getCache();
    }

    @Override
    public void process(DataStreamAdapter dataStreamAdapter) {
        this.dataStreamCache.setMatchProcessor(this);
        this.dataStreamCache.setState(TestState.UNKNOWN);

        this.next(false);
    }

    @Override
    public void close(DataStreamAdapter dataStreamAdapter) {

    }

    @Override
    public void batchComplete(DataStreamAdapter dataStreamAdapter) {
        byte[] datagram = this.dataStreamCache.getDatagramBuff();
        log.info("未知报文 {}", BytesHelp.byte2HexStr(datagram));
    }

    @Override
    public List<Map<String, Object>> sink(DataStreamAdapter dataStreamAdapter) {
        return null;
    }

}
