UPDATE MANY NWE FUNCTIONS

Origin project is based on visual studio solution,
so, when you load all the files in your editor,
it can be cause errors. So, modify is a good choice
This commit is contained in:
KenanZhu111 committed 2024-10-01 22:06:38 +08:00
1 parent 0f1a59c2aa
commit 37473233c2
7 files changed
+498 -172

No files matched your search

+30 -10
View File
@@ -1,6 +1,6 @@
function [ENU] = Station_Site_Solving() function [ENU] = Station_Site_Solving()
% 打开坐标文件 % 打开坐标文件
file=fopen('LLA_result.txt'); file=fopen('111.sp');
sPRN = []; sPRN = [];
satX = []; satX = [];
satY = []; satY = [];
@@ -41,7 +41,8 @@ while ~feof(file)
satnum = satnum + 1; satnum = satnum + 1;
P_t1(eponum, satnum) = str2double(extractBetween(line,11 + 16 + 16 + 16 ,25 + 16 + 16 + 16 )); P_t1(eponum, satnum) = str2double(extractBetween(line,11 + 16 + 16 + 16 ,25 + 16 + 16 + 16 ));
if P_t1(eponum, satnum) ~= 0 if P_t1(eponum, satnum) ~= 0
sPRN(eponum, satnum) = str2double(extractBetween(line,2 ,3 )); prnnum = str2double(extractBetween(line,2 ,3 ));
sPRN(eponum, prnnum) = str2double(extractBetween(line,2 ,3 ));
satX(eponum, satnum) = str2double(extractBetween(line,11 ,25 )); satX(eponum, satnum) = str2double(extractBetween(line,11 ,25 ));
satY(eponum, satnum) = str2double(extractBetween(line,11 + 16 ,25 + 16 )); satY(eponum, satnum) = str2double(extractBetween(line,11 + 16 ,25 + 16 ));
satZ(eponum, satnum) = str2double(extractBetween(line,11 + 16 + 16 ,25 + 16 + 16 )); satZ(eponum, satnum) = str2double(extractBetween(line,11 + 16 + 16 ,25 + 16 + 16 ));
@@ -95,8 +96,30 @@ for i = 1:1:eponum
B(j, 3) = -((satZ(i, j) - apZ) / R); B(j, 3) = -((satZ(i, j) - apZ) / R);
B(j, 4) = 1; B(j, 4) = 1;
% 简化的Hopfield模型 % % 简化的Hopfield模型
dtrop = 2.47/sind(H(i, j))+0.0121; % dtrop = 2.47/sind(H(i, j))+0.0121;
% % % % % %
P0 = 1013.25; e0 = 11.69; T0 = 288.15;
% 求大气压强
p = P0 * (1.0 - 0.0068 / T0 / apH)^5;
% 求开尔文温度
T = 288.15 - 0.0068 * apH;
% 水汽压计算
if apH > 11000
e = 0;
end
if apH <= 11000
e = e0 * (1.0 - 0.0068 * apH / T0)^4;
end
deltaSd = 0.00001552 * p / T * (40136 + 148.72 * (T - 273.16) - apH);
deltaSw = 0.0746512 * e / T^2 * (11000 - apH);
% 对流层延迟干分量
dtropd = deltaSd / sqrt(sind( rad2deg(deg2rad(H(i, j)) ^ 2) + 6.25 ) );
% 对流层延迟湿分量
dtropw = deltaSw / sqrt(sind( rad2deg(deg2rad(H(i, j)) ^ 2) + 6.25 ) );
dtrop = 0.1 * dtropw + 0.9 * dtropd;
% % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % 理想化的Saastamoinen模型/对流层改正 % % % % % % % 理想化的Saastamoinen模型/对流层改正
% P0 = 1013.25; e0 = 11.69; T0 = 288.15; % P0 = 1013.25; e0 = 11.69; T0 = 288.15;
@@ -124,9 +147,6 @@ for i = 1:1:eponum
P_t = P_t1(i, j); P_t = P_t1(i, j);
end end
l(j, 1) = P_t - R + C_V * Dt(i,j) - dtrop; l(j, 1) = P_t - R + C_V * Dt(i,j) - dtrop;
if H(i, j)<5
H(i, j) = H(i, j);
end
P(j, j) = sind(H(i, j))^2; P(j, j) = sind(H(i, j))^2;
end end
@@ -172,12 +192,12 @@ end
%绘制结果图 %绘制结果图
figure("Position",[200, 700,1000,200],"Name", "East component deviation","NumberTitle","off") figure("Position",[200, 700,1000,200],"Name", "East component deviation","NumberTitle","off")
bar(ENU(1,:))%E plot(ENU(1,:));%E
box off box off
figure("Position",[200, 400,1000,200],"Name","North component deviation","NumberTitle","off") figure("Position",[200, 400,1000,200],"Name","North component deviation","NumberTitle","off")
bar(ENU(2,:))%N plot(ENU(2,:));%N
box off box off
figure("Position",[200, 100,1000,200],"Name", "Up component deviation","NumberTitle","off") figure("Position",[200, 100,1000,200],"Name", "Up component deviation","NumberTitle","off")
bar(ENU(3,:))%U plot(ENU(3,:));%U
box off box off
+335 -132
View File
@@ -1,11 +1,3 @@
/*
* @Author: KenanZhu111 3471685733@qq.com
* @Date: 2024-09-27 19:05:41
* @LastEditors: KenanZhu111 3471685733@qq.com
* @LastEditTime: 2024-09-27 19:55:46
* @FilePath: \Sat_Position_Solving_ver1.4.7\maingui.c
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include<stdio.h> #include<stdio.h>
#include<wchar.h> #include<wchar.h>
#include<stdlib.h> #include<stdlib.h>
@@ -21,14 +13,42 @@
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define FILEEXOP TEXT("All Files(*.*)\0*.*\0"\ //FILE SELECT DIALOGS
"Obs Files(*.o*)\0*.20o;*.21o;*.22o;*.23o;*.24o\0"\ #define FILEEXOP TEXT("Obs Files(*.o*)\0*.20o;*.21o;*.22o;*.23o;*.24o\0"\
"Nav Files(*.p*)\0*.20p;*.21p;*.22p;*.23p;*.24p\0\0"); "All Files(*.*)\0*.*\0\0");
#define FILEEXSV TEXT("All Files(*.*)\0*.*\0"\
"Spos Files(*.sp*)\0*.sp\0\0");
#define FILEEXNP TEXT("Nav Files(*.p*)\0*.20p;*.21p;*.22p;*.23p;*.24p\0"\
"All Files(*.*)\0*.*\0\0")
#define FILEEXSV TEXT("Spos Files(*.sp*)\0*.sp\0"\
"All Files(*.*)\0*.*\0\0");
//DEF MAIN WINDOW BUTTONS
#define OBSBUTTON 3301
#define NAVBUTTON 3302
#define CALBUTTON 3303
#define OPTBUTTON 3304
#define PLOBUTTON 3305
#define OBSCLEAR 3306
#define NAVCLEAR 3307
//DEF MAIN WINDOW GNSS NUTTONS
#define GPSCHECK 5500
#define GLOCHECK 5501
#define BEICHECK 5502
#define GALCHECK 5503
#define SBACHECK 5504
#define SYSGROUP 1001
//DEF OPTIONS WINDOW CHECK+BOXS
#define OPTDFION 7001
#define OPTDFTRO 7002
#define OPTCONFI 7003
HWND hwndb[13];//BUTTON HANDLE
HWND hwndopt;//OPTIONS HANDLE
HWND hwndopt_def_ion;//DEFAULT ION COR
HWND hwndopt_def_tro;//DEFAULT TRO COR
HWND hwndopt_confirm;//OPTION CONFIRM
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
FILE * fp_nav = NULL; FILE * fp_nav = NULL;
FILE * fp_obs = NULL; FILE * fp_obs = NULL;
@@ -39,19 +59,86 @@ pnav_body nav_b = NULL;
pobs_head obs_h = NULL; pobs_head obs_h = NULL;
pobs_epoch obs_e = NULL; pobs_epoch obs_e = NULL;
pobs_body obs_b = NULL; pobs_body obs_b = NULL;
int o_epochnum = 0; int o_epochnum = 0;
int gps_satnum = 0; int gps_satnum = 0;
int bds_satnum = 0;
/*INITIAL SETTINGS*/
static int ionoption = 0;
static int trooption = 0;
/* ------------- */
static int FileSelobsDialog(const wchar_t* path)//FILEDIALOG FOR OBS
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXOP;
ofn.lpstrTitle = TEXT("Open From");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
return GetOpenFileName(&ofn);
}
static int FileSelnavDialog(const wchar_t* path)//FILEDIALOG FOR NAV
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXNP;
ofn.lpstrTitle = TEXT("Open From");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
return GetOpenFileName(&ofn);
}
static int FileSaveDialog(const wchar_t* path)//FILEDIALOG FOR SAVE
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrDefExt = TEXT(".sp");
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXSV;
ofn.lpstrTitle = TEXT("Save To");
ofn.Flags = OFN_OVERWRITEPROMPT;
return GetSaveFileName(&ofn);
}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);//MAIN WINDOW
LRESULT CALLBACK OptWndProc(HWND, UINT, WPARAM, LPARAM);//OPTION WINDOW
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int iCmdShow) { int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int iCmdShow) {
WNDCLASS wndclass; WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.style = CS_PARENTDC;
wndclass.lpfnWndProc = WndProc; wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0; wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0; wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance; wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszMenuName = NULL; wndclass.lpszMenuName = NULL;
@@ -59,11 +146,19 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
RegisterClass(&wndclass); RegisterClass(&wndclass);
wndclass.lpfnWndProc = OptWndProc;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON2));
wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("OPT");
RegisterClass(&wndclass);
HWND hwnd; HWND hwnd;
hwnd = CreateWindow( hwnd = CreateWindow(
TEXT("SPP"), TEXT("SPP"),
TEXT("SPP Calculate"), TEXT("SPP Calculate"),
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
650, 650,
300, 300,
0, 0,
@@ -73,8 +168,29 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
hInstance, hInstance,
NULL); NULL);
HFONT hFont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); HFONT hbFont;
SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 1); hbFont = CreateFont(
15,
0,
0,
0,
FW_LIGHT,
FALSE,
FALSE,
FALSE,
DEFAULT_CHARSET,
OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,
CLEARTYPE_QUALITY,
VARIABLE_PITCH,
TEXT("Segoe UI"));
SendMessage(hwnd, WM_SETFONT, (WPARAM)hbFont, 1);
for (int i = 0; i < 12; i++)
{
SendMessage(hwndb[i], WM_SETFONT, (WPARAM)hbFont, 1);
}
ShowWindow(hwnd, iCmdShow); ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd); UpdateWindow(hwnd);
@@ -87,33 +203,6 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
return msg.wParam; return msg.wParam;
} }
int FileSelectDialog(const wchar_t *path)
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXOP;
ofn.lpstrTitle = TEXT("Open From");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_SHOWHELP;
return GetOpenFileName(&ofn);
}
int FileSaveDialog(const wchar_t* path)
{
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrDefExt = TEXT(".sp");
ofn.lpstrFile = path;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = FILEEXSV;
ofn.lpstrTitle = TEXT("Save To");
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_SHOWHELP;
return GetSaveFileName(&ofn);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
const wchar_t wobs_file[MAX_PATH] = { 0 }; const wchar_t wobs_file[MAX_PATH] = { 0 };
@@ -121,156 +210,211 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
const wchar_t wres_file[MAX_PATH] = { 0 }; const wchar_t wres_file[MAX_PATH] = { 0 };
char obs_file[MAX_PATH] = { 0 }; char obs_file[MAX_PATH] = { 0 };
char nav_file[MAX_PATH] = { 0 }; char nav_file[MAX_PATH] = { 0 };
char res_file[MAX_PATH] = { 0 }; char res_file[MAX_PATH] = { 0 };//BE COMPATIBLE WITH MSVC
HWND hwndopt;
RECT rect; RECT rect;
TCHAR* SATSYS[5] = { TEXT("GPS"), TEXT("GLO"),TEXT("SBAS"), TEXT("BeiDou"), TEXT("Galileo") }; HBITMAP Delico;
TCHAR* SATSYS[5] = { TEXT("GPS"),TEXT("GLO"),TEXT("BeiDou"),TEXT("Galileo"),TEXT("SBAS") };
static int cxchar, cychar; static int cxchar, cychar;
switch (msg) { switch (msg) {
case WM_CREATE: case WM_CREATE:
cxchar = LOWORD(GetDialogBaseUnits()); cxchar = LOWORD(GetDialogBaseUnits());
cychar = HIWORD(GetDialogBaseUnits()); cychar = HIWORD(GetDialogBaseUnits());//GET THE SYS FONT SIZE
GetWindowRect(hwnd, &rect); GetWindowRect(hwnd, &rect);
MoveWindow(hwnd, rect.left, rect.bottom, 50 * cxchar, 15 * cychar, TRUE); MoveWindow(hwnd, rect.left, rect.bottom, 50 * cxchar, 15 * cychar, TRUE);//REPAINT THE MAIN WINDOW
CreateWindow(TEXT("Button"), TEXT("Load Obs file"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, //CREATE THE BUTTONS
hwndb[0] = CreateWindow(TEXT("Button"), TEXT("Open Obs Data"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
cxchar, 5 * cychar, cxchar, 5 * cychar,
16 * cxchar, 2 * cychar, 14 * cxchar, 2 * cychar,
hwnd, (HMENU)3301, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)OBSBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CreateWindow(TEXT("Button"), TEXT("Load Nav file"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, hwndb[1] = CreateWindow(TEXT("Button"), TEXT("Open Nav Data"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
17 * cxchar, 5 * cychar, 17 * cxchar, 5 * cychar,
16 * cxchar, 2 * cychar, 14 * cxchar, 2 * cychar,
hwnd, (HMENU)3302, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)NAVBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CreateWindow(TEXT("Button"), TEXT("Sat-Position Calculate"), WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, hwndb[2] = CreateWindow(TEXT("Button"), TEXT("Sat-Position Calculate"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
cxchar, 7 * cychar, cxchar, 7 * cychar,
32 * cxchar, 2 * cychar, 32 * cxchar, 2 * cychar,
hwnd, (HMENU)3303, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)CALBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CreateWindow(TEXT("Button"), TEXT("Options..."), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, hwndb[3] = CreateWindow(TEXT("Button"), TEXT("Options..."), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
36 * cxchar, 7 * cychar, 36 * cxchar, 7 * cychar,
10 * cxchar, 2 * cychar, 10 * cxchar, 2 * cychar,
hwnd, (HMENU)3304, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)OPTBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CreateWindow(TEXT("Button"), TEXT("Plot"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, hwndb[4] = CreateWindow(TEXT("Button"), TEXT("Plot"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
36 * cxchar, 5 * cychar, 36 * cxchar, 5 * cychar,
10 * cxchar, 2 * cychar, 10 * cxchar, 2 * cychar,
hwnd, (HMENU)3304, ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)PLOBUTTON, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
CreateWindow(TEXT("Button"), SATSYS[i], WS_VISIBLE|WS_CHILD|BS_AUTOCHECKBOX, hwndb[i + 5] = CreateWindow(TEXT("Button"), SATSYS[i], WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
(2 + 9 * i) * cxchar, 21 * cychar/2, (2 + 7 * i) * cxchar, 21 * cychar/2,
8 * cxchar, 5 * cychar/3, 7 * cxchar, 5 * cychar/3,
hwnd, (HMENU)(5500 + i), ((LPCREATESTRUCT)lParam)->hInstance, NULL); hwnd, (HMENU)(5500 + i), ((LPCREATESTRUCT)lParam)->hInstance, NULL);
} }
hwndb[10] = CreateWindow(TEXT("Button"), TEXT("Satellite System"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
1 * cxchar/2, 19 * cychar/2,
47 * cxchar, 6 * cychar/2,
hwnd, (HMENU)SYSGROUP, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[11] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_BITMAP | BS_PUSHBUTTON,
15 * cxchar, 5 * cychar,
2 * cxchar, 2 * cychar,
hwnd, (HMENU)OBSCLEAR, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndb[12] = CreateWindow(TEXT("Button"), NULL, WS_VISIBLE | WS_CHILD | BS_BITMAP | BS_PUSHBUTTON,
31 * cxchar, 5 * cychar,
2 * cxchar, 2 * cychar,
hwnd, (HMENU)NAVCLEAR, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CreateWindow(TEXT("Button"), TEXT("GNSS"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
cxchar, 19 * cychar/2,
47 * cxchar, 6 * cychar/2,
hwnd, (HMENU)(1001), ((LPCREATESTRUCT)lParam)->hInstance, NULL);
return 0; return 0;
case WM_COMMAND: case WM_COMMAND:
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case 3301: /* -------------------------- LOAD OBS DATA BUTTON -------------------------- */
while(MessageBox(hwnd,TEXT("Please choose Obs file"),TEXT("NOTICE"),MB_ICONASTERISK|MB_YESNO) == IDYES) case OBSBUTTON:
FileSelobsDialog(wobs_file);
wcstombs(obs_file, wobs_file, MAX_PATH);
fp_obs = fopen(obs_file, TEXT("r"));
if (fp_obs != NULL)
{ {
FileSelectDialog(wobs_file); o_epochnum = get_epochnum(fp_obs);
wcstombs(obs_file, wobs_file, MAX_PATH); rewind(fp_obs);
fp_obs = fopen(obs_file, TEXT("r")); obs_h = (pobs_head)malloc(sizeof(obs_head));
if (fp_obs != NULL) obs_e = (pobs_epoch)malloc(sizeof(obs_epoch) * o_epochnum);
obs_b = (pobs_body)malloc(sizeof(obs_body) * o_epochnum);
if (obs_h && obs_e && obs_b)
{ {
o_epochnum = get_epochnum(fp_obs); read_o_h(fp_obs, obs_h);
rewind(fp_obs); read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);
obs_h = (pobs_head)malloc(sizeof(obs_head));
obs_e = (pobs_epoch)malloc(sizeof(obs_epoch) * o_epochnum);
obs_b = (pobs_body)malloc(sizeof(obs_body) * o_epochnum);
if (obs_h && obs_e && obs_b)
{
read_o_h(fp_obs, obs_h);
read_o_b(fp_obs, obs_e, obs_b, obs_h->obstypenum_gps, obs_h->obstypenum_bds);
}
fclose(fp_obs);
if (o_epochnum > 0)
{
MessageBox(hwnd, TEXT("File of Obs load complete!"), TEXT("NOTICE"), MB_ICONASTERISK);
break;
}
} }
else fclose(fp_obs);
if (o_epochnum > 0)
{
MessageBox(hwnd, TEXT("File of Obs load complete!"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
break; break;
}
} }
break; break;
return 0; return 0;
case 3302: /* -------------------------- LOAD NAV DATA BUTTON -------------------------- */
while(MessageBox(hwnd,TEXT("Please choose Nav file"),TEXT("NOTICE"),MB_ICONASTERISK|MB_YESNO) == IDYES) case NAVBUTTON:
FileSelnavDialog(wnav_file);
wcstombs(nav_file, wnav_file, MAX_PATH);
fp_nav = fopen(nav_file, TEXT("r"));
if (fp_nav != NULL)
{ {
FileSelectDialog(wnav_file); gps_satnum = getgpssatnum(fp_nav);
wcstombs(nav_file, wnav_file, MAX_PATH); rewind(fp_nav);
fp_nav = fopen(nav_file, TEXT("r")); bds_satnum = getbdssatnum(fp_nav);
if (fp_nav != NULL) rewind(fp_nav);
nav_h = (pnav_head)malloc(sizeof(nav_head));
nav_b = (pnav_body)malloc(sizeof(nav_body) * (gps_satnum + bds_satnum));
if (nav_h && nav_b)
{ {
gps_satnum = getgpssatnum(fp_nav); read_n_h(fp_nav, nav_h);
rewind(fp_nav); read_n_b(fp_nav, nav_b);
nav_h = (pnav_head)malloc(sizeof(nav_head));
nav_b = (pnav_body)malloc(sizeof(nav_body) * gps_satnum * 2);
if (nav_h && nav_b)
{
read_n_h(fp_nav, nav_h);
read_n_b(fp_nav, nav_b);
}
fclose(fp_nav);
if (gps_satnum > 0)
{
MessageBox(hwnd, TEXT("File of Nav load complete!"), TEXT("NOTICE"), MB_ICONASTERISK);
break;
}
} }
else fclose(fp_nav);
if (gps_satnum > 0)
{
MessageBox(hwnd, TEXT("File of Nav load complete!"), TEXT("NOTICE"), MB_ICONASTERISK | MB_OK);
break; break;
}
} }
break; break;
return 0; return 0;
case 3303: /* ---------------------------- CALCAULATE BUTTON --------------------------- */
if (fp_obs == NULL || fp_nav == NULL) case CALBUTTON:
if (fp_obs == NULL && fp_nav == NULL)
{ {
MessageBox(hwnd, TEXT("No Data File!"), TEXT("WARNING"), MB_ICONERROR | MB_OK); MessageBox(hwnd, TEXT("No Data File!"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
}
else if (fp_obs == NULL && fp_nav != NULL)
{
MessageBox(hwnd, TEXT("No Obs Data File!"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
}
else if (fp_obs != NULL && fp_nav == NULL)
{
MessageBox(hwnd, TEXT("No Nav Data File!"), TEXT("STOP"), MB_ICONERROR | MB_OKCANCEL | MB_DEFBUTTON1);
} }
else if (fp_obs != NULL && fp_nav != NULL) else if (fp_obs != NULL && fp_nav != NULL)
{ {
while(1) int ALLSTATE = 0x0000;
for (int i = 0; i < 5; i++){ALLSTATE += SendMessage(hwndb[i + 5], BM_GETCHECK, wParam, lParam);}
if (ALLSTATE == 0x0000)
{
while (1)
{
if (MessageBox(hwnd, TEXT("No GNSS is choosen\nPlease Retry"), TEXT("NOTICE"), MB_ICONERROR | MB_RETRYCANCEL) == IDRETRY)
{
break;
}
}
}
else
{ {
FileSaveDialog(wres_file); FileSaveDialog(wres_file);
if (wres_file == TEXT("")) wcstombs(res_file, wres_file, MAX_PATH);
if (res_file[0] == '\0')
{ {
break; while (MessageBox(hwnd, TEXT("Failed to select a save path.\nThe data has been cleared!"), TEXT("WARNING"), MB_ICONWARNING | MB_OK) == IDOK)
{
break;
}
} }
else else
{ {
wcstombs(res_file, wres_file, MAX_PATH); if (SendMessage(hwndb[5], BM_GETCHECK, wParam, lParam) == BST_CHECKED)
sat_gps_pos_clac(result_file, nav_b, obs_e, obs_b, obs_h, o_epochnum, gps_satnum, res_file); {
free(obs_h); free(obs_e); free(obs_b); free(nav_h); free(nav_b); sat_gps_pos_clac(result_file, nav_b, obs_e, obs_b, obs_h, o_epochnum, gps_satnum, res_file);
fp_nav = NULL; fp_obs = NULL; result_file = NULL; }
break;
} }
free(obs_h); free(obs_e); free(obs_b); free(nav_h); free(nav_b);
fp_nav = NULL; fp_obs = NULL; result_file = NULL;
nav_h = NULL; nav_b = NULL; obs_h = NULL; obs_e = NULL; obs_b = NULL;
} }
} }
break; break;
return 0; return 0;
case 3304: /* ----------------------------- OPTIONS BUTTON ----------------------------- */
case OPTBUTTON:
DestroyWindow(hwndopt);
hwndopt = CreateWindow(TEXT("OPT"), TEXT("Options"), WS_CAPTION | WS_SYSMENU,
650, 300,
0, 0,
NULL, NULL, GetWindowLongPtr(hwndopt, GWLP_HINSTANCE), NULL);
HFONT hbFont;
hbFont = CreateFont(
15,0,0,0,
FW_LIGHT,FALSE,FALSE,FALSE,
DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,
VARIABLE_PITCH,TEXT("Segoe UI"));
SendMessage(hwndopt_def_ion, WM_SETFONT, (WPARAM)hbFont, 1);
SendMessage(hwndopt_def_tro, WM_SETFONT, (WPARAM)hbFont, 1);
SendMessage(hwndopt_confirm, WM_SETFONT, (WPARAM)hbFont, 1);//SEND FONT SETTING MESSAGE
while (ionoption == 1) { SendMessage(hwndopt_def_ion, BM_SETCHECK, wParam, lParam); break; };
while (trooption == 1) { SendMessage(hwndopt_def_tro, BM_SETCHECK, wParam, lParam); break; };//SEND SETTING STATE MESSAGE
break; break;
return 0; return 0;
/* ------------------------------- PLOT BUTTON ------------------------------ */
case PLOBUTTON:
break;
return 0;
/* ------------------------------- DEFAULT MSG ------------------------------ */
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
} }
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
if(MessageBox(hwnd, TEXT("You're shutting the program"), TEXT("Confirm"), MB_YESNO | MB_ICONASTERISK) == IDYES ) if(MessageBox(hwnd, TEXT("You're shutting the program"), TEXT("NOTICE"), MB_OKCANCEL | MB_ICONASTERISK) == IDOK )
DestroyWindow(hwnd); DestroyWindow(hwnd);
else else
return 0; return 0;
@@ -280,3 +424,62 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
} }
return DefWindowProc(hwnd, msg, wParam, lParam); return DefWindowProc(hwnd, msg, wParam, lParam);
} }
LRESULT CALLBACK OptWndProc(HWND hwndopt, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int cxchar, cychar;
RECT rect;
switch (msg)
{
case WM_CREATE:
cxchar = LOWORD(GetDialogBaseUnits());
cychar = HIWORD(GetDialogBaseUnits());
GetWindowRect(hwndopt, &rect);
MoveWindow(hwndopt, rect.left, rect.bottom, 30 * cxchar, 7 * cychar, TRUE);
ShowWindow(hwndopt, SW_SHOWDEFAULT);
UpdateWindow(hwndopt);
hwndopt_def_ion = CreateWindow(TEXT("BUTTON"), TEXT("Use Default ION_COR"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
2 * cxchar, 0, 18 * cxchar, 2 * cychar, hwndopt, (HMENU)OPTDFION, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndopt_def_tro = CreateWindow(TEXT("BUTTON"), TEXT("Use Default TRO_COR"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
2 * cxchar, 2 * cychar, 18 * cxchar, 2 * cychar, hwndopt, (HMENU)OPTDFTRO, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
hwndopt_confirm = CreateWindow(TEXT("BUTTON"), TEXT("Confirm"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20 * cxchar, 5 * cychar/2, 7 * cxchar, 3 * cychar/2, hwndopt, (HMENU)OPTCONFI, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
break;
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case OPTDFION:
break;
return 0;
case OPTDFTRO:
break;
return 0;
case OPTCONFI:
if (SendMessage(hwndopt_def_ion, BM_GETCHECK, wParam, lParam) == BST_CHECKED){ionoption = 1;}
else{ionoption = 0;}
if (SendMessage(hwndopt_def_tro, BM_GETCHECK, wParam, lParam) == BST_CHECKED){trooption = 1;}
else{trooption = 0;}//GET CHECKBOX'S SETTINGS
DestroyWindow(hwndopt);
break;
return 0;
}
break;
return 0;
case WM_CLOSE:
DestroyWindow(hwndopt);
break;
return 0;
case WM_DESTROY:
break;
return 0;
default:
return DefWindowProc(hwndopt, msg, wParam, lParam);
}
return 0;
}
+8 -8
View File
@@ -19,12 +19,12 @@
pos_ts gps_pos(int sPRN, int best_epoch, double GPSsec, pos_ts gps_pos(int sPRN, int best_epoch, double GPSsec,
pnav_body nav_b, pobs_head obs_h, pos_ts pos_t) pnav_body nav_b, pobs_head obs_h, pos_ts pos_t)
{ {
double T_S = GPSsec - pos_t.deltat[sPRN];//计算信号发射时刻 double T_S = GPSsec - pos_t.delta_t[sPRN];//计算信号发射时刻
double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA,3); double n_0 = sqrt(GM) / pow(nav_b[best_epoch].sqrtA,3);
double n = n_0 + nav_b[best_epoch].deltan; //计算卫星运行平均角速度 double n = n_0 + nav_b[best_epoch].deltan; //计算卫星运行平均角速度
double tk = T_S - nav_b[best_epoch].TOE;//计算归化时间 double tk = T_S - nav_b[best_epoch].TOE;//计算归化时间
if (tk > 32400)tk -= 604800; if (tk > 32400)tk -= 604800;
else if (tk < -32400)tk += 604800;//规划时间改正 else if (tk < -32400)tk += 604800;//归化时间改正
double Ms = nav_b[best_epoch].M0 + n * tk;//计算卫星发射时卫星的平近角M double Ms = nav_b[best_epoch].M0 + n * tk;//计算卫星发射时卫星的平近角M
double Es = Ms, E0;//迭代计算偏近点角 double Es = Ms, E0;//迭代计算偏近点角
do do
@@ -51,14 +51,14 @@ pos_ts gps_pos(int sPRN, int best_epoch, double GPSsec,
double X = x * cos(l) - y * cos(i) * sin(l); double X = x * cos(l) - y * cos(i) * sin(l);
double Y = x * sin(l) + y * cos(i) * cos(l); double Y = x * sin(l) + y * cos(i) * cos(l);
double Z = y * sin(i);//卫星在地固系下的直角坐标 double Z = y * sin(i);//卫星在地固系下的直角坐标
pos_t.X[sPRN] = cos(Earth_e * pos_t.delta_t[sPRN]) * X + sin(Earth_e * pos_t.delta_t[sPRN]) * Y; pos_t.X[sPRN] = cos(Earth_e * pos_t.delta_t[sPRN]) * X + sin(Earth_e * pos_t.delta_t[sPRN]) * Y;
pos_t.Y[sPRN] = -sin(Earth_e * pos_t.delta_t[sPRN]) * X + cos(Earth_e * pos_t.delta_t[sPRN]) * Y; pos_t.Y[sPRN] = -sin(Earth_e * pos_t.delta_t[sPRN]) * X + cos(Earth_e * pos_t.delta_t[sPRN]) * Y;
pos_t.Z[sPRN] = Z; pos_t.Z[sPRN] = Z;
double R = sqrt(pow(pos_t.X[sPRN] - obs_h->apX, 2) + pow(pos_t.Y[sPRN] - obs_h->apY, 2) + pow(pos_t.Z[sPRN] - obs_h->apY, 2)); double R = sqrt(pow(pos_t.X[sPRN] - obs_h->apX, 2) + pow(pos_t.Y[sPRN] - obs_h->apY, 2) + pow(pos_t.Z[sPRN] - obs_h->apZ, 2));
pos_t.deltat[sPRN] = pos_t.delta_t[sPRN]; pos_t.deltat[sPRN] = pos_t.delta_t[sPRN];
pos_t.delta_t[sPRN] = R / C_V;
double rela = 2*sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es)/pow(C_V,2); double rela = 2*sqrt(GM) * nav_b[best_epoch].e * nav_b[best_epoch].sqrtA * sin(Es)/pow(C_V,2);
pos_t.delta_clk[sPRN] = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk,2) - rela; pos_t.delta_clk[sPRN] = nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * tk + nav_b[best_epoch].sa2 * pow(tk,2) - rela;
pos_t.delta_t[sPRN] = R / C_V + pos_t.delta_clk[sPRN];
return pos_t; return pos_t;
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@@ -105,7 +105,7 @@ void sat_gps_pos_clac(FILE * result_file,
//计算近似的信号传播时间,接收机钟差已初始化为0(伪距/光速-接收机钟差+卫星钟差) //计算近似的信号传播时间,接收机钟差已初始化为0(伪距/光速-接收机钟差+卫星钟差)
pos_t.delta_t[sPRN] = (obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V) - station.delta_TR + nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * detat_toc + nav_b[best_epoch].sa2 * pow(detat_toc, 2); pos_t.delta_t[sPRN] = (obs_b[i].obs_gps[j][Code2Type(C1C, obs_h->obstypenum_gps, obs_h->obscode_gps)] / C_V) - station.delta_TR + nav_b[best_epoch].sa0 + nav_b[best_epoch].sa1 * detat_toc + nav_b[best_epoch].sa2 * pow(detat_toc, 2);
pos_t.deltat[sPRN] = 0.0;//判断收敛 pos_t.deltat[sPRN] = 0.0;//判断收敛
while (fabs(pos_t.delta_t[sPRN] - pos_t.deltat[sPRN]) > 0.00001){ while (fabs(pos_t.delta_t[sPRN] - pos_t.deltat[sPRN]) > 1.0e-9){
pos_t = gps_pos(sPRN, best_epoch, GPSsec, nav_b, obs_h, pos_t); pos_t = gps_pos(sPRN, best_epoch, GPSsec, nav_b, obs_h, pos_t);
} }
@@ -139,9 +139,9 @@ void sat_gps_pos_clac(FILE * result_file,
rah.A = rad2deg(tem4.A); rah.A = rad2deg(tem4.A);
rah.H = rad2deg(tem4.H); rah.H = rad2deg(tem4.H);
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
if (blh.H < 0 ||nav_b[best_epoch].sHEA != 0) if (blh.H < 0 || rah.H < 10 ||nav_b[best_epoch].sHEA != 0)
{ {
break; continue;
} }
else else
{ {
+3 -10
View File
@@ -109,9 +109,9 @@ typedef struct nav_head
//导航数据结构体 //导航数据结构体
typedef struct nav_body typedef struct nav_body
{ {
//数据块第一行内容:
int sPRN;//卫星PRN号 int sPRN_GPS;//GPS卫星PRN
//历元:TOC中卫星钟的参考时刻 int sPRN_BDS;//GPS卫星PRN
int TOC_Y;//年 int TOC_Y;//年
int TOC_M;//月 int TOC_M;//月
int TOC_D;//日 int TOC_D;//日
@@ -122,43 +122,36 @@ typedef struct nav_body
double sa1;//卫星钟偏 double sa1;//卫星钟偏
double sa2;//卫星钟漂 double sa2;//卫星钟漂
//数据块第二行内容:
double IODE;//数据、星历发布时间(数据期龄) double IODE;//数据、星历发布时间(数据期龄)
double Crs;//轨道半径的正弦调和改正项的振幅(单位:m) double Crs;//轨道半径的正弦调和改正项的振幅(单位:m)
double deltan;//卫星平均运动速率与计算值之差(rad/s) double deltan;//卫星平均运动速率与计算值之差(rad/s)
double M0;//参考时间的平近点角(rad) double M0;//参考时间的平近点角(rad)
//数据块第三行内容:
double Cuc;//维度幅角的余弦调和改正项的振幅(rad) double Cuc;//维度幅角的余弦调和改正项的振幅(rad)
double e;//轨道偏心率 double e;//轨道偏心率
double Cus;//轨道幅角的正弦调和改正项的振幅(rad) double Cus;//轨道幅角的正弦调和改正项的振幅(rad)
double sqrtA;//长半轴平方根 double sqrtA;//长半轴平方根
//数据块第四行内容:
double TOE;//星历的参考时刻(GPS周内秒) double TOE;//星历的参考时刻(GPS周内秒)
double Cic;//轨道倾角的余弦调和改正项的振幅(rad) double Cic;//轨道倾角的余弦调和改正项的振幅(rad)
double OMEGA;//参考时刻的升交点赤经 double OMEGA;//参考时刻的升交点赤经
double Cis;//维度倾角的正弦调和改正项的振幅(rad) double Cis;//维度倾角的正弦调和改正项的振幅(rad)
//数据块第五行内容:
double i0;//参考时间的轨道倾角(rad) double i0;//参考时间的轨道倾角(rad)
double Crc;//轨道平径的余弦调和改正项的振幅(m) double Crc;//轨道平径的余弦调和改正项的振幅(m)
double omega;//近地点角距 double omega;//近地点角距
double deltaomega;//升交点赤经变化率(rad) double deltaomega;//升交点赤经变化率(rad)
//数据块第六行内容:
double IDOT;//近地点角距(rad/s) double IDOT;//近地点角距(rad/s)
double L2code;//L2上的码 double L2code;//L2上的码
double GPSweek;//GPS周,于TOE一同表示 double GPSweek;//GPS周,于TOE一同表示
double L2Pflag;//L2,p码数据标记 double L2Pflag;//L2,p码数据标记
//数据块第七行内容
double sACC;//卫星精度 double sACC;//卫星精度
double sHEA;//卫星健康状态 double sHEA;//卫星健康状态
double TGD;//sec double TGD;//sec
double IODC;//钟的数据龄期 double IODC;//钟的数据龄期
//数据块第八行内容
double TTN;//电文发送时间 double TTN;//电文发送时间
double fit;//拟合区间 double fit;//拟合区间
double spare1;//空 double spare1;//空
+119 -9
View File
@@ -57,6 +57,8 @@ extern int get_epochnum(FILE* fp_obs)
/* -------------------------------- 读取O文件数据头 -------------------------------- */ /* -------------------------------- 读取O文件数据头 -------------------------------- */
extern void read_o_h(FILE* fp_obs, pobs_head obs_h) extern void read_o_h(FILE* fp_obs, pobs_head obs_h)
{ {
memset(obs_h->obscode_gps, 0, sizeof(obs_h->obscode_gps));
memset(obs_h->obscode_bds, 0, sizeof(obs_h->obscode_bds));
char buff[MAXRINEX] = { 0 }; char buff[MAXRINEX] = { 0 };
char flag = { 0 }; char flag = { 0 };
char* lable = buff + 60; char* lable = buff + 60;
@@ -95,7 +97,7 @@ extern void read_o_h(FILE* fp_obs, pobs_head obs_h)
{ {
for (i = 0; i < obs_h->obstypenum_gps; i++) for (i = 0; i < obs_h->obstypenum_gps; i++)
{ {
obs_h->obscode_gps[i] = Type2Code(i, buff); obs_h->obscode_gps[i + 1] = Type2Code(i, buff);
} }
} }
else if (obs_h->obstypenum_gps > 13) else if (obs_h->obstypenum_gps > 13)
@@ -187,6 +189,12 @@ extern void read_o_b(FILE* fp_obs, pobs_epoch obs_e, pobs_body obs_b, int type_g
obs_e[n].sat_num = strtonum(buff, 33, 3); obs_e[n].sat_num = strtonum(buff, 33, 3);
strncpy(&flag, buff + 0, 1); strncpy(&flag, buff + 0, 1);
memset(obs_e[n].sPRN, 0, sizeof(obs_e[n].sPRN));
memset(obs_e[n].sPRN_GPS, 0, sizeof(obs_e[n].sPRN_GPS));
memset(obs_e[n].sPRN_BDS, 0, sizeof(obs_e[n].sPRN_BDS));
memset(obs_b[n].obs_gps, 0, sizeof(obs_b[n].obs_gps));
memset(obs_b[n].obs_bds, 0, sizeof(obs_b[n].obs_bds));
for (i = 0; i < obs_e[n].sat_num; i++) for (i = 0; i < obs_e[n].sat_num; i++)
{ {
//判断是否为GPS卫星 //判断是否为GPS卫星
@@ -246,6 +254,10 @@ int getgpssatnum(FILE* fp_nav)
//wchar_t * fgets ( wchar_t * str, int num, FILE * stream ); //wchar_t * fgets ( wchar_t * str, int num, FILE * stream );
while (fgets(buff, MAXRINEX, fp_nav)) while (fgets(buff, MAXRINEX, fp_nav))
{ {
if (strstr(lable, "END OF HEADER"))
{
flag = 1;
}
if (flag == 1) if (flag == 1)
{ {
while (fgets(buff, MAXRINEX, fp_nav)) while (fgets(buff, MAXRINEX, fp_nav))
@@ -262,13 +274,43 @@ int getgpssatnum(FILE* fp_nav)
} }
} }
} }
}
return gps_satnum;
}
int getbdssatnum(FILE* fp_nav)
{
int bds_satnum = 0;
int flag = 0;
char buff[MAXRINEX];//用来存放读取到的字符串
char satvar;
char* lable = buff + 60;
//fgets函数,读取一行,当读取结束后返回NULL指针,格式如下:
//wchar_t * fgets ( wchar_t * str, int num, FILE * stream );
while (fgets(buff, MAXRINEX, fp_nav))
{
if (strstr(lable, "END OF HEADER")) if (strstr(lable, "END OF HEADER"))
{ {
flag = 1; flag = 1;
} }
if (flag == 1)
{
while (fgets(buff, MAXRINEX, fp_nav))
{
strncpy(&satvar, buff + 0, 1);
if (satvar != 'C')
{
continue;
}
else if (satvar == 'C')
{
bds_satnum++;
break;
}
}
}
} }
return gps_satnum; return bds_satnum;
} }
/* -------------------------------- 读取N文件数据头 -------------------------------- */ /* -------------------------------- 读取N文件数据头 -------------------------------- */
@@ -347,23 +389,23 @@ void read_n_h(FILE* fp_nav, pnav_head nav_h)
/* -------------------------------- 读取N文件数据块 -------------------------------- */ /* -------------------------------- 读取N文件数据块 -------------------------------- */
void read_n_b(FILE* fp_nav, pnav_body nav_b) void read_n_b(FILE* fp_nav, pnav_body nav_b)
{ {
int i_g = 0;//第i_g个GPS卫星数据 int i_g = 0;//第i_g个卫星数据
int i_c = 0;//第i_c个BDS卫星数据
char buff[84] = { 0 }; char buff[84] = { 0 };
char flag = { 0 };//判断符号 char flag = { 0 };//判断符号
while (fgets(buff, MAXRINEX, fp_nav)) while (fgets(buff, MAXRINEX, fp_nav))
{ {
int j_g = 0;//数据块的第j_g行数据 int j_g = 0;//数据块的第j_g行数据
int j_c = 0;//数据块的第j_C行数据 int j_c = 0;//数据块的第j_c行数据
strncpy(&flag, buff + 0, 1); strncpy(&flag, buff + 0, 1);
if(flag == 'G') if(flag == 'G')
{ {
for (j_g = 0; j_g < 8; j_g++)//读取第i_g颗 GPS卫星广播星历("总共包含8行数据") 数据块的第j_g行数据 for (j_g = 0; j_g < 8; j_g++)//读取总计第i_g颗 GPS卫星广播星历("总共包含8行数据") 数据块的第j_g行数据
{ {
switch (j_g) switch (j_g)
{ {
case 0: case 0:
nav_b[i_g].sPRN = (int)strtonum(buff, 1, 2); nav_b[i_g].sPRN_BDS = 0;
nav_b[i_g].sPRN_GPS = (int)strtonum(buff, 1, 2);
nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4); nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2); nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2); nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2);
@@ -428,9 +470,77 @@ void read_n_b(FILE* fp_nav, pnav_body nav_b)
i_g++; i_g++;
continue; continue;
} }
else if(flag != 'G') else if(flag == 'C')
{ {
fgets(buff, MAXRINEX, fp_nav); for (j_c = 0; j_c < 8; j_c++)//读取总计第i_g颗 BDS卫星广播星历("总共包含8行数据") 数据块的第j_c行数据
{
switch (j_c)
{
case 0:
nav_b[i_g].sPRN_GPS = 0;
nav_b[i_g].sPRN_BDS = (int)strtonum(buff, 1, 2);
nav_b[i_g].TOC_Y = (int)strtonum(buff, 4, 4);
nav_b[i_g].TOC_M = (int)strtonum(buff, 9, 2);
nav_b[i_g].TOC_D = (int)strtonum(buff, 12, 2);
nav_b[i_g].TOC_H = (int)strtonum(buff, 15, 2);
nav_b[i_g].TOC_Min = (int)strtonum(buff, 18, 2);
nav_b[i_g].TOC_Sec = strtonum(buff, 21, 2);
nav_b[i_g].sa0 = strtonum(buff, 23, 19);
nav_b[i_g].sa1 = strtonum(buff, 23 + 19, 19);
nav_b[i_g].sa2 = strtonum(buff, 23 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 1:
nav_b[i_g].IODE = strtonum(buff, 4, 19);
nav_b[i_g].Crs = strtonum(buff, 4 + 19, 19);
nav_b[i_g].deltan = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].M0 = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 2:
nav_b[i_g].Cuc = strtonum(buff, 4, 19);
nav_b[i_g].e = strtonum(buff, 4 + 19, 19);
nav_b[i_g].Cus = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].sqrtA = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 3:
nav_b[i_g].TOE = strtonum(buff, 4, 19);
nav_b[i_g].Cic = strtonum(buff, 4 + 19, 19);
nav_b[i_g].OMEGA = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].Cis = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 4:
nav_b[i_g].i0 = strtonum(buff, 4, 19);
nav_b[i_g].Crc = strtonum(buff, 4 + 19, 19);
nav_b[i_g].omega = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].deltaomega = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 5:
nav_b[i_g].IDOT = strtonum(buff, 4, 19);
nav_b[i_g].L2code = strtonum(buff, 4 + 19, 19);
nav_b[i_g].GPSweek = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].L2Pflag = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 6:
nav_b[i_g].sACC = strtonum(buff, 4, 19);
nav_b[i_g].sHEA = strtonum(buff, 4 + 19, 19);
nav_b[i_g].TGD = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].IODC = strtonum(buff, 4 + 19 + 19 + 19, 19);
fgets(buff, MAXRINEX, fp_nav);
break;
case 7:
nav_b[i_g].TTN = strtonum(buff, 4, 19);
nav_b[i_g].fit = strtonum(buff, 4 + 19, 19);
nav_b[i_g].spare1 = strtonum(buff, 4 + 19 + 19, 19);
nav_b[i_g].spare2 = strtonum(buff, 4 + 19 + 19 + 19, 19);
break;
}
}
i_g++;
continue; continue;
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@ extern int select_epoch(double SecofWeek, int sPRN, pnav_body nav_b, int gps_sat
int i; int i;
for (i = 0; i < gps_satnum; i++) for (i = 0; i < gps_satnum; i++)
{ {
if (sPRN == nav_b[i].sPRN) if (sPRN == nav_b[i].sPRN_GPS)
{ {
Min = fabs(SecofWeek - nav_b[i].TOE); Min = fabs(SecofWeek - nav_b[i].TOE);
if (Min <= min) if (Min <= min)
+2 -2
View File
@@ -46,9 +46,9 @@ int Type2Code(int i, char buff[1000])
int Code2Type(int typecode, int typenum, int typearr[36]) int Code2Type(int typecode, int typenum, int typearr[36])
{ {
int pos; int pos;
for(pos = 0; pos < typenum; pos++) for (pos = 0; pos < typenum; pos++)
{ {
if(typearr[pos] == typecode) if (typearr[pos] == typecode)
{ {
break; break;
} }