📄 cmd.c
字号:
PROTECT--;
CLK.RCOrate = OscErr * 1.0E-6; /* Fractional oscill. error */
N.clockoff = CLK.RCOrate*SPEED_OF_LIGHT; /* Oscillator error in m/s */
CLK.DoppFromClk = -CLK.RCOrate*1.57542E9; /* Clock "Doppler" */
ltemp = CLK.DoppFromClk/1540/0.04257475*32.0 + 0.5;
ltemp2 = -CLK.DoppFromClk/0.04257475*16.0 + 0.5;
disable();
CodeDoppFromClk = ltemp;
CarrDoppFromClk = ltemp2;
enable();
PROTECT++;
CurNavState = N;
CurClkModel = CLK;
PROTECT--;
return;
}
/* QA - Quit And Save Almanac.
Quit and save the current almanac data the file ALM.INI. */
if(cc1=='Q' && cc2=='A')
{
SaveAlmanacs("ALM.INI");
QuitGpsBuilder();
}
/* QU - Quit. */
if(cc1=='Q' && cc2=='U')
QuitGpsBuilder();
/* RA filename - Read Almanac.
Read almanac data from file "filename". */
if(cc1=='R' && cc2=='A')
{
FILE *AlmFile;
i=2;
while(TRUE)
{
if(i>=80 || cb[i]==0)
{
WarningMessage("Can't open specified file");
return;
}
if(cb[i]!=' ')
break;
i++;
}
AlmFile = fopen(&cb[i],"rb");
if(AlmFile!=NULL)
{
rewind(AlmFile);
/* First 8 characters must be "ALMANACF" */
fread(&buff,8,1,AlmFile);
if(memcmp(buff,"ALMANACF",8)==0)
{
fread(&alms[0],sizeof(almstruc),32,AlmFile);
fread(&ionoutc,sizeof(iustruc),1,AlmFile);
fread(&ephs[0],sizeof(ephstruc),32,AlmFile);
PredictAll();
}
else
{
sprintf(buff,"%s does not contain almanac data.",&cb[i]);
WarningMessage(buff);
}
fclose(AlmFile);
}
else
{
sprintf(buff,"Can't open almanac file %s",&cb[i]);
WarningMessage(buff);
}
return;
}
/* RC comment - Record comment.
Insert comment into Rinex2 Navigation and Observation files. */
if(cc1=='R' && cc2=='C')
{
Rx2Comment(&cb[2]);
return;
}
/* RH - Reference position update.
Sets the reference position to the current position. */
if(cc1=='R' && cc2=='H')
{
PROTECT++;
reflat = CurNavState.lat;
reflon = CurNavState.lon;
refhgt = CurNavState.hgt;
PROTECT--;
return;
}
/* RN x - Record RINEX2 data.
Record Rinex2 Navigation and Observation data at interval of x sec. */
if(cc1=='R' && cc2=='N')
{
Rx2Interval = atoi(&cb[2]);
if(Rx2Interval<0)
{
WarningMessage("Interval must be >= 0");
return;
}
if(Rx2Interval==0)
Rx2Stop();
else
Rx2Start(Rx2Interval);
if(DisplayFunc==7)
EraseDisplay=1;
return;
}
/* RP <position string> - Initial Position.
Set the receiver initial position to <position string>. */
if(cc1=='R' && cc2=='P')
{
double dblreflat, dblreflon, dblrefhgt;
PROTECT++;
itemp = PosStrToLatLonHgt(&cb[2],&dblreflat,&dblreflon,&dblrefhgt);
PROTECT--;
if(itemp==FALSE)
WarningMessage("Incorrect position format "
"(RP N30 20.2 W97 41.1 246.2)");
else
{
reflat = (float)dblreflat;
reflon = (float)dblreflon;
refhgt = (float)dblrefhgt;
}
return;
}
/* RS x - Reselect Satellite.
Reselects disabled satellites (0 reselects all). */
if(cc1=='R' && cc2=='S')
{
itemp = atoi(&cb[2]);
if(itemp<0 || itemp>32)
{
WarningMessage("Satellite selected must be between 0 and 32");
return;
}
else if(itemp==0)
{
for(i=1; i<=32; ++i)
Deselect[i-1] = FALSE;
}
else
Deselect[itemp-1] = FALSE;
return;
}
/* SA filename - Save Almanac.
Saves almanac data to specified file. */
if(cc1=='S' && cc2=='A')
{
i=2;
while(TRUE)
{
if((i>=80) || cb[i]==0)
{
WarningMessage("Can't open specified file");
return;
}
if(cb[i]!=' ')
break;
i++;
}
SaveAlmanacs(&cb[i]);
return;
}
/* SC filename - Screen Save.
Saves the current screen as text characters to the file specified by
"filename". */
if(cc1=='S' && cc2=='C')
{
FILE *fpScreenSave;
i=2;
while(TRUE)
{
if(i>=80 || cb[i]==0)
return;
if(cb[i]!=' ')
break;
i++;
}
fpScreenSave = fopen(&cb[i],"w");
if(fpScreenSave!=NULL) /* If the file is valid then open */
ScreenSave(fpScreenSave);
else
WarningMessage("Can't open specified file");
fclose(fpScreenSave);
return;
}
/* SS x y - Select Satellite.
Select to track satellite x on channel y. Only works in TrackMode
SELECT_SATELLITES. */
if(cc1=='S' && cc2=='S')
{
if(TrackMode==SELECT_SATELLITES)
{
sscanf(cb,"SS %d %d",&satellite,&channel);
if(channel<1 || channel>ActiveChannels)
{
sprintf(buff,"Channel must be between 1 and %2.2d",ActiveChannels);
WarningMessage(buff);
return;
}
if(satellite<1 || satellite>32)
{
WarningMessage("Satellite must be between 1 and 32");
return;
}
i = channel-1;
disable();
CH[i].corlk = CH[i].carfrlk = FALSE;
CH[i].FrameSync = CH[i].FrameSyncAndTIC = FALSE;
CH[i].LostLockDuringLastTIC = TRUE;
CH[i].LostCodeLockDuringLastTIC = TRUE;
CH[i].LostCarrierLockDuringLastTIC = TRUE;
enable();
svsel[channel-1] = satellite;
AzimuthElevationAndDoppler(satellite-1);
}
else
{
sprintf(buff,"Must be in Track Mode %1.1d to use this command",
SELECT_SATELLITES);
WarningMessage(buff);
}
return;
}
/* TM x - Track Mode.
Set the Track Mode. */
if(cc1=='T' && cc2=='M')
{
/* Process TM (track mode) command */
itemp = atoi(&cb[2]);
if(itemp<TRACK_MODE_MIN || itemp>TRACK_MODE_MAX)
{
sprintf(buff,"Track Mode must be between %1.1d and %1.1d",
TRACK_MODE_MIN,TRACK_MODE_MAX);
WarningMessage(buff);
return;
}
switch(itemp)
{
case HIGHEST_ELEVATIONS:
if(TrackMode==COLD_START) /* Don't lose tracked SVs. */
{
for(i=0;i<ActiveChannels;i++)
svsel[i] = CH[i].SV;
}
TrackMode = HIGHEST_ELEVATIONS;
break;
case SELECT_SATELLITES:
TrackMode = SELECT_SATELLITES;
break;
case COLD_START:
TrackMode = COLD_START;
FixesInColdStart = 0;
for(i=0; i<MAXCHANNELS; ++i)
CH[i].SV = 0;
cursrch = MAXSATELLITES + 1;
break;
default:
break;
}
return;
}
/* TZ x - Time Zone.
Set the time zone to x hours. */
if(cc1=='T' && cc2=='Z')
{
int y,m,d,hh,mm,ss;
long time_now;
unsigned long ctic;
int gwk;
double gsec;
struct tm *tm_now;
itemp = atoi(&cb[2]);
if(itemp<-12 || itemp>12)
{
WarningMessage("Time zone must be between +-12 hours");
return;
}
else
{
TimeZone = itemp;
PROTECT++;
if(CurClkModel.RCOtic==0)
{
time(&time_now);
daylight = 0; /* No daylight saving time */
tm_now = localtime(&time_now);
y = tm_now->tm_year + 1900;
m = tm_now->tm_mon + 1;
d = tm_now->tm_mday;
hh = tm_now->tm_hour;
mm = tm_now->tm_min;
ss = tm_now->tm_sec;
CurrentTIC(&ctic);
/* Convert UTC y/m/d hh:mm:ss to GPS week and seconds */
UTCDateToGpsTime(y,m,d,hh,mm,ss,&gwk,&gsec);
CurClkModel.Zwk = gwk;
CurClkModel.Zsec = gsec
- SECONDS_IN_HOUR*TimeZone
- ctic*TIC_PERIOD;
while(CurClkModel.Zsec<0.0)
{
CurClkModel.Zwk--;
CurClkModel.Zsec += SECONDS_IN_WEEK;
}
while(CurClkModel.Zsec>=604800.0)
{
CurClkModel.Zwk++;
CurClkModel.Zsec -= 604800.0;
}
PredictAll();
if(DisplayFunc==8)
EraseDisplay = TRUE;
}
PROTECT--;
}
return;
}
if(cc1=='W' && cc2=='N')
{
/* Process WN nn command. This is a part of the multitasking case
study, or the world's most complicated way to beep the PC's
speaker. The argument in the command is the number of Hz for
the first of five beeps. This command illustrates how you can
stack up requests for a queue server and proceed with computation
without waiting for a result. The documentation calls this the
"warn" command, but that disguises its real purpose as an tutorial
for the GPS software designer.
For true enlightenment, pull up the F9 (Task Status) display, and
watch the status of the TBeep task (Comment field) when you issue
a WN 500 command. Seeing this can help you understand multitasking
if you are not already familiar with it. */
itemp = atoi(&cb[2]);
if(itemp < 100) itemp = 500;
Beep(itemp,500); /* First beep = user's frequency, 500 ms */
Beep(itemp*2,500); /* Second beep, 1 octave higher */
Beep(itemp,500); /* Third beep = user's frequency again */
Beep(itemp*2,500); /* Fourth beep = 1 octave higher again */
Beep(itemp,500); /* Fourth beep = user's frequency again */
return;
}
/* Come here for unrecognized commands. */
WarningMessage("Command not recognized, press F1 for help.");
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -