Commit 09415979 authored by Martin Perdacher's avatar Martin Perdacher

removed energy measurements

parent 997f6878
......@@ -5,7 +5,7 @@ project(ego2)
# export CC=/opt/gcc6.1.0/usr/local/bin/gcc
# export CXX=/opt/gcc6.1.0/usr/local/bin/g++
set(UTIL_SOURCES util/dataIo.cpp util/arguments.cpp util/allocation.cpp measure/energy.cpp measure/timer.cpp util/chrisutil.cpp)
set(UTIL_SOURCES util/dataIo.cpp util/arguments.cpp util/allocation.cpp measure/timer.cpp util/chrisutil.cpp)
set(SOURCE_FILES_SELF main.cpp hilbertjoin/egojoin.cpp hilbertjoin/hilloop.cpp ${UTIL_SOURCES})
set(SOURCE_FILES_JOIN mainJoin.cpp hilbertjoin/egojoin.cpp hilbertjoin/hilloop.cpp ${UTIL_SOURCES})
......
......@@ -39,12 +39,14 @@ int main(int argc, char** argv) {
char filename[256] = "";
bool isBinary=false;
CUtilTimer timer, algtimer;
Hioki pmeter;
// Hioki pmeter;
size_t result=0l;
int stripes=14;
int actdim=3;
boost::lockfree::queue<join_pair> queue(10000);
double sortTime=0.0, reorderTime=0.0, indexTime=0.0, watthours=0.0,totaltime=0.0,algtime=0.0;
double sortTime=0.0, reorderTime=0.0, indexTime=0.0,
double watthours=0.0;
double totaltime=0.0,algtime=0.0;
double loadpercent=0.0;
parsing_args(argc, argv, &n, &epsilon, &d, filename, &isBinary, &actdim);
......@@ -77,7 +79,7 @@ int main(int argc, char** argv) {
printf("\n");
}
pmeter.reset(); pmeter.start();
// pmeter.reset(); pmeter.start();
timer.start();
outputStatistics(n, d, epsilon, array, reorder_dim);
......@@ -103,8 +105,8 @@ int main(int argc, char** argv) {
algtimer.stop();
algtime = algtimer.get_time();
pmeter.stop();
watthours=pmeter.getWH();
// pmeter.stop();
// watthours=pmeter.getWH();
#ifndef COUNT_ONLY
// if we materialize with a non-blocking linked list, then joincounts are zero
......
......@@ -8,7 +8,7 @@
#include <math.h>
#include "measure/timer.h"
#include "measure/energy.h"
// #include "measure/energy.h"
#include "util/dataIo.h"
#include "util/chrisutil.h"
#include "util/arguments.h"
......@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
char filename2[256] = "";
bool isBinary=false;
CUtilTimer timer, algtimer;
Hioki pmeter;
// Hioki pmeter;
size_t result=0l;
int stripes=14;
int actdim=3;
......@@ -118,8 +118,8 @@ int main(int argc, char** argv) {
algtimer.stop();
algtime = algtimer.get_time();
pmeter.stop();
watthours=pmeter.getWH();
// pmeter.stop();
// watthours=pmeter.getWH();
#ifndef COUNT_ONLY
// if we materialize with a non-blocking linked list, then joincounts are zero
......
#include "energy.h"
#include <sys/ioctl.h>
Hioki::Hioki(){
this->rs_232_open();
this->rs_232_config();
}
Hioki::~Hioki(){
close(fd);
}
void Hioki::start(){
const char *query = ":INTEGrate:STATe START\n";
int nbytes = write(getFd(), query, strlen(query));
if (nbytes < 0){
perror("write of 'start' failed!\n");
exit(1);
}
// printf("start: %d written\n",nbytes);
usleep( SLEEPVAL * (strlen(query) ) );
}
int Hioki::getFd(){
return fd;
}
void Hioki::setFd(int filedescriptor){
fd = filedescriptor;
}
void Hioki::reset(){
const char *query = ":INTEGrate:STATe RESET\n";
int nbytes = write(getFd(), query, strlen(query));
if (nbytes < 0){
perror("write of 'reset' failed!\n");
exit(1);
}
usleep(SLEEPVAL * (strlen(query) ) );
}
void Hioki::stop(){
const char *query = ":INTEGrate:STATe STOP\n";
int nbytes = write(getFd(), query, strlen(query));
if (nbytes < 0){
// printf("fd: %d\n", getFd());
perror("write of 'stop' failed!\n");
exit(1);
}
usleep(SLEEPVAL * (strlen(query) ) );
}
double Hioki::getWH(){
char buffer[1024];
char *bufptr;
int nbytes,nread;
double valueWH = 0.0;
const char *query = ":MEASure? WH\n";
nbytes = write(getFd(), query, strlen(query));
if (nbytes < 0){
perror("query of 'measure' failed!\n");
exit(1);
}
usleep(SLEEPVAL * (strlen(query) + 50) );
bufptr = buffer;
// are there some bytes available on input
ioctl(getFd(), FIONREAD, &nbytes);
if ( nbytes > 0 ){
nread = read(getFd(), bufptr, nbytes);
bufptr[nread] = '\0';
// receiving data in format:
// WH +0.00053E+3
bufptr += 3;
valueWH = atof(bufptr);
}else{
fprintf(stderr, "Error in parsing value!\n");
exit(1);
}
return valueWH;
}
void Hioki::rs_232_open(){
int fdesc = open(device, O_CREAT | O_RDWR | O_NOCTTY | O_NDELAY);
setFd(fdesc);
// printf("fd: %d\n", getFd() );
if(fd == -1) {
perror("failed to open port\n" );
exit(1);
}else
fcntl(getFd(), F_SETFL, 0);
}
void Hioki::rs_232_config(){
struct termios options;
// configuring port
tcgetattr(getFd(), &options);
cfsetispeed(&options, B9600); // BAUDRATE to 9600
cfsetospeed(&options, B9600);
options.c_cflag = (options.c_cflag & ~CSIZE) | CS8; // 8-bit chars
options.c_iflag &= ~IGNBRK;
options.c_lflag = 0;
options.c_oflag = 0; // no remapping, no delays
options.c_cc[VMIN] = 0; // read doesn't block
options.c_cc[VTIME] = 5; // 0.5 seconds read timeout
options.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl
options.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
// enable reading
options.c_cflag &= ~(PARENB | PARODD); // shut off parity
options.c_cflag |= 0; // 0 no parity, PARENB|PARODD odd parity, PARENB (enable parity and use even), PARENB|PARODD|CMSPAR (mark parity), and PARENB|CMSPAR (space parity).
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CRTSCTS;
/*
* Enable the receiver and set local mode...
*/
options.c_cflag |= (CLOCAL | CREAD);
/*
* Set the new options for the port...
*/
if ( tcsetattr(getFd(), TCSANOW, &options) < 0 ){
perror("Failed to apply settings\n");
exit(1);
}
}
#ifndef ENERGY_CONSUMPTION_H
#define ENERGY_CONSUMPTION_H
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#define SLEEPVAL 100000
class Hioki{
public:
Hioki();
~Hioki();
void start();
void stop();
void reset();
double getWH();
private:
const char *device = "/dev/ttyS0";
int fd;
int getFd();
void setFd(int filedescriptor);
void rs_232_config();
void rs_232_open();
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment