Skip to content

Commit

Permalink
json handler is added
Browse files Browse the repository at this point in the history
  • Loading branch information
r-shf committed Oct 18, 2015
1 parent 256c36c commit 993d53d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/ehealth/sensordisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 27,7 @@ int main(int argc, char** argv) {
Pipeline* pipe = Factory::createPipeline("E-Health Client");

Filter* sensor = Factory::createFilter("ehealthsensor", "ehealthsensor");
Filter* display = Factory::createFilter("ehealthsender", "ehealthdisplay");
Filter* display = Factory::createFilter("ehealthdisplay", "ehealthdisplay");

pipe->addFilters(sensor, display, nullptr);

Expand Down
5 changes: 4 additions & 1 deletion examples/ehealth/sensorsender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 24,14 @@ using namespace tmf;

int main(int argc, char** argv) {

Pipeline* pipe = Factory::createPipeline("E-Health Client");
Pipeline* pipe = Factory::createPipeline("E-Health Sensor Sender");

Filter* sensor = Factory::createFilter("ehealthsensor", "ehealthsensor");
Filter* sender = Factory::createFilter("ehealthsender", "ehealthsender");

sender->setProp("userid", "1292805552");
sender->setProp("sendingPeriod", 1000);

pipe->addFilters(sensor, sender, nullptr);

pipe->connectFilters(sensor, sender);
Expand Down
6 changes: 5 additions & 1 deletion filters/ehealth/EHealthSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 29,13 @@ FilterRegister<EHealthSender> EHealthSender::reg("ehealthsender");
EHealthSender::EHealthSender(const string & name) :
Filter(name) {
input = createInputPort<SensorData>("sensor input");
minPeriod = 50;
maxPeriod = 20000;
}

void EHealthSender::init() {

jsonHandler.userid = getProp("userid");
sendingPeriod = std::stoi(getProp("sendingPeriod"));
}

void EHealthSender::run() {
Expand All @@ -41,6 44,7 @@ void EHealthSender::run() {
cout << inputData->timestamp << ": ";
switch(inputData->sensorID) {
case 1:
//jsonHandler.sensordata[inputData->sensorID]
cout << "Airflow: " << inputData->airflow << endl;
break;
case 2:
Expand Down
5 changes: 4 additions & 1 deletion filters/ehealth/EHealthSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 26,17 @@
#include "core/Port.h"

#include <ehealthsensor/Sensor.h>
#include <filters/ehealth/tools/JSONHandler.h>

struct EHealthSender: public tmf::Filter {
private:

tmf::InputPort<ehealthsensor::SensorData> * input;

static tmf::FilterRegister<EHealthSender> reg;


int minPeriod, maxPeriod, sendingPeriod;
JSONHandler jsonHandler;
public:

EHealthSender(const std::string& name);
Expand Down
27 changes: 27 additions & 0 deletions filters/ehealth/tools/JSONHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 1,27 @@
/*
*
* Tiny Multimedia Framework
* Copyright (C) 2014 Arash Shafiei
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

#include "filters/ehealth/tools/JSONHandler.h"

using namespace std;

string JSONHandler::toJSON() {
return "{}";
}
44 changes: 44 additions & 0 deletions filters/ehealth/tools/JSONHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 1,44 @@
/*
*
* Tiny Multimedia Framework
* Copyright (C) 2014 Arash Shafiei
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


#ifndef JSONHANDLER_H
#define JSONHANDLER_H

#include <vector>
#include <map>
#include <string>

class JSONData {
public:
std::string timestamp;
std::vector<std::map<std::string, std::string>> data;
};

class JSONHandler
{
public:
std::string userid;
JSONData sensordata[9];

std::string toJSON();
};

#endif // JSONHANDLER_H

0 comments on commit 993d53d

Please sign in to comment.