package kr.gmtc.tss.data.vo;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

import kr.gmtc.tss.util.vo.DynamicVO;

public class SetDynamicVO extends DynamicVO implements Comparable<SetDynamicVO> {

	private boolean inserted=false;
	private String marineAreaId="";
	
	public long timeStamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(9)).toEpochMilli();
	
	public SetDynamicVO() {
	}
	
	public SetDynamicVO(DynamicVO vo) {

		this.targetSensor = vo.getTargetSensor();
		this.packetID = vo.getPacketID();
		this.shipID = vo.getShipID();
		this.dateTime = vo.getDateTime();
		this.areaID = vo.getAreaID();
		this.msgType = vo.getMsgType();
		this.dataLength = vo.getDataLength();

		setMode(vo.getMode());
		setRot(vo.getRot());
		setSog(vo.getSog());
		setPosacc(vo.getPosacc());

		setLonInt(vo.getLonInt());
		setLatInt(vo.getLatInt());
		setLongitude(vo.getLongitude());
		setLatitude(vo.getLatitude());
		setCog(vo.getCog());
		setHeading(vo.getHeading());
		setEndflag(vo.getEndflag());
		setCommState(vo.getCommState());
		setSyncState(vo.getSyncState());
		setSlotTimeOut(vo.getSlotTimeOut());
		setSubMessage(vo.getSubMessage());
		setSlotInc(vo.getSlotInc());
		setNumberOfSlot(vo.getNumberOfSlot());
		setSlotOffSet(vo.getSlotOffSet());
		setKeepFlag(vo.getKeepFlag());
		setNaviStatus(vo.getNaviStatus());
		setSpecialManoeuve(vo.getSpecialManoeuve());
		setClassBUnit(vo.getClassBUnit());
		setClassBDisplay(vo.getClassBDisplay());
		setClassBBand(vo.getClassBBand());
		setClassBMsg22(vo.getClassBMsg22());
		setClassBDSC(vo.getClassBDSC());
		setModeFlag(vo.getModeFlag());
		setRaim(vo.getRaim());
		setIsRepeat(vo.getIsRepeat());
		setbSUTC(vo.getbSUTC());
		setbSUTCStr(vo.getbSUTCStr());
		setTimeStamp(vo.getTimeStamp());
		setmSec(vo.getmSec());
		
	}

	
	
	
	

	public String getMarineAreaId() {
		return marineAreaId;
	}

	public void setMarineAreaId(String marineAreaId) {
		this.marineAreaId = marineAreaId;
	}

	public boolean isInserted() {
		return inserted;
	}

	public void setInserted(boolean inserted) {
		this.inserted = inserted;
	}

	@Override
    public int hashCode() {
        return (this.getShipID()+this.getDateTime().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+this.getLongitude()+this.getLatitude()).hashCode();
    }
    
    @Override
    public boolean equals(Object obj) {
        //p1.equals(p2)
        if(obj instanceof SetDynamicVO) {
        	SetDynamicVO p = (SetDynamicVO)obj;
            return this.hashCode()==p.hashCode(); 
            
        }
        return false;
    }

	@Override
	public int compareTo(SetDynamicVO o) {
		
		return this.getTimeStamp()-o.getTimeStamp();
	}
	
}
