Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

text file a added parts of the problem The universities un-manned drone initiati

ID: 674062 • Letter: T

Question

text file a

added parts of the problem

The universities un-manned drone initiative has exploded in popularity, and there are drones everywhere. EVERYWHERE! In response, a standard transmission format has been established for drone communications. This project involves designing solutions to implementing the functions in a c++ program to validate and process a file transmission in this new format. The input file contains information from the drone, including identifying info, locality coordinates, and a series of paired data values. Your solution will process and output this data in the required formats as shown below. The new standard transmission format is detailed below on input. That is followed by a section on the required output and formatting. Example input and output is provided to demonstrate the solution requirements. You should read this document and examine the source code files and input files repeatedly to understand this assignment. The input file holds an initial line of data (fifty characters long) containing all of the drone information. This is referred to as the Drone Upload Message Packet, or DUMP. Immediately following the DUMP, are fifteen pairs of data values similar to the data processed in project one....

Explanation / Answer

/*

*/

/*

Data File with 3 sets of Drone data:

1234567790DroaneBeeDro1234567DO1.12.23.34.45.56.6U
0.0   123.5   0.1   147.0   0.2   148.3
0.3   157.9   0.4   163.2   0.5   258.2
0.6   223.2   0.7   247.1   0.8   248.8
0.9   257.6   1.0   363.7   1.1   398.1
1.2   417.3   1.3   383.4   1.4   378.5
1574562399DroaeBeeXCom1234569AP7.79.91.12.23.34.4U
0.0   123.5   0.1   147.0   0.2   148.3
0.3   157.9   0.4   163.2   0.5   258.2
0.6   223.2   0.7   247.1   0.8   248.8
0.9   257.6   1.0   363.7   1.1   398.1
1.2   417.3   1.3   383.4   1.4   378.5
1234567790SwingletCamD12345712BQ5.56.67.79.91.12.2U
0.0   123.5   0.1   147.0   0.2   148.3
0.3   157.9   0.4   163.2   0.5   258.2
0.6   223.2   0.7   247.1   0.8   248.8
0.9   257.6   1.0   363.7   1.1   398.1
1.2   417.3   1.3   383.4   1.4   378.5


*/

// variables:

// declare file pointer(s)
// FILE *fp1;
// declare all the variable as per the drone format given in the question

/*
char secCd [10];   // secCd = security Code
char drNm[12];    // drone name
int serNum;   // serial Number
char flStat;   // fligh Status one char long
char mR;        // mR = mission Role one char long
float   x1,y1,z1,x2,y2,z2;    coordinates of aircraft and home base
char arm;       // arm = U => unarmed, A=> armed, single char long
float label,array[30];   // the pairs of data following the drone header

*/
// label runs from 0.0, 0.1, etc up to 1.4
// array[nonLabelElements] stores 15 values from 123.5 to 378.5
// array[30] stores 15 labels and 15 values as paired in the data file
// similar to a name value pairs - a typical data storage tactics or techniques
/*
array[0] = 0.0, array[1] = 123.5
array[2] = 0.1, array[3] = 147.0
array[4] = 0.2, array[5] = 148.3
array[6] = 0.3, array[7] = 157.9
array[8] = 0.4, array[9] = 163.2
array[10] = 0.5, array[11] = 258.2
array[12] = 0.6, array[13] = 223.2
float label = 0.0;
for(i=0;i<=30;i++)
array[i] =
*/

/*

// open the file(s)
fp1 = fopen("E:/Files/drone.txt","r");

*/

// read the data contents in the file

// now to the source code:


/*drone*/

#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>   // input output filestream
#include <fstream.h>       // file stream
#include <conio.h>       // for clear screen clrscr()
#include <string.h>       // character and String handling functions
#include <iomanip.h>   // input output manipulations header file

void funcValidate()   {   // validation function
int i=0,j=0,k;    // index variables
float array[30]; // , actualPairValuesFormat[30], expectedPairValuesFormat[30];
   char expectedHeaderFormat[50];
   char expectedPairValuesFormat[30];

   char actualHeaderFormat[50];
   char actualPairValuesFormat[30];

array[0] = 0.0; array[1] = 123.5;
array[2] = 0.1; array[3] = 147.0;
array[4] = 0.2; array[5] = 148.3;
array[6] = 0.3; array[7] = 157.9;
array[8] = 0.4; array[9] = 163.2;
array[10] = 0.5; array[11] = 258.2;
array[12] = 0.6; array[13] = 223.2;

for (i = 0; i<=29; i++)  
   actualPairValuesFormat[i] = array[i];
cout << " File Contents: ";
for (i = 0; i<=29; i++)       {
   cout << " Label: " << array[i] ;
   cout << " Value: " << array[i];
   cout << endl;
   }   // end for

for (i = 0; i<=49; i++)  
   if (expectedHeaderFormat[i] == actualHeaderFormat[i] ) { ; }   // DO NOTHING
   else   { cout << " Format mismatch in header "; exit(0); } // end else // exit function
for (i = 0; i<=29; i++)  
   if ( expectedPairValuesFormat[j] == actualPairValuesFormat[j++] ) { ; }   // do nothing
   else   { cout << " Format mismatch in labels and values pairs "; exit(0); } // end else
cout << " Format OK ";
// } // end for i
} // end function funcValidate()
/* void funcTransmitFile()   {   // file transmission function
   cout << " File Transmission Function ";
} // end function funcTransmitFile() */

int main()   {
// declare file pointer(s)
FILE *fp1;
// declare all the variable as per the drone format given in the question
char secCd [10];   // secCd = security Code
char drNm[12];    // drone name
int serNum, i;   // serial Number; i = index variable
char flStat;   // fligh Status one char long
char mR;        // mR = mission Role one char long
float   x1,y1,z1,x2,y2,z2;    // coordinates of aircraft and home base
char arm;       // arm = U => unarmed, A=> armed, single char long
float label=0.0,value=0.0, array[30];   // the pairs of data following the drone header
// label runs from 0.0, 0.1, etc up to 1.4
// array[nonLabelElements] stores 15 values from 123.5 to 378.5
// array[30] stores 15 labels and 15 values as paired in the data file
// similar to a name value pairs - a typical data storage tactics or techniques
/*
array[0] = 0.0, array[1] = 123.5
array[2] = 0.1, array[3] = 147.0
array[4] = 0.2, array[5] = 148.3
array[6] = 0.3, array[7] = 157.9
array[8] = 0.4, array[9] = 163.2
array[10] = 0.5, array[11] = 258.2
array[12] = 0.6, array[13] = 223.2
array[evenIndex] = label, array[oddIndex] = value
label = 0.0;
for(i=0;i<=29;i++)
if (i%2 == 0) {
   label += 0.1;   // 0.1, 0.2, 0.3, etc up to 1.4
   array[i] = label;
} // end if
*/
clrscr();
// open the file(s)
fp1 = fopen("E:/Files/drone.txt","r");
cout << " File contents: ";
// read the data contents in the file
/*
for(i=0;i<=30;i++)   {
   fscanf(fp1, "%f %f", &label, &value);
   if ( feof(fp1) ) break;
   cout << " Label: " << label << " Value: " << value;
} // end for i to read file      
*/
funcValidate();
// close the file stream(s)
fclose(fp1);
return 0;
} // end main