You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "protocolEuropeanGeneral.h"
  2. #include "../../alg/generic/md5.h"
  3. CSTR defenderStatusMode[] = {"OPERATIONAL", "DEGRADED"};
  4. CSTR defenderFaultCode[] = {"Critical", "Warning", "Info"};
  5. CSTR defenderCategories[] = {DFSL_CATEGORY_ERROR, DFSL_CATEGORY_STATUS, DFSL_CATEGORY_ALARM_2D, DFSL_CATEGORY_ALARM_3D};
  6. CSTR defenderTypeDescription[] = {"Fault Event", "Status Message", "Target Detection Event", "Target Detection Event"};
  7. CSTR defenderTypeSeverity[] = {"very-low", "low", "medium", "high", "very-high"};
  8. /**
  9. * number of seconds from 1 Jan. 1601 00:00 to 1 Jan 1970 00:00 UTC
  10. */
  11. bool correctSHDTime(int diff)
  12. {
  13. #ifdef __linux__
  14. struct timeval tData;
  15. struct timezone tTZ;
  16. tTZ.tz_minuteswest = 0;
  17. tTZ.tz_dsttime = 0;
  18. if (gettimeofday(&tData, &tTZ) == -1)
  19. {
  20. return false;
  21. }
  22. else
  23. {
  24. tData.tv_sec += diff / 1000;
  25. tData.tv_usec += (diff * 1000) % 1000000;
  26. };
  27. if (settimeofday(&tData, &tTZ) == -1)
  28. {
  29. return false;
  30. };
  31. #else
  32. unsigned __int64 tMilliseconds;
  33. SYSTEMTIME Ztime;
  34. GetSystemTime(&Ztime);
  35. SystemTimeToFileTime(&Ztime, (FILETIME *) &tMilliseconds);
  36. tMilliseconds += diff * 10000;
  37. FileTimeToSystemTime((FILETIME *) &tMilliseconds, &Ztime);
  38. if (0 == SetSystemTime(&Ztime))
  39. {
  40. return false;
  41. }
  42. #endif
  43. return true;
  44. }