Esempio n. 1
0
 def execute_song(self):
     """ organizes methods, and runs a song
     """
     print("entering execute_song()")
     while self._song_over is False:
         self._summarize_period()
         grip_info = gather_info(parse_csv(self._last_30_sec))
         self.user_stats.set_grips(grip_info)
         best_grip = evaluate_best_grip(grip_info)
         self._compile_result(grip_avg_summary_str(grip_info))
         self._last_worst_grip = evaluate_worst_grip(grip_info, self._last_worst_grip)
         summary = self.select_response()
         self._compile_result(summary)
         self._compile_result('system time = {}'.format(strftime("%H:%M:%S")))
         self._compile_result(' ')
         if self._song_over is True:
             # print('Number of grips this song = ', self._grip_count)
             return
         if self._feedback_plat == "RIVA":
             self._RIVA_message_num += 1
             text_to_RIVA(summary)
         else:#if self._feedback_plat == "Text":
             self._RIVA_message_num += 1
             to_no_voice_log(emo_less_feedback(self._RIVA_message_num, self._last_worst_grip, best_grip))
         ###else:
         ###    self._RIVA_message_num += 1
         ###    text_to_ispeech(ispeech_formatter(summary))
     print("leaving execute_song()")
     return
Esempio n. 2
0
 def _read_lastline(self):
     """ Returns the last line of the csv containing the user's grip information
     """
     #print("entering _read_lastline()")
     #print(read_csv(CSV_functions.MUSICGLOVE))
     try:
         last_line = parse_csv(read_csv(CSV_functions.MUSICGLOVE))[-1]
     except IndexError:
         return "Empty File"
     return last_line
