Pacemaker code Implementation for SFWRENG 3K04

Dependencies:   FXOS8700Q Queue mbed-rtos mbed

Fork of Pacemaker by Eric dollar

chamberData.cpp

Committer:
FiveDollar
Date:
2016-11-29
Revision:
30:0cb4890910cd
Parent:
27:f8deff828a00

File content as of revision 30:0cb4890910cd:

#pragma once
#include "mbed.h"
#include "chamberData.h"

chamberData::chamberData(){
}

chamberData::chamberData(char chamberType){
    p_PaceAmp = 3.75; //decimal value between 0 and 1 which is a factor applied to 3.3V output.  ie. 0.5 will give 0.5(3.3) V of output
    p_PaceWidth = 0.4;
    p_RP = 0;
    p_Sensitivity = 0;
    mychamber = chamberType;
       
}
char chamberData::getChamberType(){
    return mychamber;
}

int chamberData::chngPaceAmp(double amp){
    if(mychamber == 'a'){
        if(amp>3.2 || amp<0.5){
            return 0; 
        }else{
            p_PaceAmp = (amp-0)/(7-0);
            return 1;
        }
    }else{
        if(amp>7 || amp<3.5){
            return 0;
        }else{
            p_PaceAmp = (amp-0)/(7-0);
            return 1;
        }
    }
}

double chamberData::getPaceAmp(){
    return p_PaceAmp;
}

int chamberData::chngPaceWidth(double width){
    if(mychamber == 'a'){
        if(width!=0.05){
            return 0;
        }else{
            p_PaceWidth = width;
            return 1;
        }
    }else{
        if(width>1.9 || width< 0.1){
            return 0;
        }else{
            p_PaceWidth = width;
            return 1;
        }
    }
}

double chamberData::getPaceWidth(){
    return p_PaceWidth;
}

int chamberData::chngRP(double RP){
    if(mychamber == 'a'){
        if(RP>500 || RP<150){
            return 0;
        }else{
            p_RP = RP;
            return 1;
        }
    }else{
        if(RP>500 || RP< 150){
            return 0;
        }else{
            p_RP = RP;
            return 1;
        }
    }
}

double chamberData::getRP(){
    return p_RP;
}

int chamberData::chngSensitivity(double sensitivity){
   if(mychamber == 'a'){
        if(sensitivity!=0.05 || sensitivity!= 0.25 || sensitivity!=0.75){
            return 0;
        }else{
            p_Sensitivity = sensitivity;
            return 1;
        }
    }else{
        if(sensitivity>10 || sensitivity< 1){
            return 0;
        }else{
            p_Sensitivity = sensitivity;
            return 1;
        }
    }
}

double chamberData::getSensitivity(){
    return p_Sensitivity;
}
chamberData::~chamberData(){}