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.
UserInput.cpp
00001 #include "UserInput.h" 00002 #include "mbed.h" 00003 #include "stdio.h" 00004 #include <stdlib.h> 00005 #include <string> 00006 00007 00008 extern Serial pc; 00009 extern LocalFileSystem local; 00010 00011 00012 //this class pulls variables that the user has inputed 00013 00014 //Companys name 00015 //there name is on the 1st line of details.txt 00016 //it returns an string 00017 string UserInput::company(){ 00018 00019 char Company[100]; 00020 00021 FILE *p1UI = fopen ("/local/details.txt" , "r"); 00022 if (p1UI == NULL){ 00023 pc.printf("Error opening file"); 00024 }else { 00025 fgets (Company, 100 , p1UI); 00026 fclose (p1UI); 00027 } 00028 return Company; 00029 } 00030 00031 00032 //the name of the companys pipe 00033 //the name is on the 2rd line of details.txt 00034 //it returns string 00035 string UserInput::pipeName(){ 00036 00037 char PipeName[100]; 00038 00039 FILE *p2UI = fopen ("/local/details.txt" , "r"); 00040 if (p2UI == NULL){ 00041 pc.printf("Error opening file"); 00042 }else { 00043 for(int i = 0; i < 2; i++){ 00044 fgets (PipeName, 100 , p2UI); 00045 } 00046 fclose (p2UI); 00047 } 00048 return PipeName; 00049 } 00050 00051 //number of sensors for bending 00052 //the value for the number of sensors is on the 3rd line of details.txt 00053 //it returns int 00054 int UserInput::numberOfSensorsB(){ 00055 00056 char NoOfSensorB_S[100]; 00057 int NoOfSensorB; 00058 00059 FILE *p3UI = fopen ("/local/details.txt" , "r"); 00060 if (p3UI == NULL){ 00061 pc.printf("Error opening file"); 00062 }else { 00063 for(int i = 0; i < 3; i++){ 00064 fgets (NoOfSensorB_S, 100 , p3UI); 00065 NoOfSensorB = atoi(NoOfSensorB_S); 00066 } 00067 fclose (p3UI); 00068 } 00069 return NoOfSensorB; 00070 } 00071 00072 00073 //distance between sensors for bending 00074 //the value for the distance is on the 4th line of details.txt 00075 //it returns the value at a floating point number 00076 float UserInput::distanceB(){ 00077 00078 char DistanceB_S[100]; 00079 double DistanceB; 00080 00081 FILE *p4UI = fopen ("/local/details.txt" , "r"); 00082 if (p4UI == NULL){ 00083 pc.printf("Error openingfile"); 00084 }else { 00085 for(int i = 0; i < 4; i++){ 00086 fgets (DistanceB_S, 100 , p4UI); 00087 DistanceB = atof(DistanceB_S); 00088 } 00089 fclose (p4UI); 00090 } 00091 return DistanceB; 00092 } 00093 00094 00095 //number of sensors for straiting 00096 //the value for the number of sensors is on the 5th line of details.txt 00097 //it returns the int 00098 int UserInput::numberOfSensorsS(){ 00099 00100 char NoOfSensorS_S[100]; 00101 int NoOfSensorS; 00102 00103 FILE *p5UI = fopen ("/local/details.txt" , "r"); 00104 if (p5UI == NULL){ 00105 pc.printf("Error opening file"); 00106 }else { 00107 for(int i = 0; i < 5; i++){ 00108 fgets (NoOfSensorS_S, 100 , p5UI); 00109 NoOfSensorS = atoi(NoOfSensorS_S); 00110 } 00111 fclose (p5UI); 00112 } 00113 return NoOfSensorS; 00114 } 00115 00116 00117 //distance between sensors for straiting 00118 //the valuse for the distance in on the 6th line of details.txt 00119 //it returns the value at a floating point number 00120 float UserInput::distanceS(){ 00121 00122 char DistanceS_S[100]; 00123 double DistanceS; 00124 00125 FILE *p6UI = fopen ("/local/details.txt" , "r"); 00126 if (p6UI == NULL){ 00127 pc.printf("Error opening file"); 00128 }else { 00129 for(int i = 0; i < 6; i++){ 00130 fgets (DistanceS_S, 100 , p6UI); 00131 DistanceS = atof(DistanceS_S); 00132 } 00133 fclose (p6UI); 00134 } 00135 return DistanceS; 00136 }
Generated on Sat Jul 23 2022 19:08:16 by
