<commit_before>'''
Created on 29/10/2013

@author: tue
'''


import logging
import pykka
import time

logger = logging.getLogger('mopidy_arcam')


class ArcamReader(pykka.ThreadingActor):
    """
    Independent reader thread which does the communication with the Arcam amplifier.
    
    """
    _read_lines = ""
    
    def __init__(self, talker):
        super(ArcamReader, self).__init__()
        
        self._arcam_talker = talker
        self._commandresponse_map = self._arcam_talker.commandResponseMap.get()
        
    def on_start(self):
        # Let's start reading
        logger.info("Starting to read.")
        while (True):
            _response_word = self._arcam_talker.read_word().get()
            if _response_word != None:
                if len(_response_word) > 0:
                    # We have data -> one command
                    print "Read: ", _response_word
                    print "command: ", _response_word[:4]
                    print "action: ", _response_word[5:8]
                    print "Map conversion: ", self._commandresponse_map.get(_response_word[:4])
                    
                    if self._commandresponse_map.get(_response_word[:4]) == "Main.Volume":
                        # Have the volume been updated?
                        print "Main.Volume have been updated to: ", self._arcam_talker.calc_volume_int(_response_word[7]).get()
            else:
                print "Nothing yet."
            time.sleep(2)<commit_msg>need to change the value to int<commit_after>'''
Created on 29/10/2013

@author: tue
'''


import logging
import pykka
import time

logger = logging.getLogger('mopidy_arcam')


class ArcamReader(pykka.ThreadingActor):
    """
    Independent reader thread which does the communication with the Arcam amplifier.
    
    """
    _read_lines = ""
    
    def __init__(self, talker):
        super(ArcamReader, self).__init__()
        
        self._arcam_talker = talker
        self._commandresponse_map = self._arcam_talker.commandResponseMap.get()
        
    def on_start(self):
        # Let's start reading
        logger.info("Starting to read.")
        while (True):
            _response_word = self._arcam_talker.read_word().get()
            if _response_word != None:
                if len(_response_word) > 0:
                    # We have data -> one command
                    print "Read: ", _response_word
                    print "command: ", _response_word[:4]
                    print "action: ", _response_word[5:8]
                    print "Map conversion: ", self._commandresponse_map.get(_response_word[:4])
                    
                    if self._commandresponse_map.get(_response_word[:4]) == "Main.Volume":
                        # Have the volume been updated?
                        print "ord(_response_word[7])", ord(_response_word[7])
                        print "Main.Volume have been updated to: ", self._arcam_talker.calc_volume_int(ord(_response_word[7])).get()
            else:
                print "Nothing yet."
            time.sleep(2)
{'fraction_non_alphanumeric': 0.10045219638242894, 'fraction_numerical': 0.010981912144702842, 'mean_word_length': 1.905253283302064, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1643179', 'n_tokens_mistral': 882, 'n_tokens_neox': 837, 'n_words': 194}