⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmd.c

📁 GPS导航定位程序
💻 C
📖 第 1 页 / 共 3 页
字号:
                {
                    CmdFileNesting--;
                    WarningMessage("Can't open specified file");
                    return;
                }
                if(cb[i]!=' ')
                    break;
                i++;
            }
            CmdFile[CmdFileNesting] = fopen(&cb[i],"rt");
            if(CmdFile[CmdFileNesting]!=NULL)
                rewind(CmdFile[CmdFileNesting]);
            else
            {
                WarningMessage("Can't open specified file");
            }
            CmdFileNesting++;
        }
        else
        {
            WarningMessage("Command file nesting limit");
            for(i=0; i<CmdFileNesting; ++i)
                fclose(CmdFile[i]);
            CmdFileNesting = 0;
        }
        return;
    }

    /* CH x - Channels.
       Sets the number of active channels to x. */

    if(cc1=='C' && cc2=='H')
    {
        itemp = atoi(&cb[2]);
        if(itemp<1 || itemp>MAXCHANNELS)
        {
            sprintf(buff,"Number of channels must be between 1 and %2.2d",
                    MAXCHANNELS);
            WarningMessage(buff);
            return;
        }

        PROTECT++;
        ActiveChannels = itemp;
        itemp = 0;
        for(i=1;i<=ActiveChannels;i++)
            itemp |= (1<<(i-1)); 
        ActiveChannelMask = itemp;
        PROTECT--;

        /* Idle the channels which have been disabled. */

        for(i=ActiveChannels;i<MAXCHANNELS;i++)
            SetUpChannel(i,0,0);                       

        return;
    }

    /* CI x - Coasting Interval.
       Sets the tracking loops coasting interval in seconds. */

    if(cc1=='C' && cc2=='I')
    {
        itemp = atoi(&cb[2]);
        if(itemp>=0 && itemp<=60)
            Coast = (unsigned)itemp*1000U;
        else
            WarningMessage("Coasting interval must be between 0 and 60 "
                           "seconds");
        return;
    }


    /* CS <position string> - Cold Start.
       Perform a cold start with a reference position <position string>. */

    if(cc1=='C' && cc2=='S')
    {
        PROTECT++;
        N = CurNavState;
        CLK = CurClkModel;
        PROTECT--;
        itemp = PosStrToLatLonHgt(&cb[2],&N.lat,&N.lon,&N.hgt);
        if(itemp==FALSE)
        {
            WarningMessage("Incorrect position format "
                           "(CS N30 20.2 W97 41.1 246.2)");
            return;
        }
        else
        {
            /* Reinitialize CurNavState and CurClkModel, and the correlator's
               carrier and code Doppler compensation factors */

            disable(); 
            CodeDoppFromClk = CarrDoppFromClk = 0;
            enable();
            CLK.VARClkError = CLK.DoppFromClk = 1.0;
            PROTECT++;
            CurClkModel = CLK;
            PROTECT--;
            N.velx = N.vely = N.velz = N.clockoff = 0.0;
            LatLonHgtToXYZ(N.lat,N.lon,N.hgt,&N.x,&N.y,&N.z);
            LatLonToNorthEastUp(N.lat,N.lon,N.topo);
            N.tofnavmat = 0L; /* Force new nav matrix computation */
            PROTECT++;
            CurNavState = N;
            PROTECT--;
            PredictAll();
            for(i=0; i<MAXCHANNELS; ++i)
                CH[i].SV = 0;
            cursrch = MAXSATELLITES + 1;
            FixesInColdStart = 0;
            TrackMode = COLD_START; 
        }
        return;
    }

    /* DC x - Differential Corrections.
       Set differential corrections input at COM port x. */

    if(cc1=='D' && cc2=='C')
    {
        itemp = atoi(&cb[2]);
        if(itemp>2 || itemp<0)
        {
            WarningMessage("Port number must be 1 or 2");
            return;
        }
        if(BeacPort)
            RestoreSerialInt();
        if(itemp)
            InitSerialPort(itemp);
        BeacPort = itemp;
        if(DisplayFunc==6)
            EraseDisplay=1;
        return;
    }

    /* DM - Don't Move.
       Toggle software between perform solution and don't perform
       solution. */

    if(cc1=='D' && cc2=='M')
    {
        DontMove = (DontMove==FALSE)? TRUE:FALSE;
        return;
    }

    /* DS x - Deselect Select.
       Deselect satellite x. */

    if(cc1=='D' && cc2=='S')
    {
        itemp = atoi(&cb[2]);
        if(itemp<1 || itemp>32)
        {
            WarningMessage("Satellite number must be between 1 and 32");
            return;
        }
        Deselect[itemp-1] = TRUE;
        return;
    }

    /* EM x - Elevation Mask.
       Set elevation mask to x degrees. */

    if(cc1=='E' && cc2=='M')
    {
        dtemp = atof(&cb[2]);
        if(dtemp<-90.0 || dtemp>90.0)
        {
            WarningMessage("Elevation mask must be between +-90.0");
            return;
        }

        ElvMask = dtemp;
        if(DisplayFunc==8)
            EraseDisplay=1;
        return;
    }

    /* FK x - Function Key.
       Mimics pressing function key x. */

    if(cc1=='F' && cc2=='K')
    {
        itemp = atoi(&cb[2]);
        switch(itemp)
        {
            case 1:
                FakeKey = F1_KEY;
                break;
            case 2:
                FakeKey = F2_KEY;
                break;
            case 3:
                FakeKey = F3_KEY;
                break;
            case 4:
                FakeKey = F4_KEY;
                break;
            case 5:
                FakeKey = F5_KEY;
                break;
            case 6:
                FakeKey = F6_KEY;
                break;
            case 7:
                FakeKey = F7_KEY;
                break;
            case 8:
                FakeKey = F8_KEY;
                break;
            case 9:
                FakeKey = F9_KEY;
                break;
            case 10:
                FakeKey = F10_KEY;
                break;
            case 11:
                FakeKey = F11_KEY;
                break;
            case 12:
                FakeKey = F12_KEY;
                break;
            default:
                WarningMessage("Function key must be between 1 and 12");
                break;  /* Default to FK 1 */
        }
        return;
    }

    /* GM x - GDOP Mask.
       Set GDOP mask to x. */
    
    if(cc1=='G' && cc2=='M')
    {
        dtemp = atof(&cb[2]);
        if(dtemp<=0.0)
        {
            WarningMessage("GDOP mask must be > 0.0");
            return;
        }

        GdopMask = dtemp;
        if(DisplayFunc==8)
            EraseDisplay=1;
        return;
    }

    /* IC - Integrated Carrier.
       Toggle the use of integrated carrier phase measurements. */

    if(cc1=='I' && cc2=='C')
    {
        IntegratedCarrier = (IntegratedCarrier==FALSE)? TRUE:FALSE;
        return;
    }

    /* ID x - Identficiation.
       Set the receiver identification number as saved in the SIA output
       file (see DL). */
    
    if((cc1=='I') && (cc2=='D'))
    {
        itemp = atoi(&cb[2]);
        if(itemp<0 || itemp>4)
        {
            WarningMessage("Receiver ID must be between 1 and 4");
            return;
        }

        ReceiverID = itemp;
        return;
    }

    /* IP <position string> - Initial Position.
       Set the receiver initial position to <position string>. */

    if(cc1=='I' && cc2=='P')
    {
        PROTECT++;
        N = CurNavState;
        PROTECT--;
        itemp = PosStrToLatLonHgt(&cb[2],&N.lat,&N.lon,&N.hgt);
        if(itemp==FALSE)
        {
            WarningMessage("Incorrect position format "
                           "(IP N30 20.2 W97 41.1 246.2)");
            return;
        }
        else
        {
            N.velx = N.vely = N.velz = N.clockoff = 0.0;
            LatLonHgtToXYZ(N.lat,N.lon,N.hgt,&N.x,&N.y,&N.z);
            LatLonToNorthEastUp(N.lat,N.lon,N.topo);
            CurNavState.tofnavmat = 0L; /* New nav matrix computation */
            PROTECT++;
            CurNavState = N;
            PROTECT--;
            PredictAll(); /* New Doppler predictions */
        }
        return;
    }

    /* LC comment - Log File Comment.
       Inserts the text string 'comment' in the last field of the data log
       record. */

    if((cc1=='L') && (cc2=='C'))
    {
        i=2;
        while(TRUE)
        {
            if(cb[i]!=' ')
                break;
            i++;
        }
        strcpy(DataLogComment,&cb[i]);
        return;
    }

    /* LF filename - Log File.
       Log data in the SIA format to file "filename" at a rate specified
       by the LI command. */

    if(cc1=='L' && cc2=='F')
    {
        if(fpDataLog!=NULL)     /* Close the current open log file */
        {
            DataRecordsLogged = 0;
            fclose(fpDataLog);
        }
        i=2;
        while(TRUE)
        {
            if(i>=80 || cb[i]==0)  /* Invalid file name */
            {
                DataRecordsLogged = 0;
                fclose(fpDataLog);
                fpDataLog = NULL;
                if(DisplayFunc==10)
                    EraseDisplay=1;
                return;
            }
            if(cb[i]!=' ')
                break;
            i++;
        }

        fpDataLog = fopen(&cb[i],"w");
        if(fpDataLog!=NULL)           /* If the file is valid then open */
        {
            sprintf(DataLogFile,"%s",&cb[i]);
            if(DisplayFunc==10)
                EraseDisplay=1;
        }
        else
            WarningMessage("Can't open specified file");

        return;
    }
  
    /* LI x - Log Interval.
       Changes the interval of logged data (to file) to x second intervals. */

    if(cc1=='L' && cc2=='I')
    {
        itemp = atoi(&cb[2]);
        if(itemp>=1 && itemp<=60)
        {
            DataLogInterval = itemp;
            if(DisplayFunc==10)
                EraseDisplay=1;
        }
        else
            WarningMessage("Invalid log interval (1-60)");
        return;
    }

    /* LS - Log Serial.
       Send log file data out through COM1. */

    if(cc1=='L' && cc2=='S')
    {
        DataLogSerial = (DataLogSerial==FALSE)? TRUE:FALSE;
        if(DataLogSerial==TRUE) _bios_serialcom(_COM_INIT,0,
            _COM_9600|_COM_CHR8|_COM_STOP1|_COM_NOPARITY);
        if(DisplayFunc==10)
            EraseDisplay=1;
        return;
    }

    /* OE x - Oscillator Error.
       Set the oscillator error to x ppm. */

    if(cc1=='O' && cc2=='E')
    {
        OscErr = atof(&cb[2]);  /* Get spec'd oscillator freq error in ppm */
        OscAcc = InitOscAcc;    /* Reset clock variance & accuracy filter */
        CurClkModel.VARClkError = InitOscAcc*InitOscAcc;
        PROTECT++;
        CLK = CurClkModel;
        N = CurNavState;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -