SyncHelper.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "stdafx.h"
  2. #include"SyncHelper.h"
  3. long long HostServer::SyncHelper::parseTime(const char * c)
  4. {
  5. long long ttt0 = (((long long)(c[0]))<<32) & (0x000000FF00000000);
  6. long long ttt1 = (((long long)(c[1]))<<24) & (0x00000000FF000000);
  7. long long ttt2 = (((long long)(c[2]))<<16) & (0x0000000000FF0000);
  8. long long ttt3 = (((long long)(c[3]))<<8) & (0x000000000000FF00);
  9. long long all = ttt0 + ttt1 + ttt2 + ttt3 + ((long long)(c[4]&(0xFF)));
  10. return all;
  11. }
  12. unsigned long long HostServer::SyncHelper::parseId(unsigned int id, unsigned char antNum)
  13. {
  14. return (id << 8) + antNum;
  15. }
  16. unsigned long long HostServer::SyncHelper::parseFromFstream(ifstream &f, int size)
  17. {
  18. unsigned long long x(0);
  19. for(int i(0); i < size; i++)
  20. {
  21. int t;
  22. f >> hex >> t;
  23. x = (x << 8) + t;
  24. }
  25. return x;
  26. }
  27. unsigned long long HostServer::SyncHelper::parseTimeFromFstream(ifstream &f)
  28. {
  29. char* t = new char[5];
  30. for (int i = 0; i < 5; i++)
  31. {
  32. int tmp;
  33. f >> hex >> tmp;
  34. t[i] = tmp;
  35. }
  36. auto time = SyncHelper::parseTime(t);
  37. delete[] t;
  38. return time;
  39. }