本文整理汇总了C++中Power类的典型用法代码示例。如果您正苦于以下问题:C++ Power类的具体用法?C++ Power怎么用?C++ Power使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Power类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findLowestPowerLimitRequest
Power PowerControlKnob::findLowestPowerLimitRequest()
{
if (m_requests.size() == 0)
{
const auto& pl1Capabilities = m_powerControl->getCapabilities().getCapability(PowerControlType::PL1);
return pl1Capabilities.getMaxPowerLimit();
}
else
{
Power lowestPower;
for (auto request = m_requests.begin(); request != m_requests.end(); request++)
{
if (lowestPower.isValid() == false)
{
lowestPower = request->second;
}
else
{
if (request->second < lowestPower)
{
lowestPower = request->second;
}
}
}
return lowestPower;
}
}
示例2: VirtualMachine
void StartInstance::Launch()
{
isInit = true;
VirtualMachine *vm = new VirtualMachine();
if (isInit)
{
Power *p = new Power();
std::cout << "V1" << std::endl;
map->seeMap();
std::cout << "-----------" << std::endl;
map = p->findPowerOnMap(map);
std::cout << "V2" << std::endl;
map->seeMap();
std::cout << "-----------" << std::endl;
vm->setMap(map->getMap());
vm->Launch(*map->getMap());
}
else
{
std::string error = "Error Initialisation";
throw myException(error);
}
}
示例3: evaluate_tree
// TODO: Expand to allow for more functions.
// TODO: When parsing e^(f(z)), use Exponential class instead of Power class.
// Evaluates the given expression tree on the given variable value.
ComplexNumber evaluate_tree(const ExpressionTreeNode *root, const ComplexNumber z) {
if (root->is_op_node()) {
ExpressionTreeBinaryOp *temp = (ExpressionTreeBinaryOp *) root;
ComplexNumber left = evaluate_tree(temp->get_left(), z);
ComplexNumber right = evaluate_tree(temp->get_right(), z);
// Find the appropriate operator, apply, then return.
if (temp->get_operator() == PLUS) {
return left + right;
} else if (temp->get_operator() == MINUS) {
return left - right;
} else if (temp->get_operator() == TIMES) {
return left * right;
} else if (temp->get_operator() == DIVIDE) {
return left / right;
} else { // temp->get_operator() == EXP
Power p (right);
return p.eval(left);
}
} else if (root->is_func_node()) {
ExpressionTreeFunction *temp = (ExpressionTreeFunction *) root;
ComplexNumber arg = evaluate_tree(temp->get_argument(), z);
// Find the appropriate function, evaluate, then return.
if (temp->get_function() == LOG) {
Logarithm l (1, 0);
return l.eval(arg);
} else if (temp->get_function() == SIN) {
Sine s (1, 1, 0);
return s.eval(arg);
} else if (temp->get_function() == COS) {
Cosine c (1, 1, 0);
return c.eval(arg);
} else { // temp->get_function() == TAN
Tangent t (1, 1, 0);
return t.eval(arg);
}
} else if (root->is_leaf_node()) {
ExpressionTreeLeaf *temp = (ExpressionTreeLeaf *) root;
return temp->get_val(); // Return the value itself
} else if (root->is_const_node()) {
ExpressionTreeConstant *temp = (ExpressionTreeConstant *) root;
// Return the corresponding mathematical constant
if (temp->get_constant() == e) {
return E;
} else if (temp->get_constant() == pi) {
return PI;
} else { // temp->get_constant() == phi
return PHI;
}
} else { // root->is_var_node()
return z;
}
}
示例4: Power
Expression * Division::shallowReduce(Context& context, AngleUnit angleUnit) {
Expression * e = Expression::shallowReduce(context, angleUnit);
if (e != this) {
return e;
}
Power * p = new Power(operand(1), new Rational(-1), false);
Multiplication * m = new Multiplication(operand(0), p, false);
detachOperands();
p->shallowReduce(context, angleUnit);
replaceWith(m, true);
return m->shallowReduce(context, angleUnit);
}
示例5:
std::shared_ptr<XmlNode> PowerControlKnob::getXml() const
{
auto knobStatus = XmlNode::createWrapperElement("power_control_status");
if (m_powerControl->supportsPowerControls())
{
auto pl1Capabilities = m_powerControl->getCapabilities().getCapability(PowerControlType::PL1);
knobStatus->addChild(pl1Capabilities.getXml());
Power currentPowerLimit = m_powerControl->getPowerLimitPL1();
auto powerControl = XmlNode::createDataElement("power_limit", currentPowerLimit.toString());
knobStatus->addChild(powerControl);
}
return knobStatus;
}
示例6: getPolicyServices
void PowerControlKnob::limit(UIntN target)
{
if (canLimit(target))
{
try
{
getPolicyServices().messageLogging->writeMessageDebug(PolicyMessage(
FLF, "Calculating request to limit power controls.", getParticipantIndex(), getDomainIndex()));
const auto& pl1Capabilities = m_powerControl->getCapabilities().getCapability(PowerControlType::PL1);
Power minimumPowerLimit = pl1Capabilities.getMinPowerLimit();
Power stepSize = pl1Capabilities.getPowerStepSize();
Power nextPowerLimit(pl1Capabilities.getMaxPowerLimit());
Power targetRequest = getTargetRequest(target);
if (targetRequest >= pl1Capabilities.getMaxPowerLimit())
{
// limit one step from current power
Power currentPower = m_powerControl->getAveragePower();
getPolicyServices().messageLogging->writeMessageDebug(PolicyMessage(
FLF, "Current power is " + currentPower.toString() + ".", getParticipantIndex(), getDomainIndex()));
nextPowerLimit = calculateNextLowerPowerLimit(currentPower, minimumPowerLimit, stepSize, targetRequest);
}
else
{
// limit one step size down
nextPowerLimit = std::max((int)targetRequest - (int)stepSize, (int)minimumPowerLimit);
}
m_requests[target] = nextPowerLimit;
stringstream message;
message << "Requesting to limit power to " << nextPowerLimit.toString() << ".";
getPolicyServices().messageLogging->writeMessageDebug(
PolicyMessage(FLF, message.str(), getParticipantIndex(), getDomainIndex()));
}
catch (std::exception& ex)
{
getPolicyServices().messageLogging->writeMessageDebug(
PolicyMessage(FLF, ex.what(), getParticipantIndex(), getDomainIndex()));
throw ex;
}
}
}
示例7: snapToCapabilitiesBounds
Bool PowerControlKnob::commitSetting()
{
try
{
if (m_powerControl->supportsPowerControls())
{
// find lowest power limit in request
Power lowestPowerLimit = snapToCapabilitiesBounds(findLowestPowerLimitRequest());
// set new power status
Power currentPowerLimit = m_powerControl->getPowerLimitPL1();
if (currentPowerLimit != lowestPowerLimit)
{
stringstream messageBefore;
messageBefore << "Attempting to change power limit to " << lowestPowerLimit.toString() << ".";
getPolicyServices().messageLogging->writeMessageDebug(
PolicyMessage(FLF, messageBefore.str(), getParticipantIndex(), getDomainIndex()));
m_powerControl->setPowerLimitPL1(lowestPowerLimit);
stringstream messageAfter;
messageAfter << "Changed power limit to " << lowestPowerLimit.toString() << ".";
getPolicyServices().messageLogging->writeMessageDebug(
PolicyMessage(FLF, messageAfter.str(), getParticipantIndex(), getDomainIndex()));
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch (std::exception& ex)
{
getPolicyServices().messageLogging->writeMessageDebug(
PolicyMessage(FLF, ex.what(), getParticipantIndex(), getDomainIndex()));
throw ex;
}
}
示例8: main
int main(){
Power *p = new Power();
// printf("ResistanceVal : %f",p->ResistanceVal());
int loop=1;
while(loop){
printf("Enter one of the Menu items:\n");
printf("1.Resistance:\n");
printf("2.Current:\n");
printf("3.Band colors:\n");
printf("4.Exit:\n");
int inp;
float r,c;
char str1[8],str2[8],str3[8];
scanf("%d",&inp);
switch(inp){
case 1 :
printf("Enter Resistance\n");
scanf("%f",&r);
p->ChangeResistance(r);
printf("ResistanceVal:=%f\n",p->ResistanceVal());
printf("CurrentVal:=%f\n",p->CurrentVal());
printf("VoltageVal:=%f\n",p->VoltageVal());
printf("Power:=%f\n",p->get_power());
break;
case 2 :
printf("Enter Current\n");
scanf("%f",&c);
p->ChangeCurrent(c);
printf("ResistanceVal:=%f\n",p->ResistanceVal());
printf("CurrentVal:=%f\n",p->CurrentVal());
printf("VoltageVal:=%f\n",p->VoltageVal());
printf("Power:=%f\n",p->get_power());
break;
case 3 :
printf("Enter First String\n");
gets(str1);
printf("Enter Second String\n");
gets(str2);
printf("Enter Third String\n");
gets(str3);
p->BandResistance(str1,str2,str3);
printf("ResistanceVal:=%f\n",p->ResistanceVal());
printf("CurrentVal:=%f\n",p->CurrentVal());
printf("VoltageVal:=%f\n",p->VoltageVal());
printf("Power:=%f\n",p->get_power());
break;
case 4 :
loop=0;
break;
}
}
return 0;
}
示例9: i2c0
namespace portapack {
portapack::IO io {
portapack::gpio_dir,
portapack::gpio_lcd_rd,
portapack::gpio_lcd_wr,
portapack::gpio_io_stbx,
portapack::gpio_addr,
portapack::gpio_lcd_te,
portapack::gpio_unused,
};
lcd::ILI9341 display;
I2C i2c0(&I2CD0);
SPI ssp0(&SPID1);
SPI ssp1(&SPID2);
wolfson::wm8731::WM8731 audio_codec { i2c0, portapack::wm8731_i2c_address };
si5351::Si5351 clock_generator {
i2c0, hackrf::one::si5351_i2c_address
};
ClockManager clock_manager {
i2c0, clock_generator
};
ReceiverModel receiver_model {
clock_manager
};
TransmitterModel transmitter_model {
clock_manager
};
uint8_t bl_tick_counter = 0;
class Power {
public:
void init() {
/* VAA powers:
* MAX5864 analog section.
* MAX2837 registers and other functions.
* RFFC5072 analog section.
*
* Beware that power applied to pins of the MAX2837 may
* show up on VAA and start powering other components on the
* VAA net. So turn on VAA before driving pins from MCU to
* MAX2837.
*/
/* Turn on VAA */
gpio_vaa_disable.clear();
gpio_vaa_disable.output();
/* 1V8 powers CPLD internals.
*/
/* Turn on 1V8 */
gpio_1v8_enable.set();
gpio_1v8_enable.output();
/* Set VREGMODE for switching regulator on HackRF One */
gpio_vregmode.set();
gpio_vregmode.output();
}
void shutdown() {
gpio_1v8_enable.clear();
gpio_vaa_disable.set();
}
private:
};
static Power power;
void init() {
for(const auto& pin : pins) {
pin.init();
}
/* Configure other pins */
LPC_SCU->SFSI2C0 =
(1U << 3)
| (1U << 11)
;
power.init();
gpio_max5864_select.set();
gpio_max5864_select.output();
gpio_max2837_select.set();
gpio_max2837_select.output();
led_usb.setup();
led_rx.setup();
led_tx.setup();
clock_manager.init();
//.........这里部分代码省略.........
示例10: power
// Override.
ComplexNumber NthRoot::eval(const ComplexNumber z) const {
Power power (1 / n);
return power.eval(z);
}
示例11: shutdown
void shutdown() {
display.shutdown();
radio::disable();
audio_codec.reset();
clock_manager.shutdown();
power.shutdown();
// TODO: Wait a bit for supplies to discharge?
chSysDisable();
systick_stop();
hackrf::one::reset();
}
示例12: main
int main(void)
{
char i = 0;
Systick_Init();
button.rise(&toggle);
while (1)
{
Delay(250);
led1 = !led1;
if(i >= 20)
{
i = 0;
led1 = 0;
power.stop();
}
else i++;
}
}
示例13: init
void init() {
for(const auto& pin : pins) {
pin.init();
}
/* Configure other pins */
LPC_SCU->SFSI2C0 =
(1U << 3)
| (1U << 11)
;
power.init();
gpio_max5864_select.set();
gpio_max5864_select.output();
gpio_max2837_select.set();
gpio_max2837_select.output();
led_usb.setup();
led_rx.setup();
led_tx.setup();
clock_manager.init();
clock_manager.set_reference_ppb(persistent_memory::correction_ppb());
clock_manager.run_at_full_speed();
clock_manager.start_audio_pll();
audio_codec.init();
clock_manager.enable_first_if_clock();
clock_manager.enable_second_if_clock();
clock_manager.enable_codec_clocks();
radio::init();
touch::adc::init();
}