#include "SimCore/Identifier.hpp"
#include "WHISPER/Messages/Message.hpp"
#include <SimCore/Messages/SensorTrack.hpp>




namespace SimCore 
{
    SensorTrack::SensorTrack(WHISPER::SourceType src,SimCore::Identifier id,SimCore::TrackKind trackkind):trackKind_(trackkind),ID_(id), 
    Message(id.getParentNumber(),id.getNumber(),WHISPER::MsgTopics::TRACK,WHISPER::SENSOR_TRACK,src)
    {

    }
    SensorTrack::SensorTrack()
    {}

    SensorTrack::SensorTrack(WHISPER::Message receivedMessageObj)
    {
         if (receivedMessageObj.msgType_ == WHISPER::MsgType::SENSOR_TRACK) 
    {
      
      msg = messages::header::Message();
      msg.ParseFromString(receivedMessageObj.serialize());
      topic_ = msg.topic();
      sourceType_ = msg.sourcetype();
      msgType_ = msg.msgtype();

    
        if (msg.mutable_payload()->Is<messages::track::SensorTrack>()) 
        {
          auto SensorTrackMessage = messages::track::SensorTrack();
          msg.mutable_payload()->UnpackTo(&SensorTrackMessage);
          if (SensorTrackMessage.has_radartrack()) 
          {
            

          }
        }else if (msg.mutable_payload()->Is<messages::track::RadarTrack>()) 
        {
          auto trackMessage = new messages::track::RadarTrack();
          msg.mutable_payload()->UnpackTo(trackMessage);

        }
      
    
    }
    }



     void SensorTrack::setID(SimCore::Identifier id)
    {
        ID_ = id;
    }

     SimCore::Identifier SensorTrack::getID()
    {
        return ID_;
    }

}

