int main() { //Do something int desArray[size];//Our Descending numbers to sort int myArray[size];//Array for working with stuff char choice = '0'; while (choice != '1'){ UserMenu(&choice); switch(choice){ case '2': PopulateArrayDes(myArray);break; case '3': CopyArrays(desArray,myArray);break; case '4': DisplayArray10Items(myArray);break; case '5': ShellSortAsc(myArray);break; case '6': ShellSortAsc(myArray);break; case '7': CalculateTimeSS(myArray);break; case '8': CalculateTimeSS(myArray);break; }//switch }//while ExitProg(); return 0; }
//---------------------------------------------------------------------- // This is the Main routine for thermoms. // int main(int argc, char **argv) { int Fahrenheit=FALSE,num,i,j; char str[800]; ThermoStateType ThermoState; uchar ThermoSN[MAXDEVICES][8]; //the serial numbers for the devices int portnum=0; // check arguments to see if request instruction with '?' or too many if ((argc < 2) || (argc > 3) || ((argc > 1) && (argv[1][0] == '?' || argv[1][1] == '?'))) ExitProg("\nusage: thermoms 1wire_net_name </Fahrenheit>\n" " - Thermochron configuration on the 1-Wire Net port\n" " - 1wire_net_port required port name\n" " example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" \n" " (Linux DS2480),\"{1,5}\" (Win32 TMEX)\n" " - </Fahrenheit> optional Fahrenheit mode (default Celsius)\n" " - version 2.00\n",1); // attempt to acquire the 1-Wire Net if((portnum = owAcquireEx(argv[1])) < 0) { OWERROR_DUMP(stdout); exit(1); } // success printf("Port opened: %s\n",argv[1]); //---------------------------------------- // Introduction printf("\n/---------------------------------------------\n"); printf(" Find and mission DS1921 Thermochron iButton(s)\n" " Version 2.00\n\n"); // check arguments Fahrenheit = FALSE; if (argc >= 3) { if ((argv[2][0] == '/') && ((argv[2][1] == 'F') || (argv[2][1] == 'f'))) Fahrenheit = TRUE; } // get list of Thermochron's num = FindDevices(portnum, &ThermoSN[0],THERMO_FAM, MAXDEVICES); // check if not present or more then 1 present if (num == 0) ExitProg("Thermochron not present on 1-Wire\n",1); // loop to mission each Thermochron for (i = 0; i < num; i++) { // set the serial number portion in the thermo state printf("\nRead status of Thermochron: "); for (j = 7; j >= 0; j--) { ThermoState.MissStat.serial_num[j] = ThermoSN[i][j]; printf("%02X",ThermoSN[i][j]); } printf("\n"); // read Thermochron state if (ReadThermoStatus(portnum,&ThermoSN[i][0],&ThermoState,stdout)) { // display mission status InterpretStatus(&ThermoState.MissStat); MissionStatusToString(&ThermoState.MissStat, Fahrenheit, &str[0]); printf("\n%s\n",str); // ask user mission questions if (!InputMissionType(&ThermoState,Fahrenheit)) { printf("Input abort\n"); continue; } GAMEOVER(); // run the script to display the thermochron if (MissionThermo(portnum,&ThermoSN[i][0],&ThermoState,stdout)) { // read Thermochron state if (ReadThermoStatus(portnum,&ThermoSN[i][0],&ThermoState,stdout)) { // display the new mission status InterpretStatus(&ThermoState.MissStat); MissionStatusToString(&ThermoState.MissStat, Fahrenheit, &str[0]); printf("\n%s\n",str); } else printf("ERROR reading Thermochon state\n"); } else printf("ERROR, Thermochon missioning not complete\n"); } else printf("ERROR reading Thermochon state\n"); } // release the 1-Wire Net owRelease(portnum); printf("\nClosing port %s.\n", argv[1]); printf("End program normally\n"); exit(0); return 0; }
//---------------------------------------------------------------------- // This is the Main routine for thermodl. // int main() //short argc, char **argv) { int Fahrenheit=FALSE,filenum,num,i,j; char return_msg[128]; FILE *fp; ThermoStateType ThermoState; uchar ThermoSN[MAXDEVICES][8]; //the serial numbers for the devices int portnum=0; // check arguments to see if request instruction with '?' or too many if ((argc < 2) || (argc > 4) || ((argc > 1) && (argv[1][0] == '?' || argv[1][1] == '?'))) ExitProg("\nusage: thermodl 1wire_net_name <output_filename> </Fahrenheit>\n" " - Thermochron download on the 1-Wire Net port\n" " - 1wire_net_port required port name\n" " example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" \n" " (Linux DS2480),\"1\" (Win32 TMEX)\n" " - <output_filename> optional output filename\n" " - </Fahrenheit> optional Fahrenheit mode (default Celsius)\n" " - version 2.00\n",1); // attempt to acquire the 1-Wire Net if (!owAcquire(portnum,argv[1],return_msg)) ExitProg(return_msg,1); // success printf("%s",return_msg); //---------------------------------------- // Introduction printf("\n/----------------------------------------------\n"); printf(" Find and download DS1921 Thermochron iButton(s)\n" " Version 2.00\n\n"); // check arguments for temperature conversion and filename Fahrenheit = FALSE; filenum = 0; if (argc >= 3) { if (argv[2][0] != '/') filenum = 2; else if ((argv[2][1] == 'F') || (argv[2][1] == 'f')) Fahrenheit = TRUE; if (argc == 4) { if (argv[3][0] != '/') filenum = 3; else if ((argv[3][1] == 'F') || (argv[3][1] == 'f')) Fahrenheit = TRUE; } } // open the output file fp = NULL; if (filenum > 0) { fp = fopen(argv[filenum],"w+"); if(fp == NULL) { printf("ERROR, Could not open output file!\n"); exit(1); } else printf("File '%s' opened to write mission results.\n", argv[filenum]); } // get list of Thermochron's num = FindDevices(portnum, &ThermoSN[0],THERMO_FAM, MAXDEVICES); // check if not present or more then 1 present if (num == 0) ExitProg("Thermochron not present on 1-Wire\n",1); // loop to download each Thermochron for (i = 0; i < num; i++) { // set the serial number portion in the thermo state printf("\nDownloading: "); for (j = 7; j >= 0; j--) { ThermoState.MissStat.serial_num[j] = ThermoSN[i][j]; printf("%02X",ThermoSN[i][j]); } printf("\n"); // download the Thermochron found if (DownloadThermo(portnum,&ThermoSN[i][0],&ThermoState,stdout)) { // interpret the results of the download InterpretStatus(&ThermoState.MissStat); InterpretAlarms(&ThermoState.AlarmData, &ThermoState.MissStat); InterpretHistogram(&ThermoState.HistData); InterpretLog(&ThermoState.LogData, &ThermoState.MissStat); // print the output PrintResults(&ThermoState,fp,Fahrenheit); } else { fprintf(fp,"\nError downloading device: "); for (j = 0; j < 8; j++) fprintf(fp,"%02X",ThermoSN[i][j]); fprintf(fp,"\n"); } } // close opened file if (fp != NULL) { printf("File '%s' closed.\n", argv[filenum]); fclose(fp); } // release the 1-Wire Net //owRelease(portnum,return_msg); printf("\n%s",return_msg); ExitProg("End program normally\n",0); return 0; }