Skip to content
Snippets Groups Projects
Commit ba56f197 authored by Bram Veenboer's avatar Bram Veenboer
Browse files

Remove deprecated testPowerSensor.cc program

parent 93d6522a
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2016
// ASTRON (Netherlands Institute for Radio Astronomy) / John W. Romein
// P.O. Box 2, 7990 AA Dwingeloo, the Netherlands
// This file is part of PowerSensor.
// PowerSensor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// PowerSensor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with PowerSensor. If not, see <http://www.gnu.org/licenses/>.
#include <iostream>
#include <iomanip>
#include "PowerSensor.h"
#include <cstdlib>
#include <iostream>
#include <inttypes.h>
#include <unistd.h>
#define MAX_MICRO_SECONDS 4000000
int main(int argc, char **argv)
{
if (argc > 2) {
std::cerr << "usage: " << argv[0] << " [device]" << std::endl;
exit(1);
}
const char *device = argc == 2 ? argv[1] : "/dev/ttyUSB0";
PowerSensor powerSensor(device, "/tmp/sensor_values");
PowerSensor::State states[2];
states[0] = powerSensor.read();
for (uint32_t micros = 100, i = 1; micros <= MAX_MICRO_SECONDS; micros *= 2, i ^= 1) {
usleep(micros);
states[i] = powerSensor.read();
std::cout << "exp. time: " << micros * 1e-6 << " s, "
"measured: " << PowerSensor::seconds(states[i ^ 1], states[i]) << " s, " <<
PowerSensor::Joules(states[i ^ 1], states[i]) << " J, " <<
PowerSensor::Watt(states[i ^ 1], states[i]) << " W" <<
std::endl;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment