package org.ts.ddcs.DataTemplate;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.log.LogHelper;
import org.ts.ddcs.Tool.BytesHelp;

/**
 * 水资源设置测站编码
 * 0x10
 */

@SuppressWarnings("all")
public class DataTemplateSzyC10 extends DataTemplateSzy2012 {

    private String dataInfo;

    @Override
    public  void  Stream(){
        try {
            if(this.dataArea.length>0){
                int count =0;
                JSONObject jsonData = new JSONObject();
                jsonData.put("func", "10");
                JSONArray datas = new JSONArray();

//                JSONObject rtu = new JSONObject();
//                rtu.put("rtuCode",BytesHelp.byte2HexStr(BytesHelp.subBytes(this.dataArea,count,5)));
                datas.add(BytesHelp.byte2HexStr(BytesHelp.subBytes(this.dataArea,count,5)));
                count +=5;
                byte[] pw = BytesHelp.subBytes(this.dataArea,count,2);
                count +=2;
                byte[] tm = BytesHelp.subBytes(this.dataArea,count,4);
                count+=4;
                byte[] delay= BytesHelp.subBytes(this.dataArea,count,1);
                count+=1;
                jsonData.put("data", datas);
                this.dataInfo = jsonData.toJSONString();
                if (count != this.dataArea.length){
                    LogHelper.info("******************* 10 DATA ERROR******************* ");
                }
            }
        }catch (Exception e){
            LogHelper.error(e);
        }
    }

    @Override
    public String getDataInfo() {
        return dataInfo;
    }

    @Override
    public String GetViewName() {
        return "设置测站编码报";
    }
}