Esempio n. 3
0
 def test_for_restart(self):
     """ Tests whether the a new song has been started
     """
     #print("entering test_for_restart()")
     self._compile_result("UserName: "******"Welcome_str"
     #    self.first_song = False
     if self._feedback_plat == "RIVA":
         self._RIVA_message_num += 1
         text_to_RIVA("Welcome_str")
     else:# self._feedback_plat == "Text":
         self._RIVA_message_num += 1
         #to_no_voice_log("NewData:{};TTS:{}".format(self._RIVA_message_num, msg))
     ###else:
     ###    text_to_ispeech(ispeech_formatter(msg))
     while True:
         self._check_completion()
         if self._song_over is False:
             print("Song Started")
             if self._feedback_plat == "RIVA":
                 reset_RIVA_log()
                 self._RIVA_message_num += 1
                 #text_to_RIVA(self.response_welcome())
             elif self._feedback_plat == "Text":
                 to_no_voice_log((emo_less_feedback(0, 0, 0)))
             self.execute_song()
             print("Re-entered Test_for_restart()")
             if self._song_over is True:
                 interface_info = gather_info(
                     parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
                 #print(interface_info)
                 #print("Song_over min/max = ", min_max)
                 self.user_stats.set_grips(interface_info)
                 self._compile_result(grip_avg_summary_str(interface_info))
                 evaluated_info = [evaluate_worst_grip(interface_info, self._last_worst_grip),
                                   evaluate_best_grip(interface_info)]
                 summary = summary_generator(evaluated_info[0], evaluated_info[1])
                 if self._feedback_plat == "RIVA":
                     self._RIVA_message_num += 1
                     #print("message_num={} summary={}".format(self._message_num, summary))
                     text_to_RIVA(summary)
                 else:# self._feedback_plat == "Text":
                     to_no_voice_log(emo_less_feedback(self._RIVA_message_num, evaluated_info[0], evaluated_info[1]))
                 ###else:
                 ###    text_to_ispeech(ispeech_formatter(summary))
                 self._last_30_sec = []
                 self._compile_result(summary)
                 self._csv_result.extend(read_csv(CSV_functions.MUSICGLOVE))
                 make_csv(self._csv_result, CSV_functions.M_GLOVE_SUMMARIES, what_song(self._grip_count))
                 self.__init__(self.user_name, restart=True)
                 self._RIVA_message_num = 1
         else:
             pass
     return
Esempio n. 4
0
 def _set_last_30_sec(self):
     """ sets the grip list for the past 30 seconds of the song
     """
     #print("entering set_last_30")
     grip_list = read_csv(CSV_functions.MUSICGLOVE, test=True)
     self._all_grips = parse_csv(grip_list)
     #print("grip_list = ", grip_list)
     if self._grip_count == 0:
         self._grip_count = len(grip_list)
     else:
         for j in range(self._grip_count):
             #print("j = {} and grip_list = {}".format(j, len(grip_list)))
             grip_list.remove(grip_list[0])
         self._grip_count += len(grip_list)
         #self._all_grips += parse_csv(read_csv(CSV_functions.MUSICGLOVE))
     self._last_30_sec = grip_list
     return
Esempio n. 5
0
 test_csv = [['1', '1', '-1'], ['4', '4', '-4'], ['3', '3', '-3'],
             ['3', '3', '3'], ['3', '3', '3'], ['2', '2', '2'],
             ['2', '2', '2'], ['3', '3', '3'], ['2', '2', '2'],
             ['1', '1', '1'], ['2', '2', '-2'], ['1', '1', '1'],
             ['4', '4', '-4'], ['3', '3', '-3'], ['3', '3', '-3'],
             ['3', '3', '-3'], ['2', '2', '-2'], ['2', '2', '-2'],
             ['3', '3', '-3'], ['2', '2', '-2'], ['1', '1', '-1'],
             ['2', '2', '-2'], ['3', '3', '-3'], ['2', '2', '-2'],
             ['1', '1', '-1'], ['1', '1', '1'], ['4', '4', '4'],
             ['3', '3', '-3'], ['2', '2', '2'], ['1', '1', '-1'],
             ['1', '1', '-1'], ['4', '4', '4'], ['3', '3', '3'],
             ['3', '3', '-3'], ['3', '3', '-3'], ['2', '2', '-2'],
             ['2', '2', '-2'], ['3', '3', '-3'], ['2', '2', '-2'],
             ['1', '1', '-1'], ['2', '2', '-2'], ['1', '1', '1']]
 print(test_csv)
 print(parse_csv(test_csv))
 test_info = gather_info(parse_csv(test_csv))
 print(test_info)
 test = User_Stats()
 test.set_grips(test_info)
 print()
 print("new values: {}, {}, {}, {}, {}, {}".format(test._red_avg,test._blue_avg, test._green_avg, test._purple_avg, test._yellow_avg, test._overall_avg))
 print("_difference = ", test._difference)
 print("old values: {}, {}, {}, {}, {}, {}".format(test._old_red_avg,test._old_blue_avg, test._old_green_avg, test._old_purple_avg, test._old_yellow_avg, test._old_overall_avg))
 print("test 1 = " + test.select_feedback())
 for t in [1,2,3,4,5]:
     print("t= {}; avg= {}; old_avg= {}".format(int(t), test.get_grip_avg(t), test.get_old_grip_avg(t)))
 '''test.set_overall_avg(-1)
 print("test 2 = " + test.select_feedback())
 test.set_overall_avg(14.003)
 print("test 3 = " + test.select_feedback())
Esempio n. 6
0
 def tester2(self) -> None:
     """Updates log file to simulate specified user interaction with MGlove
     """
     grip_number = self.grip_number
     seconds = self.seconds
     self.clear_csv()
     while seconds > 0:
         print("2nd simulated song started")
         for i in range(32):
             self.update_csv(self.chosen_grip(grip_number,150))
             seconds-=1
             sleep(1)
         print("expect welcome")
         for i in range(32):
             seconds-=1
             self.update_csv(self.chosen_grip(grip_number,300))
             sleep(1)
         print("expect Negative")
         grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
         user_stats = User_Stats(new_song=False)
         for i in range(32):
             seconds-=1
             self.update_csv(self.chosen_grip(grip_number,1))
             sleep(1)
         print("expect Positive")
         grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
         user_stats = User_Stats(new_song=False)
         for i in range(7):
             seconds-=5
             self.update_csv(self.chosen_grip(1,250))
             for j in range(1,5):
                 self.update_csv(self.chosen_grip(j+1,150))
             sleep(5)
         print("expect red prompt")
         grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
         user_stats = User_Stats(new_song=False)
         for i in range(7):
             seconds-=5
             self.update_csv(self.chosen_grip(1,300))
             for j in range(1,5):
                 self.update_csv(self.chosen_grip(j+1,150))
             sleep(5)
         print("expect Negative red response")
         grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
         user_stats = User_Stats(new_song=False)
         for i in range(7):
             seconds-=5
             self.update_csv(self.chosen_grip(1,150))
             for j in range(1,5):
                 self.update_csv(self.chosen_grip(j+1,150))
             sleep(5)
         print("expect Positive red response")
         grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
         user_stats = User_Stats(new_song=False)
         for i in range(7):
             seconds-=5
             self.update_csv(self.chosen_grip(1,1))
             for j in range(1,5):
                 self.update_csv(self.chosen_grip(j+1,150))
             sleep(5)
     print("2nd simulated song is over")
Esempio n. 7
0
                    temp_list.append(line)
                    new_list = []
        print("Number of lines this song = ",len(temp_list))
        for i in range(len(temp_list)):
            self.write_csv(new_list, temp_list[i])
            new_list.append(temp_list[i])
            sleep(1)





if __name__ == "__main__":
    import CSV_functions
    from CSV_functions import read_csv
    from Interface import parse_csv, grip_times
    from time import sleep
    from user_stats import User_Stats
    with open(CSV_FILE, 'w', newline='') as outfile:
        outfile.write('')
    tester = N_test()
    tester.tester1()
    grip_list = grip_times(parse_csv(read_csv(CSV_functions.MUSICGLOVE)))
    user_stats = User_Stats()
    sleep(40)

    tester.tester2()
    sleep(40)

    tester.tester3()