package com.fs.watch.calculation;

import com.fs.watch.service.WatchEcgDataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EcgPreprocessor {
    private final WatchEcgDataService watchEcgDataService;
    private static final Logger log = LoggerFactory.getLogger(EcgPreprocessor.class);

    public EcgPreprocessor(WatchEcgDataService watchEcgDataService) {
        this.watchEcgDataService = watchEcgDataService;
    }

//    public void DataPrepare(byte[] payload,String deviceId) {
//        HisDataOuterClass.HisNotification hisNotify = null;
//        try {
//            hisNotify = HisDataOuterClass.HisNotification.parseFrom(payload);
//        } catch (InvalidProtocolBufferException ex) {
//            ex.printStackTrace();
//            return;
//        }
//        if(hisNotify.hasHisData()){
//            HisDataOuterClass.HisData hisData = hisNotify.getHisData();
//            if(hisData.hasEcg()){
//                HisEcgData.HisDataECG ecgData = hisData.getEcg();
//                /*
//                	save rawDataList with data_time, later combine all ecg data
//                	with the same data_time, same data_time means it's the same
//                	ecg measurement
//                 */
//                String data_time = MyDateTimeUtils.convert2DateTimeString(ecgData.getTimeStamp().getDateTime().getSeconds());
//                List<Integer> rawDataList = ecgData.getRawDataList();
//                log.info(String.format("%s ecg count:%d",data_time,rawDataList.size()));
//                WatchEcgData watchEcgData = new WatchEcgData();
//                watchEcgData.setDeviceId(deviceId);
//                watchEcgData.setJsonDataVal(rawDataList.toString());
//                watchEcgData.setCount(rawDataList.size());
//                watchEcgData.setCreateTime(DateUtils.parseDate(data_time));
//                watchEcgDataService.insert(watchEcgData);
//            }
//        }
//    }
}
