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.
Dependencies: mbed
Revision 71:60f06e7e50a3, committed 2015-09-03
- Comitter:
- aidanPJG
- Date:
- Thu Sep 03 15:32:01 2015 +0000
- Parent:
- 70:168d67695a65
- Commit message:
- tried to add date but it failed;
Changed in this revision
--- a/Calculate.cpp Thu Sep 03 15:10:51 2015 +0000
+++ b/Calculate.cpp Thu Sep 03 15:32:01 2015 +0000
@@ -5,9 +5,9 @@
#include "Data.h"
//*************defining methods used in this method
-void printArray(double array[20], double timesArray[20], int NoOfPins,double speedAvg[20], double timesTotal[20]);
+void printArray(double array[20], double timesArray[20], int NoOfPins,double speedAvg[20], double timesTotal[20], string date);
void data(int sensor_number, double time, double speed, double timesTotal, double speedAvg);
-void reset(int distance, int NoOfPins);
+void reset(int distance, int NoOfPins, string date);
//*********mbed pins*********************************
extern Serial pc; //defines the communication between MBed and pc
@@ -30,7 +30,7 @@
double totalTimes[20]; //total runnning times
-int calculate(double distance, int NoOfPins) //run when the pipe is being bent around the former.
+int calculate(double distance, int NoOfPins, string date) //run when the pipe is being bent around the former.
{
while(true) //keep doing this
{
@@ -87,12 +87,12 @@
}
}
- printArray(speeds,times,NoOfPins,avgSpeeds,totalTimes); //write info to Mbed xl
- reset(distance, NoOfPins); //reset after all sensors on former have been used. Prepare for it to start from the start again.
+ printArray(speeds,times,NoOfPins,avgSpeeds,totalTimes, date); //write info to Mbed xl
+ reset(distance, NoOfPins, date); //reset after all sensors on former have been used. Prepare for it to start from the start again.
}
}
-void reset(int distance, int NoOfPins) //reset after all sensors on former have been used. Prepare for it to start from the start again.
+void reset(int distance, int NoOfPins, string date) //reset after all sensors on former have been used. Prepare for it to start from the start again.
{
while ( sensor[0]){
@@ -114,12 +114,12 @@
t.reset(); //clock reset
//******start again************
- calculate(distance, NoOfPins); //be ready for another bend on same former.
+ calculate(distance, NoOfPins, date); //be ready for another bend on same former.
}
-void printArray(double array[20], double timesArray[20], int NoOfPins, double speedAvg[20], double timesTotal[20]) //for printing arrays to xl doc on the mbed.
+void printArray(double array[20], double timesArray[20], int NoOfPins, double speedAvg[20], double timesTotal[20], string date) //for printing arrays to xl doc on the mbed.
{
- initialise(bendCounter); //used to create the Datalog file header.Should happen once for every bend test. BendCounter is the iteration of the bend
+ initialise(bendCounter, date); //used to create the Datalog file header.Should happen once for every bend test. BendCounter is the iteration of the bend
for (int i = 0; i < NoOfPins ; i++) //for every sensor
{
data( i,times[i],speeds[i],timesTotal[i],speedAvg[i]); //printing to Datalog
--- a/Calculate.h Thu Sep 03 15:10:51 2015 +0000 +++ b/Calculate.h Thu Sep 03 15:32:01 2015 +0000 @@ -1,7 +1,8 @@ #ifndef CALCULATE_H #define CALCULATE_H +#include <string> -int calculate(double distance, int NoOfPins); +int calculate(double distance, int NoOfPins, string date); void printArray(double array[3], int timesArray[3],int NoOfPins); #endif \ No newline at end of file
--- a/Data.cpp Thu Sep 03 15:10:51 2015 +0000
+++ b/Data.cpp Thu Sep 03 15:32:01 2015 +0000
@@ -1,12 +1,13 @@
#include "mbed.h"
+#include <string>
LocalFileSystem local("local");
extern Serial pc;
-void initialise(int counter )
+void initialise(int counter, string date )
{
FILE *fp1 = fopen("/local/Datalog.xls", "a"); // opens or creates fill Datalog,
- fprintf(fp1, " Test %d \n", counter); //gives header
+ fprintf(fp1, " Test %d \n %s \n", counter, date); //gives header
fprintf(fp1, " Sensor \t Total Time \t Time Diff \t Inst Speed \t Avg Speed\n"); //writes field names
fclose(fp1); //closes the file so it can be opened by another method
}
--- a/Data.h Thu Sep 03 15:10:51 2015 +0000 +++ b/Data.h Thu Sep 03 15:32:01 2015 +0000 @@ -2,7 +2,7 @@ #define DATA_H void data(int sensor_number, double time, double speed); -void initialise(int counter); +void initialise(int counter, string date); void averageData(); #endif \ No newline at end of file
--- a/UserInput.cpp Thu Sep 03 15:10:51 2015 +0000
+++ b/UserInput.cpp Thu Sep 03 15:32:01 2015 +0000
@@ -32,3 +32,15 @@
}
return(sensorDistance);
}
+string inputDate()
+{
+ while (1) //keep doing this
+ {
+ if (pc.readable())
+ {
+ pc.scanf("%s", &date); //has to &lf because must know the size of it before getting it in
+ break;
+ }
+ }
+ return(date);
+}
--- a/UserInput.h Thu Sep 03 15:10:51 2015 +0000 +++ b/UserInput.h Thu Sep 03 15:32:01 2015 +0000 @@ -1,7 +1,9 @@ #ifndef USERINPUT.H #define USERINPUT.H +#include <string> double inputDistance(); int inputNoOfPins(); +string inputDate(); #endif \ No newline at end of file
--- a/main.cpp Thu Sep 03 15:10:51 2015 +0000
+++ b/main.cpp Thu Sep 03 15:32:01 2015 +0000
@@ -41,5 +41,6 @@
{
int pins = inputNoOfPins(); //gets number of pins
double distance = inputDistance(); //gets the distance between the pins
- calculate(distance,pins); //runs calculate method.
+ string date = inputDate();
+ calculate(distance,pins,date); //runs calculate method.
}
\ No newline at end of file