Exemplo n.º 1
0
void OMNeTBattery::draw(int deviceID, DrawAmount& amount, int activity) {
    if (amount.getType() == DrawAmount::CURRENT) {
        double current = amount.getValue();
        if (activity < 0 && current != 0) {
            error("Invalid parameters for OMNeTBattery::draw");
        }

        EV << simTime() << " device " << deviceID << " drew current " << current << "mA, activity = " << activity << endl;

        // update the residual capacity (finish previous current draw)
        updateResidualEnergy();

        // set the new current draw in the device vector
        deviceEntryVector[deviceID]->currentEnergyDraw = current;
        deviceEntryVector[deviceID]->currentActivity = activity;
    }
    else if (amount.getType() == DrawAmount::ENERGY) {
        double energy = amount.getValue();
        if (!(activity >= 0 && activity < deviceEntryVector[deviceID]->numberOfActivities)) {
            error("Invalid activity specified");
        }

        EV << simTime() << " device " << deviceID <<  " deduct " << energy << " mW-s, activity = " << activity << endl;

        // deduct a fixed energy cost
        deviceEntryVector[deviceID]->accts[activity] += energy;
        residualCapacityInMilliWattSeconds -= energy;

        // update the residual capacity (ongoing current draw)
        updateResidualEnergy();
    }
    else {
        error("Unknown power type!");
    }
}
Exemplo n.º 2
0
void OMNeTBattery::receiveChangeNotification(int category, const cObject* notificationDetails) {
    Enter_Method_Silent();
    if (category == NF_RADIOSTATE_CHANGED)     {
        const RadioState* radioState = check_and_cast<const RadioState*>(notificationDetails);
        DeviceEntryMap::iterator foundDeviceEntry = deviceEntryMap.find(radioState->getRadioId());
        if (foundDeviceEntry==deviceEntryMap.end()) {
            // device has not been registered
            return;
        }

        DeviceEntry* deviceEntry = foundDeviceEntry->second;
        if (radioState->getState() >= deviceEntry->numberOfActivities) {
            error("Can not handle change in radio state for radio id %u (%u registered activities, but state was %u)", radioState->getRadioId(), deviceEntry->numberOfActivities, radioState->getState());
        }

        double current = deviceEntry->radioUsageCurrent[radioState->getState()];

        EV << "[BATTERY:] Wireless device consumes energy from now on with " << current << "mA, new radio state = " << RadioState::stateName(radioState->getState()) << std::endl;

        // update the residual capacity (finish previous current draw)
        updateResidualEnergy();

        // set the new current draw in the device vector
        deviceEntry->currentEnergyDraw = current;
        deviceEntry->currentActivity = radioState->getState();
    }
}
Exemplo n.º 3
0
void OMNeTBattery::handleMessage(cMessage* message) {
    if (message->isSelfMessage() == false) {
        error("Can not handle any external messages");
    }

    updateResidualEnergy();
    if(residualCapacityInMilliWattSeconds > 0) {
        scheduleAt(simTime() + updateInterval, publishMessage);
    }
}
Exemplo n.º 4
0
CameraView::CameraView(Camera * camera, QWidget *parent, int tabIdx):
    QWidget(parent),
    ui(new Ui::CameraView){

    _cam = camera;
    _tabIdx = tabIdx;

    connect(_cam, SIGNAL(CTAFrameUpdatedSignal()), this, SLOT(showCTAFrame()));
    connect(_cam, SIGNAL(ATCFrameUpdatedSignal()), this, SLOT(showATCFrame()));
    connect(_cam, SIGNAL(ATCRecFrameUpdatedSignal()), this, SLOT(showATCRecFrame()));
    connect(_cam, SIGNAL(frameRateUpdatedSignal()), this, SLOT(updateFrameRate()));
    //***NBS***//
    connect(_cam, SIGNAL(residualEnergyUpdatedSignal()), this, SLOT(updateResidualEnergy()));
    //***NBS***//
    connect(_cam,SIGNAL(curBandwidthChangedSignal(int,double)),this,SLOT(updateBandwidthSlot(int,double)));
    connect (_cam,SIGNAL(recognitionCompletedSignal(QString,QString)),SLOT(updateRecognitionResultSlot(QString,QString)));

    ui->setupUi(this);

    ui->label_image->setText("");

}