#include "CounterPkg.h"
#include <string.h>

CounterPkg::CounterPkg() : TelepatiPkg(){
  type=COUNTER;
  rd=0;
  rt=0;
  s=0;
}
CounterPkg::CounterPkg(unsigned int recvData, unsigned int recvTotal, unsigned int send) : TelepatiPkg(){
  type=COUNTER;
  rd=recvData;
  rt=recvTotal;
  s=send;
}

CounterPkg::CounterPkg(byte* ptr) : TelepatiPkg(ptr){
  int dim=sizeof(unsigned int);
  memcpy(&rd, (ptr+STD_HEADER_SIZE), dim);
  memcpy(&rt, (ptr+STD_HEADER_SIZE+dim), dim);
  memcpy(&s, (ptr+STD_HEADER_SIZE+(dim*2)), dim);
}


CounterPkg::~CounterPkg(){
}


TelepatiPkg* CounterPkg::clone(){
  CounterPkg* clone=new CounterPkg(rd, rt, s);
  clone->serialNum=serialNum;
  return clone;
}


byte* CounterPkg::getMsg(){
  delete [] message;
  int dim=sizeof(unsigned int);
  message=createStdHeader(dim*3);
  memcpy((message+STD_HEADER_SIZE), &rd, dim);
  memcpy((message+STD_HEADER_SIZE+dim), &rt, dim);
  memcpy((message+STD_HEADER_SIZE+(dim*2)), &s, dim);
  return message;
}
