Pacemaker code Implementation for SFWRENG 3K04

Dependencies:   FXOS8700Q Queue mbed-rtos mbed

Fork of Pacemaker by Eric dollar

dataStruct.cpp

Committer:
trane3
Date:
2016-11-24
Revision:
19:d58e1e1a9a24
Parent:
16:08d5e5a3ee74
Child:
28:4f36e100ccbe

File content as of revision 19:d58e1e1a9a24:

#pragma once
#include "dataStruct.h"
#include "rtos.h"

dataStruct::dataStruct(hardware* hWare): myQueue(1,N),thread(&dataStruct::threadStarter){
    myHardware = hWare; 
    thread.signal_set(START_THREAD);
    }
    
dataStruct::~dataStruct(){
    }

void dataStruct::threadStarter(void const *p){
    dataStruct *instance = (dataStruct*)p;
    instance->storeData();
    }

void dataStruct::storeData(){
    thread.signal_wait(START_THREAD);
    while(true){
        streamValue = myHardware->getSense();
        if(myQueue.GetNumberOfItems() <= N){
            myQueue.Put(&streamValue);
            }
        Thread::wait(4);
    }
}

queue dataStruct::getData(){
    queue temp = myQueue;
    myQueue.Flush();
    return temp;
}