/// /// main function /// @author csci243 /// /// @param argc number of command line arguments, including program name /// @param argv supplied command line arguments, including program name /// @returns errorCode error Code; EXIT_SUCCESS if no error /// int main( int argc, char **argv ) { mtime *atime = NULL ; song *song1 = NULL ; song *song2 = NULL ; song *song3 = NULL ; printf( "Creating a time...\n" ) ; atime = newMTime( 6, 30, "pm" ) ; printf( "Starting song tests...\n" ) ; song1 = newSong( "Summer Days", "Beach Boys" ) ; printf( "First song initialized...\n" ) ; char *artist = songGetArtist( song1 ) ; char *title = songGetTitle( song1 ) ; printf( "The current song1 song is: %s by %s.\n", title, artist ) ; free( artist ) ; free ( title ) ; char * sstr = songToString( song1 ) ; printf( "Otherwise... %s\n", sstr ) ; free(sstr); songPlay( song1, atime ) ; sstr = songToString( song1 ) ; printf( "After playing the song... %s\n", sstr ) ; free(sstr); mtime *glp = songGetLastPlayed( song1 ) ; char *sglp = mtimeToString(glp) ; artist = songGetArtist( song1 ) ; title = songGetTitle( song1 ) ; printf( "The same song referencing members is: %s by %s. Last played at: %s\n", title, artist, sglp ) ; free( artist ) ; free( title ) ; mtimeDelete( glp ) ; free( sglp ) ; songDelete( song1 ) ; artist = malloc( sizeof( "Goo Goo Dolls" ) + 1 ) ; title = malloc( sizeof( "The Black Hole" ) + 1 ) ; strcpy( artist, "Goo Goo Dolls" ) ; strcpy( title, "The Black Hole" ) ; song2 = newSong( title, artist ) ; free( artist ) ; free( title ) ; sstr = songToString ( song2 ) ; printf( "The o song is: %s\n", sstr ) ; free(sstr); song1 = songCopy( song2 ) ; sstr = songToString( song1 ) ; free(song1); printf( "The copy of song2 song is: %s \n", sstr ) ; free(sstr); songDelete( song2 ) ; sstr = songToString( song1 ) ; printf( "After deleting the original, the song1 song is ... %s\n", sstr ) ; free(sstr); char *pstr ; song3 = songCopy( song1 ) ; if ( songEquals( song1, song3 ) ) { sstr = songToString( song1 ) ; pstr = songToString( song3 ) ; printf( "The song3 song %s\n is the same as song1 song %s\n", pstr, sstr ) ; free( pstr ) ; free(sstr); songDelete(song3); } else printf( "ERROR: songCopy() failure!\n" ) ; song3 = newSong( "Its a Beatiful Morning", "Chicago" ) ; sstr = songToString( song3 ) ; printf( "The current song3 song is: %s\n", sstr ) ; free(sstr); songPlay( song3, newMTime(4, 42, "am") ) ; sstr = songToString( song3 ) ; printf( "The current song3 song is: %s\n", sstr ) ; free( sstr ) ; songDelete( song1 ) ; songDelete( song3 ) ; return EXIT_SUCCESS ; }
/** * Process OI Op Codes passed by controller */ void OpenInterface::handleOpCode(byte oc) { #ifdef DEBUG_SERIAL switch (oc) { case ('s'): oc = OC_SAFE; break; case ('d'): oc = OC_DIRECT_DRIVE; break; case ('g'): oc = OC_SENSORS; break; } #endif switch (oc) { case(OC_LOW_SIDE_DRIVERS): callCallbackWithOneByte(controlLsdOutputCallback); break; case(OC_LEDS): callCallbackWithThreeBytes(controlLedsCallback); break; case(OC_PWM_LOW_SIDE_DRIVERS): callCallbackWithThreeBytes(controlLsdPwmCallback); break; case(OC_DIGITAL_OUTPUTS): callCallbackWithOneByte(controlDigitalOutputCallback); break; case(OC_STREAM): stream(); break; case(OC_PAUSE_RESUME_STREAM): break; case(OC_SEND_IR): callCallbackWithOneByte(sendIrCallback); break; case(OC_SHOW_SCRIPT): showScript(); break; case(OC_WAIT_EVENT): callCallbackWithOneByte(waitEventCallback); break; case(OC_PLAY_SCRIPT): scriptPlay(); break; case(OC_SCRIPT): scriptSet(); break; case(OC_WAIT_ANGLE): if (waitAngleCallback) { waitAction(waitAngleCallback); } break; case(OC_WAIT_DISTANCE): if (waitDistanceCallback) { waitAction(waitDistanceCallback); } break; case(OC_WAIT_TIME): waitTime(); break; case(OC_DEMO): case(OC_SPOT): case(OC_COVER): case(OC_COVER_AND_DOCK): // These are all demo codes. Implement? break; case(OC_QUERY_LIST): queryList(); break; case (OC_START): sensor[OI_SENSOR_OI_MODE] = OI_MODE_PASSIVE; break; case (OC_BAUD): break; case (OC_CONTROL): case (OC_SAFE): sensor[OI_SENSOR_OI_MODE] = OI_MODE_SAFE; break; case (OC_SENSORS): getSensors(); break; case (OC_SONG): song(); break; case(OC_PLAY_SONG): songPlay(); break; case (OC_DIRECT_DRIVE): driveDirect(); break; case (OC_DRIVE): drive(); break; case (OC_FULL): sensor[OI_SENSOR_OI_MODE] = OI_MODE_FULL; break; } }