当前位置: 首页>>代码示例>>C++>>正文


C++ Temperature类代码示例

本文整理汇总了C++中Temperature的典型用法代码示例。如果您正苦于以下问题:C++ Temperature类的具体用法?C++ Temperature怎么用?C++ Temperature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Temperature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
    UltraSonic us;
    Motor motor(0, 255);
    LED led(100, 255);
    Brightness bg;
    Temperature temp;
    led.setPin(4);
    led.on();
    sleep(1);
    led.off();
    us.setPin(0, 1);
    us.autoScan();
    motor.setPin(2, 3, 22, 23, 24, 25);
    motor.setLeftSpeed(-100);
    motor.setRightSpeed(100);
    sleep(2);
    motor.setLeftSpeed(100);
    motor.setRightSpeed(-100);
    sleep(2);

    for(int i = 0; i < 5; i++){
        cout << us.getDistance() << endl;
        cout << bg.getValue() << endl;
        cout << temp.getValue() << endl;
        sleep(1);
    }
    cin.get();
    return 0;
}
开发者ID:rootming,项目名称:AutoCar,代码行数:30,代码来源:main.cpp

示例2: main

int main(){
    
	char unit;
	double temp;
	char ans;
	Temperature T;

	do{
	cout << "Please enter the temperature unit (Celsius = C, Kelvin = K, Fahrenheit = F): " << endl;
	cin >> unit;
	cout << "Please enter the temperature given the unit you entered previously: " << endl;
	cin>>temp;
	if (unit == 'C' || unit == 'c')
	{T.setTempCelsius(temp);}
	if (unit == 'F' || unit == 'F')
	{T.setTempFahrenheit(temp);}
	if (unit == 'K' || unit == 'K')
	{T.setTempKelvin(temp);}
	
	T.ShowResult();
	cout << "Re-calculate?" <<endl;
	cin>>ans;
	}while(ans=='Y'|| ans =='y');
	

}
开发者ID:cc3387,项目名称:CPP_Course,代码行数:26,代码来源:Question_10.cpp

示例3: getParticipantServices

