def procLine(self, parent):
        VALID_FLAGS = ["MAIN_SCR", "SUB_SCR"]

        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcVideo.name):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Video name found twice, read %s, at line num %d."
                % (parent.tokens[parent.currToken],
                   parent.lineNumList[parent.currToken]))
            return (810)
        ProcVideo.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.VIDEO_NAME)
        ProcVideo.outHndl.write("    {0: <20} = {1}\n".format(
            name.upper(), self.currEnum))
        self.currEnum += 1

        # Copy location
        loc = parent.tokens[parent.currToken + 1]
        ProcVideo.loc.append(loc)

        # Verify flagStr
        if not parent.helpFuncs.isValidString(
                parent.tokens[parent.currToken + 2], VALID_FLAGS):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Video illegal flags, read %s, at line num %d." %
                (parent.tokens[parent.currToken + 2],
                 parent.lineNumList[parent.currToken + 2]))
            return (811)
        ProcVideo.flagStr.append(parent.tokens[parent.currToken + 2])

        # increment currToken
        parent.currToken += 3
        return (0)
    def procLine(self, parent):
        VALID_FLAGS = ["MAIN_SCR", "SUB_SCR"]

        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcVideo.name):
            parent.consoleObj.updateConsole("!!! Error !!! Video name found twice, read %s, at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (810)
        ProcVideo.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.VIDEO_NAME)
        ProcVideo.outHndl.write("    {0: <20} = {1}\n".format(name.upper(), self.currEnum))
        self.currEnum += 1
        
        # Copy location
        loc = parent.tokens[parent.currToken + 1]
        ProcVideo.loc.append(loc)
        
        # Verify flagStr
        if not parent.helpFuncs.isValidString(parent.tokens[parent.currToken + 2], VALID_FLAGS):
            parent.consoleObj.updateConsole("!!! Error !!! Video illegal flags, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
            return (811)
        ProcVideo.flagStr.append(parent.tokens[parent.currToken + 2])
        
        # increment currToken
        parent.currToken += 3
        return (0)
    def procLine(self, parent, bgndClip):

        # Copy name
        name = parent.tokens[parent.currToken]
        if bgndClip:
            if (name in ProcSound.bgndName):
                parent.consoleObj.updateConsole("!!! Error !!! Background sound name found twice, read %s, at line num %d." %
                   (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                return (710)
            ProcSound.bgndName.append(name)
            ProcChains.addName(parent.procChains, name, ProcChains.BGND_SOUND_NAME)
        else:
            if (name in ProcSound.sndName):
                parent.consoleObj.updateConsole("!!! Error !!! Sound name found twice, read %s, at line num %d." %
                   (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                return (711)
            ProcSound.sndName.append(name)
            ProcChains.addName(parent.procChains, name, ProcChains.SOUND_NAME)
        ProcSound.outHndl.write("    {0: <20} = {1}\n".format(name.upper(), self.currEnum))
        self.currEnum += 1
        
        # Copy location
        loc = parent.tokens[parent.currToken + 1]
        if bgndClip:
            ProcSound.bgndLoc.append(loc)
        else:
            ProcSound.sndLoc.append(loc)
        
        # increment currToken
        parent.currToken += 2
        return (0)
    def procLine(self, parent):
        VALID_FLAGS = ["STATE_INPUT", "FALL_EDGE", "RISE_EDGE"]
        GEN_FLAGS = ["rs232Intf.CFG_INP_STATE", "rs232Intf.CFG_INP_FALL_EDGE", "rs232Intf.CFG_INP_RISE_EDGE"]

        name = parent.tokens[parent.currToken]
        if name in ProcInpCards.name:
            parent.consoleObj.updateConsole("!!! Error !!! Found %s name twice at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (310)
        ProcInpCards.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.INPUT_BIT)
        
        # Verify card num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 1]):
            parent.consoleObj.updateConsole("!!! Error !!! Input card num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
            return (311)
        # Convert from 1 base to 0 based card num
        cardNum = parent.helpFuncs.out - 1
        # Card number is base 1
        if (cardNum < 0) or (cardNum >= ProcInpCards.numInpCards):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal input card num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
            return (312)
        ProcInpCards.cardNum.append(cardNum)
        
        # Verify pin num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 2]):
            parent.consoleObj.updateConsole("!!! Error !!! Input pin num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
            return (313)
        # Convert from 1 base to 0 based pin num
        pinNum = parent.helpFuncs.out - 1
        # Pin number is base 1
        if (pinNum < 0) or (pinNum >= ProcInpCards.NUM_INP_BITS):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal input pin num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
            return (314)
        if (ProcInpCards.inpCfgBits[cardNum] & (1 << pinNum)) != 0: 
            parent.consoleObj.updateConsole("!!! Error !!! Input pin configured multiple times, at line num %d." %
               (parent.lineNumList[parent.currToken + 2]))
            return (315)
        ProcInpCards.inpCfgBits[cardNum] |= (1 << pinNum)
        ProcInpCards.pinNum.append(pinNum)
        
        # Verify flagStr
        if not parent.helpFuncs.isValidString(parent.tokens[parent.currToken + 3], VALID_FLAGS):
            parent.consoleObj.updateConsole("!!! Error !!! Input illegal flags, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 3], parent.lineNumList[parent.currToken + 3]))
            return (316)
        flagStr = GEN_FLAGS[parent.helpFuncs.out]
        ProcInpCards.flagStr.append(flagStr)
        
        # Grab description
        desc = parent.tokens[parent.currToken + 4]
        ProcInpCards.desc.append(desc)
        
        # increment currToken
        parent.currToken += 5
        return (0)
Beispiel #5
0
 def procLine(self, parent):
     name = parent.tokens[parent.currToken]
     ProcLedCards.name.append(name)
     if ProcChains.checkNameExists(parent.procChains, name):
         parent.consoleObj.updateConsole("!!! Error !!! LED bit name already exists, read %s, at line num %d." %
            (name, parent.lineNumList[parent.currToken]))
         return (410)           
     ProcChains.addName(parent.procChains, name, ProcChains.LED_BIT)
     
     # Verify card num
     if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 1]):
         parent.consoleObj.updateConsole("!!! Error !!! LED card num, read %s, at line num %d." %
            (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
         return (411)
     # Convert from 1 base to 0 based card num
     cardNum = parent.helpFuncs.out - 1
     # Card number is base 1
     if (cardNum < 0) or (cardNum >= ProcLedCards.numLedCards):
         parent.consoleObj.updateConsole("!!! Error !!! Illegal LED card num, read %s, at line num %d." %
            (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
         return (412)
     ProcLedCards.cardNum.append(cardNum)
     
     # Verify pin num
     if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 2]):
         parent.consoleObj.updateConsole("!!! Error !!! LED pin num, read %s, at line num %d." %
            (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
         return (413)
     # Convert from 1 base to 0 based pin num, bit 0 = 0x80, bit 7 = 0x01
     pinNum = 7 - (parent.helpFuncs.out - 1)
     # Pin number is base 1
     if (pinNum < 0) or (pinNum >= ProcLedCards.NUM_LED_BITS):
         parent.consoleObj.updateConsole("!!! Error !!! Illegal LED pin num, read %s, at line num %d." %
            (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
         return (414)
     if (ProcLedCards.ledCfgBits[cardNum] & (1 << pinNum)) != 0: 
         parent.consoleObj.updateConsole("!!! Error !!! LED pin configured multiple times, at line num %d." %
            (parent.lineNumList[parent.currToken + 2]))
         return (415)
     ProcLedCards.ledCfgBits[cardNum] |= (1 << pinNum)
     ProcLedCards.pinNum.append(pinNum)
     
     # Grab description
     desc = parent.tokens[parent.currToken + 3]
     ProcLedCards.desc.append(desc)
     
     # increment currToken
     parent.currToken += 4
     return (0)
    def procAllChains(self, parent):
        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcVidChains.nameSet):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Name found twice, read %s, at line num %d." %
                (parent.tokens[parent.currToken],
                 parent.lineNumList[parent.currToken]))
            return (1410)
        ProcVidChains.nameSet.add(name)
        ProcChains.addName(parent.procChains, name,
                           ProcChains.VIDEO_CHAIN_NAME)
        ProcVidChains.outHndl.write("    ## Video Chain {0}\n".format(name))
        ProcVidChains.outHndl.write(
            "    #    - Groups have video name then WAIT command\n")
        ProcVidChains.outHndl.write(
            "    #    - Chain ends with REPEAT if desired\n")
        ProcVidChains.outHndl.write("    {0} = [\n".format(name))

        # Verify opening symbol
        parent.currToken += 1
        if not parent.helpFuncs.isOpenSym(parent.tokens[parent.currToken]):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Expected opening symbol, read %s, at line num %d."
                % (parent.tokens[parent.currToken],
                   parent.lineNumList[parent.currToken]))
            return (1411)
        closeSymb = parent.helpFuncs.findMatch(parent)
        parent.currToken += 1
        typeProc = ProcVidChains.PROC_VIDEO
        while parent.currToken < closeSymb:
            if parent.tokens[parent.currToken] in ProcVidChains.tokenLookup:
                tokenType = ProcVidChains.tokenLookup[parent.tokens[
                    parent.currToken]]
            else:
                tokenType = ProcVidChains.UNKNOWN
            if tokenType == ProcVidChains.WAIT_COMMAND:
                if typeProc != ProcVidChains.PROC_COMMAND:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! WAIT command in video chain in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1412)
                # Next token should be wait timeout (ms)
                if not parent.helpFuncs.isInt(
                        parent.tokens[parent.currToken + 1]):
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! WAIT parameter should be integer, read %s, at line num %d."
                        % (parent.tokens[parent.currToken + 1],
                           parent.lineNumList[parent.currToken + 1]))
                    return (1413)
                ProcVidChains.outHndl.write(" WAIT, " +
                                            parent.tokens[parent.currToken +
                                                          1] + "],\n")
                parent.currToken += 2
                # Next token must be a comma
                if (ProcVidChains.tokenLookup[parent.tokens[parent.currToken]]
                        != ProcVidChains.COMMA):
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Comma missing after wait command, found %s, at line num %d."
                        % (parent.tokens[parent.currToken],
                           parent.lineNumList[parent.currToken]))
                    return (1414)
                parent.currToken += 1
                typeProc = ProcVidChains.PROC_VIDEO
            elif tokenType == ProcVidChains.REPEAT_COMMAND:
                if (typeProc == ProcVidChains.PROC_VIDEO):
                    ProcVidChains.outHndl.write("        [0, ")
                elif (typeProc == ProcVidChains.PROC_COMMAND):
                    pass
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! REPEAT command in video chain in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1415)
                ProcVidChains.outHndl.write("REPEAT, 0] ]\n\n")
                typeProc = ProcVidChains.PROC_DONE_CHAIN
                parent.currToken += 1
            elif tokenType == ProcVidChains.COMMA:
                if (typeProc == ProcVidChains.PROC_VIDEO) or (
                        typeProc == ProcVidChains.PROC_COMMAND):
                    # No processing necessary, next sound will start the line
                    parent.currToken += 1
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Unexpected comma at line num %d." %
                        (parent.lineNumList[parent.currToken]))
                    return (1416)
            else:
                #This must be a video name
                if (ProcChains.checkNameExists(
                        parent.procChains, parent.tokens[parent.currToken])):
                    if (ProcChains.getNameType(parent.procChains,
                                               parent.tokens[parent.currToken])
                            != ProcChains.VIDEO_NAME):
                        parent.consoleObj.updateConsole(
                            "!!! Error !!! Symbol %s should only be a video name, at line num %d."
                            % (parent.tokens[parent.currToken],
                               parent.lineNumList[parent.currToken]))
                        return (1417)
                    else:
                        if typeProc == ProcVidChains.PROC_VIDEO:
                            ProcVidChains.outHndl.write(
                                "        [Videos.{0}, ".format(
                                    parent.tokens[parent.currToken]))
                            typeProc = ProcVidChains.PROC_COMMAND
                            parent.currToken += 1
                        elif typeProc == ProcVidChains.PROC_COMMAND:
                            # Two or more sounds back to back, put a wait of 0 between them
                            ProcVidChains.outHndl.write(
                                "WAIT, 0],\n        [Videos.{0}, ".format(
                                    parent.tokens[parent.currToken]))
                            parent.currToken += 1
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Can't understand symbol, read %s, at line num %d."
                        % (parent.tokens[parent.currToken],
                           parent.lineNumList[parent.currToken]))
                    return (1418)
        if (typeProc != ProcVidChains.PROC_DONE_CHAIN):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Video chain did not end properly, at line num %d."
                % (parent.lineNumList[parent.currToken]))
            return (1419)
        parent.currToken += 1
        return (0)
    def procAllChains(self, parent):
        # Create the lists to support multiple LED cards
        ledCard = [[] for _ in range(ProcLedCards.numLedCards)]

        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcLedChains.nameSet):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Name found twice, read %s, at line num %d." %
                (parent.tokens[parent.currToken],
                 parent.lineNumList[parent.currToken]))
            return (1210)
        ProcLedChains.nameSet.add(name)
        ProcChains.addName(parent.procChains, name, ProcChains.LED_CHAIN_NAME)
        ProcLedChains.outHndl.write("    ## LED Chain {0}\n".format(name))
        ProcLedChains.outHndl.write("    #    - First entry is LED mask\n")
        ProcLedChains.outHndl.write(
            "    #    - Next groups have a bitfield of LEDs to change and command\n"
        )
        ProcLedChains.outHndl.write("    {0} = [".format(name))

        # Verify opening symbol
        parent.currToken += 1
        if not parent.helpFuncs.isOpenSym(parent.tokens[parent.currToken]):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Expected opening symbol, read %s, at line num %d."
                % (parent.tokens[parent.currToken],
                   parent.lineNumList[parent.currToken]))
            return (1211)
        closeSymb = parent.helpFuncs.findMatch(parent)
        parent.currToken += 1
        typeProc = ProcLedChains.PROC_MASK
        firstBit = True
        while parent.currToken < closeSymb:
            if parent.tokens[parent.currToken] in ProcLedChains.tokenLookup:
                tokenType = ProcLedChains.tokenLookup[parent.tokens[
                    parent.currToken]]
            else:
                tokenType = ProcLedChains.UNKNOWN
            if (tokenType == ProcLedChains.OPEN_PAREN) or (
                    tokenType == ProcLedChains.CLOSE_PAREN):
                # Opening and closing parenthesis are dropped since they aren't necessary
                # Move to next symbol
                parent.currToken += 1
            elif tokenType == ProcLedChains.WAIT_COMMAND:
                if typeProc != ProcLedChains.PROC_COMMAND:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! WAIT command in LED chain in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1212)
                # Next token should be wait timeout (ms)
                if not parent.helpFuncs.isInt(
                        parent.tokens[parent.currToken + 1]):
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! WAIT parameter should be integer, read %s, at line num %d."
                        % (parent.tokens[parent.currToken + 1],
                           parent.lineNumList[parent.currToken + 1]))
                    return (1213)
                ProcLedChains.outHndl.write(" WAIT, " +
                                            parent.tokens[parent.currToken +
                                                          1] +
                                            "],\n          [ ")
                # If any close parenthesis exist eat them
                parent.currToken += 2
                while (ProcLedChains.tokenLookup[parent.tokens[
                        parent.currToken]] == ProcLedChains.CLOSE_PAREN):
                    parent.currToken += 1
                # Next token must be a comma
                if (ProcLedChains.tokenLookup[parent.tokens[parent.currToken]]
                        != ProcLedChains.COMMA):
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Comma missing after wait command, found %s, at line num %d."
                        % (parent.tokens[parent.currToken],
                           parent.lineNumList[parent.currToken]))
                    return (1214)
                parent.currToken += 1
                typeProc = ProcLedChains.PROC_LED_BIT
                firstBit = True
            elif tokenType == ProcLedChains.END_CHAIN_COMMAND:
                if typeProc != ProcLedChains.PROC_COMMAND:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! END_CHAIN command in LED chain in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1215)
                ProcLedChains.outHndl.write("END_CHAIN, 0] ] ]\n\n")
                parent.currToken += 1
                typeProc = ProcLedChains.PROC_DONE_CHAIN
            elif tokenType == ProcLedChains.REPEAT_COMMAND:
                if typeProc != ProcLedChains.PROC_COMMAND:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! REPEAT command in LED chain in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1216)
                ProcLedChains.outHndl.write("REPEAT, 0] ] ]\n\n")
                parent.currToken += 1
                typeProc = ProcLedChains.PROC_DONE_CHAIN
            elif tokenType == ProcLedChains.COMMA:
                if typeProc == ProcLedChains.PROC_MASK:
                    ProcLedChains.outHndl.write("\n        [ ")
                    for card in xrange(ProcLedCards.numLedCards):
                        if (card != 0):
                            ProcLedChains.outHndl.write(", ")
                        if len(ledCard[card]) == 0:
                            ProcLedChains.outHndl.write("0")
                        else:
                            for bit in xrange(len(ledCard[card])):
                                if (bit != 0):
                                    ProcLedChains.outHndl.write(" | ")
                                ProcLedChains.outHndl.write(ledCard[card][bit])
                    ProcLedChains.outHndl.write(" ],\n        [ [ ")
                    parent.currToken += 1
                    typeProc = ProcLedChains.PROC_LED_BIT
                    firstBit = True
                    ledCard = [[] for _ in range(ProcLedCards.numLedCards)]
                elif typeProc == ProcLedChains.PROC_LED_BIT:
                    ProcLedChains.outHndl.write("[ ")
                    for card in xrange(ProcLedCards.numLedCards):
                        if (card != 0):
                            ProcLedChains.outHndl.write(", ")
                        if len(ledCard[card]) == 0:
                            ProcLedChains.outHndl.write("0")
                        else:
                            for bit in xrange(len(ledCard[card])):
                                if (bit != 0):
                                    ProcLedChains.outHndl.write(" | ")
                                ProcLedChains.outHndl.write(ledCard[card][bit])
                    ProcLedChains.outHndl.write(" ], ")
                    parent.currToken += 1
                    typeProc = ProcLedChains.PROC_COMMAND
                    ledCard = [[] for _ in range(ProcLedCards.numLedCards)]
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Unexpected comma at line num %d." %
                        (parent.lineNumList[parent.currToken]))
                    return (1217)
            elif tokenType == ProcLedChains.LOGIC_OR:
                if ((typeProc != ProcLedChains.PROC_LED_BIT) and
                    (typeProc != ProcLedChains.PROC_MASK)) or firstBit:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Unexpected | at line num %d." %
                        (parent.lineNumList[parent.currToken]))
                    return (1218)
                parent.currToken += 1
            elif tokenType == ProcLedChains.ZERO:
                if not firstBit:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! 0 not first bit in mask at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1219)
                if (typeProc == ProcLedChains.PROC_MASK):
                    ProcLedChains.outHndl.write(",\n        [ [ ")
                    parent.currToken += 1
                    typeProc = ProcLedChains.PROC_LED_BIT
                    firstBit = True
                elif (typeProc == ProcLedChains.PROC_LED_BIT):
                    parent.currToken += 1
                    typeProc = ProcLedChains.PROC_LED_BIT
                    firstBit = True
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Unexpected 0 at line num %d." %
                        (parent.lineNumList[parent.currToken]))
                    return (1220)
            else:
                #This must be a bit name symbol
                if (ProcChains.checkNameExists(
                        parent.procChains, parent.tokens[parent.currToken])):
                    if (ProcChains.getNameType(parent.procChains,
                                               parent.tokens[parent.currToken])
                            != ProcChains.LED_BIT):
                        parent.consoleObj.updateConsole(
                            "!!! Error !!! Symbol %s should only be an LED bit, at line num %d."
                            % (parent.tokens[parent.currToken],
                               parent.lineNumList[parent.currToken]))
                        return (1221)
                    else:
                        # HRS:  This could be improved to verify any set bits are in the mask
                        card = parent.procChains.findBit(
                            parent.tokens[parent.currToken].upper()) >> 16
                        ledCard[card].append("LedBitNames.{0}".format(
                            parent.tokens[parent.currToken].upper()))
                        firstBit = False
                        parent.currToken += 1
                else:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Can't understand symbol, read %s, at line num %d."
                        % (parent.tokens[parent.currToken],
                           parent.lineNumList[parent.currToken]))
                    return (1222)
        if (typeProc != ProcLedChains.PROC_DONE_CHAIN):
            parent.consoleObj.updateConsole(
                "!!! Error !!! LED chain did not end properly, at line num %d."
                % (parent.lineNumList[parent.currToken]))
            return (1223)
        parent.currToken += 1
        return (0)
    def procAllModes(self, parent):
        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcModes.nameSet):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Mode name found twice, read %s, at line num %d."
                % (parent.tokens[parent.currToken],
                   parent.lineNumList[parent.currToken]))
            return (1510)
        ProcModes.nameSet.add(name)
        ProcModes.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.MODE_NAME)
        ProcModes.outHndl.write("        [State.{0}, ".format(name.upper()))
        parent.currToken += 1

        # Next symbol should be the description in quotes.
        # HRS:  This should probably support spaces inside the quotes but that will break the current
        #  tokenizer function.
        desc = parent.tokens[parent.currToken]
        if (not desc.startswith('"')) or (not desc.endswith('"')):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Descriptions strings should start and end with quotes, read %s, at line num %d."
                % (desc, parent.lineNumList[parent.currToken]))
            return (1511)
        ProcModes.desc.append(desc)
        parent.currToken += 1

        # Verify opening symbol
        if not parent.helpFuncs.isOpenSym(parent.tokens[parent.currToken]):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Expected opening symbol, read %s, at line num %d."
                % (parent.tokens[parent.currToken],
                   parent.lineNumList[parent.currToken]))
            return (1512)
        closeSymb = parent.helpFuncs.findMatch(parent)
        parent.currToken += 1
        typeProc = ProcModes.PROC_INIT_CHAIN
        subState = ProcModes.FIND_OPEN_PAREN
        while parent.currToken < closeSymb:
            if parent.tokens[parent.currToken] in ProcModes.tokenLookup:
                tokenType = ProcModes.tokenLookup[parent.tokens[
                    parent.currToken]]
            else:
                tokenType = ProcModes.UNKNOWN
            if (tokenType == ProcModes.OPEN_PAREN):
                # Opening is the beginning of a chain group
                if (subState != ProcModes.FIND_OPEN_PAREN):
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Expected opening paren, read %s, at line num %d."
                        % (parent.tokens[parent.currToken],
                           parent.lineNumList[parent.currToken]))
                    return (1513)
                # Find the matching close parenthesis
                if (typeProc == ProcModes.PROC_INIT_CHAIN) or (
                        typeProc == ProcModes.PROC_PROCESS_CHAIN):
                    ProcModes.outHndl.write("[")
                closeChainList = parent.helpFuncs.findMatch(parent)
                parent.currToken += 1
                subState = ProcModes.FIND_CHAIN
                hasEntries = False
            elif (tokenType == ProcModes.CLOSE_PAREN):
                if not hasEntries:
                    # If this is an audio, LED, scoring, or video chain, need to add starting bracket
                    # to create an empty list
                    if (typeProc == ProcModes.PROC_AUDIO_CHAIN) or (typeProc == ProcModes.PROC_LED_CHAIN) or \
                        (typeProc == ProcModes.PROC_SCORING) or (typeProc == ProcModes.PROC_VIDEO_CHAIN):
                        ProcModes.outHndl.write("[")
                    # If there are no entries, a close parenthesis is valid
                    ProcModes.outHndl.write("]")
                else:
                    if (subState != ProcModes.FIND_COMMA) and (
                            subState != ProcModes.FIND_END):
                        parent.consoleObj.updateConsole(
                            "!!! Error !!! Found close parenthesis at incorrect location at line num %d."
                            % (parent.lineNumList[parent.currToken]))
                        return (1514)
                    else:
                        if (typeProc == ProcModes.PROC_INIT_CHAIN) or (
                                typeProc == ProcModes.PROC_PROCESS_CHAIN):
                            ProcModes.outHndl.write("]")
                subState = ProcModes.FIND_OPEN_PAREN
                if (typeProc == ProcModes.PROC_SCORING):
                    ProcModes.outHndl.write(" ],\n")
                    typeProc = ProcModes.PROC_END_MODE
                else:
                    ProcModes.outHndl.write(", ")
                    typeProc += 1
                parent.currToken += 1
            elif (tokenType == ProcModes.COMMA):
                if subState != ProcModes.FIND_COMMA:
                    parent.consoleObj.updateConsole(
                        "!!! Error !!! Comma in incorrect location at line num %d."
                        % (parent.lineNumList[parent.currToken]))
                    return (1515)
                ProcModes.outHndl.write(", ")
                parent.currToken += 1
                subState = ProcModes.FIND_CHAIN
            else:
                #This must be a name symbol
                if (ProcChains.checkNameExists(
                        parent.procChains, parent.tokens[parent.currToken])):
                    nameType = ProcChains.getNameType(
                        parent.procChains, parent.tokens[parent.currToken])
                    if (typeProc == ProcModes.PROC_INIT_CHAIN):
                        if (nameType != ProcChains.CHAIN_NAME):
                            parent.consoleObj.updateConsole(
                                "!!! Error !!! Expected a chain name in init chain, read %s, at line num %d."
                                % (parent.tokens[parent.currToken],
                                   parent.lineNumList[parent.currToken]))
                            return (1516)
                        ProcModes.outHndl.write(
                            "RulesFunc." + parent.tokens[parent.currToken])
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_PROCESS_CHAIN):
                        if (nameType != ProcChains.CHAIN_NAME):
                            parent.consoleObj.updateConsole(
                                "!!! Error !!! Expected a chain name in process chain, read %s, at line num %d."
                                % (parent.tokens[parent.currToken],
                                   parent.lineNumList[parent.currToken]))
                            return (1517)
                        ProcModes.outHndl.write(
                            "RulesFunc." + parent.tokens[parent.currToken])
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_VIDEO_CHAIN):
                        if (nameType == ProcChains.VIDEO_NAME):
                            ProcModes.outHndl.write(
                                "Videos." +
                                parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.VIDEO_CHAIN_NAME):
                            # HRS:  Warning, in the original code, chains were not contained within another list,
                            #   but were simply part of the procChains table.  This will need to be fixed by removing
                            #   the extra list (which would make multiple chains not work), or combining the chains
                            #   into one.
                            ProcModes.outHndl.write(
                                "VideoChains." +
                                parent.tokens[parent.currToken])
                        elif (nameType == ProcChains.IMAGE_NAME):
                            ProcModes.outHndl.write(
                                "Images." +
                                parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.IMAGE_CHAIN_NAME):
                            # HRS:  Warning, in the original code, chains were not contained within another list,
                            #   but were simply part of the procChains table.  This will need to be fixed by removing
                            #   the extra list (which would make multiple chains not work), or combining the chains
                            #   into one.
                            ProcModes.outHndl.write(
                                "ImageChains." +
                                parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole(
                                "!!! Error !!! Expected a video/image or video/image chain, read %s, at line num %d."
                                % (parent.tokens[parent.currToken],
                                   parent.lineNumList[parent.currToken]))
                            return (1518)
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_AUDIO_CHAIN):
                        if (nameType == ProcChains.SOUND_NAME):
                            ProcModes.outHndl.write(
                                "Sounds." +
                                parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.SOUND_CHAIN_NAME):
                            ProcModes.outHndl.write(
                                "SoundChains." +
                                parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole(
                                "!!! Error !!! Expected a sound or sound chain name, read %s, at line num %d."
                                % (parent.tokens[parent.currToken],
                                   parent.lineNumList[parent.currToken]))
                            return (1519)
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_LED_CHAIN):
                        if (nameType == ProcChains.LED_CHAIN_NAME):
                            ProcModes.outHndl.write(
                                "LedChains." + parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole(
                                "!!! Error !!! Expected an LED chain name, read %s, at line num %d."
                                % (parent.tokens[parent.currToken],
                                   parent.lineNumList[parent.currToken]))
                            return (1520)
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_SCORING):
                        print "Not implemented"
                        parent.currToken += 1
                    else:
                        parent.consoleObj.updateConsole(
                            "!!! Error !!! Parsing error, invalid typeProc = %d, at line num %d."
                            % (typeProc, parent.lineNumList[parent.currToken]))
                        return (1521)
                else:
                    # Assume this is the name of a chain
                    ProcChains.possChainDict[parent.tokens[
                        parent.currToken]] = parent.lineNumList[
                            parent.currToken]
                    ProcModes.outHndl.write("RulesFunc." +
                                            parent.tokens[parent.currToken])
                    subState = ProcModes.FIND_COMMA
                    hasEntries = True
                    parent.currToken += 1
        if (typeProc != ProcModes.PROC_END_MODE):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Mode did not end properly, at line num %d." %
                (parent.lineNumList[parent.currToken]))
            return (1523)
        parent.currToken += 1
        return (0)
    def procLine(self, parent):
        VALID_FLAGS = ["USE_SWITCH", "AUTO_CLR"]
        GEN_FLAGS = ["rs232Intf.CFG_SOL_USE_SWITCH", "rs232Intf.CFG_SOL_AUTO_CLR"]
        MAX_INIT_KICK = 255
        MAX_DUTY_CYCLE = 15
        MAX_MIN_OFF = 7

        name = parent.tokens[parent.currToken]
        ProcSolCards.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.SOLENOID_BIT)
        
        # Verify card num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 1]):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid card num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
            return (210)
        # Convert from 1 base to 0 based card num
        cardNum = parent.helpFuncs.out - 1
        # Card number is base 1
        if (cardNum < 0) or (cardNum >= ProcSolCards.numSolCards):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal solenoid card num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
            return (211)
        ProcSolCards.cardNum.append(cardNum)
        
        # Verify pin num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 2]):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid pin num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
            return (212)
        # Convert from 1 base to 0 based pin num
        pinNum = parent.helpFuncs.out - 1
        # Pin number is base 1
        if (pinNum < 0) or (pinNum >= ProcSolCards.NUM_SOL_BITS):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal solenoid pin num, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 2], parent.lineNumList[parent.currToken + 2]))
            return (213)
        if (ProcSolCards.solCfgBits[cardNum] & (1 << pinNum)) != 0: 
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid pin configured multiple times, at line num %d." %
               (parent.lineNumList[parent.currToken + 2]))
            return (214)
        ProcSolCards.solCfgBits[cardNum] |= (1 << pinNum)
        ProcSolCards.pinNum.append(pinNum)
        
        # Verify flagStr
        if not parent.helpFuncs.isValidString(parent.tokens[parent.currToken + 3], VALID_FLAGS):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid illegal flags, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 3], parent.lineNumList[parent.currToken + 3]))
            return (215)
        flagStr = GEN_FLAGS[parent.helpFuncs.out]
        ProcSolCards.flagStr.append(flagStr)
        
        # Verify init kick
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 4]):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid initKick, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 4], parent.lineNumList[parent.currToken + 4]))
            return (216)
        initKick = parent.helpFuncs.out
        # Verify init kick is not out of range
        if (initKick < 0) or (initKick > MAX_INIT_KICK):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal initKick value, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 4], parent.lineNumList[parent.currToken + 4]))
            return (217)
        ProcSolCards.initKick.append(initKick)
        
        # Verify dutyCycle
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 5]):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid dutyCycle, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 5], parent.lineNumList[parent.currToken + 5]))
            return (218)
        dutyCycle = parent.helpFuncs.out
        # Verify dutyCycle is not out of range
        if (dutyCycle < 0) or (dutyCycle > MAX_DUTY_CYCLE):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal dutyCycle value, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 5], parent.lineNumList[parent.currToken + 5]))
            return (219)
        ProcSolCards.dutyCycle.append(dutyCycle)
        
        # Verify minOff
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 6]):
            parent.consoleObj.updateConsole("!!! Error !!! Solenoid minOff, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 6], parent.lineNumList[parent.currToken + 6]))
            return (220)
        minOff = parent.helpFuncs.out
        # Verify minOff is not out of range
        if (minOff < 0) or (minOff > MAX_MIN_OFF):
            parent.consoleObj.updateConsole("!!! Error !!! Illegal minOff value, read %s, at line num %d." %
               (parent.tokens[parent.currToken + 6], parent.lineNumList[parent.currToken + 6]))
            return (221)
        ProcSolCards.minOff.append(minOff)
        
        # Grab description
        desc = parent.tokens[parent.currToken + 7]
        ProcSolCards.desc.append(desc)
        
        # increment currToken
        parent.currToken += 8
        return (0)
Beispiel #10
0
    def procLine(self, parent):
        VALID_FLAGS = ["STATE_INPUT", "FALL_EDGE", "RISE_EDGE"]
        GEN_FLAGS = [
            "rs232Intf.CFG_INP_STATE", "rs232Intf.CFG_INP_FALL_EDGE",
            "rs232Intf.CFG_INP_RISE_EDGE"
        ]

        name = parent.tokens[parent.currToken]
        if name in ProcInpCards.name:
            parent.consoleObj.updateConsole(
                "!!! Error !!! Found %s name twice at line num %d." %
                (parent.tokens[parent.currToken],
                 parent.lineNumList[parent.currToken]))
            return (310)
        ProcInpCards.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.INPUT_BIT)

        # Verify card num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 1]):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Input card num, read %s, at line num %d." %
                (parent.tokens[parent.currToken + 1],
                 parent.lineNumList[parent.currToken + 1]))
            return (311)
        # Convert from 1 base to 0 based card num
        cardNum = parent.helpFuncs.out - 1
        # Card number is base 1
        if (cardNum < 0) or (cardNum >= ProcInpCards.numInpCards):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Illegal input card num, read %s, at line num %d."
                % (parent.tokens[parent.currToken + 1],
                   parent.lineNumList[parent.currToken + 1]))
            return (312)
        ProcInpCards.cardNum.append(cardNum)

        # Verify pin num
        if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 2]):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Input pin num, read %s, at line num %d." %
                (parent.tokens[parent.currToken + 2],
                 parent.lineNumList[parent.currToken + 2]))
            return (313)
        # Convert from 1 base to 0 based pin num
        pinNum = parent.helpFuncs.out - 1
        # Pin number is base 1
        if (pinNum < 0) or (pinNum >= ProcInpCards.NUM_INP_BITS):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Illegal input pin num, read %s, at line num %d."
                % (parent.tokens[parent.currToken + 2],
                   parent.lineNumList[parent.currToken + 2]))
            return (314)
        if (ProcInpCards.inpCfgBits[cardNum] & (1 << pinNum)) != 0:
            parent.consoleObj.updateConsole(
                "!!! Error !!! Input pin configured multiple times, at line num %d."
                % (parent.lineNumList[parent.currToken + 2]))
            return (315)
        ProcInpCards.inpCfgBits[cardNum] |= (1 << pinNum)
        ProcInpCards.pinNum.append(pinNum)

        # Verify flagStr
        if not parent.helpFuncs.isValidString(
                parent.tokens[parent.currToken + 3], VALID_FLAGS):
            parent.consoleObj.updateConsole(
                "!!! Error !!! Input illegal flags, read %s, at line num %d." %
                (parent.tokens[parent.currToken + 3],
                 parent.lineNumList[parent.currToken + 3]))
            return (316)
        flagStr = GEN_FLAGS[parent.helpFuncs.out]
        ProcInpCards.flagStr.append(flagStr)

        # Grab description
        desc = parent.tokens[parent.currToken + 4]
        ProcInpCards.desc.append(desc)

        # increment currToken
        parent.currToken += 5
        return (0)
