Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 4:179fc666147c, committed 2016-12-06
- Comitter:
- kieftea
- Date:
- Tue Dec 06 19:55:30 2016 +0000
- Parent:
- 3:655f4fed48d7
- Commit message:
- Receive returns just a single string; Each parameter has its unique ID as an enum value for the switch; All set functions must be updated/written
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control.cpp Tue Dec 06 19:55:30 2016 +0000 @@ -0,0 +1,382 @@ +#include "control.h" +#include <iostream> +#include <sstream> +#include "parameters.h" +#include "serial.h" + +using namespace std; + + //SERIAL SENDER + void control::sendProgData(){ + control::sendActivityThreshold(); + control::sendATRDuration(); + control::sendATREnable(); + control::sendATRFallback(); + control::sendAtrRP(); + control::sendDynamicAVDelay(); + control::sendFixedAVDelay(); + control::sendHysterisisRateLimit(); + control::sendLowerRateLimit(); + control::sendMaximumSensorRate(); + control::sendPulseWidth(); + control::sendPVARP(); + control::sendPVARPExt(); + control::sendRateSmoothing(); + control::sendReactionTime(); + control::sendRecoveryTime(); + control::sendRegulatedAmplitude(); + control::sendResponseFactor(); + control::sendSensedAVDelayOffset(); + control::sendSensitivity(); + control::sendUnregulatedAmplitude(); + control::sendUpperRateLimit(); + control::sendVentBlanking(); + control::sendVentRP(); + control::sendpaceMode(); + } + + void control::sendProgData(control::ID input){ + switch(input){ + case control::P0000: + break; + case control::PS001: + control::sendActivityThreshold(); + break; + case control::PI002: + control::sendATRDuration(); + break; + case control::PS003: + control::sendATREnable(); + break; + case control::PI004: + control::sendATRFallback(); + break; + case control::PI005: + control::sendAtrRP(); + break; + case control::PS006: + control::sendDynamicAVDelay(); + break; + case control::PI007: + control::sendFixedAVDelay(); + break; + case control::PI008: + control::sendHysterisisRateLimit(); + break; + case control::PI009: + control::sendLowerRateLimit(); + break; + case control::PI010: + control::sendMaximumSensorRate(); + break; + case control::PD011: + control::sendPulseWidth(); + break; + case control::PI012: + control::sendPVARP(); + break; + case control::PI013: + control::sendPVARPExt(); + break; + case control::PI014: + control::sendRateSmoothing(); + break; + case control::PI015: + control::sendReactionTime(); + break; + case control::PI016: + control::sendRecoveryTime(); + break; + case control::PD017: + control::sendRegulatedAmplitude(); + break; + case control::PI018: + control::sendResponseFactor(); + break; + case control::PI019: + control::sendSensedAVDelayOffset(); + break; + case control::PD020: + control::sendSensitivity(); + break; + case control::PD021: + control::sendUnregulatedAmplitude(); + break; + case control::PI022: + control::sendUpperRateLimit(); + break; + case control::PI023: + control::sendVentBlanking(); + break; + case control::PI024: + control::sendVentRP(); + break; + case control::PS025: + control::sendpaceMode(); + break; + } + + } + void control::sendActivityThreshold(){ + + } + void control::sendATRDuration(){ + + } + void control::sendATREnable(){ + + } + void control::sendATRFallback(){ + + } + void control::sendAtrRP(){ + + } + void control::sendDynamicAVDelay(){ + + } + void control::sendFixedAVDelay(){ + + } + void control::sendHysterisisRateLimit(){ + + } + void control::sendLowerRateLimit(){ + + } + void control::sendMaximumSensorRate(){ + + } + void control::sendPulseWidth(){ + + } + void control::sendPVARP(){ + + } + void control::sendPVARPExt(){ + + } + void control::sendRateSmoothing(){ + + } + void control::sendReactionTime(){ + + } + void control::sendRecoveryTime(){ + + } + void control::sendRegulatedAmplitude(){ + + } + void control::sendResponseFactor(){ + + } + void control::sendSensedAVDelayOffset(){ + + } + void control::sendSensitivity(){ + + } + void control::sendUnregulatedAmplitude(){ + + } + void control::sendUpperRateLimit(){ + + } + void control::sendVentBlanking(){ + + } + void control::sendVentRP(){ + + } + void control::sendpaceMode(){ + + } + + + //SERIAL ACCESSOR + void control::getProgData(){ + control::getActivityThreshold(); + control::getATRDuration(); + control::getATREnable(); + control::getATRFallback(); + control::getAtrRP(); + control::getDynamicAVDelay(); + control::getFixedAVDelay(); + control::getHysterisisRateLimit(); + control::getLowerRateLimit(); + control::getMaximumSensorRate(); + control::getPulseWidth(); + control::getPVARP(); + control::getPVARPExt(); + control::getRateSmoothing(); + control::getReactionTime(); + control::getRecoveryTime(); + control::getRegulatedAmplitude(); + control::getResponseFactor(); + control::getSensedAVDelayOffset(); + control::getSensitivity(); + control::getUnregulatedAmplitude(); + control::getUpperRateLimit(); + control::getVentBlanking(); + control::getVentRP(); + control::getpaceMode(); + } + + void control::getProgData(control::ID input){ + switch(input){ + case control::P0000: + break; + case control::PS001: + control::getActivityThreshold(); + break; + case control::PI002: + control::getATRDuration(); + break; + case control::PS003: + control::getATREnable(); + break; + case control::PI004: + control::getATRFallback(); + break; + case control::PI005: + control::getAtrRP(); + break; + case control::PS006: + control::getDynamicAVDelay(); + break; + case control::PI007: + control::getFixedAVDelay(); + break; + case control::PI008: + control::getHysterisisRateLimit(); + break; + case control::PI009: + control::getLowerRateLimit(); + break; + case control::PI010: + control::getMaximumSensorRate(); + break; + case control::PD011: + control::getPulseWidth(); + break; + case control::PI012: + control::getPVARP(); + break; + case control::PI013: + control::getPVARPExt(); + break; + case control::PI014: + control::getRateSmoothing(); + break; + case control::PI015: + control::getReactionTime(); + break; + case control::PI016: + control::getRecoveryTime(); + break; + case control::PD017: + control::getRegulatedAmplitude(); + break; + case control::PI018: + control::getResponseFactor(); + break; + case control::PI019: + control::getSensedAVDelayOffset(); + break; + case control::PD020: + control::getSensitivity(); + break; + case control::PD021: + control::getUnregulatedAmplitude(); + break; + case control::PI022: + control::getUpperRateLimit(); + break; + case control::PI023: + control::getVentBlanking(); + break; + case control::PI024: + control::getVentRP(); + break; + case control::PS025: + control::getpaceMode(); + break; + } + + } + /* void control::getActivityThreshold(){ + setActivityThreshold(receive()); + } + void control::getATRDuration(){ + setATRDuration(atoi(receive())); + } + void control::getATREnable(){ + setATREnable(receive()); + } + void control::getATRFallback(){ + setATRFallback((receive())); + } + void control::getAtrRP(){ + setAtrRP((receive())); + } + void control::getDynamicAVDelay(){ + setDynamicAVDelay(receive()); + } + void control::getFixedAVDelay(){ + setFixedAVDelay((recieve())); + } + void control::getHysterisisRateLimit(){ + setHysterisisRateLimit((recieve())); + } + void control::getLowerRateLimit(){ + setLowerRateLimit(stoi(recieve())); + } + void control::getMaximumSensorRate(){ + setMaximumSensorRate(stoi(recieve())); + } + void control::getPulseWidth(){ + setPulseWidth(stod(recieve())); + } + void control::getPVARP(){ + setPVARP(stoi(recieve())); + } + void control::getPVARPExt(){ + setPVARPExt(stoi(recieve())); + } + void control::getRateSmoothing(){ + setRateSmoothing(stoi(recieve())); + } + void control::getReactionTime(){ + setReactionTime(stoi(recieve())); + } + void control::getRecoveryTime(){ + setRecoveryTime(stoi(recieve())); + } + void control::getRegulatedAmplitude(){ + setRegulatedAmplitude(stod(recieve())); + } + void control::getResponseFactor(){ + setResponseFactor(stoi(recieve())); + } + void control::getSensedAVDelayOffset(){ + setSensedAVDelayOffset(stoi(recieve())); + } + void control::getSensitivity(){ + setSensitivity(stod(recieve())); + } + void control::getUnregulatedAmplitude(){ + setUnregulatedAmplitude(stod(recieve())); + } + void control::getUpperRateLimit(){ + setUpperRateLimit(stoi(recieve())); + } + void control::getVentBlanking(){ + setVentBlanking(stoi(recieve())); + } + void control::getVentRP(){ + setVentRP(stoi(recieve())); + } + void control::getpaceMode(){ + setpaceMode(recieve()); + } */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/control.h Tue Dec 06 19:55:30 2016 +0000 @@ -0,0 +1,102 @@ +/* + * File: pacemaker.h + * Author: Evan + * + * Created on December 5, 2016, 1:56 PM + */ + +#ifndef CONTROL_H +#define CONTROL_H + +class control{ + +public: + void sendProgData(); + void sendProgData(ID input); + void sendActivityThreshold(); + void sendATRDuration(); + void sendATREnable(); + void sendATRFallback(); + void sendAtrRP(); + void sendDynamicAVDelay(); + void sendFixedAVDelay(); + void sendHysterisisRateLimit(); + void sendLowerRateLimit(); + void sendMaximumSensorRate(); + void sendPulseWidth(); + void sendPVARP(); + void sendPVARPExt(); + void sendRateSmoothing(); + void sendReactionTime(); + void sendRecoveryTime(); + void sendRegulatedAmplitude(); + void sendResponseFactor(); + void sendSensedAVDelayOffset(); + void sendSensitivity(); + void sendUnregulatedAmplitude(); + void sendUpperRateLimit(); + void sendVentBlanking(); + void sendVentRP(); + void sendpaceMode(); + + void getProgData(ID input); + void getActivityThreshold(); + void getATRDuration(); + void getATREnable(); + void getATRFallback(); + void getAtrRP(); + void getDynamicAVDelay(); + void getFixedAVDelay(); + void getHysterisisRateLimit(); + void getLowerRateLimit(); + void getMaximumSensorRate(); + void getPulseWidth(); + void getPVARP(); + void getPVARPExt(); + void getRateSmoothing(); + void getReactionTime(); + void getRecoveryTime(); + void getRegulatedAmplitude(); + void getResponseFactor(); + void getSensedAVDelayOffset(); + void getSensitivity(); + void getUnregulatedAmplitude(); + void getUpperRateLimit(); + void getVentBlanking(); + void getVentRP(); + void getpaceMode(); + + enum ID { + P0000, + PS001, + PI002, + PS003, + PI004, + PI005, + PS006, + PI007, + PI008, + PI009, + PI010, + PD011, + PI012, + PI013, + PI014, + PI015, + PI016, + PD017, + PI018, + PI019, + PD020, + PD021, + PI022, + PI023, + PI024, + PS025 + }; +}; + + + +#endif /* CONTROL_H */ +
--- a/serial.cpp Mon Dec 05 21:31:39 2016 +0000 +++ b/serial.cpp Tue Dec 06 19:55:30 2016 +0000 @@ -1,5 +1,5 @@ -#include "mbed.h" -#include "rtos.h" +//#include "mbed.h" +//#include "rtos.h" #include <string> #include <sstream> @@ -8,8 +8,7 @@ Serial pc(USBTX, USBRX); Thread *RX_THREAD_POINTER; string test; -string* paramArray = new string[25]; -int index=0; +bool flag=true; // Rx Interupt routine void Rx_interrupt(void){ @@ -25,50 +24,39 @@ Thread::signal_wait(0x1); while (pc.readable()) { //pc.putc(pc.getc()); // read data from UART - pc.printf("\r\nInput: \r\n"); + //pc.printf("\r\nInput: \r\n"); stringstream ss; char temp; temp = pc.getc(); - pc.putc(temp); + //pc.putc(temp); while (temp != '*'){ ss << temp; temp = pc.getc(); - pc.putc(temp); + //pc.putc(temp); } ss >> test; - if(index<25){ - //in_Array[i] = temp; - //pc.printf("%s\r\n", test); - //pc.printf("\r\n"); - led2=!led2; - paramArray[index++] = test; - } else { - //i = 0; - pc.attach(&Rx_interrupt); - //return; - } + flag = false; + pc.attach(&Rx_interrupt); } pc.attach(&Rx_interrupt); // Enable Rx interrupt } } -string* recieve(){ - paramArray = new string[24]; - index=0; +string recieve(){ Thread t_rx(rx_thread); RX_THREAD_POINTER = &t_rx; // Set thread pointer as globally-accessible t_rx.set_priority(osPriorityHigh); pc.attach(Rx_interrupt); //pc.printf("\r\nStart\r\n"); - while(test != "DONE"){ + while(flag){ led1=!led1; //pc.printf("%s\r\n",test); Thread::wait(1000); } - return paramArray; + return test; } void send(string input){
--- a/serial.h Mon Dec 05 21:31:39 2016 +0000 +++ b/serial.h Tue Dec 06 19:55:30 2016 +0000 @@ -1,14 +1,14 @@ #ifndef SERIAL_H #define SERIAL_H -#include "mbed.h" -#include "rtos.h" +//#include "mbed.h" +//#include "rtos.h" #include <string> #include <sstream> void Rx_interrupt(void); void rx_thread(void const *argument); -string* recieve(); +string recieve(); void send(string input); #endif \ No newline at end of file