TemperatureStatus DomainTemperature_002::getTemperatureStatus(UIntN participantIndex, UIntN domainIndex)
{
    try
    {
        Temperature temperature = getParticipantServices()->primitiveExecuteGetAsTemperatureTenthK(
            esif_primitive_type::GET_TEMPERATURE, domainIndex);

        if (!temperature.isValid())
        {
            getParticipantServices()->writeMessageWarning(
                ParticipantMessage(FLF, "Last set temperature for virtual sensor is invalid."));
            return TemperatureStatus(Temperature::minValidTemperature);
        }

        return TemperatureStatus(temperature);
    }
    catch (primitive_destination_unavailable)
    {
        return TemperatureStatus(Temperature::minValidTemperature);
    }
    catch (dptf_exception& ex)
    {
        getParticipantServices()->writeMessageWarning(ParticipantMessage(FLF, ex.what()));
        return TemperatureStatus(Temperature::minValidTemperature);
    }
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例4: catch

void ParticipantGetSpecificInfo_001::RequestPrimitiveTemperatureAndAddToMap(esif_primitive_type primitive,
    ParticipantSpecificInfoKey::Type key, std::map<ParticipantSpecificInfoKey::Type, UIntN>& resultMap,
    UIntN instance)
{
    try
    {
        Temperature temp = m_participantServicesInterface->primitiveExecuteGetAsTemperatureC(primitive,
            Constants::Esif::NoDomain, static_cast<UInt8>(instance));
        resultMap.insert(std::pair<ParticipantSpecificInfoKey::Type, UIntN>(key, temp.getTemperature()));
    }
    catch (...)
    {
        // if the primitive isn't available we receive an exception and we don't add this item to the map
    }
}
开发者ID:qbbian,项目名称:dptf,代码行数:15,代码来源:ParticipantGetSpecificInfo_001.cpp

示例5: main

int main()
{
    Temperature       temp;
    Pressure          press;
    EnvironmentWindow win;
    PanicSirene       panic;

    temp.attach(win);
    temp.attach(panic);
    press.attach(win);

    temp.temperatureChanged();
    press.pressureChanged();

    return (0);
}
开发者ID:yiminyangguang520,项目名称:DesignPattern,代码行数:16,代码来源:ObserveDemo.cpp

示例6: refreshDomainSetIfUninitialized

void ParticipantProxy::setTemperatureThresholds(const Temperature& lowerBound, const Temperature& upperBound)
{
    refreshDomainSetIfUninitialized();
    if (m_domains.size() > 0)
    {
        if (m_domains[0].getTemperatureProperty().implementsTemperatureInterface())
        {
            m_policyServices.messageLogging->writeMessageDebug(PolicyMessage(FLF,
                "Setting thresholds to " + lowerBound.toString() + ":" + upperBound.toString() + "."));
            m_domains[0].getTemperatureProperty().setTemperatureNotificationThresholds(lowerBound, upperBound);
        }
    }

    m_previousLowerBound = lowerBound;
    m_previousUpperBound = upperBound;
}
开发者ID:hoangt,项目名称:dptf,代码行数:16,代码来源:ParticipantProxy.cpp

示例7: temperature_out_of_range

void Temperature::throwIfInvalid(const Temperature& temperature) const
{
    if (temperature.isValid() == false)
    {
        throw temperature_out_of_range("Temperature is not valid.");
    }
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例8: if

Bool Temperature::operator==(const Temperature& rhs) const
{
    // Do not throw an exception if temperature is not valid.

    if (this->isValid() == true && rhs.isValid() == true)
    {
        return (this->m_temperature == rhs.m_temperature);
    }
    else if (this->isValid() == false && rhs.isValid() == false)
    {
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: toVector

MARG::MARG(const MARGConfiguration& configuration,
	     const Readout::MARG& readout,
		 const Temperature& temperature_difference,
		 const Calibration& calibration)
{
#ifdef USE_TEMPERATURE_COMPENSATION
	const int16_t temperature_offset[2] = {
		(int16_t)((temperature_difference.degreesCelsius() * LSM9DS0_OFFSET_PER_CELSIUS_G) / configuration.gScaleMdps()),
		(int16_t)((temperature_difference.degreesCelsius() * LSM9DS0_OFFSET_PER_CELSIUS_A) / configuration.aScaleMg())
	};
	const float temperature_scale[2] = {
		(float)temperature_difference.degreesCelsius() * sensitivity_per_celsius_g,
		(float)temperature_difference.degreesCelsius() * sensitivity_per_celsius_a
	};
#else
	const int16_t temperature_offset[2] = { 0, 0 };
	const float temperature_scale[2] = { 1, 1 };
#endif

	const Vector<int16_t> raw_offset_adjusted[2] = {
		readout.g - calibration.g_offset - temperature_offset[0],
		readout.a - calibration.a_offset - temperature_offset[1]
	};
	const Vector<float> scale_adjusted[2] = {
		calibration.g_scale * (1 + temperature_scale[0]),
		calibration.a_scale * (1 + temperature_scale[1])
	};

	g_ = toVector(raw_offset_adjusted[0] * scale_adjusted[0], configuration.gScaleMdps() / 1000 * M_PI / 180);
	a_ = toVector(raw_offset_adjusted[1] * scale_adjusted[1], configuration.aScaleMg() / 1000);
	m_ = toVector(readout.m * calibration.m_rotation - calibration.m_offset, configuration.mScaleMgauss() / 1000);
	
	if (calibration.hasInvertedPlacement()) {
		a_.setX(-a_.x());
		a_.setY(-a_.y());
	}
	if (!calibration.hasInvertedPlacement()) {
		g_.setX(-g_.x());
		g_.setY(-g_.y());
	}

	g_.setX(-g_.x());
	g_.setY(-g_.y());
	g_.setZ(-g_.z());
}
开发者ID:hlohse,项目名称:sound-glove,代码行数:45,代码来源:MARG.cpp

示例10: fromCelsius

Temperature Temperature::snapWithinAllowableTripPointRange(Temperature aux)
{
    if ((UInt32)aux != Constants::MaxUInt32)
    {
        Temperature minAux = fromCelsius(ESIF_SDK_MIN_AUX_TRIP);
        if (aux.isValid() && aux < minAux)
        {
            aux = minAux;
        }

        Temperature maxAux = fromCelsius(ESIF_SDK_MAX_AUX_TRIP);
        if (aux.isValid() && aux > maxAux)
        {
            aux = maxAux;
        }
    }

    return aux;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例11: addMessage

void DptfMessage::addMessage(const std::string& messageKey, Temperature messageValue)
{
    try
    {
        m_messageKeyValuePair.push_back(MessageKeyValuePair(messageKey, messageValue.toString()));
    }
    catch (...)
    {
    }
}
开发者ID:hoangt,项目名称:dptf,代码行数:10,代码来源:DptfMessage.cpp

示例12: throwIfParticipantDomainCombinationInvalid

void EsifServices::primitiveExecuteSetAsTemperatureC(esif_primitive_type primitive, Temperature temperature,
    UIntN participantIndex, UIntN domainIndex, UInt8 instance)
{
    throwIfParticipantDomainCombinationInvalid(FLF, participantIndex, domainIndex);

#ifdef ONLY_LOG_TEMPERATURE_THRESHOLDS
    // Added to help debug issue with missing temperature threshold events
    if (primitive == esif_primitive_type::SET_TEMPERATURE_THRESHOLDS)
    {
        ManagerMessage message = ManagerMessage(m_dptfManager, FLF,
            "Setting new temperature threshold for participant.");
        message.addMessage("Temperature", temperature.toString());
        message.setEsifPrimitive(primitive, instance);
        message.setParticipantAndDomainIndex(participantIndex, domainIndex);
        writeMessageDebug(message, MessageCategory::TemperatureThresholds);
    }
#endif

    eEsifError rc = m_esifInterface.fPrimitiveFuncPtr(m_esifHandle, m_dptfManager,
        (void*)m_dptfManager->getIndexContainer()->getIndexPtr(participantIndex),
        (void*)m_dptfManager->getIndexContainer()->getIndexPtr(domainIndex),
        EsifDataTemperature(temperature), EsifDataVoid(), primitive, instance);

#ifdef ONLY_LOG_TEMPERATURE_THRESHOLDS
    // Added to help debug issue with missing temperature threshold events
    if (primitive == esif_primitive_type::SET_TEMPERATURE_THRESHOLDS &&
        rc != ESIF_OK)
    {
        ManagerMessage message = ManagerMessage(m_dptfManager, FLF,
            "Failed to set new temperature threshold.");
        message.addMessage("Temperature", temperature.toString());
        message.setEsifPrimitive(primitive, instance);
        message.setParticipantAndDomainIndex(participantIndex, domainIndex);
        message.setEsifErrorCode(rc);
        writeMessageError(message, MessageCategory::TemperatureThresholds);
    }
#endif

    throwIfNotSuccessful(FLF, rc, primitive, participantIndex, domainIndex, instance);
}
开发者ID:zeros1122,项目名称:dptf,代码行数:40,代码来源:EsifServices.cpp

示例13: findTripPointCrossed

UIntN ActivePolicy::findTripPointCrossed(SpecificInfo& tripPoints, const Temperature& temperature)
{
    auto trips = tripPoints.getSortedByKey();
    for (UIntN index = 0; index < trips.size(); index++)
    {
        if (temperature.getTemperature() >= trips[index].second)
        {
            UIntN acIndex = trips[index].first - ParticipantSpecificInfoKey::AC0;
            return acIndex;
        }
    }
    return Constants::Invalid;
}
开发者ID:qbbian,项目名称:dptf,代码行数:13,代码来源:ActivePolicy.cpp

示例14: determineUpperTemperatureThreshold

UIntN ActivePolicy::determineUpperTemperatureThreshold(const Temperature& currentTemperature, SpecificInfo& tripPoints) const
{
    auto trips = tripPoints.getSortedByKey();
    UIntN upperTemperatureThreshold = Constants::Invalid;
    for (UIntN ac = 0; ac < trips.size(); ++ac)
    {
        if ((currentTemperature.getTemperature() < trips[ac].second) &&
            (trips[ac].second != Constants::Invalid))
        {
            upperTemperatureThreshold = trips[ac].second;
        }
    }
    return upperTemperatureThreshold;
}
开发者ID:qbbian,项目名称:dptf,代码行数:14,代码来源:ActivePolicy.cpp

示例15: determineLowerTemperatureThreshold

UIntN ActivePolicy::determineLowerTemperatureThreshold(const Temperature& currentTemperature, SpecificInfo& tripPoints) const
{
    auto trips = tripPoints.getSortedByKey();
    UIntN lowerTemperatureThreshold = Constants::Invalid;
    for (UIntN ac = 0; ac < trips.size(); ++ac)
    {
        if (currentTemperature.getTemperature() >= trips[ac].second)
        {
            lowerTemperatureThreshold = trips[ac].second;
            break;
        }
    }
    return lowerTemperatureThreshold;
}
开发者ID:qbbian,项目名称:dptf,代码行数:14,代码来源:ActivePolicy.cpp


注:本文中的Temperature类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。