package org.ts.ddcs.DataSaveProcesser;

import org.ts.ddcs.DataTemplate.DataTemplateInterface;
import org.ts.ddcs.Entity.CommandEntity;
import org.ts.ddcs.Log.LogHelper;
import org.ts.ddcs.Tool.BytesHelp;
import org.ts.ddcs.Worker.DataProcess;
import org.ts.ddcs.Worker.DataProcessHolder;

import java.util.concurrent.LinkedBlockingQueue;


/**
 * 0xF4
 * 发送升级配置文件
 */
@SuppressWarnings("all")
public class DataSaveProcesserSzyCF4 extends DataSaveProcesser {
    @Override
    public void Save(DataTemplateInterface dataTemplateInterface) {
        super.Save(dataTemplateInterface);
        String rtucode = BytesHelp.byte2HexStr(dataTemplateInterface.RtuCode());
        LogHelper.info("SAVE:"+dataTemplateInterface.GetFeture()+" "+rtucode);

        byte[] content = dataTemplateInterface.GetContent();
        byte[] packageIndexBuff = BytesHelp.subBytes(content, 0, 2);
        int packageIndex = BytesHelp.bytes2Int(packageIndexBuff, 0, 2);
        LogHelper.info("F4 " + packageIndex);
//        LinkedBlockingQueue<CommandEntity> datagramlist = DataProcessHolder.newInstance().dataProcess.relpayCommandToRtu.get(rtucode);
//        if (null != datagramlist) {
//            CommandEntity datagram = datagramlist.peek();
//            if (null != datagram) {
//                if (datagram.getKey().equals(Integer.toString(packageIndex))) {
//                    datagramlist.poll();
//                }
//            }
//        }
        //DataProcess.DownloadNotify(rtucode);

       // DataProcessHolder.newInstance().dataProcess.SubmitRelayManageTask(dataTemplateInterface);
    }
}
