123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829 |
- #include "../../includes/includes.h"
- #include "./lct_public.h"
- LCT_FIRSTPATH_LIST_T gLct_stFirstPathList = {0};
- LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T gLct_astPredictionDirectionDataList[PUB_SYS_CARRIER_NUM] = {0};
- LCT_COORDSEL_ORIGINAL_COORD_T gLct_stOriginalLctCoordList = {0};
- LCT_COORDSEL_MEAN_COORD_T gLct_stMeanLctCoordList = {0};
- flt32 gLct_afMeanWeight[LCT_COORDSEL_ORIGINAL_COORD_LIST_LEN] = {0.20, 0.30, 0.50};
- uint32 gLct_dwPredictionTimes = 0;
- uint32 gLct_dwFpBaseOffset = 0;
- extern PUB_SYS_STATUS_T gg_stSysStatus;
- extern uint32 gg_dwFrameNo;
- void lct_main_init(LCT_FIRSTPATH_PARAM_T stLctFirstpathParam, LCT_COORDCAL_PARAM_T stLctCoordcalParam, LCT_COORDSEL_PARAM_T stLctCoordselParam)
- {
-
- memset(&gLct_stFirstPathList, 0, sizeof(LCT_FIRSTPATH_LIST_T));
- memset(&gLct_stOriginalLctCoordList, 0, sizeof(LCT_COORDSEL_ORIGINAL_COORD_T));
- memset(&gLct_stMeanLctCoordList, 0, sizeof(LCT_COORDSEL_MEAN_COORD_T));
- memset(gLct_astPredictionDirectionDataList, 0, sizeof(LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T) * PUB_SYS_CARRIER_NUM);
- lct_firstpath_init(stLctFirstpathParam);
- lct_coordcal_init(stLctCoordcalParam);
- lct_coordsel_init(stLctCoordselParam);
- }
- void lct_main_reset()
- {
-
-
- if (!gg_stSysStatus.bySyncFlag)
- {
- memset(&gLct_stFirstPathList, 0, sizeof(LCT_FIRSTPATH_LIST_T));
- memset(&gLct_stOriginalLctCoordList, 0, sizeof(LCT_COORDSEL_ORIGINAL_COORD_T));
- memset(&gLct_stMeanLctCoordList, 0, sizeof(LCT_COORDSEL_MEAN_COORD_T));
- memset(gLct_astPredictionDirectionDataList, 0, sizeof(LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T) * PUB_SYS_CARRIER_NUM);
- gLct_dwPredictionTimes = 0;
- gg_stSysStatus.byBtsCaptureFlag = 0;
- gg_stSysStatus.byReLocationFlag = 0;
- }
- return;
- }
- void lct_main(PUB_LCT_BTS_LIST_T *pstLctBtsList, PUB_LOCATION_DATA_T *pstLctDataList, PUB_CURRENT_LCT_RESULT_T *pstCurrentLctResult)
- {
- uint8 byRemainder = 0;
- LCT_FIRSTPATH_T *pstFirstPathList = NULL;
- uint8 byBtsNum = 0;
- LCT_MINIMUM_VALUE_GROUP_T stMinimumValueGroup = {0};
- uint8 byPredictionFlag = 0;
- COORD_T stPredictionCoord = {0};
- uint16 wMinimumNum = 0;
- uint8 byCalMinimumNum = 0;
- uint8 byTrackMinimumNum = 0;
- uint8 byPredicMinimumNum = 0;
- LCT_COORDSEL_OPTIMUM_COORD_T stOptimumCoord = {0};
- uint32 dwMainBtsId = 0;
- int32 dwMainBtsBuildId = 0;
- int32 dwMainBtsLayerId = 0;
- uint8 byFlag = 0;
- COORD_T stMeanCoord = {0};
- PUB_LOCATION_DATA_T *pstLctData = NULL;
- uint8 byImuMoveFlag = 0;
-
- lct_main_reset();
-
- if (gg_stSysStatus.bySyncFlag && pstLctBtsList->byBtsNum > 1)
- {
-
- byRemainder = (gg_dwFrameNo - 1) % PUB_SYS_SLOT_NUM;
- if (byRemainder == 0)
- {
-
- lct_firstpath_main(pstLctBtsList, pstLctDataList, &gLct_stFirstPathList);
-
- if (PUB_DEBUG_ENABLE)
- {
- lct_main_write_text_file(&gLct_stFirstPathList);
- }
-
- lct_coordcal_main(pstLctBtsList, pstLctDataList, &gLct_stFirstPathList, &byPredictionFlag, &stPredictionCoord, &stMinimumValueGroup, &wMinimumNum);
-
- if (wMinimumNum > 0)
- {
-
- lct_coordsel_main(&stMinimumValueGroup, byPredictionFlag, stPredictionCoord, &stOptimumCoord);
-
- if (stOptimumCoord.byResultFlag)
- {
-
- if (stOptimumCoord.bySourceFlag == 3)
- {
- gLct_dwPredictionTimes++;
- }
- else
- {
- gLct_dwPredictionTimes = 0;
- }
-
- if (gLct_dwPredictionTimes >= LCT_MAIN_MAX_USE_PREDICTION_COORD_TIMES)
- {
- pstCurrentLctResult->dwCpltFlag = 1;
- pstCurrentLctResult->dwSuccessFlag = 1;
- gg_stSysStatus.byBtsCaptureFlag = 0;
- gg_stSysStatus.byReLocationFlag = 1;
- }
- else
- {
- pstCurrentLctResult->dwCpltFlag = 1;
- pstCurrentLctResult->dwSuccessFlag = 1;
- gg_stSysStatus.byBtsCaptureFlag = 1;
- gg_stSysStatus.byReLocationFlag = 0;
- }
-
-
-
- lct_main_update_bts_firstpath_trace_index(stOptimumCoord.bySourceFlag, &gLct_stFirstPathList, pstLctDataList);
-
- lct_main_find_main_bts(&gLct_stFirstPathList, &dwMainBtsId, &dwMainBtsBuildId, &dwMainBtsLayerId);
-
- lct_main_save_original_coord(dwMainBtsBuildId, dwMainBtsLayerId, stOptimumCoord.stCoord, &gLct_stOriginalLctCoordList);
- stMeanCoord = stOptimumCoord.stCoord;
-
- lct_main_mean_original_coord(&gLct_stOriginalLctCoordList, gLct_afMeanWeight, &gLct_stMeanLctCoordList, &stMeanCoord);
-
- lct_toa_cal_bts_first_path_index_offset(stOptimumCoord.bySourceFlag, &gLct_stFirstPathList, &gLct_stMeanLctCoordList, gLct_dwFpBaseOffset, &gLct_dwFpBaseOffset);
-
- lct_main_update_phone_tendency(&gLct_stMeanLctCoordList, gLct_astPredictionDirectionDataList);
-
- byImuMoveFlag = imu_cal_distance_lct();
-
- lct_main_organize_lct_result(dwMainBtsBuildId, dwMainBtsLayerId, &gLct_stFirstPathList, &stMeanCoord, byImuMoveFlag, pstCurrentLctResult);
-
- if (PUB_DEBUG_ENABLE)
- {
- printf("frame no:%d, source:%d, x :%d, y: %d\n", gg_dwFrameNo - 1, stOptimumCoord.bySourceFlag, stMeanCoord.dwX, stMeanCoord.dwY);
- char *filePathx = "E:\\work\\ips8000\\aplm8000sdk\\output\\coord\\coordx.bin";
- char *filePathy = "E:\\work\\ips8000\\aplm8000sdk\\output\\coord\\coordy.bin";
- util_write_coord_to_bin_file(filePathx, 1, (uint32 *)&stMeanCoord.dwX);
- util_write_coord_to_bin_file(filePathy, 1, (uint32 *)&stMeanCoord.dwY);
- }
- }
-
- else
- {
- pstCurrentLctResult->dwCpltFlag = 1;
- pstCurrentLctResult->dwSuccessFlag = 0;
- gg_stSysStatus.byBtsCaptureFlag = 0;
-
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstLctData = &pstLctDataList[i];
- pstLctData->wAheadFrameCalPahtIndex = 0;
- pstLctData->wAheadFrameTrackPathIndex = 0;
- }
- printf("minimum avalid\n");
- }
- }
- else
- {
- pstCurrentLctResult->dwCpltFlag = 1;
- pstCurrentLctResult->dwSuccessFlag = 0;
- gg_stSysStatus.byBtsCaptureFlag = 0;
-
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstLctData = &pstLctDataList[i];
- pstLctData->wAheadFrameCalPahtIndex = 0;
- pstLctData->wAheadFrameTrackPathIndex = 0;
- }
- printf("no minimum\n");
- }
- }
- }
- else
- {
- printf("error, sync flag:%d, bts num:%d\n", gg_stSysStatus.bySyncFlag, pstLctBtsList->byBtsNum);
- }
- return;
- }
- void lct_main_dbcheck_coord_by_bts_polygon(LCT_FIRSTPATH_LIST_T *pstBtsFirstPathList, LCT_COORDSEL_OPTIMUM_COORD_T *pstOptimumCoord)
- {
- uint8 byFirstPathListLen = pstBtsFirstPathList->byBtsNum;
- LCT_FIRSTPATH_T *pstFirstPathList = pstBtsFirstPathList->astFirstPath;
- int32 dwTemp = 0;
- int32 dwMinValueX = 2147483647;
- int32 dwMaxValueX = -2147483648;
- int32 dwMinValueY = 2147483647;
- int32 dwMaxValueY = -2147483648;
- uint32 dwGapX = 0;
- uint32 dwGapY = 0;
- int32 dwX = 0;
- int32 dwY = 0;
-
- for (uint8 i = 0; i < byFirstPathListLen; i++)
- {
- dwTemp = pstFirstPathList[i].dwCoordX;
- if (dwTemp > dwMaxValueX)
- {
- dwMaxValueX = dwTemp;
- }
- if (dwTemp < dwMinValueX)
- {
- dwMinValueX = dwTemp;
- }
- dwTemp = pstFirstPathList[i].dwCoordY;
- if (dwTemp > dwMaxValueY)
- {
- dwMaxValueY = dwTemp;
- }
- if (dwTemp < dwMinValueY)
- {
- dwMinValueY = dwTemp;
- }
- }
-
- dwGapX = dwMaxValueX - dwMinValueX;
- dwGapY = dwMaxValueY - dwMinValueY;
-
- dwX = pstOptimumCoord->stCoord.dwX;
- if (dwGapX < 350)
- {
- dwX = util_distance_gen_rand_num((dwMaxValueX + dwMinValueX) / 2, 50);
- }
- else if (dwGapX >= 350 && dwGapX < 900)
- {
- dwX = pstOptimumCoord->stCoord.dwX * 0.85;
- }
- else if (dwGapX >= 900 && dwGapX < 1500)
- {
- dwX = pstOptimumCoord->stCoord.dwX * 0.95;
- }
-
- dwY = pstOptimumCoord->stCoord.dwY;
- if (dwGapY < 350)
- {
- dwY = util_distance_gen_rand_num((dwMaxValueY + dwMinValueY) / 2, 50);
- }
- else if (dwGapY >= 350 && dwGapY < 900)
- {
- dwY = pstOptimumCoord->stCoord.dwY * 0.85;
- }
- else if (dwGapY >= 900 && dwGapY < 1500)
- {
- dwY = pstOptimumCoord->stCoord.dwY * 0.95;
- }
-
- pstOptimumCoord->stCoord.dwX = dwX;
- pstOptimumCoord->stCoord.dwY = dwY;
- return;
- }
- int32 lct_main_gen_rand_num(int32 dwBaseData, uint16 wRange)
- {
- int32 dwTotalRange = 2 * wRange + 1;
- int32 dwRemainder = 0;
- int32 randomNum = 0;
-
- srand(time(NULL));
-
- dwRemainder = rand() % dwTotalRange;
- randomNum = dwBaseData - wRange + dwRemainder;
- return randomNum;
- }
- void lct_main_update_bts_firstpath_trace_index(uint8 byLctSourceFlag, LCT_FIRSTPATH_LIST_T *pstBtsFirstPathList, PUB_LOCATION_DATA_T *pstLctDataList)
- {
- uint8 byBtsNum = pstBtsFirstPathList->byBtsNum;
- LCT_FIRSTPATH_T *pstFirstPathList = NULL;
- uint16 wFrameTraceIndex = 0;
- uint8 byFreqIndex = 0;
- PUB_LOCATION_DATA_T *pstLctData = NULL;
- for (uint8 i = 0; i < byBtsNum; i++)
- {
- pstFirstPathList = &pstBtsFirstPathList->astFirstPath[i];
-
- if (byLctSourceFlag == 1)
- {
- wFrameTraceIndex = pstFirstPathList->wFrameCalIndex;
- }
-
- else if (byLctSourceFlag == 2)
- {
- wFrameTraceIndex = pstFirstPathList->wFrameTrackIndex;
- }
-
- else
- {
- wFrameTraceIndex = 0;
- }
-
- pstFirstPathList->wFrameTrackIndex = wFrameTraceIndex;
- }
-
- for (uint8 j = 0; j < PUB_SYS_CARRIER_NUM; j++)
- {
- pstLctData = &pstLctDataList[j];
- pstLctData->wAheadFrameCalPahtIndex = 0;
- pstLctData->wAheadFrameTrackPathIndex = 0;
- }
- for (uint8 k = 0; k < byBtsNum; k++)
- {
- pstFirstPathList = &pstBtsFirstPathList->astFirstPath[k];
- byFreqIndex = pstFirstPathList->byFreqIndex;
- pstLctData = &pstLctDataList[byFreqIndex];
- pstLctData->wAheadFrameCalPahtIndex = pstFirstPathList->wFrameCalIndex;
- pstLctData->wAheadFrameTrackPathIndex = pstFirstPathList->wFrameTrackIndex;
- }
- return;
- }
- void lct_main_find_main_bts(LCT_FIRSTPATH_LIST_T *pstFirstPathList, uint32 *pdwBtsId, int32 *pwBuildId, int32 *pdwLayerId)
- {
- LCT_FIRSTPATH_T *pstFirstPahtData = NULL;
- uint8 byExist = 0;
- for (uint8 i = 0; i < pstFirstPathList->byBtsNum; i++)
- {
- pstFirstPahtData = &pstFirstPathList->astFirstPath[i];
- if (pstFirstPahtData->byMainFlag == 1)
- {
- *pdwBtsId = pstFirstPahtData->dwBtsId;
- *pwBuildId = pstFirstPahtData->dwBuildId;
- *pdwLayerId = pstFirstPahtData->dwLayerId;
- byExist = 1;
- break;
- }
- }
- if (!byExist)
- {
- pstFirstPahtData = &pstFirstPathList->astFirstPath[0];
- *pdwBtsId = pstFirstPahtData->dwBtsId;
- *pwBuildId = pstFirstPahtData->dwBuildId;
- *pdwLayerId = pstFirstPahtData->dwLayerId;
- }
- return;
- }
- void lct_main_save_original_coord(int32 dwBuildId, int32 dwLayerId, COORD_T stCoord, LCT_COORDSEL_ORIGINAL_COORD_T *pstOriginalLctCoordList)
- {
- uint8 byCoordListLen = pstOriginalLctCoordList->byListLen;
-
- gg_stSysStatus.dwBuildId = dwBuildId;
- gg_stSysStatus.dwLayerId = dwLayerId;
-
- if (byCoordListLen < LCT_COORDSEL_ORIGINAL_COORD_LIST_LEN)
- {
- pstOriginalLctCoordList->astCoordList[byCoordListLen] = stCoord;
- pstOriginalLctCoordList->byListLen++;
- }
-
- else
- {
-
- memmove(pstOriginalLctCoordList->astCoordList, &pstOriginalLctCoordList->astCoordList[1], sizeof(COORD_T) * (LCT_COORDSEL_ORIGINAL_COORD_LIST_LEN - 1));
- pstOriginalLctCoordList->astCoordList[LCT_COORDSEL_ORIGINAL_COORD_LIST_LEN - 1] = stCoord;
- }
- return;
- }
- void lct_main_mean_original_coord(LCT_COORDSEL_ORIGINAL_COORD_T *pstOriginalLctCoordList, flt32 *pfMeanWeightList, LCT_COORDSEL_MEAN_COORD_T *pstMeanCoordList, COORD_T *pstMeanCoord)
- {
- uint8 byListLen = pstOriginalLctCoordList->byListLen;
- flt32 fX = 0;
- flt32 fY = 0;
- uint8 byCoordListLen = pstMeanCoordList->byListLen;
-
- if ((byListLen < LCT_COORDSEL_ORIGINAL_COORD_LIST_LEN))
- {
- return;
- }
-
- for (uint8 i = 0; i < byListLen; i++)
- {
- fX += pstOriginalLctCoordList->astCoordList[i].dwX * pfMeanWeightList[i];
- fY += pstOriginalLctCoordList->astCoordList[i].dwY * pfMeanWeightList[i];
- }
- pstMeanCoord->dwX = fX;
- pstMeanCoord->dwY = fY;
- pstMeanCoord->dwZ = 120;
-
-
- if (byCoordListLen < LCT_COORDSEL_MEAN_COORD_LIST_LEN)
- {
- pstMeanCoordList->astCoordList[byCoordListLen] = *pstMeanCoord;
- pstMeanCoordList->byListLen++;
- }
-
- else
- {
-
- memmove(pstMeanCoordList->astCoordList, &pstMeanCoordList->astCoordList[1], sizeof(COORD_T) * (LCT_COORDSEL_MEAN_COORD_LIST_LEN - 1));
- pstMeanCoordList->astCoordList[LCT_COORDSEL_MEAN_COORD_LIST_LEN - 1] = *pstMeanCoord;
- }
- return;
- }
- void lct_main_organize_lct_result(int32 dwBuildId, int32 dwLayerId, LCT_FIRSTPATH_LIST_T *pstFirstPathList, COORD_T *pstMeanCoord, uint32 dwImuMoveFlag, PUB_CURRENT_LCT_RESULT_T *pstCurrentLctResult)
- {
- uint8 byBtsNum = pstFirstPathList->byBtsNum;
- PUB_LCT_BTS_T *pstLctBtsData = NULL;
- uint8 byExist = 0;
-
- pstCurrentLctResult->stCoord = *pstMeanCoord;
-
- pstCurrentLctResult->dwBuildId = dwBuildId;
- pstCurrentLctResult->dwLayerId = dwLayerId;
-
- pstCurrentLctResult->dwLctBtsNum = byBtsNum;
- for (uint8 i = 0; i < byBtsNum; i++)
- {
- pstCurrentLctResult->adwBtsIdList[i] = pstFirstPathList->astFirstPath[i].dwBtsId;
- }
-
- pstCurrentLctResult->dwImuMoveFlag = dwImuMoveFlag;
- return;
- }
- void lct_main_save_mean_coord(COORD_T stCoord, LCT_COORDSEL_MEAN_COORD_T *pstMeanCoordList)
- {
- uint8 byCoordListLen = pstMeanCoordList->byListLen;
-
- if (byCoordListLen < LCT_COORDSEL_MEAN_COORD_LIST_LEN)
- {
- pstMeanCoordList->astCoordList[byCoordListLen] = stCoord;
- pstMeanCoordList->byListLen++;
- }
-
- else
- {
-
- memmove(pstMeanCoordList->astCoordList, &pstMeanCoordList->astCoordList[1], sizeof(COORD_T) * (LCT_COORDSEL_MEAN_COORD_LIST_LEN - 1));
- pstMeanCoordList->astCoordList[LCT_COORDSEL_MEAN_COORD_LIST_LEN - 1] = stCoord;
- }
- return;
- }
- void lct_main_adjust_firstpath_index_offset(LCT_FIRSTPATH_LIST_T *pstAheadLctFirstPahtGroup, COORD_T stLctCoord, uint8 byPathSource, PUB_LOCATION_DATA_T *pstLctDataList)
- {
- uint8 byBtsNum = pstAheadLctFirstPahtGroup->byBtsNum;
- LCT_FIRSTPATH_T stMainBtsFirstPath = {0};
- LCT_FIRSTPATH_T *pstSlaveBtsFirstPath = NULL;
- uint8 byMainFlag = 0;
- flt32 fMainTimeLen = 0;
- int32 dwMainAbsoluteIndex = 0;
- flt32 fSlaveTimeLen = 0;
- int32 dwSlaveAbsoluteIndex = 0;
- flt32 fDelayDiff = 0;
- int32 xx = 0;
- int32 yy = 0;
- int32 zz = 0;
- flt32 fDistance = 0;
- int32 dwTimeOffset = 0;
- int32 dwSampleOffset = 0;
- int32 dwIndexOffset = 0;
-
- for (uint8 i = 0; i < byBtsNum; i++)
- {
- stMainBtsFirstPath = pstAheadLctFirstPahtGroup->astFirstPath[i];
- if (stMainBtsFirstPath.byMainFlag == 1)
- {
- byMainFlag = 1;
- break;
- }
- }
-
- if (!byMainFlag)
- {
- return;
- }
-
- xx = stLctCoord.dwX - stMainBtsFirstPath.dwCoordX;
- yy = stLctCoord.dwY - stMainBtsFirstPath.dwCoordY;
- zz = stLctCoord.dwZ - stMainBtsFirstPath.dwCoordZ;
- fDistance = sqrt(xx * xx + yy * yy + zz * zz);
- fMainTimeLen = fDistance / 100 / PUB_AUDIO_SPEED * 1000;
-
- for (uint8 j = 0; j < byBtsNum; j++)
- {
- pstSlaveBtsFirstPath = &pstAheadLctFirstPahtGroup->astFirstPath[j];
-
- if (pstSlaveBtsFirstPath->byMainFlag == 2)
- {
-
- xx = stLctCoord.dwX - pstSlaveBtsFirstPath->dwCoordX;
- yy = stLctCoord.dwY - pstSlaveBtsFirstPath->dwCoordY;
- zz = stLctCoord.dwZ - pstSlaveBtsFirstPath->dwCoordZ;
- fDistance = sqrt(xx * xx + yy * yy + zz * zz);
- fSlaveTimeLen = fDistance / 100 / PUB_AUDIO_SPEED * 1000;
-
- fDelayDiff = (fSlaveTimeLen - fMainTimeLen);
-
- dwTimeOffset = (int32)(48 * fDelayDiff);
- if (byPathSource == 1)
- {
- dwMainAbsoluteIndex = stMainBtsFirstPath.dwCalPathIndex;
- dwSlaveAbsoluteIndex = pstSlaveBtsFirstPath->dwCalPathIndex;
- }
- else if (byPathSource == 2)
- {
- dwMainAbsoluteIndex = stMainBtsFirstPath.dwTrackPathIndex;
- dwSlaveAbsoluteIndex = pstSlaveBtsFirstPath->dwTrackPathIndex;
- }
- else
- {
- dwMainAbsoluteIndex = stMainBtsFirstPath.dwCalPathIndex * 0.4 + stMainBtsFirstPath.dwTrackPathIndex * 0.6;
- dwSlaveAbsoluteIndex = pstSlaveBtsFirstPath->dwCalPathIndex * 0.4 + pstSlaveBtsFirstPath->dwTrackPathIndex * 0.6;
- }
-
- dwSampleOffset = dwSlaveAbsoluteIndex - dwMainAbsoluteIndex;
-
- dwIndexOffset = dwSampleOffset - dwTimeOffset;
-
- lct_main_adjust_slave_bts_list_index(pstSlaveBtsFirstPath->byFreqIndex, pstLctDataList, pstSlaveBtsFirstPath->dwBtsId, dwIndexOffset);
-
- lct_main_adjust_frame_index(pstSlaveBtsFirstPath, dwIndexOffset);
- }
- }
- return;
- }
- void lct_main_adjust_slave_bts_list_index(uint8 byFreqIndex, PUB_LOCATION_DATA_T *pstLocationDataList, uint32 dwBtsId, int32 dwIndexOffset)
- {
- PUB_LOCATION_DATA_T *pstLocationData = NULL;
- uint8 byFlag = 0;
- int32 dwIndex = 0;
-
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstLocationData = &pstLocationDataList[i];
- if (pstLocationData->dwSetBtsId == dwBtsId && i == byFreqIndex)
- {
- byFlag = 1;
- break;
- }
- }
-
- if (byFlag)
- {
-
- if (dwIndexOffset > 0)
- {
-
- pstLocationData->dwDdcIndex -= dwIndexOffset;
-
- dwIndex = pstLocationData->dwLocationIndex - dwIndexOffset;
- if (dwIndex >= 0)
- {
- pstLocationData->dwLocationIndex = dwIndex;
- }
- else
- {
- pstLocationData->dwLocationIndex = PUB_LCT_DATA_LIST_LEN + dwIndex;
- }
-
- dwIndex = pstLocationData->dwFourthLocationIndex - dwIndexOffset;
- if (dwIndex >= 0)
- {
- pstLocationData->dwFourthLocationIndex = dwIndex;
- }
- else
- {
- pstLocationData->dwFourthLocationIndex = PUB_LCT_DATA_LIST_LEN + dwIndex;
- }
- }
-
- else
- {
- dwIndexOffset = abs(dwIndexOffset);
-
- pstLocationData->dwDdcIndex += dwIndexOffset;
-
- dwIndex = pstLocationData->dwLocationIndex + dwIndexOffset;
- if (dwIndex >= PUB_LCT_DATA_LIST_LEN)
- {
- pstLocationData->dwLocationIndex = dwIndex - PUB_LCT_DATA_LIST_LEN;
- }
- else
- {
- pstLocationData->dwLocationIndex = dwIndex;
- }
-
- dwIndex = pstLocationData->dwFourthLocationIndex + dwIndexOffset;
- if (dwIndex >= PUB_LCT_DATA_LIST_LEN)
- {
- pstLocationData->dwFourthLocationIndex = dwIndex - PUB_LCT_DATA_LIST_LEN;
- }
- else
- {
- pstLocationData->dwFourthLocationIndex = dwIndex;
- }
- }
- }
- }
- void lct_main_adjust_frame_index(LCT_FIRSTPATH_T *pstSlaveBtsFirstPath, int32 dwIndexOffset)
- {
-
- if (dwIndexOffset > 0)
- {
- pstSlaveBtsFirstPath->wFrameCalIndex -= dwIndexOffset;
- if (pstSlaveBtsFirstPath->wFrameTrackIndex > 0)
- {
- pstSlaveBtsFirstPath->wFrameTrackIndex -= dwIndexOffset;
- }
- }
-
- else
- {
- dwIndexOffset = abs(dwIndexOffset);
- pstSlaveBtsFirstPath->wFrameCalIndex += dwIndexOffset;
- if (pstSlaveBtsFirstPath->wFrameTrackIndex > 0)
- {
- pstSlaveBtsFirstPath->wFrameTrackIndex += dwIndexOffset;
- }
- }
- }
- void lct_main_write_text_file(LCT_FIRSTPATH_LIST_T *pstFirstPahtGroup)
- {
- LCT_MAIN_TEST_FIRST_PATH_T stTmp = {0};
- LCT_FIRSTPATH_T stFirstPath = {0};
- char *pFilePaht = "E:\\work\\ips8000\\aplm8000sdk\\output\\firstpath\\firstpath.txt";
- for (uint8 i = 0; i < pstFirstPahtGroup->byBtsNum; i++)
- {
- stFirstPath = pstFirstPahtGroup->astFirstPath[i];
- stTmp.dwFrameNo = gg_dwFrameNo - 1;
- stTmp.dwFreqIndex = stFirstPath.byFreqIndex;
- stTmp.dwMaxValue = (uint32)stFirstPath.fMaxAmplValue;
-
- stTmp.dwCalDdcIndex = stFirstPath.dwCalPathIndex;
-
- stTmp.dwTrackDdcIndex = stFirstPath.dwTrackPathIndex;
-
- util_write_real_number_to_txt_file(pFilePaht, sizeof(LCT_MAIN_TEST_FIRST_PATH_T) / 4, (uint32 *)(&stTmp));
- }
- return;
- }
- void lct_main_update_phone_tendency(LCT_COORDSEL_MEAN_COORD_T *pstMeanLctCoordList, LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstPredictionDirectionDataList)
- {
- LCT_FIRSTPATH_PREDICTION_DIRECTION_DATA_T *pstDirectionData = NULL;
- flt32 fDistanceC = 0;
- flt32 fDistanceA = 0;
- uint8 byLen = pstMeanLctCoordList->byListLen;
- if (byLen < 2)
- {
- return;
- }
- COORD_T stPointC = pstMeanLctCoordList->astCoordList[byLen - 1];
- COORD_T stPointA = pstMeanLctCoordList->astCoordList[byLen - 2];
- for (uint8 i = 0; i < PUB_SYS_CARRIER_NUM; i++)
- {
- pstDirectionData = &pstPredictionDirectionDataList[i];
- if (pstDirectionData->byValidFlag)
- {
- fDistanceC = util_distance_cal_p2p_distance(pstDirectionData->dwCoordX, pstDirectionData->dwCoordY, stPointC.dwX, stPointC.dwY);
- fDistanceA = util_distance_cal_p2p_distance(pstDirectionData->dwCoordX, pstDirectionData->dwCoordY, stPointA.dwX, stPointA.dwY);
- if (fDistanceC > fDistanceA)
- {
- pstDirectionData->byDirectionTendency = 2;
- }
- else if (fDistanceC < fDistanceA)
- {
- pstDirectionData->byDirectionTendency = 1;
- }
- else
- {
- pstDirectionData->byDirectionTendency = 0;
- }
- }
- }
- }
|