Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Committer:
chills
Date:
Mon Jan 08 16:54:15 2018 +0000
Revision:
44:e0eac2382810
Parent:
43:fb9faec1dc72
2018_01_08 16:51; SETT working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 6:97f586597310 1 /*
thomasmorris 6:97f586597310 2 ELEC 351 Group T
thomasmorris 6:97f586597310 3 Team Members : Christopher Hills, Thomas Morris
thomasmorris 42:ae1640bca2e1 4 Current Verision 19
thomasmorris 42:ae1640bca2e1 5 Overiew: Working Tasks 1,2,3,5,6,7,8,9,10,11,12,13,14,15
thomasmorris 8:0e4481b64353 6
thomasmorris 12:536eca338ae8 7 Last Revision: Added Mail Box to serial
thomasmorris 8:0e4481b64353 8 Todo:
thomasmorris 42:ae1640bca2e1 9 Add functionality to SD card import chris's work on delete serial commnads
thomasmorris 42:ae1640bca2e1 10 Commnet code
thomasmorris 42:ae1640bca2e1 11 Check for race conditions
thomasmorris 42:ae1640bca2e1 12 Move code around
thomasmorris 42:ae1640bca2e1 13 Other fixes
thomasmorris 6:97f586597310 14 */
thomasmorris 6:97f586597310 15
thomasmorris 25:36699ed589ab 16 #include "SETUP.hpp"
thomasmorris 35:26b0a9b55d82 17 #include "NETWORK.hpp"
thomasmorris 38:8d86e0d8a816 18
thomasmorris 38:8d86e0d8a816 19 #define Do_Read_Data 1
thomasmorris 38:8d86e0d8a816 20 #define Dont_Read_Data 0
thomasmorris 38:8d86e0d8a816 21 #define Do_Delete_Data 1
thomasmorris 38:8d86e0d8a816 22 #define Dont_Delete_Data 0
chills 24:7d2da96e05ad 23
chills 33:3b5096f0126a 24 Mutex Time_Lock_Main;
thomasmorris 38:8d86e0d8a816 25 Mutex Data_Buffer_Lock;
thomasmorris 38:8d86e0d8a816 26
thomasmorris 41:859b5e1e3d9a 27 int Write_Data(DATA Data_Store, int Write_Pointer)//Writes data passed in to the array at address Write Pointer
thomasmorris 38:8d86e0d8a816 28 {
thomasmorris 41:859b5e1e3d9a 29 Data_Buffer_Lock.lock();//Appling lock for critial section
thomasmorris 38:8d86e0d8a816 30 Data_Buffer[Write_Pointer] = Data_Store;
thomasmorris 41:859b5e1e3d9a 31 if(Write_Pointer < mailsize - 1)//Checks if write pointer will be greater than mail size
thomasmorris 38:8d86e0d8a816 32 {
thomasmorris 41:859b5e1e3d9a 33 Write_Pointer = Write_Pointer + 1;//Increment write pointer
thomasmorris 38:8d86e0d8a816 34 }
thomasmorris 38:8d86e0d8a816 35 else
thomasmorris 38:8d86e0d8a816 36 {
thomasmorris 41:859b5e1e3d9a 37 Write_Pointer = 0;//Else set it to 0 thus a FIFO system
thomasmorris 38:8d86e0d8a816 38 }
thomasmorris 41:859b5e1e3d9a 39 Data_Buffer_Lock.unlock();//Releasing lock for critial section
thomasmorris 41:859b5e1e3d9a 40 return Write_Pointer;//New address of Write pointer
thomasmorris 38:8d86e0d8a816 41
thomasmorris 38:8d86e0d8a816 42 }
thomasmorris 38:8d86e0d8a816 43 DATA Read_Data(int Read_Pointer)
thomasmorris 38:8d86e0d8a816 44 {
thomasmorris 41:859b5e1e3d9a 45 Data_Buffer_Lock.lock();//Appling lock for critial section
thomasmorris 38:8d86e0d8a816 46 DATA Temp_Data = Data_Buffer[Read_Pointer];
thomasmorris 41:859b5e1e3d9a 47 Data_Buffer_Lock.unlock();//Releasing lock for critial section
thomasmorris 38:8d86e0d8a816 48
thomasmorris 38:8d86e0d8a816 49 return Temp_Data;
thomasmorris 38:8d86e0d8a816 50 }
thomasmorris 38:8d86e0d8a816 51 void Delete_Data(int Delete_Pointer)
thomasmorris 38:8d86e0d8a816 52 {
thomasmorris 41:859b5e1e3d9a 53 Data_Buffer_Lock.lock();//Appling lock for critial section
thomasmorris 38:8d86e0d8a816 54 Data_Buffer[Delete_Pointer].set_all_zero();
thomasmorris 41:859b5e1e3d9a 55 Data_Buffer_Lock.unlock();//Releasing lock for critial section
thomasmorris 41:859b5e1e3d9a 56 }
thomasmorris 41:859b5e1e3d9a 57
thomasmorris 41:859b5e1e3d9a 58 void SD_Card()//Writes data to the SD card
thomasmorris 41:859b5e1e3d9a 59 {
thomasmorris 41:859b5e1e3d9a 60 while(1)
thomasmorris 41:859b5e1e3d9a 61 {
thomasmorris 42:ae1640bca2e1 62 Thread::wait(Sample_Rate*1000); //Waits until a new is taken before checking again
thomasmorris 42:ae1640bca2e1 63 if(Write_Pointer == mailsize - 1)
thomasmorris 42:ae1640bca2e1 64 {
thomasmorris 42:ae1640bca2e1 65 if(Log_Value==1){cout << "In SD_Card Thread" << endl;}
thomasmorris 41:859b5e1e3d9a 66
thomasmorris 42:ae1640bca2e1 67 //Open to WRITE
thomasmorris 42:ae1640bca2e1 68 FILE* fp = fopen("/sd/test.csv","a");
thomasmorris 42:ae1640bca2e1 69 if(Log_Value==1){cout << "File Opened" << endl;}
thomasmorris 42:ae1640bca2e1 70
thomasmorris 42:ae1640bca2e1 71 for(int SD_Card_Data_Pointer = 0; SD_Card_Data_Pointer != mailsize; SD_Card_Data_Pointer++)
thomasmorris 42:ae1640bca2e1 72 {
thomasmorris 42:ae1640bca2e1 73 time_t Time = Data_Buffer[SD_Card_Data_Pointer].get_time();
thomasmorris 42:ae1640bca2e1 74 tm* Time_Pointer = localtime(&Time);
thomasmorris 42:ae1640bca2e1 75 int temp_day = Time_Pointer->tm_mday;
thomasmorris 42:ae1640bca2e1 76 int temp_month = (Time_Pointer->tm_mon+1);//Set to current month
thomasmorris 42:ae1640bca2e1 77 int temp_year = (Time_Pointer->tm_year+1900);//Set to current year
thomasmorris 42:ae1640bca2e1 78
thomasmorris 42:ae1640bca2e1 79 int temp_hours = Time_Pointer->tm_hour;
thomasmorris 42:ae1640bca2e1 80 int temp_minute = Time_Pointer->tm_min;
thomasmorris 42:ae1640bca2e1 81
thomasmorris 42:ae1640bca2e1 82 float temp_temperature = Data_Buffer[SD_Card_Data_Pointer].get_temperature();
thomasmorris 42:ae1640bca2e1 83 float temp_pressure = Data_Buffer[SD_Card_Data_Pointer].get_pressure();
thomasmorris 42:ae1640bca2e1 84 float temp_light = Data_Buffer[SD_Card_Data_Pointer].get_light();
thomasmorris 42:ae1640bca2e1 85
thomasmorris 42:ae1640bca2e1 86 fprintf(fp, "Date: %d/%d/%d,",temp_day,temp_month,temp_year);//Date
thomasmorris 42:ae1640bca2e1 87 fprintf(fp, "Time: %d:%d,",temp_hours,temp_minute);//Time
thomasmorris 42:ae1640bca2e1 88 fprintf(fp, "Temperature: %1.1f,",temp_temperature);//Temperature
thomasmorris 42:ae1640bca2e1 89 fprintf(fp, "Pressure: %1.1f,",temp_pressure);//Pressure
thomasmorris 42:ae1640bca2e1 90 fprintf(fp, "Light: %5.3f,",temp_light);//Light
thomasmorris 42:ae1640bca2e1 91 fprintf(fp, "End of Data \n");//End of data
thomasmorris 42:ae1640bca2e1 92 }
thomasmorris 42:ae1640bca2e1 93 if(Log_Value==1){cout << "Dumped data to SD Card" <<endl;}
thomasmorris 42:ae1640bca2e1 94 //Close File
thomasmorris 42:ae1640bca2e1 95 fclose(fp);
thomasmorris 42:ae1640bca2e1 96 }
thomasmorris 41:859b5e1e3d9a 97 }
thomasmorris 38:8d86e0d8a816 98 }
chills 43:fb9faec1dc72 99
chills 43:fb9faec1dc72 100 bool Decimal_Check(char Input[100])
chills 43:fb9faec1dc72 101 {
chills 43:fb9faec1dc72 102 for(int x = 0; x < mailsize; x++)
chills 43:fb9faec1dc72 103 {
chills 43:fb9faec1dc72 104 if(Input[x] == '.'){return true;}
chills 43:fb9faec1dc72 105 }
chills 43:fb9faec1dc72 106 return false;
chills 43:fb9faec1dc72 107 }
chills 43:fb9faec1dc72 108
chills 43:fb9faec1dc72 109 int Decimal_Position(char Input[100])
chills 43:fb9faec1dc72 110 {
chills 43:fb9faec1dc72 111 for(int x = 0; x < mailsize; x++)
chills 43:fb9faec1dc72 112 {
chills 43:fb9faec1dc72 113 if(Input[x] == '.'){return x;}
chills 43:fb9faec1dc72 114 }
chills 43:fb9faec1dc72 115 }
chills 43:fb9faec1dc72 116
thomasmorris 35:26b0a9b55d82 117 void Network()
thomasmorris 8:0e4481b64353 118 {
thomasmorris 35:26b0a9b55d82 119 while(1)
thomasmorris 35:26b0a9b55d82 120 {
thomasmorris 41:859b5e1e3d9a 121 Thread::wait(NetworkWait);//Waits Network Wait amount of time
thomasmorris 37:7c4d7f206039 122 if(Log_Value==1){cout << "In Network Thread" << endl;} //Log this
thomasmorris 36:a0098306fc58 123
thomasmorris 36:a0098306fc58 124 time_t Time = Data_Active.get_time();
thomasmorris 36:a0098306fc58 125 tm* Time_Pointer = localtime(&Time);
thomasmorris 36:a0098306fc58 126 int temp_day = Time_Pointer->tm_mday;
thomasmorris 41:859b5e1e3d9a 127 int temp_month = (Time_Pointer->tm_mon+1);//Set to current month
thomasmorris 41:859b5e1e3d9a 128 int temp_year = (Time_Pointer->tm_year+1900);//Set to current year
thomasmorris 36:a0098306fc58 129
thomasmorris 36:a0098306fc58 130 int temp_hours = Time_Pointer->tm_hour;
thomasmorris 36:a0098306fc58 131 int temp_minute = Time_Pointer->tm_min;
thomasmorris 36:a0098306fc58 132
thomasmorris 36:a0098306fc58 133 float temp_temperature = Data_Active.get_temperature();
thomasmorris 36:a0098306fc58 134 float temp_pressure = Data_Active.get_pressure();
thomasmorris 36:a0098306fc58 135 float temp_light = Data_Active.get_light();
thomasmorris 36:a0098306fc58 136
thomasmorris 36:a0098306fc58 137
thomasmorris 41:859b5e1e3d9a 138 Networking(temp_day,temp_month,temp_year,temp_hours,temp_minute,temp_temperature,temp_pressure,temp_light);//Pass in networking data and time values
thomasmorris 35:26b0a9b55d82 139 }
chills 13:db857b3744c6 140 }
thomasmorris 31:4a88bf97b53e 141 void LCD_Write_Year()
thomasmorris 12:536eca338ae8 142 {
thomasmorris 41:859b5e1e3d9a 143 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 144 if(Log_Value == 1){cout<<"In LCD_Write_Year Time lock taken"<<endl;}
chills 33:3b5096f0126a 145 time_t Time = time(NULL);
chills 33:3b5096f0126a 146 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 147 int Years = 1900 + Time_Pointer->tm_year;
thomasmorris 41:859b5e1e3d9a 148 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 149 if(Log_Value == 1){cout<<"In LCD_Write_Year Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 150 stringstream ss;
thomasmorris 31:4a88bf97b53e 151 ss << Years;
thomasmorris 31:4a88bf97b53e 152 string Year_String = ss.str();
thomasmorris 31:4a88bf97b53e 153 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 154 LCD.Write_String("Set Year");
thomasmorris 31:4a88bf97b53e 155 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 156 LCD.Write_String(Year_String);
thomasmorris 30:4cde05cc7c4f 157 }
thomasmorris 31:4a88bf97b53e 158 void LCD_Write_Month()
thomasmorris 31:4a88bf97b53e 159 {
thomasmorris 41:859b5e1e3d9a 160 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 161 if(Log_Value == 1){cout<<"In LCD_Write_Month Time lock taken"<<endl;}
chills 33:3b5096f0126a 162 time_t Time = time(NULL);
chills 33:3b5096f0126a 163 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 164 int Months = 1 + Time_Pointer->tm_mon;
thomasmorris 41:859b5e1e3d9a 165 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 166 if(Log_Value == 1){cout<<"In LCD_Write_Month Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 167 stringstream ss;
thomasmorris 31:4a88bf97b53e 168 ss << Months;
thomasmorris 31:4a88bf97b53e 169 string Month_String = ss.str();
thomasmorris 31:4a88bf97b53e 170 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 171 LCD.Write_String("Set Month");
thomasmorris 31:4a88bf97b53e 172 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 173 LCD.Write_String(Month_String);
thomasmorris 31:4a88bf97b53e 174 }
thomasmorris 31:4a88bf97b53e 175 void LCD_Write_Day()
thomasmorris 31:4a88bf97b53e 176 {
thomasmorris 41:859b5e1e3d9a 177 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 178 if(Log_Value == 1){cout<<"In LCD_Write_Day Time lock taken"<<endl;}
chills 33:3b5096f0126a 179 time_t Time = time(NULL);
chills 33:3b5096f0126a 180 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 181 int Days = Time_Pointer->tm_mday;
thomasmorris 41:859b5e1e3d9a 182 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 183 if(Log_Value == 1){cout<<"In LCD_Write_Day Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 184 stringstream ss;
thomasmorris 31:4a88bf97b53e 185 ss << Days;
thomasmorris 31:4a88bf97b53e 186 string Day_String = ss.str();
thomasmorris 31:4a88bf97b53e 187 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 188 LCD.Write_String("Set Day");
thomasmorris 31:4a88bf97b53e 189 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 190 LCD.Write_String(Day_String);
thomasmorris 31:4a88bf97b53e 191 }
thomasmorris 31:4a88bf97b53e 192 void LCD_Write_Hour()
thomasmorris 30:4cde05cc7c4f 193 {
thomasmorris 41:859b5e1e3d9a 194 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 195 if(Log_Value == 1){cout<<"In LCD_Write_Hour Time lock taken"<<endl;}
chills 33:3b5096f0126a 196 time_t Time = time(NULL);
chills 33:3b5096f0126a 197 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 198 int Hours = Time_Pointer->tm_hour;
thomasmorris 41:859b5e1e3d9a 199 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 200 if(Log_Value == 1){cout<<"In LCD_Write_Hour Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 201 stringstream ss;
thomasmorris 31:4a88bf97b53e 202 ss << Hours;
thomasmorris 31:4a88bf97b53e 203 string Hour_String = ss.str();
thomasmorris 31:4a88bf97b53e 204 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 205 LCD.Write_String("Set Hour");
thomasmorris 31:4a88bf97b53e 206 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 207 LCD.Write_String(Hour_String);
thomasmorris 31:4a88bf97b53e 208 }
thomasmorris 31:4a88bf97b53e 209 void LCD_Write_Minute()
thomasmorris 31:4a88bf97b53e 210 {
thomasmorris 41:859b5e1e3d9a 211 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 212 if(Log_Value == 1){cout<<"In LCD_Write_Minute Time lock taken"<<endl;}
chills 33:3b5096f0126a 213 time_t Time = time(NULL);
chills 33:3b5096f0126a 214 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 215 int Minutes = Time_Pointer->tm_min;
thomasmorris 41:859b5e1e3d9a 216 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 217 if(Log_Value == 1){cout<<"In LCD_Write_Minute Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 218 stringstream ss;
thomasmorris 31:4a88bf97b53e 219 ss << Minutes;
thomasmorris 31:4a88bf97b53e 220 string Minute_String = ss.str();
thomasmorris 31:4a88bf97b53e 221 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 222 LCD.Write_String("Set Minute");
thomasmorris 31:4a88bf97b53e 223 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 224 LCD.Write_String(Minute_String);
thomasmorris 31:4a88bf97b53e 225 }
thomasmorris 31:4a88bf97b53e 226 void LCD_Write_Seconds()
thomasmorris 31:4a88bf97b53e 227 {
thomasmorris 41:859b5e1e3d9a 228 Time_Lock_Main.lock();//Appling lock for critial section
thomasmorris 37:7c4d7f206039 229 if(Log_Value == 1){cout<<"In LCD_Write_Seconds Time lock taken"<<endl;}
chills 33:3b5096f0126a 230 time_t Time = time(NULL);
chills 33:3b5096f0126a 231 tm* Time_Pointer = localtime(&Time);
chills 33:3b5096f0126a 232 int Seconds = Time_Pointer->tm_sec;
thomasmorris 41:859b5e1e3d9a 233 Time_Lock_Main.unlock();//Releasing lock for critial section
thomasmorris 37:7c4d7f206039 234 if(Log_Value == 1){cout<<"In LCD_Write_Seconds Time lock released"<<endl;}
thomasmorris 31:4a88bf97b53e 235 stringstream ss;
thomasmorris 31:4a88bf97b53e 236 ss << Seconds;
thomasmorris 31:4a88bf97b53e 237 string Second_String = ss.str();
thomasmorris 31:4a88bf97b53e 238 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 239 LCD.Write_String("Set Second");
thomasmorris 31:4a88bf97b53e 240 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 241 LCD.Write_String(Second_String);
thomasmorris 7:dfe19413fdc2 242 }
thomasmorris 30:4cde05cc7c4f 243
thomasmorris 30:4cde05cc7c4f 244 void LCD_Output()
chills 34:c0b8705f183d 245 {
thomasmorris 30:4cde05cc7c4f 246 while(1)
thomasmorris 29:64b1f95a807c 247 {
thomasmorris 41:859b5e1e3d9a 248 Thread::wait(10);//Small wait
thomasmorris 30:4cde05cc7c4f 249 if(mode == 0)//Default mode
thomasmorris 30:4cde05cc7c4f 250 {
thomasmorris 37:7c4d7f206039 251 if(Log_Value == 1){cout << "In mode 0 " << endl;}//Log this
chills 33:3b5096f0126a 252
thomasmorris 41:859b5e1e3d9a 253 Thread::wait(Default_Mode_Toggle_Time);//Wait for this amount of time
thomasmorris 37:7c4d7f206039 254 if(Log_Value == 1){cout<<"Writing Data to LCD"<<endl;}
chills 34:c0b8705f183d 255 sprintf (LCD_buffer, "%1.1f %1.1f %1.1f",Data_Active.get_temperature(),Data_Active.get_pressure(),Data_Active.get_light());//Used for converting to a sting
chills 33:3b5096f0126a 256
thomasmorris 30:4cde05cc7c4f 257 LCD.DDRAM_Address(0x00);
thomasmorris 30:4cde05cc7c4f 258 LCD.Write_String("Temp Pres li");
thomasmorris 30:4cde05cc7c4f 259 LCD.DDRAM_Address(0x40);
thomasmorris 41:859b5e1e3d9a 260 LCD.Write_String(LCD_buffer);//Print out current data values to the LCD
thomasmorris 25:36699ed589ab 261
thomasmorris 41:859b5e1e3d9a 262 Thread::wait(Default_Mode_Toggle_Time); //Wait for this amount of time
thomasmorris 37:7c4d7f206039 263 if(Log_Value == 1){cout<<"Writing Time and Date to LCD"<<endl;}
thomasmorris 41:859b5e1e3d9a 264 Time_Lock_Main.lock();//lock Time_lock for critial section
chills 34:c0b8705f183d 265 time_t Time = Data_Active.get_time();
chills 34:c0b8705f183d 266 tm* Time_Pointer = localtime(&Time);
thomasmorris 30:4cde05cc7c4f 267 LCD.Display_Clear();
chills 33:3b5096f0126a 268 sprintf (LCD_buffer, "%d:%d %d,%d",Time_Pointer->tm_hour,Time_Pointer->tm_min,(Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));//Used for converting to a sting
thomasmorris 41:859b5e1e3d9a 269 Time_Lock_Main.unlock();//unlock Time_lock for critial section
chills 33:3b5096f0126a 270
thomasmorris 30:4cde05cc7c4f 271 LCD.DDRAM_Address(0x00);
thomasmorris 30:4cde05cc7c4f 272 LCD.Write_String("Current Time:");
thomasmorris 30:4cde05cc7c4f 273 LCD.DDRAM_Address(0x40);
thomasmorris 41:859b5e1e3d9a 274 LCD.Write_String(LCD_buffer);//Print the current time to the LCD
thomasmorris 31:4a88bf97b53e 275
thomasmorris 37:7c4d7f206039 276 if(Log_Value == 1){cout<<"Checking Switches for next mode"<<endl;}
thomasmorris 31:4a88bf97b53e 277 if(SW1.read() & SW2.read() == 1)
thomasmorris 31:4a88bf97b53e 278 {
thomasmorris 31:4a88bf97b53e 279 mode = 1;
thomasmorris 31:4a88bf97b53e 280 }
thomasmorris 30:4cde05cc7c4f 281 }
thomasmorris 30:4cde05cc7c4f 282 else if(mode == 1)//Choose either date setting or time setting
thomasmorris 30:4cde05cc7c4f 283 {
chills 34:c0b8705f183d 284 if(Log_Value == 1){cout << "In Mode 1" << endl;}
thomasmorris 30:4cde05cc7c4f 285 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 286 while(1)
thomasmorris 31:4a88bf97b53e 287 {
thomasmorris 31:4a88bf97b53e 288 LCD.DDRAM_Address(0x00);
thomasmorris 31:4a88bf97b53e 289 LCD.Write_String("Date Time");
thomasmorris 31:4a88bf97b53e 290 LCD.DDRAM_Address(0x40);
thomasmorris 31:4a88bf97b53e 291 LCD.Write_String("< >");
thomasmorris 31:4a88bf97b53e 292 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 293 if(Log_Value == 1){cout<<"Checking SW1 to go to Date setting"<<endl;}
thomasmorris 37:7c4d7f206039 294 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 295 {
thomasmorris 37:7c4d7f206039 296 mode = 2;//Date Setting
thomasmorris 31:4a88bf97b53e 297 break;
thomasmorris 31:4a88bf97b53e 298 }
thomasmorris 37:7c4d7f206039 299 if(Log_Value == 1){cout<<"Checking SW2 to go to Time setting"<<endl;}
thomasmorris 37:7c4d7f206039 300 if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 301 {
thomasmorris 37:7c4d7f206039 302 mode = 5;//Time Setting
thomasmorris 31:4a88bf97b53e 303 break;
thomasmorris 31:4a88bf97b53e 304 }
thomasmorris 31:4a88bf97b53e 305 }
thomasmorris 30:4cde05cc7c4f 306 }
thomasmorris 30:4cde05cc7c4f 307 else if(mode == 2)//Set the Year
thomasmorris 30:4cde05cc7c4f 308 {
chills 34:c0b8705f183d 309 if(Log_Value == 1){cout << "In Mode 2" << endl;}
thomasmorris 31:4a88bf97b53e 310 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 311 while(1)
thomasmorris 31:4a88bf97b53e 312 {
thomasmorris 32:8f2795716e97 313 LCD_Write_Year();
thomasmorris 31:4a88bf97b53e 314 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 315 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go to Month setting"<<endl;}
chills 33:3b5096f0126a 316 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 317 {
chills 33:3b5096f0126a 318 mode = 3;
chills 33:3b5096f0126a 319 break;
chills 33:3b5096f0126a 320 }
thomasmorris 37:7c4d7f206039 321 if(Log_Value == 1){cout<<"Checking SW1 to add Year"<<endl;}
thomasmorris 31:4a88bf97b53e 322 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 323 {
thomasmorris 31:4a88bf97b53e 324 Add_Year();
thomasmorris 31:4a88bf97b53e 325 }
thomasmorris 37:7c4d7f206039 326 if(Log_Value == 1){cout<<"Checking SW2 to subtract Year"<<endl;}
thomasmorris 31:4a88bf97b53e 327 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 328 {
thomasmorris 31:4a88bf97b53e 329 Subtract_Year();
thomasmorris 31:4a88bf97b53e 330 }
thomasmorris 31:4a88bf97b53e 331 LCD_Write_Year();
thomasmorris 31:4a88bf97b53e 332 }
thomasmorris 30:4cde05cc7c4f 333 }
thomasmorris 30:4cde05cc7c4f 334 else if(mode == 3)//Set the Month
thomasmorris 30:4cde05cc7c4f 335 {
chills 34:c0b8705f183d 336 if(Log_Value == 1){cout << "In Mode 3" << endl;}
thomasmorris 31:4a88bf97b53e 337 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 338 while(1)
thomasmorris 32:8f2795716e97 339 {
thomasmorris 32:8f2795716e97 340 LCD_Write_Month();
thomasmorris 31:4a88bf97b53e 341 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 342 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go to Day setting"<<endl;}
chills 33:3b5096f0126a 343 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 344 {
chills 33:3b5096f0126a 345 mode = 4;
chills 33:3b5096f0126a 346 break;
thomasmorris 37:7c4d7f206039 347 }
thomasmorris 37:7c4d7f206039 348 if(Log_Value == 1){cout<<"Checking SW1 to add Month"<<endl;}
thomasmorris 31:4a88bf97b53e 349 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 350 {
thomasmorris 31:4a88bf97b53e 351 Add_Month();
thomasmorris 31:4a88bf97b53e 352 }
thomasmorris 37:7c4d7f206039 353 if(Log_Value == 1){cout<<"Checking SW2 to subtract Month"<<endl;}
thomasmorris 31:4a88bf97b53e 354 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 355 {
thomasmorris 31:4a88bf97b53e 356 Subtract_Month();
thomasmorris 32:8f2795716e97 357 }
chills 33:3b5096f0126a 358
thomasmorris 31:4a88bf97b53e 359 }
thomasmorris 30:4cde05cc7c4f 360 }
thomasmorris 30:4cde05cc7c4f 361 else if(mode == 4)//Set the Day
thomasmorris 30:4cde05cc7c4f 362 {
chills 34:c0b8705f183d 363 if(Log_Value == 1){cout << "In Mode 4" << endl;}
thomasmorris 31:4a88bf97b53e 364 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 365 while(1)
thomasmorris 32:8f2795716e97 366 {
thomasmorris 32:8f2795716e97 367 LCD_Write_Day();
thomasmorris 31:4a88bf97b53e 368 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 369 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go Default setting"<<endl;}
chills 33:3b5096f0126a 370 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 371 {
chills 33:3b5096f0126a 372 mode = 0;
chills 33:3b5096f0126a 373 break;
chills 33:3b5096f0126a 374 }
thomasmorris 37:7c4d7f206039 375 if(Log_Value == 1){cout<<"Checking SW1 to add Day"<<endl;}
thomasmorris 31:4a88bf97b53e 376 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 377 {
thomasmorris 31:4a88bf97b53e 378 Add_Day();
thomasmorris 31:4a88bf97b53e 379 }
thomasmorris 37:7c4d7f206039 380 if(Log_Value == 1){cout<<"Checking SW2 to subtract Day"<<endl;}
thomasmorris 31:4a88bf97b53e 381 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 382 {
thomasmorris 31:4a88bf97b53e 383 Subtract_Day();
thomasmorris 32:8f2795716e97 384 }
thomasmorris 31:4a88bf97b53e 385 }
thomasmorris 30:4cde05cc7c4f 386 }
thomasmorris 30:4cde05cc7c4f 387 else if(mode == 5)//Set the Hour
thomasmorris 30:4cde05cc7c4f 388 {
chills 34:c0b8705f183d 389 if(Log_Value == 1){cout << "In Mode 5" << endl;}
thomasmorris 31:4a88bf97b53e 390 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 391 while(1)
thomasmorris 31:4a88bf97b53e 392 {
thomasmorris 32:8f2795716e97 393 LCD_Write_Hour();
thomasmorris 32:8f2795716e97 394 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 395 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go Minute setting"<<endl;}
chills 33:3b5096f0126a 396 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 397 {
chills 33:3b5096f0126a 398 mode = 6;
chills 33:3b5096f0126a 399 break;
thomasmorris 37:7c4d7f206039 400 }
thomasmorris 37:7c4d7f206039 401 if(Log_Value == 1){cout<<"Checking SW1 to add Hour"<<endl;}
thomasmorris 31:4a88bf97b53e 402 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 403 {
thomasmorris 31:4a88bf97b53e 404 Add_Hour();
thomasmorris 31:4a88bf97b53e 405 }
thomasmorris 37:7c4d7f206039 406 if(Log_Value == 1){cout<<"Checking SW2 to subtract Hour"<<endl;}
thomasmorris 31:4a88bf97b53e 407 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 408 {
thomasmorris 31:4a88bf97b53e 409 Subtract_Hour();
thomasmorris 31:4a88bf97b53e 410 }
thomasmorris 31:4a88bf97b53e 411 }
thomasmorris 30:4cde05cc7c4f 412 }
thomasmorris 30:4cde05cc7c4f 413 else if(mode == 6)//Set the Minute
thomasmorris 30:4cde05cc7c4f 414 {
chills 34:c0b8705f183d 415 if(Log_Value == 1){cout << "In Mode 6" << endl;}
thomasmorris 31:4a88bf97b53e 416 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 417 while(1)
thomasmorris 31:4a88bf97b53e 418 {
thomasmorris 32:8f2795716e97 419 LCD_Write_Minute();
thomasmorris 32:8f2795716e97 420 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 421 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go Seconds setting"<<endl;}
chills 33:3b5096f0126a 422 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 423 {
chills 33:3b5096f0126a 424 mode = 7;
chills 33:3b5096f0126a 425 break;
chills 33:3b5096f0126a 426 }
thomasmorris 37:7c4d7f206039 427 if(Log_Value == 1){cout<<"Checking SW1 to add Minute"<<endl;}
thomasmorris 31:4a88bf97b53e 428 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 429 {
thomasmorris 31:4a88bf97b53e 430 Add_Minute();
thomasmorris 31:4a88bf97b53e 431 }
thomasmorris 37:7c4d7f206039 432 if(Log_Value == 1){cout<<"Checking SW2 to subtract Minute"<<endl;}
thomasmorris 31:4a88bf97b53e 433 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 434 {
thomasmorris 31:4a88bf97b53e 435 Subtract_Minute();
thomasmorris 32:8f2795716e97 436 }
thomasmorris 31:4a88bf97b53e 437 }
thomasmorris 30:4cde05cc7c4f 438 }
thomasmorris 30:4cde05cc7c4f 439 else if(mode == 7)//Set the Seconds
thomasmorris 30:4cde05cc7c4f 440 {
chills 34:c0b8705f183d 441 if(Log_Value == 1){cout << "In Mode 7" << endl;}
thomasmorris 31:4a88bf97b53e 442 LCD.Display_Clear();
thomasmorris 31:4a88bf97b53e 443 while(1)
thomasmorris 31:4a88bf97b53e 444 {
thomasmorris 32:8f2795716e97 445 LCD_Write_Seconds();
thomasmorris 32:8f2795716e97 446 Thread::wait(1000);
thomasmorris 37:7c4d7f206039 447 if(Log_Value == 1){cout<<"Checking SW1 and SW2 to go Default setting"<<endl;}
chills 33:3b5096f0126a 448 if(SW1.read() & SW2.read() == 1)
chills 33:3b5096f0126a 449 {
chills 33:3b5096f0126a 450 mode = 0;
chills 33:3b5096f0126a 451 break;
thomasmorris 37:7c4d7f206039 452 }
thomasmorris 37:7c4d7f206039 453 if(Log_Value == 1){cout<<"Checking SW1 to add Second"<<endl;}
thomasmorris 31:4a88bf97b53e 454 if(SW1.read() == 1 & SW2.read() == 0)
thomasmorris 31:4a88bf97b53e 455 {
thomasmorris 31:4a88bf97b53e 456 Add_Second();
thomasmorris 31:4a88bf97b53e 457 }
thomasmorris 37:7c4d7f206039 458 if(Log_Value == 1){cout<<"Checking SW1 to subtract Second"<<endl;}
thomasmorris 31:4a88bf97b53e 459 else if(SW2.read() == 1 & SW1.read() == 0)
thomasmorris 31:4a88bf97b53e 460 {
thomasmorris 31:4a88bf97b53e 461 Subtract_Second();
thomasmorris 32:8f2795716e97 462 }
thomasmorris 31:4a88bf97b53e 463 }
thomasmorris 30:4cde05cc7c4f 464 }
thomasmorris 30:4cde05cc7c4f 465 else
thomasmorris 30:4cde05cc7c4f 466 {
thomasmorris 37:7c4d7f206039 467 if(Log_Value == 1){cout<<"Mode Error occured mode now set to 0"<<endl;}
thomasmorris 35:26b0a9b55d82 468 mode = 0;
thomasmorris 7:dfe19413fdc2 469 }
thomasmorris 7:dfe19413fdc2 470 }
thomasmorris 7:dfe19413fdc2 471 }
thomasmorris 29:64b1f95a807c 472 void Serial_Commands()//Used for getting input from the user to determine the opperations to perform
thomasmorris 22:eb4cc12087b2 473 {
thomasmorris 38:8d86e0d8a816 474 char input[100];
thomasmorris 25:36699ed589ab 475 while(1) {
thomasmorris 38:8d86e0d8a816 476
thomasmorris 37:7c4d7f206039 477 if(Log_Value == 1){cout<<"In Serial_Commands"<<endl;}
thomasmorris 38:8d86e0d8a816 478 for (int x = 0; x < 100; x++){input[x] = ' ';};
thomasmorris 38:8d86e0d8a816 479
thomasmorris 37:7c4d7f206039 480 cout << "Please type in a command" << endl;//Log this
chills 34:c0b8705f183d 481
thomasmorris 38:8d86e0d8a816 482 cin.getline(input,sizeof(input),'\r');
thomasmorris 38:8d86e0d8a816 483
thomasmorris 38:8d86e0d8a816 484 //READ ALL FIX THIS
thomasmorris 39:5c499989d2b9 485 if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ' & input[5] == 'A' & input[6] == 'L' & input[7] == 'L')
thomasmorris 22:eb4cc12087b2 486 {
thomasmorris 38:8d86e0d8a816 487 if(Log_Value == 1){cout<<"READ ALL Confirmed"<<endl;}
thomasmorris 39:5c499989d2b9 488
thomasmorris 41:859b5e1e3d9a 489 Data_Buffer_Lock.lock();//Lock data buffer due to critical section
thomasmorris 39:5c499989d2b9 490 int Start_Address_Read_All = Write_Pointer;
thomasmorris 41:859b5e1e3d9a 491 Data_Buffer_Lock.unlock();//unLock data buffer due to critical section
thomasmorris 39:5c499989d2b9 492
thomasmorris 39:5c499989d2b9 493 for(int x_Read_All = (Start_Address_Read_All - mailsize); x_Read_All != Start_Address_Read_All; x_Read_All = x_Read_All )
thomasmorris 39:5c499989d2b9 494 {
thomasmorris 39:5c499989d2b9 495 if(x_Read_All < 0){x_Read_All = x_Read_All + mailsize;}
thomasmorris 39:5c499989d2b9 496 else {x_Read_All = x_Read_All;}
thomasmorris 39:5c499989d2b9 497
thomasmorris 39:5c499989d2b9 498 DATA Serial_Read_Data = Read_Data(x_Read_All);
thomasmorris 39:5c499989d2b9 499
thomasmorris 39:5c499989d2b9 500 time_t Time = Serial_Read_Data.get_time();
thomasmorris 39:5c499989d2b9 501 tm* Time_Pointer = localtime(&Time);
thomasmorris 39:5c499989d2b9 502
thomasmorris 39:5c499989d2b9 503 strftime(scom_time_buffer, 32, "%I:%M %p\t", Time_Pointer); //Format time as a string
thomasmorris 39:5c499989d2b9 504 pc.printf("Date = %d %d %d\t", Time_Pointer->tm_mday, (Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));
thomasmorris 39:5c499989d2b9 505 pc.printf("Time = %s", scom_time_buffer); //Print the string formatted time
thomasmorris 39:5c499989d2b9 506 pc.printf("Temperature = %f\t", Serial_Read_Data.get_temperature()); //Print Temperature
thomasmorris 39:5c499989d2b9 507 pc.printf("Pressure = %f\t", Serial_Read_Data.get_pressure()); //Print Pressure
thomasmorris 39:5c499989d2b9 508 pc.printf("Light = %f\n\r", Serial_Read_Data.get_light()); //Print Light
thomasmorris 39:5c499989d2b9 509
thomasmorris 39:5c499989d2b9 510 if(x_Read_All == mailsize - 1){x_Read_All = 0;}
thomasmorris 39:5c499989d2b9 511 else {x_Read_All = x_Read_All + 1;}
thomasmorris 39:5c499989d2b9 512 }
thomasmorris 38:8d86e0d8a816 513 }
thomasmorris 38:8d86e0d8a816 514
thomasmorris 42:ae1640bca2e1 515 //DELETE ALL FIX THIS - Might need to disable sampling during the delete
thomasmorris 38:8d86e0d8a816 516 else if(input[0] == 'D' & input[1] == 'E' & input[2] == 'L' & input[3] == 'E' & input[4] == 'T' & input[5] == 'E' & input[6] == ' ' & input[7] == 'A' & input[8] == 'L' & input[9] == 'L' & input[10] == ' ')
chills 26:78f5e454e59f 517 {
thomasmorris 38:8d86e0d8a816 518 if(Log_Value == 1){cout<<"DELETE ALL Confirmed"<<endl;}
thomasmorris 42:ae1640bca2e1 519
thomasmorris 42:ae1640bca2e1 520 Data_Buffer_Lock.lock();
thomasmorris 42:ae1640bca2e1 521 int Start_Address = Write_Pointer;
thomasmorris 42:ae1640bca2e1 522 Data_Buffer_Lock.unlock();
thomasmorris 42:ae1640bca2e1 523
thomasmorris 42:ae1640bca2e1 524 for(int x_Delete_All = (Start_Address - mailsize); x_Delete_All != Start_Address; x_Delete_All = x_Delete_All)
thomasmorris 42:ae1640bca2e1 525 {
thomasmorris 42:ae1640bca2e1 526 if(x_Delete_All < 0){x_Delete_All = x_Delete_All + mailsize;}
thomasmorris 42:ae1640bca2e1 527 else {x_Delete_All = x_Delete_All;}
thomasmorris 42:ae1640bca2e1 528
thomasmorris 42:ae1640bca2e1 529 Delete_Data(x_Delete_All);
thomasmorris 42:ae1640bca2e1 530
thomasmorris 42:ae1640bca2e1 531 if(x_Delete_All == mailsize - 1){x_Delete_All = 0;}
thomasmorris 42:ae1640bca2e1 532 else {x_Delete_All = x_Delete_All + 1;}
thomasmorris 42:ae1640bca2e1 533
thomasmorris 42:ae1640bca2e1 534 }
thomasmorris 38:8d86e0d8a816 535 }
thomasmorris 38:8d86e0d8a816 536
thomasmorris 41:859b5e1e3d9a 537 //READ
thomasmorris 38:8d86e0d8a816 538 else if(input[0] == 'R' & input[1] == 'E' & input[2] == 'A' & input[3] == 'D' & input[4] == ' ')
thomasmorris 38:8d86e0d8a816 539 {
thomasmorris 38:8d86e0d8a816 540 int NumberOfChars = 0; int ArrayAddress = 0; string ReadNumber; int NumberToRead;
thomasmorris 38:8d86e0d8a816 541 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 38:8d86e0d8a816 542 for(int x=5; x < NumberOfChars; x++){ReadNumber += input[x];}
thomasmorris 38:8d86e0d8a816 543 stringstream Number(ReadNumber);
thomasmorris 38:8d86e0d8a816 544 Number >> NumberToRead;
thomasmorris 38:8d86e0d8a816 545
thomasmorris 39:5c499989d2b9 546 if(Log_Value == 1){cout<<"Getting Data"<<endl;}
thomasmorris 39:5c499989d2b9 547
thomasmorris 41:859b5e1e3d9a 548 Data_Buffer_Lock.lock();//Lock data buffer due to critical section
thomasmorris 39:5c499989d2b9 549 int Start_Address = Write_Pointer;
thomasmorris 41:859b5e1e3d9a 550 Data_Buffer_Lock.unlock();//unLock data buffer due to critical section
chills 43:fb9faec1dc72 551
thomasmorris 39:5c499989d2b9 552 for(int x = (Start_Address - NumberToRead); x != Start_Address; x = x )
thomasmorris 39:5c499989d2b9 553 {
thomasmorris 39:5c499989d2b9 554 if(x < 0){x = x + mailsize;}
thomasmorris 39:5c499989d2b9 555 else {x = x;}
thomasmorris 39:5c499989d2b9 556
thomasmorris 39:5c499989d2b9 557 DATA Serial_Read_Data = Read_Data(x);
thomasmorris 39:5c499989d2b9 558
thomasmorris 39:5c499989d2b9 559 time_t Time = Serial_Read_Data.get_time();
thomasmorris 39:5c499989d2b9 560 tm* Time_Pointer = localtime(&Time);
thomasmorris 39:5c499989d2b9 561
thomasmorris 39:5c499989d2b9 562 strftime(scom_time_buffer, 32, "%I:%M %p\t", Time_Pointer); //Format time as a string
thomasmorris 39:5c499989d2b9 563 pc.printf("Date = %d %d %d\t", Time_Pointer->tm_mday, (Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));
thomasmorris 39:5c499989d2b9 564 pc.printf("Time = %s", scom_time_buffer); //Print the string formatted time
thomasmorris 39:5c499989d2b9 565 pc.printf("Temperature = %f\t", Serial_Read_Data.get_temperature()); //Print Temperature
thomasmorris 39:5c499989d2b9 566 pc.printf("Pressure = %f\t", Serial_Read_Data.get_pressure()); //Print Pressure
thomasmorris 39:5c499989d2b9 567 pc.printf("Light = %f\n\r", Serial_Read_Data.get_light()); //Print Light
thomasmorris 39:5c499989d2b9 568
thomasmorris 39:5c499989d2b9 569 if(x == mailsize - 1){x = 0;}
thomasmorris 39:5c499989d2b9 570 else {x = x + 1;}
thomasmorris 39:5c499989d2b9 571
thomasmorris 39:5c499989d2b9 572 Green_led.Toggle();
thomasmorris 39:5c499989d2b9 573 }
thomasmorris 39:5c499989d2b9 574 //Serial_Comms_Data_Get();
thomasmorris 38:8d86e0d8a816 575 if(Log_Value == 1){cout << "Read " << NumberToRead << " samples" << endl;}
thomasmorris 38:8d86e0d8a816 576
thomasmorris 25:36699ed589ab 577 }
thomasmorris 38:8d86e0d8a816 578
thomasmorris 42:ae1640bca2e1 579 //DELETE look into this mgiht need to turn off sampling
thomasmorris 38:8d86e0d8a816 580 else if(input[0] == 'D' & input[1] == 'E' & input[2] == 'L' & input[3] == 'E' & input[4] == 'T' & input[5] == 'E' & input[6] == ' ')
thomasmorris 22:eb4cc12087b2 581 {
thomasmorris 38:8d86e0d8a816 582 int NumberOfChars = 0; int ArrayAddress = 0; string DeleteNumber; int NumberToDelete;
thomasmorris 38:8d86e0d8a816 583 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 38:8d86e0d8a816 584 for(int x=7; x < NumberOfChars; x++){DeleteNumber += input[x];}
thomasmorris 38:8d86e0d8a816 585 stringstream Number(DeleteNumber);
thomasmorris 38:8d86e0d8a816 586 Number >> NumberToDelete;
thomasmorris 38:8d86e0d8a816 587
thomasmorris 38:8d86e0d8a816 588 if(Log_Value == 1){cout << "Deleted " << NumberToDelete << " samples" << endl;}
thomasmorris 38:8d86e0d8a816 589
thomasmorris 42:ae1640bca2e1 590 Data_Buffer_Lock.lock();
thomasmorris 42:ae1640bca2e1 591 int Start_Address = Write_Pointer;
thomasmorris 42:ae1640bca2e1 592 Data_Buffer_Lock.unlock();
thomasmorris 42:ae1640bca2e1 593
thomasmorris 42:ae1640bca2e1 594 for(int x_Delete = (Start_Address - NumberToDelete); x_Delete != Start_Address; x_Delete = x_Delete )
thomasmorris 42:ae1640bca2e1 595 {
thomasmorris 42:ae1640bca2e1 596 if(x_Delete < 0){x_Delete = x_Delete + mailsize;}
thomasmorris 42:ae1640bca2e1 597 else {x_Delete = x_Delete;}
thomasmorris 42:ae1640bca2e1 598
thomasmorris 42:ae1640bca2e1 599 Delete_Data(x_Delete);
thomasmorris 42:ae1640bca2e1 600
thomasmorris 42:ae1640bca2e1 601 if(x_Delete == mailsize - 1){x_Delete = 0;}
thomasmorris 42:ae1640bca2e1 602 else {x_Delete = x_Delete + 1;}
thomasmorris 42:ae1640bca2e1 603
thomasmorris 42:ae1640bca2e1 604 }
thomasmorris 42:ae1640bca2e1 605 //Serial_Comms_Data_Get();
thomasmorris 42:ae1640bca2e1 606 if(Log_Value == 1){cout << "Deleted " << NumberToDelete << " samples" << endl;}
thomasmorris 42:ae1640bca2e1 607
chills 34:c0b8705f183d 608 }
thomasmorris 38:8d86e0d8a816 609
thomasmorris 38:8d86e0d8a816 610 //STATE
thomasmorris 38:8d86e0d8a816 611 else if(input[0] == 'S' & input[1] == 'T' & input[2] == 'A' & input[3] == 'T' & input[4] == 'E' & input[5] == ' ')
chills 34:c0b8705f183d 612 {
thomasmorris 38:8d86e0d8a816 613 int NumberOfChars = 0; int ArrayAddress = 0; string StateNumber; int NumberToState;
thomasmorris 38:8d86e0d8a816 614 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 38:8d86e0d8a816 615 for(int x=6; x < NumberOfChars; x++){StateNumber += input[x];}
thomasmorris 38:8d86e0d8a816 616 stringstream Number(StateNumber);
thomasmorris 38:8d86e0d8a816 617 Number >> NumberToState;
thomasmorris 38:8d86e0d8a816 618
thomasmorris 41:859b5e1e3d9a 619 if(NumberToState==0){Sampling_Timer.detach(); Console_Output_Timer.detach();}//Stop Sampling
thomasmorris 41:859b5e1e3d9a 620 if(NumberToState==1){Sampling_Timer.attach(&Sampling_ISR,Sample_Rate);}//Start Sampling
chills 26:78f5e454e59f 621 }
thomasmorris 38:8d86e0d8a816 622
thomasmorris 38:8d86e0d8a816 623 //SETDATE
thomasmorris 38:8d86e0d8a816 624 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'D' & input[4] == 'A' & input[5] == 'T' & input[6] == 'E' & input[7] == ' ' & input[10] == ' ' & input[13] == ' ')
thomasmorris 38:8d86e0d8a816 625 {
thomasmorris 41:859b5e1e3d9a 626 //int NumberOfChars = 0; int ArrayAddress = 0;
thomasmorris 38:8d86e0d8a816 627 string DayNumber, MonthNumber, YearNumber;
thomasmorris 38:8d86e0d8a816 628 int NumberToDay, NumberToMonth, NumberToYear;
thomasmorris 38:8d86e0d8a816 629
thomasmorris 38:8d86e0d8a816 630 for(int x=8; x < 10; x++){DayNumber += input[x];}
thomasmorris 38:8d86e0d8a816 631 stringstream Number_1(DayNumber);
thomasmorris 38:8d86e0d8a816 632 Number_1 >> NumberToDay;
thomasmorris 38:8d86e0d8a816 633
thomasmorris 38:8d86e0d8a816 634 for(int x=11; x < 13; x++){MonthNumber += input[x];}
thomasmorris 38:8d86e0d8a816 635 stringstream Number_2(MonthNumber);
thomasmorris 38:8d86e0d8a816 636 Number_2 >> NumberToMonth;
thomasmorris 38:8d86e0d8a816 637
thomasmorris 38:8d86e0d8a816 638 for(int x=14; x < 18; x++){YearNumber += input[x];}
thomasmorris 38:8d86e0d8a816 639 stringstream Number_3(YearNumber);
thomasmorris 38:8d86e0d8a816 640 Number_3 >> NumberToYear;
thomasmorris 38:8d86e0d8a816 641
thomasmorris 38:8d86e0d8a816 642 set_new_date(NumberToDay,NumberToMonth,NumberToYear);
thomasmorris 38:8d86e0d8a816 643 }
thomasmorris 38:8d86e0d8a816 644
thomasmorris 38:8d86e0d8a816 645 //SETTIME
thomasmorris 38:8d86e0d8a816 646 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'T' & input[4] == 'I' & input[5] == 'M' & input[6] == 'E' & input[7] == ' ' & input[10] == ' ' & input[13] == ' ')
thomasmorris 22:eb4cc12087b2 647 {
thomasmorris 41:859b5e1e3d9a 648 //int NumberOfChars = 0; int ArrayAddress = 0;
thomasmorris 38:8d86e0d8a816 649 string HourNumber, MinuteNumber, SecondNumber;
thomasmorris 38:8d86e0d8a816 650 int NumberToHour, NumberToMinute, NumberToSecond;
thomasmorris 38:8d86e0d8a816 651
thomasmorris 38:8d86e0d8a816 652 for(int x=8; x < 10; x++){HourNumber += input[x];}
thomasmorris 38:8d86e0d8a816 653 stringstream Number_1(HourNumber);
thomasmorris 38:8d86e0d8a816 654 Number_1 >> NumberToHour;
thomasmorris 38:8d86e0d8a816 655
thomasmorris 38:8d86e0d8a816 656 for(int x=11; x < 13; x++){MinuteNumber += input[x];}
thomasmorris 38:8d86e0d8a816 657 stringstream Number_2(MinuteNumber);
thomasmorris 38:8d86e0d8a816 658 Number_2 >> NumberToMinute;
thomasmorris 38:8d86e0d8a816 659
thomasmorris 38:8d86e0d8a816 660 for(int x=14; x < 16; x++){SecondNumber += input[x];}
thomasmorris 38:8d86e0d8a816 661 stringstream Number_3(SecondNumber);
thomasmorris 38:8d86e0d8a816 662 Number_3 >> NumberToSecond;
thomasmorris 38:8d86e0d8a816 663
thomasmorris 38:8d86e0d8a816 664 set_new_time(NumberToHour,NumberToMinute,NumberToSecond);
thomasmorris 38:8d86e0d8a816 665 }
thomasmorris 38:8d86e0d8a816 666
thomasmorris 38:8d86e0d8a816 667 //SETT
thomasmorris 38:8d86e0d8a816 668 else if(input[0] == 'S' & input[1] == 'E' & input[2] == 'T' & input[3] == 'T' & input[4] == ' ')
thomasmorris 38:8d86e0d8a816 669 {
thomasmorris 38:8d86e0d8a816 670
chills 43:fb9faec1dc72 671 int NumberOfChars = 0; int ArrayAddress = 0;
chills 43:fb9faec1dc72 672 string SettNumber; float NumberToSett;
chills 43:fb9faec1dc72 673 int Post_Decimal_Count; int Decimal_Divider = 10;
chills 43:fb9faec1dc72 674 float Sample_Rate_Integer = 0; string Sample_Rate_Integer_String;
chills 43:fb9faec1dc72 675 float Sample_Rate_Decimal = 0; string Sample_Rate_Decimal_String;
thomasmorris 38:8d86e0d8a816 676 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
chills 43:fb9faec1dc72 677
chills 43:fb9faec1dc72 678 if (Decimal_Check(input) == true)
chills 43:fb9faec1dc72 679 {
chills 43:fb9faec1dc72 680 for(int x = 5; x < Decimal_Position(input); x++){Sample_Rate_Integer_String += input[x];}
chills 43:fb9faec1dc72 681 stringstream Number_1(Sample_Rate_Integer_String);
chills 43:fb9faec1dc72 682 Number_1 >> Sample_Rate_Integer;
chills 43:fb9faec1dc72 683
chills 43:fb9faec1dc72 684 for(int x = Decimal_Position(input) + 1; x < NumberOfChars; x++){Sample_Rate_Decimal_String += input[x];}
chills 43:fb9faec1dc72 685 stringstream Number_2(Sample_Rate_Decimal_String);
chills 43:fb9faec1dc72 686 Number_2 >> Sample_Rate_Decimal;
chills 43:fb9faec1dc72 687
chills 43:fb9faec1dc72 688 for(int tens_power = 1; tens_power != NumberOfChars - Decimal_Position(input) - 1; tens_power++)
chills 43:fb9faec1dc72 689 {
chills 43:fb9faec1dc72 690 Decimal_Divider = Decimal_Divider * 10;
chills 43:fb9faec1dc72 691 }
chills 43:fb9faec1dc72 692 NumberToSett = Sample_Rate_Integer + (Sample_Rate_Decimal / float(Decimal_Divider));
chills 43:fb9faec1dc72 693 }
chills 43:fb9faec1dc72 694 else
chills 43:fb9faec1dc72 695 {
chills 43:fb9faec1dc72 696 for(int x=5; x < NumberOfChars; x++){SettNumber += input[x];}
chills 43:fb9faec1dc72 697 stringstream Number_3(SettNumber);
chills 43:fb9faec1dc72 698 Number_3 >> NumberToSett;
chills 43:fb9faec1dc72 699 }
thomasmorris 38:8d86e0d8a816 700
chills 43:fb9faec1dc72 701 if(NumberToSett > 0){Sample_Rate = NumberToSett;}
chills 26:78f5e454e59f 702
chills 26:78f5e454e59f 703 Sampling_Timer.detach();
chills 26:78f5e454e59f 704 Console_Output_Timer.detach();
chills 26:78f5e454e59f 705 Sampling_Timer.attach(&Sampling_ISR,Sample_Rate);
thomasmorris 38:8d86e0d8a816 706 }
thomasmorris 38:8d86e0d8a816 707
thomasmorris 38:8d86e0d8a816 708 //LOGGING
thomasmorris 38:8d86e0d8a816 709 else if(input[0] == 'L' & input[1] == 'O' & input[2] == 'G' & input[3] == 'G' & input[4] == 'I' & input[5] == 'N' & input[6] == 'G' & input[7] == ' ')
thomasmorris 38:8d86e0d8a816 710 {
thomasmorris 38:8d86e0d8a816 711 int NumberOfChars = 0; int ArrayAddress = 0; string LoggingNumber; int NumberToLogging;
thomasmorris 38:8d86e0d8a816 712 while(input[ArrayAddress] != '\0'){NumberOfChars++; ArrayAddress++;}
thomasmorris 38:8d86e0d8a816 713 for(int x=8; x < NumberOfChars; x++){LoggingNumber += input[x];}
thomasmorris 38:8d86e0d8a816 714 stringstream Number(LoggingNumber);
thomasmorris 38:8d86e0d8a816 715 Number >> NumberToLogging;
thomasmorris 38:8d86e0d8a816 716
thomasmorris 38:8d86e0d8a816 717 cout << "Successfully entered logging" << endl;
thomasmorris 38:8d86e0d8a816 718 cout << NumberToLogging << endl;
thomasmorris 38:8d86e0d8a816 719 Log_Value = NumberToLogging;
thomasmorris 25:36699ed589ab 720 }
thomasmorris 38:8d86e0d8a816 721
thomasmorris 38:8d86e0d8a816 722 //HELP
thomasmorris 38:8d86e0d8a816 723 else if(input[0] == 'H' & input[1] == 'E' & input[2] == 'L' & input[3] == 'P')// Use this to display all of the availble commands
thomasmorris 25:36699ed589ab 724 {
thomasmorris 41:859b5e1e3d9a 725 HELP();//Run HELP Command
thomasmorris 22:eb4cc12087b2 726 }
thomasmorris 38:8d86e0d8a816 727
thomasmorris 38:8d86e0d8a816 728 //STOP
thomasmorris 38:8d86e0d8a816 729 else if(input[0] == 'S' & input[1] == 'T' & input[2] == 'O' & input[3] == 'P')
chills 26:78f5e454e59f 730 {
thomasmorris 28:09b5c46c8afd 731 Console_Output_Timer.detach(); //Stops Sampling
chills 26:78f5e454e59f 732 }
thomasmorris 25:36699ed589ab 733 else
thomasmorris 22:eb4cc12087b2 734 {
chills 26:78f5e454e59f 735 cout << "Please enter an acceptable command" << endl;
thomasmorris 22:eb4cc12087b2 736 }
thomasmorris 22:eb4cc12087b2 737 }
thomasmorris 22:eb4cc12087b2 738 }
thomasmorris 38:8d86e0d8a816 739 void Serial_Comms_Data_Get()
thomasmorris 29:64b1f95a807c 740 {
thomasmorris 37:7c4d7f206039 741 if(Log_Value == 1){cout<<"Getting Data"<<endl;}
chills 34:c0b8705f183d 742 time_t Time = Data_Active.get_time();
chills 34:c0b8705f183d 743 tm* Time_Pointer = localtime(&Time);
chills 34:c0b8705f183d 744 strftime(scom_time_buffer, 32, "%I:%M %p\t", Time_Pointer); //Format time as a string
chills 34:c0b8705f183d 745 pc.printf("Date = %d %d %d\t", Time_Pointer->tm_mday, (Time_Pointer->tm_mon+1),(Time_Pointer->tm_year+1900));
chills 34:c0b8705f183d 746 pc.printf("Time = %s", scom_time_buffer); //Print the string formatted time
chills 34:c0b8705f183d 747 pc.printf("Temperature = %f\t", Data_Active.get_temperature()); //Print Temperature
chills 34:c0b8705f183d 748 pc.printf("Pressure = %f\t", Data_Active.get_pressure()); //Print Pressure
chills 34:c0b8705f183d 749 pc.printf("Light = %f\n\r", Data_Active.get_light()); //Print Light
thomasmorris 29:64b1f95a807c 750
thomasmorris 29:64b1f95a807c 751 Green_led.Toggle();
chills 34:c0b8705f183d 752
thomasmorris 29:64b1f95a807c 753 }
thomasmorris 5:2594b953f111 754
thomasmorris 41:859b5e1e3d9a 755 void Sampling_ISR(){t1.signal_set(SamplingTime);}
chills 26:78f5e454e59f 756
chills 26:78f5e454e59f 757
thomasmorris 5:2594b953f111 758 void Sample()//Samples the hardware and prints the result to the LCD
thomasmorris 5:2594b953f111 759 {
thomasmorris 30:4cde05cc7c4f 760 while(1)
thomasmorris 30:4cde05cc7c4f 761 {
chills 10:46946784326d 762 Thread::signal_wait(SamplingTime); //Set the time between samples
thomasmorris 37:7c4d7f206039 763 if(Log_Value == 1){cout<<"Sample Time"<<endl;}
chills 34:c0b8705f183d 764 Data_Active.set_temperature(sensor.getTemperature()); //Read Temperature
chills 34:c0b8705f183d 765 Data_Active.set_pressure(sensor.getPressure()); //Read Pressure
chills 34:c0b8705f183d 766 Data_Active.set_light(adcIn.read()); //Read Light
chills 33:3b5096f0126a 767
chills 33:3b5096f0126a 768 Time_Lock_Main.lock();
chills 34:c0b8705f183d 769 time_t buffer_time = time(NULL);
chills 33:3b5096f0126a 770 Time_Lock_Main.unlock();
thomasmorris 25:36699ed589ab 771
chills 34:c0b8705f183d 772 Data_Active.set_time(buffer_time);
thomasmorris 25:36699ed589ab 773
chills 44:e0eac2382810 774 Red_led.flash(0.02);
thomasmorris 39:5c499989d2b9 775 Write_Pointer = Write_Data(Data_Active,Write_Pointer);
thomasmorris 5:2594b953f111 776 t1.signal_set(NotSamplingTime);
thomasmorris 37:7c4d7f206039 777 if(Log_Value == 1){cout<<"New Sample avaliable"<<endl;}
thomasmorris 41:859b5e1e3d9a 778 t2.signal_set(SD_Data_Ready);
thomasmorris 5:2594b953f111 779 }
thomasmorris 25:36699ed589ab 780 }
thomasmorris 25:36699ed589ab 781 int main()
thomasmorris 25:36699ed589ab 782 {
thomasmorris 37:7c4d7f206039 783 set_time(1515352584); //Set RTC time to December 10 2017
thomasmorris 30:4cde05cc7c4f 784
chills 10:46946784326d 785 pc.baud(9600); //Sets the Serial Comms Baud Rate
thomasmorris 25:36699ed589ab 786
chills 20:cbb71f84cff9 787 LCD.Initialise();
thomasmorris 28:09b5c46c8afd 788 LCD.DDRAM_Address(0x00);
thomasmorris 29:64b1f95a807c 789
chills 43:fb9faec1dc72 790 /*
thomasmorris 25:36699ed589ab 791 post(); //Power on Self Test
thomasmorris 25:36699ed589ab 792
noutram 3:a88838ff33e7 793 //Initialise the SD card (this needs to move)
noutram 1:e1cf7663f5ff 794 if ( sd.init() != 0) {
noutram 1:e1cf7663f5ff 795 printf("Init failed \n");
thomasmorris 28:09b5c46c8afd 796 LCD.Display_Clear();
thomasmorris 28:09b5c46c8afd 797 LCD.Write_String("CANNOT INIT SD"); //Change me
noutram 1:e1cf7663f5ff 798 errorCode(FATAL);
thomasmorris 25:36699ed589ab 799 }
noutram 1:e1cf7663f5ff 800 //Create a filing system for SD Card
thomasmorris 25:36699ed589ab 801 FATFileSystem fs("sd", &sd);
noutram 0:36e89e3ed7c4 802
noutram 1:e1cf7663f5ff 803 //Open to WRITE
thomasmorris 41:859b5e1e3d9a 804 FILE* fp = fopen("/sd/test.csv","a");//test.csv is created in the SD Card
noutram 1:e1cf7663f5ff 805 if (fp == NULL) {
noutram 1:e1cf7663f5ff 806 error("Could not open file for write\n");
thomasmorris 28:09b5c46c8afd 807 LCD.Display_Clear();
thomasmorris 37:7c4d7f206039 808 LCD.Write_String("CANNOT OPEN FILE");
noutram 1:e1cf7663f5ff 809 errorCode(FATAL);
noutram 1:e1cf7663f5ff 810 }
thomasmorris 41:859b5e1e3d9a 811 //Close File
thomasmorris 41:859b5e1e3d9a 812 fclose(fp);
thomasmorris 37:7c4d7f206039 813 int network_temp;
thomasmorris 37:7c4d7f206039 814 network_temp = Network_Init();
thomasmorris 37:7c4d7f206039 815 if(network_temp == 1)//Sets up the network and checks if the network cable is not pluged in
thomasmorris 37:7c4d7f206039 816 {
thomasmorris 37:7c4d7f206039 817 error("Could not access network");
thomasmorris 37:7c4d7f206039 818 LCD.Display_Clear();
thomasmorris 37:7c4d7f206039 819 LCD.Write_String("Could not access network");
thomasmorris 41:859b5e1e3d9a 820 errorCode(NETWORK_FATAL);
thomasmorris 37:7c4d7f206039 821 }
noutram 3:a88838ff33e7 822 //Last message before sampling begins
chills 43:fb9faec1dc72 823 */
thomasmorris 28:09b5c46c8afd 824 LCD.Display_Clear();
thomasmorris 35:26b0a9b55d82 825 LCD.Write_String("READY PLAYER");
thomasmorris 31:4a88bf97b53e 826 LCD.DDRAM_Address(0x40);
thomasmorris 35:26b0a9b55d82 827 LCD.Write_String(" One ");
thomasmorris 31:4a88bf97b53e 828 LCD.DDRAM_Address(0x00);
thomasmorris 25:36699ed589ab 829
thomasmorris 25:36699ed589ab 830 Sample_Rate = TimerInterval;
chills 24:7d2da96e05ad 831 //Run interrupt
chills 26:78f5e454e59f 832 Sampling_Timer.attach(&Sampling_ISR,Sample_Rate);
chills 24:7d2da96e05ad 833
thomasmorris 5:2594b953f111 834 t1.start(Sample);
chills 44:e0eac2382810 835 //t2.start(SD_Card);
thomasmorris 30:4cde05cc7c4f 836 t3.start(LCD_Output);
chills 43:fb9faec1dc72 837 //t4.start(Network);
thomasmorris 23:3c85d7f657a2 838 t5.start(Serial_Commands);
thomasmorris 25:36699ed589ab 839
thomasmorris 5:2594b953f111 840 //Main thread ID
thomasmorris 25:36699ed589ab 841
thomasmorris 5:2594b953f111 842 idMain = osThreadGetId(); //CMSIS RTOS call
thomasmorris 25:36699ed589ab 843
thomasmorris 5:2594b953f111 844 //Thread ID
thomasmorris 5:2594b953f111 845 id1 = t1.gettid();
thomasmorris 5:2594b953f111 846 id2 = t2.gettid();
thomasmorris 21:3c078c799caa 847 id3 = t3.gettid();
thomasmorris 21:3c078c799caa 848 id4 = t4.gettid();
chills 24:7d2da96e05ad 849 id5 = t5.gettid();
chills 43:fb9faec1dc72 850
noutram 1:e1cf7663f5ff 851 while(true) {
thomasmorris 41:859b5e1e3d9a 852 if(onBoardSwitch == 1)
thomasmorris 41:859b5e1e3d9a 853 {
chills 43:fb9faec1dc72 854 //fclose(fp);//Close File
chills 43:fb9faec1dc72 855 //sd.deinit();//Close down
thomasmorris 41:859b5e1e3d9a 856 LCD.Display_Clear();
thomasmorris 41:859b5e1e3d9a 857 LCD.DDRAM_Address(0x00);
thomasmorris 41:859b5e1e3d9a 858 LCD.Write_String("SD Card");
thomasmorris 41:859b5e1e3d9a 859 LCD.DDRAM_Address(0x40);
thomasmorris 41:859b5e1e3d9a 860 LCD.Write_String("Unmounted");
thomasmorris 41:859b5e1e3d9a 861 LCD.DDRAM_Address(0x00);
thomasmorris 41:859b5e1e3d9a 862 cout << "SD Card Unmounted" << endl;
thomasmorris 41:859b5e1e3d9a 863 }
chills 43:fb9faec1dc72 864
noutram 1:e1cf7663f5ff 865 greenLED = 1;
noutram 1:e1cf7663f5ff 866 wait(0.5);
noutram 1:e1cf7663f5ff 867 greenLED = 0;
thomasmorris 25:36699ed589ab 868 wait(0.1);
noutram 0:36e89e3ed7c4 869 }
thomasmorris 41:859b5e1e3d9a 870 }//End of Main