Beispiel #11
0
    def createLedBitNames(self, parent):
        HDR_COMMENTS = [
            "# @file    ledBitNames.py",
            "# @author  AutoGenerated",
            "# @date    ",
            "#",
            "# @note    Open Pinball Project",
            "# @note    Copyright 2014, Hugh Spahr",
            "#",
            "# @brief These are the LED bit names.  It has a bitmask for each LED.",
            "",
            "#===============================================================================",
            "",
            "## LED bit name enumeration.",
            "#  Contains a bit mask for each LED.  Can also contain bitfield masks.",
            "#  Top most nibble contains the index of the LED card base 0.",
            "class LedBitNames:"]

        # Open the file or create if necessary
        outHndl = open(parent.consoleObj.outDir + os.sep + "ledBitNames.py", 'w+')
        stdHdrHndl = open("stdHdr.txt", 'r')
        for line in stdHdrHndl:
            outHndl.write(line)
        stdHdrHndl.close()
        for line in HDR_COMMENTS:
            if line.startswith("# @date"):
                outHndl.write(line + time.strftime("%m/%d/%Y") + "\n")
            else:
                outHndl.write(line + "\n")
                
        # Write out NUM_LED_CARDS
        outHndl.write("    ## Number of LED boards in the system\n")
        outHndl.write("    NUM_LED_BRDS = {0}\n\n".format(ProcLedCards.numLedCards))
        
        # Write out LED bit enumeration
        for cardIndex in xrange(ProcLedCards.numLedCards):
            allBitsName = "LED{0}_ALL_BITS_MSK".format(cardIndex + 1)
            outHndl.write("    {0:32} = 0x{1:05x}\n".format( allBitsName,
                (cardIndex * 0x10000) + 0x00ff))
            ProcChains.addName(parent.procChains, allBitsName, ProcChains.LED_BIT)
            parent.procChains.ledDict[allBitsName] = (cardIndex * 0x10000) + 0x00ff
            for bitIndex in xrange(ProcLedCards.NUM_LED_BITS):
                found = self.findBitIndex(cardIndex, bitIndex)
                if found:
                    outHndl.write("    {0:32} = 0x{1:05x}\n".format(ProcLedCards.name[self.out].upper(),
                        ((cardIndex << 16) | (1 << bitIndex))))
                    # Create the LED name dictionary
                    parent.procChains.ledDict[ProcLedCards.name[self.out].upper()] = ((cardIndex << 16) | (1 << bitIndex))
        
                    
        # Write out the bit name strings
        outHndl.write("\n    ## LED board bit names\n")
        outHndl.write("    # Indexed into using the [LedBitNames](@ref ledBitNames.LedBitNames) class\n")
        outHndl.write("    LED_BRD_BIT_NAMES = [ ")
        for cardIndex in xrange(ProcLedCards.numLedCards):
            if (cardIndex != 0):
                outHndl.write(",\n        ")
            outHndl.write("[")
            for bitIndex in xrange(ProcLedCards.NUM_LED_BITS):
                if (bitIndex != 0):
                    if ((bitIndex % 4) == 0):
                        outHndl.write(",\n        ")
                    else:
                        outHndl.write(", ")
                found = self.findBitIndex(cardIndex, bitIndex)
                if found:
                    outHndl.write(ProcLedCards.desc[self.out])
                else:
                    outHndl.write("\"Unused\"")
            outHndl.write("]")
        outHndl.write(" ]\n\n")
        outHndl.close()
        parent.consoleObj.updateConsole("Completed: ledBitNames.py file.")
        return (0)
    def procAllModes(self, parent):
        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcModes.nameSet):
            parent.consoleObj.updateConsole("!!! Error !!! Mode name found twice, read %s, at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (1510)
        ProcModes.nameSet.add(name)
        ProcModes.name.append(name)
        ProcChains.addName(parent.procChains, name, ProcChains.MODE_NAME)
        ProcModes.outHndl.write("        [State.{0}, ".format(name.upper()))
        parent.currToken += 1
        
        # Next symbol should be the description in quotes.
        # HRS:  This should probably support spaces inside the quotes but that will break the current
        #  tokenizer function.
        desc = parent.tokens[parent.currToken]
        if (not desc.startswith('"')) or (not desc.endswith('"')):
            parent.consoleObj.updateConsole("!!! Error !!! Descriptions strings should start and end with quotes, read %s, at line num %d." %
               (desc, parent.lineNumList[parent.currToken]))
            return (1511)
        ProcModes.desc.append(desc)
        parent.currToken += 1

        # Verify opening symbol
        if not parent.helpFuncs.isOpenSym(parent.tokens[parent.currToken]):
            parent.consoleObj.updateConsole("!!! Error !!! Expected opening symbol, read %s, at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (1512)
        closeSymb = parent.helpFuncs.findMatch(parent)
        parent.currToken += 1
        typeProc = ProcModes.PROC_INIT_CHAIN
        subState = ProcModes.FIND_OPEN_PAREN
        while parent.currToken < closeSymb:
            if parent.tokens[parent.currToken] in ProcModes.tokenLookup:
                tokenType = ProcModes.tokenLookup[parent.tokens[parent.currToken]]
            else:
                tokenType = ProcModes.UNKNOWN
            if (tokenType == ProcModes.OPEN_PAREN):
                # Opening is the beginning of a chain group
                if (subState != ProcModes.FIND_OPEN_PAREN):
                    parent.consoleObj.updateConsole("!!! Error !!! Expected opening paren, read %s, at line num %d." %
                       (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                    return (1513)
                # Find the matching close parenthesis
                if (typeProc == ProcModes.PROC_INIT_CHAIN) or (typeProc == ProcModes.PROC_PROCESS_CHAIN):
                    ProcModes.outHndl.write("[")
                closeChainList = parent.helpFuncs.findMatch(parent)
                parent.currToken += 1
                subState = ProcModes.FIND_CHAIN
                hasEntries = False
            elif (tokenType == ProcModes.CLOSE_PAREN):
                if not hasEntries:
                    # If this is an audio, LED, scoring, or video chain, need to add starting bracket
                    # to create an empty list
                    if (typeProc == ProcModes.PROC_AUDIO_CHAIN) or (typeProc == ProcModes.PROC_LED_CHAIN) or \
                        (typeProc == ProcModes.PROC_SCORING) or (typeProc == ProcModes.PROC_VIDEO_CHAIN):
                        ProcModes.outHndl.write("[")
                    # If there are no entries, a close parenthesis is valid
                    ProcModes.outHndl.write("]")
                else:
                    if (subState != ProcModes.FIND_COMMA) and (subState != ProcModes.FIND_END): 
                        parent.consoleObj.updateConsole("!!! Error !!! Found close parenthesis at incorrect location at line num %d." %
                           (parent.lineNumList[parent.currToken]))
                        return (1514)
                    else:
                        if (typeProc == ProcModes.PROC_INIT_CHAIN) or (typeProc == ProcModes.PROC_PROCESS_CHAIN):
                            ProcModes.outHndl.write("]")
                subState = ProcModes.FIND_OPEN_PAREN
                if (typeProc == ProcModes.PROC_SCORING):
                    ProcModes.outHndl.write(" ],\n")
                    typeProc = ProcModes.PROC_END_MODE
                else:
                    ProcModes.outHndl.write(", ")
                    typeProc += 1
                parent.currToken += 1
            elif (tokenType == ProcModes.COMMA):
                if subState != ProcModes.FIND_COMMA: 
                    parent.consoleObj.updateConsole("!!! Error !!! Comma in incorrect location at line num %d." %
                       (parent.lineNumList[parent.currToken]))
                    return (1515)
                ProcModes.outHndl.write(", ")
                parent.currToken += 1
                subState = ProcModes.FIND_CHAIN
            else:
                #This must be a name symbol
                if (ProcChains.checkNameExists(parent.procChains, parent.tokens[parent.currToken])):
                    nameType = ProcChains.getNameType(parent.procChains, parent.tokens[parent.currToken])
                    if (typeProc == ProcModes.PROC_INIT_CHAIN):
                        if (nameType != ProcChains.CHAIN_NAME):
                            parent.consoleObj.updateConsole("!!! Error !!! Expected a chain name in init chain, read %s, at line num %d." %
                               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                            return (1516)
                        ProcModes.outHndl.write("RulesFunc." + parent.tokens[parent.currToken])
                        subState = ProcModes.FIND_COMMA
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_PROCESS_CHAIN):
                        if (nameType != ProcChains.CHAIN_NAME):
                            parent.consoleObj.updateConsole("!!! Error !!! Expected a chain name in process chain, read %s, at line num %d." %
                               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                            return (1517)
                        ProcModes.outHndl.write("RulesFunc." + parent.tokens[parent.currToken])
                        subState = ProcModes.FIND_COMMA 
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_VIDEO_CHAIN):
                        if (nameType == ProcChains.VIDEO_NAME):
                            ProcModes.outHndl.write("Videos." + parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.VIDEO_CHAIN_NAME):
                            # HRS:  Warning, in the original code, chains were not contained within another list,
                            #   but were simply part of the procChains table.  This will need to be fixed by removing
                            #   the extra list (which would make multiple chains not work), or combining the chains
                            #   into one.
                            ProcModes.outHndl.write("VideoChains." + parent.tokens[parent.currToken])
                        elif (nameType == ProcChains.IMAGE_NAME):
                            ProcModes.outHndl.write("Images." + parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.IMAGE_CHAIN_NAME):
                            # HRS:  Warning, in the original code, chains were not contained within another list,
                            #   but were simply part of the procChains table.  This will need to be fixed by removing
                            #   the extra list (which would make multiple chains not work), or combining the chains
                            #   into one.
                            ProcModes.outHndl.write("ImageChains." + parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole("!!! Error !!! Expected a video/image or video/image chain, read %s, at line num %d." %
                               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                            return (1518)
                        subState = ProcModes.FIND_COMMA 
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_AUDIO_CHAIN):
                        if (nameType == ProcChains.SOUND_NAME):
                            ProcModes.outHndl.write("Sounds." + parent.tokens[parent.currToken].upper())
                        elif (nameType == ProcChains.SOUND_CHAIN_NAME):
                            ProcModes.outHndl.write("SoundChains." + parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole("!!! Error !!! Expected a sound or sound chain name, read %s, at line num %d." %
                               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                            return (1519)
                        subState = ProcModes.FIND_COMMA 
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_LED_CHAIN):
                        if (nameType == ProcChains.LED_CHAIN_NAME):
                            ProcModes.outHndl.write("LedChains." + parent.tokens[parent.currToken])
                        else:
                            parent.consoleObj.updateConsole("!!! Error !!! Expected an LED chain name, read %s, at line num %d." %
                               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                            return (1520)
                        subState = ProcModes.FIND_COMMA 
                        hasEntries = True
                        parent.currToken += 1
                    elif (typeProc == ProcModes.PROC_SCORING):
                        print "Not implemented"
                        parent.currToken += 1
                    else:
                        parent.consoleObj.updateConsole("!!! Error !!! Parsing error, invalid typeProc = %d, at line num %d." %
                           (typeProc, parent.lineNumList[parent.currToken]))
                        return (1521)
                else:
                    # Assume this is the name of a chain
                    ProcChains.possChainDict[parent.tokens[parent.currToken]] = parent.lineNumList[parent.currToken]
                    ProcModes.outHndl.write("RulesFunc." + parent.tokens[parent.currToken])
                    subState = ProcModes.FIND_COMMA
                    hasEntries = True
                    parent.currToken += 1
        if (typeProc != ProcModes.PROC_END_MODE):
            parent.consoleObj.updateConsole("!!! Error !!! Mode did not end properly, at line num %d." %
               (parent.lineNumList[parent.currToken]))
            return (1523)
        parent.currToken += 1
        return (0)
    def procAllChains(self, parent):
        # Copy name
        name = parent.tokens[parent.currToken]
        if (name in ProcVidChains.nameSet):
            parent.consoleObj.updateConsole("!!! Error !!! Name found twice, read %s, at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (1410)
        ProcVidChains.nameSet.add(name)
        ProcChains.addName(parent.procChains, name, ProcChains.VIDEO_CHAIN_NAME)
        ProcVidChains.outHndl.write("    ## Video Chain {0}\n".format(name))
        ProcVidChains.outHndl.write("    #    - Groups have video name then WAIT command\n")
        ProcVidChains.outHndl.write("    #    - Chain ends with REPEAT if desired\n")
        ProcVidChains.outHndl.write("    {0} = [\n".format(name))

        # Verify opening symbol
        parent.currToken += 1
        if not parent.helpFuncs.isOpenSym(parent.tokens[parent.currToken]):
            parent.consoleObj.updateConsole("!!! Error !!! Expected opening symbol, read %s, at line num %d." %
               (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
            return (1411)
        closeSymb = parent.helpFuncs.findMatch(parent)
        parent.currToken += 1
        typeProc = ProcVidChains.PROC_VIDEO
        while parent.currToken < closeSymb:
            if parent.tokens[parent.currToken] in ProcVidChains.tokenLookup:
                tokenType = ProcVidChains.tokenLookup[parent.tokens[parent.currToken]]
            else:
                tokenType = ProcVidChains.UNKNOWN
            if tokenType == ProcVidChains.WAIT_COMMAND:
                if typeProc != ProcVidChains.PROC_COMMAND: 
                    parent.consoleObj.updateConsole("!!! Error !!! WAIT command in video chain in incorrect location at line num %d." %
                       (parent.lineNumList[parent.currToken]))
                    return (1412)
                # Next token should be wait timeout (ms) 
                if not parent.helpFuncs.isInt(parent.tokens[parent.currToken + 1]):
                    parent.consoleObj.updateConsole("!!! Error !!! WAIT parameter should be integer, read %s, at line num %d." %
                       (parent.tokens[parent.currToken + 1], parent.lineNumList[parent.currToken + 1]))
                    return (1413)
                ProcVidChains.outHndl.write(" WAIT, " + parent.tokens[parent.currToken + 1] + "],\n")
                parent.currToken += 2
                # Next token must be a comma
                if (ProcVidChains.tokenLookup[parent.tokens[parent.currToken]] != ProcVidChains.COMMA):
                    parent.consoleObj.updateConsole("!!! Error !!! Comma missing after wait command, found %s, at line num %d." %
                       (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                    return (1414)
                parent.currToken += 1
                typeProc = ProcVidChains.PROC_VIDEO
            elif tokenType == ProcVidChains.REPEAT_COMMAND:
                if (typeProc == ProcVidChains.PROC_VIDEO):
                    ProcVidChains.outHndl.write("        [0, ")
                elif (typeProc == ProcVidChains.PROC_COMMAND):
                    pass
                else:  
                    parent.consoleObj.updateConsole("!!! Error !!! REPEAT command in video chain in incorrect location at line num %d." %
                       (parent.lineNumList[parent.currToken]))
                    return (1415)
                ProcVidChains.outHndl.write("REPEAT, 0] ]\n\n")
                typeProc = ProcVidChains.PROC_DONE_CHAIN
                parent.currToken += 1
            elif tokenType == ProcVidChains.COMMA:
                if (typeProc == ProcVidChains.PROC_VIDEO) or (typeProc == ProcVidChains.PROC_COMMAND):
                    # No processing necessary, next sound will start the line
                    parent.currToken += 1
                else:
                    parent.consoleObj.updateConsole("!!! Error !!! Unexpected comma at line num %d." %
                       (parent.lineNumList[parent.currToken]))
                    return (1416)
            else:
                #This must be a video name
                if (ProcChains.checkNameExists(parent.procChains, parent.tokens[parent.currToken])):
                    if (ProcChains.getNameType(parent.procChains, parent.tokens[parent.currToken]) != ProcChains.VIDEO_NAME):
                        parent.consoleObj.updateConsole("!!! Error !!! Symbol %s should only be a video name, at line num %d." %
                           (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                        return (1417)
                    else:
                        if typeProc == ProcVidChains.PROC_VIDEO:
                            ProcVidChains.outHndl.write("        [Videos.{0}, ".format(parent.tokens[parent.currToken]))
                            typeProc = ProcVidChains.PROC_COMMAND
                            parent.currToken += 1
                        elif typeProc == ProcVidChains.PROC_COMMAND:
                            # Two or more sounds back to back, put a wait of 0 between them
                            ProcVidChains.outHndl.write("WAIT, 0],\n        [Videos.{0}, ".format(parent.tokens[parent.currToken]))
                            parent.currToken += 1
                else:
                    parent.consoleObj.updateConsole("!!! Error !!! Can't understand symbol, read %s, at line num %d." %
                       (parent.tokens[parent.currToken], parent.lineNumList[parent.currToken]))
                    return (1418)
        if (typeProc != ProcVidChains.PROC_DONE_CHAIN):
            parent.consoleObj.updateConsole("!!! Error !!! Video chain did not end properly, at line num %d." %
               (parent.lineNumList[parent.currToken]))
            return (1419)
        parent.currToken += 1
        return (0)