本文整理汇总了C++中OutputPin::outputSignal方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputPin::outputSignal方法的具体用法?C++ OutputPin::outputSignal怎么用?C++ OutputPin::outputSignal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPin
的用法示例。
在下文中一共展示了OutputPin::outputSignal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onElectricThink
void onElectricThink()
{
InputPin *value = getInputPin("value");
OutputPin *control = getOutputPin("control");
Signal::Voltage fValue = value->outputSignal().getVoltage();
bool controlOutput = control->outputSignal().isHigh();
if(mBelowMax)
{
if(fValue < mHigher)
controlOutput = true;
else
{
mBelowMax = false;
controlOutput = false;
}
}
else
{
if(fValue > mLower)
controlOutput = false;
else
{
mBelowMax = true;
controlOutput = true;
}
}
if(control->outputSignal().isHigh() != controlOutput)
control->inputSignal(Signal(controlOutput));
Device::sleep();
}
示例2: onThink
virtual void onThink()
{
SinkConnector *energyIn = getInput("energy-in");
SourceConnector *energyOut = getOutput("energy-out");
OutputPin *readout = getOutputPin("readout");
mStored.attemptPumpSource(energyIn, Testing::Generator::ENERGY_PER_GENERATION);
mStored.attemptPumpSink(energyOut, Testing::Generator::ENERGY_PER_GENERATION / 2);
// 'waste' some output
energyOut->pumpSource(Testing::Generator::ENERGY_PER_GENERATION / 4);
Resource::Quantity stored = mStored.getQuantity() + energyOut->sourceQuantity();
float percentFull = (float) stored / mStored.getCapacity();
if(readout->outputSignal().getVoltage() != percentFull)
readout->inputSignal(Signal(percentFull));
cout << "[capacitor] percent full: " << (percentFull * 100.0) << endl;
// go to sleep
if(mStored.getQuantity() <= 0)
Module::sleep();
}