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.
665 lines
15 KiB
665 lines
15 KiB
#include "protocolRGoose.h"
|
|
|
|
#include "../../alg/generic/md5.h"
|
|
|
|
#define LOG(X) m_pLog->Log("RGoose", this, X)
|
|
#define LOGS(X) basicLogCollection::getInstance()->Log("RGoose", NULL, X)
|
|
#define LOG_ERROR(X) m_pLog->Log("RGoose", this, _LOG_ERROR, X)
|
|
|
|
CSTR RGooseStatusMode[] = {"Operational", "Degraded"};
|
|
CSTR RGooseFaultCode[] = {"Critical", "Warning", "Info"};
|
|
CSTR RGooseCategories[] = {"STATUS", "ALARM", "ERROR"};
|
|
CSTR RGooseTypeDescription[] = {"Status Message", "Target Detection Event", "Fault Event"};
|
|
CSTR RGooseTypeSeverity[] = {"very-low", "low", "medium", "high", "very-high"};
|
|
|
|
CSTR protocolRGoose::buildURL(CSTR templ, int dim, CSTR devID)
|
|
{
|
|
CSTR RetVal;
|
|
char tpl[256];
|
|
RetVal = (CSTR) malloc(256);
|
|
sprintf(tpl, "http://%s:%d%s", m_pServerIP, m_nServerPort, templ);
|
|
sprintf(RetVal, tpl, dim, devID);
|
|
return RetVal;
|
|
}
|
|
|
|
/* Default Constructor */
|
|
protocolRGoose::protocolRGoose(config_setting_t * Settings) :
|
|
protocolHTTP(basicSettingsProvider::getInstance()->getSubNode(Settings, "DEFENDER_CONNECTION"))
|
|
{
|
|
|
|
m_pLog = basicLogCollection::getInstance();
|
|
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode(Settings, "DEFENDER_CONNECTION");
|
|
|
|
m_pScannerName = (CSTR) malloc(OS_SCANNER_NAME_SIZE);
|
|
if (m_pScannerName == NULL)
|
|
{
|
|
return;
|
|
}
|
|
memset(m_pScannerName, 0, OS_SCANNER_NAME_SIZE);
|
|
|
|
m_pServerIP = (CSTR) malloc(OS_CEP_ADDRESS_SIZE);
|
|
if (m_pServerIP == NULL)
|
|
{
|
|
return;
|
|
}
|
|
memset(m_pServerIP, 0, OS_CEP_ADDRESS_SIZE);
|
|
|
|
m_bCurrentStatus = false;
|
|
|
|
if (m_pSettings != NULL)
|
|
{
|
|
|
|
config_setting_t * pSetting;
|
|
|
|
if (! config_setting_lookup_string(m_pSettings, "SCANNER_NAME", (const char **) &m_pScannerName))
|
|
{
|
|
strncpy(m_pScannerName, "LRF_2D_001", 64);
|
|
LOG(m_pScannerName);
|
|
pSetting = config_setting_add(m_pSettings, "SCANNER_NAME", CONFIG_TYPE_STRING);
|
|
config_setting_set_string(pSetting, m_pScannerName);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
if (! config_setting_lookup_int(m_pSettings, "SCANNER_DIMENTIONS", &m_nScannerDimentions))
|
|
{
|
|
m_nScannerDimentions = 2;
|
|
pSetting = config_setting_add(m_pSettings, "SCANNER_DIMENTIONS", CONFIG_TYPE_INT);
|
|
config_setting_set_int(pSetting, m_nScannerDimentions);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
if (! config_setting_lookup_string(m_pSettings, "CEP_IP_ADDRESS", (const char **) &m_pServerIP))
|
|
{
|
|
strncpy(m_pServerIP, "192.168.200.204", 16);
|
|
LOG(m_pServerIP);
|
|
pSetting = config_setting_add(m_pSettings, "CEP_IP_ADDRESS", CONFIG_TYPE_STRING);
|
|
config_setting_set_string(pSetting, m_pServerIP);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
if (! config_setting_lookup_int(m_pSettings, "CEP_IP_PORT", &m_nServerPort))
|
|
{
|
|
m_nServerPort = 80;
|
|
pSetting = config_setting_add(m_pSettings, "CEP_IP_PORT", CONFIG_TYPE_INT);
|
|
config_setting_set_int(pSetting, m_nServerPort);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
|
|
basicSettingsProvider::getInstance()->validate();
|
|
};
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
1.2 GHz
|
|
Number of Cores
|
|
Quad-Core
|
|
Type
|
|
Tegra 3
|
|
Processor Number
|
|
T30SL
|
|
Manufacturer
|
|
NVIDIA
|
|
|
|
|
|
|
|
|
|
|
|
Verify that you have the following installed on your system
|
|
Ubuntu 16.04 LTS (with GCC 5.4)
|
|
NVIDIA Display Driver ver. 375
|
|
NVIDIA VideoSDK 7.1
|
|
cuDNN 6 & TensorRT 2.1
|
|
NVIDIA CUDA 8.0
|
|
Download the DeepStream 1.0 tar file (below)
|
|
Extract the package at the location of your choice
|
|
Follow the usage instructions from the Deepstream_User_guide.pdf in the downloaded package.
|
|
|
|
|
|
*/
|
|
|
|
protocolRGoose::~protocolRGoose()
|
|
{
|
|
if (m_pScannerName != NULL)
|
|
{
|
|
free(m_pScannerName);
|
|
}
|
|
if (m_pServerIP != NULL)
|
|
{
|
|
free(m_pServerIP);
|
|
}
|
|
}
|
|
|
|
void protocolRGoose::setScannerName(CSTR Name)
|
|
{
|
|
sprintf(m_pScannerName, "%s", Name);
|
|
}
|
|
|
|
void protocolRGoose::setProtocolType(bool DeviceIs3D)
|
|
{
|
|
if (DeviceIs3D)
|
|
{
|
|
m_nScannerDimentions = 3;
|
|
}
|
|
else
|
|
{
|
|
m_nScannerDimentions = 2;
|
|
};
|
|
}
|
|
|
|
CSTR protocolRGoose::assembleStatusData(bool StatusOK)
|
|
{
|
|
CSTR RetVal;
|
|
CSTR tBuf;
|
|
CSTR tSRC;
|
|
CSTR tTARGET;
|
|
CSTR tID;
|
|
RetVal = (CSTR) malloc(CLOG);
|
|
if (RetVal != NULL)
|
|
{
|
|
tBuf = getTimeStamp();
|
|
if (tBuf != NULL)
|
|
{
|
|
tTARGET = (CSTR) malloc(128);
|
|
if (tTARGET != NULL)
|
|
{
|
|
tSRC = (CSTR) malloc(128);
|
|
if (tSRC)
|
|
{
|
|
tID = (CSTR) malloc(64);
|
|
if (tID != NULL)
|
|
{
|
|
sprintf(tID, "%s", MD5String(tBuf));
|
|
sprintf(tSRC, DFSL_SensorSourceDto, DFSL_HARDWARE_TYPE, DFSL_SOURCE_NAME, m_pScannerName);
|
|
sprintf(tTARGET, "{ \"status\": \"%s\" }", RGooseStatusMode[((StatusOK) ? 1 : 0)]);
|
|
sprintf(RetVal, PACKAGE_SE_DATA_STATUS_ELEMENT, RGooseTypeDescription[DC_STATUS], tBuf, tSRC, "DFSL_STATUS_DATA", "EventLidarStatus", tID, tTARGET);
|
|
free(tID);
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
}
|
|
else
|
|
{
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(RetVal);
|
|
RetVal = NULL;
|
|
};
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
CSTR protocolRGoose::assembleFaultData(uint8_t Code, CSTR Desc)
|
|
{
|
|
CSTR RetVal;
|
|
CSTR tBuf;
|
|
CSTR tSRC;
|
|
CSTR tTARGET;
|
|
CSTR tID;
|
|
RetVal = (CSTR) malloc(CLOG);
|
|
if (RetVal != NULL)
|
|
{
|
|
tBuf = getTimeStamp();
|
|
if (tBuf != NULL)
|
|
{
|
|
tTARGET = (CSTR) malloc(128);
|
|
if (tTARGET != NULL)
|
|
{
|
|
tSRC = (CSTR) malloc(128);
|
|
if (tSRC)
|
|
{
|
|
tID = (CSTR) malloc(64);
|
|
if (tID != NULL)
|
|
{
|
|
sprintf(tID, "%s", MD5String(tBuf));
|
|
sprintf(tSRC, DFSL_SensorSourceDto, DFSL_HARDWARE_TYPE, DFSL_SOURCE_NAME, m_pScannerName);
|
|
sprintf(tTARGET, "{ \"code\": %d, \"description\": \"%s\" }", Code, Desc);
|
|
sprintf(RetVal, PACKAGE_SE_DATA_STATUS_ELEMENT, RGooseTypeDescription[DC_ERROR], tBuf, tSRC, "DFSL_FAULT_DATA", "EventLidarFault", tID, tTARGET);
|
|
free(tID);
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
}
|
|
else
|
|
{
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(RetVal);
|
|
RetVal = NULL;
|
|
};
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
CSTR protocolRGoose::assembleTargetData(int targetID, int Range, int Width, int Azimuth, int Elevation)
|
|
{
|
|
CSTR RetVal;
|
|
CSTR tBuf;
|
|
CSTR tSRC;
|
|
CSTR tTARGET;
|
|
CSTR tID;
|
|
RetVal = (CSTR) malloc(CLOG);
|
|
if (RetVal != NULL)
|
|
{
|
|
tBuf = getTimeStamp();
|
|
if (tBuf != NULL)
|
|
{
|
|
tTARGET = (CSTR) malloc(128);
|
|
if (tTARGET != NULL)
|
|
{
|
|
tSRC = (CSTR) malloc(128);
|
|
if (tSRC)
|
|
{
|
|
tID = (CSTR) malloc(64);
|
|
if (tID != NULL)
|
|
{
|
|
sprintf(tID, "%s", MD5String(tBuf));
|
|
sprintf(tSRC, DFSL_SensorSourceDto, DFSL_HARDWARE_TYPE, DFSL_SOURCE_NAME, m_pScannerName);
|
|
sprintf(tTARGET, DFSL_LidarTargetDto, targetID, Azimuth, Elevation, Range, Width);
|
|
sprintf(RetVal, PACKAGE_SE_DATA_ELEMENT, RGooseTypeDescription[DC_ALARM], tBuf, tSRC, "DFSL_TARGET_DATA", "EventLidarTarget", tID, tTARGET);
|
|
free(tID);
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
}
|
|
else
|
|
{
|
|
free(tSRC);
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
free(tTARGET);
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(tBuf);
|
|
free(RetVal);
|
|
};
|
|
}
|
|
else
|
|
{
|
|
free(RetVal);
|
|
RetVal = NULL;
|
|
};
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
static uint32_t DEFENDER_MESSAGE_ID = 0;
|
|
|
|
size_t protocolRGoose::assembleDefenderJSON(CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data)
|
|
{
|
|
char tBuffer[CLOG];
|
|
size_t RetVal;
|
|
CSTR tBuf;
|
|
RetVal = 0;
|
|
tBuf = getTimeStamp();
|
|
DEFENDER_MESSAGE_ID++;
|
|
// memset( tBuffer, 0, CLOG );
|
|
if (tBuf != NULL)
|
|
{
|
|
// char ID[64];
|
|
switch (Type)
|
|
{
|
|
case DC_STATUS: Severity = 0; break;
|
|
case DC_ERROR : Severity = 2; break;
|
|
case DC_ALARM : Severity = 4; break;
|
|
default : Severity = 2;
|
|
};
|
|
// sprintf( ID, "%s", MD5String( tBuf ) );
|
|
sprintf(tBuffer, DFSL_SE_ENVELOPE, DEFENDER_MESSAGE_ID, RGooseCategories[Type], RGooseTypeSeverity[Severity], tBuf, tBuf, tBuf, tBuf, Location, Data);
|
|
RetVal = strlen(tBuffer);
|
|
memcpy(Buffer, tBuffer, RetVal);
|
|
Buffer[RetVal] = (char) 0;
|
|
free(tBuf);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::buildStatusPackage(unsigned char * Buffer, int & BufferSize, bool Status)
|
|
{
|
|
if (Buffer != NULL)
|
|
{
|
|
CSTR tBuf;
|
|
tBuf = assembleStatusData(Status);
|
|
#ifdef DEBUG
|
|
LOG(tBuf);
|
|
#endif
|
|
if (tBuf != NULL)
|
|
{
|
|
BufferSize = assembleDefenderJSON((CSTR) Buffer, DC_STATUS, (Status) ? 0 : 2, DFSL_DEFAULT_LOCATION, tBuf);
|
|
#ifdef DEBUG
|
|
LOG((CSTR) Buffer);
|
|
#endif
|
|
free(tBuf);
|
|
return true;
|
|
}
|
|
};
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::buildFaultPackage(unsigned char * Buffer, int & BufferSize, unsigned char Type, CSTR Description)
|
|
{
|
|
if (Buffer != NULL)
|
|
{
|
|
CSTR tBuf;
|
|
tBuf = assembleFaultData(Type, Description);
|
|
if (tBuf != NULL)
|
|
{
|
|
BufferSize = assembleDefenderJSON((CSTR) Buffer, DC_ERROR, 3, DFSL_DEFAULT_LOCATION, tBuf);
|
|
free(tBuf);
|
|
return true;
|
|
};
|
|
};
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::buildEvent2DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, int Angle, int Range, int Width)
|
|
{
|
|
if (Buffer != NULL)
|
|
{
|
|
CSTR tBuf;
|
|
tBuf = assembleTargetData(targetID, Range, Width, Angle, 0);
|
|
if (tBuf != NULL)
|
|
{
|
|
BufferSize = assembleDefenderJSON((CSTR) Buffer, DC_ALARM, 3, DFSL_DEFAULT_LOCATION, tBuf);
|
|
free(tBuf);
|
|
return true;
|
|
};
|
|
};
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::buildEvent3DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, int Angle1, int Angle2, int Range)
|
|
{
|
|
if (Buffer != NULL)
|
|
{
|
|
CSTR tBuf;
|
|
tBuf = assembleTargetData(targetID, Range, 0, Angle1, Angle2);
|
|
#ifdef DEBUG
|
|
LOG(tBuf);
|
|
#endif
|
|
if (tBuf != NULL)
|
|
{
|
|
BufferSize = assembleDefenderJSON((CSTR) Buffer, DC_ALARM, 3, DFSL_DEFAULT_LOCATION, tBuf);
|
|
#ifdef DEBUG
|
|
LOG((CSTR) Buffer);
|
|
#endif
|
|
free(tBuf);
|
|
return true;
|
|
};
|
|
};
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::buildClockSyncPackage(unsigned char * Buffer, int & BufferSize)
|
|
{
|
|
/*if( Buffer!= NULL ){
|
|
CSTR tBuf;
|
|
tBuf = getSHTimeStamp();
|
|
if( tBuf != NULL ){
|
|
sprintf(
|
|
((char *)(Buffer+BufferSize)),
|
|
PACKAGE_ENVELOPE_TEMPLATE_CLOCKSYNC,
|
|
tBuf
|
|
);
|
|
BufferSize = strlen( (char *)Buffer );
|
|
free( tBuf );
|
|
return true;
|
|
};
|
|
};*/
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::buildCallBackPackage(unsigned char * Buffer, int & BufferSize, CSTR CallBackPath)
|
|
{
|
|
/*if( Buffer!= NULL ){
|
|
sprintf(
|
|
((char *)(Buffer+BufferSize)),
|
|
PACKAGE_ENVELOPE_TEMPLATE_REG_CALL,
|
|
CallBackPath
|
|
);
|
|
BufferSize = strlen( (char *)Buffer );
|
|
return true;
|
|
};*/
|
|
return false;
|
|
}
|
|
|
|
bool protocolRGoose::Alarm2D(int Angle, int Range, int Width, int ID)
|
|
{
|
|
bool RetVal = false;
|
|
char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL;
|
|
CSTR UID;
|
|
UID = getUniqID_MD5();
|
|
if (UID != NULL)
|
|
{
|
|
URL = buildURL(SERVICE_URL_TEMPLATE_EVENT, m_nScannerDimentions, m_pScannerName);
|
|
RetVal = buildEvent2DPackage((unsigned char *) Buffer, BufferSize, UID, ID, Angle, Range, Width);
|
|
if (URL != NULL)
|
|
{
|
|
RetVal = issuePost(URL, Buffer, BufferSize);
|
|
free(URL);
|
|
};
|
|
free(UID);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::Alarm3D(int Angle1, int Angle2, int Range, int ID)
|
|
{
|
|
bool RetVal = false;
|
|
char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL;
|
|
CSTR UID;
|
|
UID = getUniqID_MD5();
|
|
if (UID != NULL)
|
|
{
|
|
URL = buildURL(SERVICE_URL_TEMPLATE_EVENT, m_nScannerDimentions, m_pScannerName);
|
|
#ifdef DEBUG
|
|
LOG(URL);
|
|
#endif
|
|
RetVal = buildEvent3DPackage((unsigned char *) Buffer, BufferSize, UID, ID, Angle1, Angle2, Range);
|
|
if (URL != NULL)
|
|
{
|
|
RetVal = issuePost(URL, Buffer, BufferSize);
|
|
free(URL);
|
|
};
|
|
free(UID);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::VisibilityChanged(bool Worsened)
|
|
{
|
|
bool RetVal = false;
|
|
char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL;
|
|
URL = buildURL(SERVICE_URL_TEMPLATE_STATUS, m_nScannerDimentions, m_pScannerName);
|
|
#ifdef DEBUG
|
|
LOG(URL);
|
|
#endif
|
|
RetVal = buildStatusPackage((unsigned char *) Buffer, BufferSize, ! Worsened);
|
|
if (URL != NULL)
|
|
{
|
|
RetVal = issuePost(URL, Buffer, BufferSize);
|
|
free(URL);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::StatusUpdate(void)
|
|
{
|
|
bool RetVal = false;
|
|
char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL;
|
|
URL = buildURL(SERVICE_URL_TEMPLATE_STATUS, m_nScannerDimentions, m_pScannerName);
|
|
#ifdef DEBUG
|
|
LOG(URL);
|
|
#endif
|
|
RetVal = buildStatusPackage((unsigned char *) Buffer, BufferSize, m_bCurrentStatus);
|
|
if (URL != NULL)
|
|
{
|
|
RetVal = issuePost(URL, Buffer, BufferSize);
|
|
free(URL);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::ErrorReporting(int lvl, CSTR Descr)
|
|
{
|
|
bool RetVal = false;
|
|
char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL;
|
|
URL = buildURL(SERVICE_URL_TEMPLATE_FAULT, m_nScannerDimentions, m_pScannerName);
|
|
#ifdef DEBUG
|
|
LOG(URL);
|
|
#endif
|
|
RetVal = buildFaultPackage((unsigned char *) Buffer, BufferSize, lvl, Descr);
|
|
if (URL != NULL)
|
|
{
|
|
RetVal = issuePost(URL, Buffer, BufferSize);
|
|
free(URL);
|
|
};
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::StartTimeSynch(void)
|
|
{
|
|
bool RetVal = false;
|
|
LOG("TimeSYnc");
|
|
/*char Buffer[1024];
|
|
int BufferSize = 0;
|
|
CSTR URL = NULL;
|
|
URL = buildURL( SERVICE_URL_TEMPLATE_CLOCKSYNC, m_nScannerDimentions, m_pScannerName );
|
|
RetVal = buildClockSyncPackage(( unsigned char *) Buffer, BufferSize );
|
|
if( URL != NULL ){
|
|
RetVal = issuePost( URL, Buffer, BufferSize );
|
|
free( URL );
|
|
};*/
|
|
return RetVal;
|
|
}
|
|
|
|
bool protocolRGoose::packetHandler(protocolPackage * Package)
|
|
{
|
|
// LOG("PACKET HANDLER");
|
|
if (Package == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (Package->m_nSize == 0)
|
|
{
|
|
return false;
|
|
}
|
|
if (Package->m_pData == NULL)
|
|
{
|
|
return false;
|
|
}
|
|
if (Package->m_nCode != 200)
|
|
{
|
|
return false;
|
|
}
|
|
try
|
|
{
|
|
XMLNode node1 = XMLNode::parseString((const char *) Package->m_pData, "root");
|
|
if (node1.isEmpty())
|
|
{
|
|
char BUBU[128];
|
|
sprintf(BUBU, "The package[%d:%d] XML data is not a valid XML data. Cann't find root element.", strlen((CSTR) Package->m_pData), Package->m_nSize);
|
|
LOG_ERROR(BUBU);
|
|
}
|
|
else
|
|
{
|
|
LOG(node1.getName());
|
|
if (strstr(node1.getName(), "ClockSync") != NULL)
|
|
{
|
|
#ifdef __linux__
|
|
unsigned long long t0, t1, t2, t3;
|
|
#else
|
|
unsigned __int64 t0, t1, t2, t3;
|
|
#endif
|
|
XMLNode node3 = node1.getChildNode("t0", 0);
|
|
XMLNode node4 = node1.getChildNode("t1", 0);
|
|
XMLNode node5 = node1.getChildNode("t2", 0);
|
|
t3 = getTimeValue();
|
|
#ifdef __linux__
|
|
t0 = atoll(node3.getText(0));
|
|
t1 = atoll(node4.getText(0));
|
|
t2 = atoll(node5.getText(0));
|
|
#else
|
|
t0 = _atoi64(node3.getText(0));
|
|
t1 = _atoi64(node4.getText(0));
|
|
t2 = _atoi64(node5.getText(0));
|
|
#endif
|
|
int offset = ((t1 - t0) + (t2 - t3)) / 2;
|
|
int latency = (t3 - t0) - (t2 - t1);
|
|
int jagajaga = offset + latency;
|
|
// if( 0 & correctSHTime( jagajaga ) ){
|
|
// LOG("Time is Synced");
|
|
// g_iTimeDiff = 0;
|
|
// } else {
|
|
// LOG_ERROR("Time Sync Unucessfull - Will use DIFF!");
|
|
// g_iTimeDiff = jagajaga;
|
|
correctSysTime(jagajaga);
|
|
//};
|
|
};
|
|
};
|
|
}
|
|
catch (exception e)
|
|
{
|
|
return false;
|
|
};
|
|
return true;
|
|
}
|
|
|
|
#undef LOG
|
|
#undef LOG_ERROR
|