コード例 #1
0
ファイル: position.cpp プロジェクト: DanielHeo94/IntelliPilot
void System::Publish::position(void *arg) {

        gpsCustom _mode(_gps, "GPGSA", 1);
        gpsCustom _fixtype(_gps, "GPGSA", 2);
        gpsCustom _pdop(_gps, "GPGSA", 15);
        gpsCustom _vdop(_gps, "GPGSA", 17);

        gpsCustom _nummessages(_gps, "GPGSV", 1);
        gpsCustom _messagenum(_gps, "GPGSV", 2);
        gpsCustom _numsatsinview(_gps, "GPGSV", 3);
        gpsCustom _prn(_gps, "GPGSV", 4);
        gpsCustom _elevation(_gps, "GPGSV", 5);
        gpsCustom _azimuth(_gps, "GPGSV", 6);
        gpsCustom _snr(_gps, "GPGSV", 7);

        gpsCustom _cog(_gps, "GPRMC", 8);
        gpsCustom _timestamp(_gps, "GPRMC", 1);

        for (;; ) {
                unsigned long start = millis();
                do
                {
                        while (Serial2.available())
                                _gps.encode(Serial2.read());
                } while (millis() - start < 100);

                positionBox.latitude = _gps.location.lat();
                positionBox.longitude = _gps.location.lng();
                positionBox.cog = _cog.value();

                gpsInfoBox.mode = _mode.value();
                gpsInfoBox.fixtype = _fixtype.value();
                gpsInfoBox.pdop = _pdop.value();
                gpsInfoBox.hdop = _gps.hdop.value();
                gpsInfoBox.vdop = _vdop.value();
                gpsInfoBox.numbers_of_gpgsv_messages = _nummessages.value();
                gpsInfoBox.index_number_of_gpgsv_message = _messagenum.value();
                gpsInfoBox.numbers_of_sats_inview = _numsatsinview.value();
                gpsInfoBox.prn = _prn.value();
                gpsInfoBox.snr = _snr.value();
                gpsInfoBox.elevation = _elevation.value();
                gpsInfoBox.azimuth = _azimuth.value();
                gpsInfoBox.timestamp = _timestamp.value();
                gpsInfoBox.number_of_satellites = _gps.satellites.value();
        }
}
コード例 #2
0
StreamFunction * MonteCarloRun::genStreamFunc()
{
    boost::shared_lock<boost::shared_mutex> modTypeLock(*_modType->getMutex());
    AMC::ModType tempModType = _modType->getData();
    modTypeLock.unlock();

    boost::shared_lock<boost::shared_mutex> fcLock(*_modType->getMutex());
    double fc = _fc->getData();
    fcLock.unlock();

    StreamFunction * baseFunc;

    switch(tempModType)
    {
    case (AMC::ModType::AM_DSB_FC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::DOUBLE, 0);
        break;

    case (AMC::ModType::AM_DSB_SC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::DOUBLE, 1);
        break;

    case (AMC::ModType::AM_LSB_FC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::LOWER, 0);
        break;

    case (AMC::ModType::AM_LSB_SC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::LOWER, 1);
        break;

    case (AMC::ModType::AM_USB_FC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::UPPER, 0);
        break;

    case (AMC::ModType::AM_USB_SC):
        baseFunc = new AmFunction(new cosFunction(_freq()), _modIndex(), fc, AmDemod::SideBand::UPPER, 1);
        break;

    case (AMC::ModType::FM):
        baseFunc = new FmFunction(new cosFunction(_freq()), _fmModIndex(), fc);
        break;

    case (AMC::ModType::ASK_2):
        baseFunc = new DigitalFunction(new MAskFunction(2), _digiFreq(), fc);
        break;

    case (AMC::ModType::MASK):
        baseFunc = new DigitalFunction(new MAskFunction(std::pow(2, _constSize())), _digiFreq(), fc);
        break;

    case (AMC::ModType::PSK_2):
        baseFunc = new DigitalFunction(new MPskFunction(2), _digiFreq(), fc);
        break;

    case (AMC::ModType::MPSK):
        baseFunc = new DigitalFunction(new MPskFunction(std::pow(2, _constSize())), _digiFreq(), fc);
        break;

    case (AMC::ModType::MQAM):
        baseFunc = new DigitalFunction(new MQamFunction(std::pow(2, _constSize())), _digiFreq(), fc);
        break;

    default:
        baseFunc = new StreamFunction();
        break;
    }

    return new AwgnFunction(baseFunc, _snr(), _rate, 10e3);
}