コード例 #1
0
ファイル: tool.cpp プロジェクト: jgrande/ginga
int Tool::execute( cfg::cmd::CommandLine &cmd ) {
	if (cmd.isSet("set")) {
		set();
	}
	if (cmd.isSet("debug")) {
		debug();
	}

	if (cmd.isSet("help")) {
		printf("%s allowed options\n%s\n", name().c_str(), cmd.desc().c_str());
	} else if (cmd.isSet("version")) {
		printVersion();
	} else if (cmd.isSet("build")) {
		printBuild();
	} else if (cmd.isSet("pretend")) {
		pretend();
	} else if (cmd.isSet("defaults")) {
		defaults();
	} else {
		setupSignals();

		//	Initialize log system
		util::log::init();

		int result = run( cmd );

		//	Finalize log system
		util::log::fin();

		return result;
	}
	return 0;
}
コード例 #2
0
ファイル: SchedMain.c プロジェクト: horsetailfiddlehead/ee478
void main() {
    int i = 0;
    int j = 0;
    char test[2] = {'2', '\0'};

    systemSetup(&globalData);

#if FRONT_NOT_BACK
    TRISAbits.RA0 = 0;
    ANSELAbits.ANSA0 = 0;

    printMainMenu(&globalData);
#else
    //    TRISDbits.RD4 = 0;
    //    ANSELDbits.ANSD4 = 0;
    //    PORTDbits.RD4 = 1;
#endif



    while (1) {
#if FRONT_NOT_BACK


        // get the updated cards
        if (globalData.runGetUpdatedCards == 1) {
            getUpdatedCards();
            globalData.runGetUpdatedCards = FALSE;
        }
#else
        // move the reader -- if we had one -- to the proper location


        /*
         * run LED driver
         */
        if (globalData.updateLEDFlag) {
            globalData.updateLEDFlag = FALSE;
            updateLEDs();
        }
#endif

        // process pending i2c tasks
        if (globalData.sendI2C == 1) {
            sendBytes(i2cData.dataOut, i2cData.outLength);
            globalData.sendI2C = FALSE;
        }
        if (globalData.gotI2C == 1) {
            processI2C();
            globalData.gotI2C = 0;
        }

#if FRONT_NOT_BACK
        if (!globalData.keyFlag) {
            // Check keystroke
            keypad(&globalData);
        }

        if (globalData.keyFlag && !globalData.displayedKey || globalData.myRequestStatus != 0) {
            globalData.keyFlag = FALSE;
            globalData.displayedKey = TRUE;

            switch (globalData.displayPage) {
                case 0: // main menu
                    processPrintCursor(&globalData, 3, BLUE, WHITE);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to singleplayer
                                globalData.displayPage = 1;
                                printSelectGame(&globalData);
                                break;
                            case 1: // multi
                                globalData.displayPage = 2;
                                printSelectGame(&globalData);
                                break;
                            case 2: // build
                                globalData.displayPage = 3;
                                printBuild(&globalData);
                                break;
                            case 0xFF: // back
                                globalData.displayPage = 0;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                    }
                    break;
                case 1: // display sp game menu
                    processPrintCursor(&globalData, 4, GREEN, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                globalData.displayPage = 4;
                                singlePlayer(&globalData);
                                break;
                            case 1: // go to clue
                                globalData.displayPage = 5;
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                break;
                            case 2: // go to error
                                globalData.displayPage = 6;
                                printBSOD();
                                break;
                            case 3: // go to error
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                globalData.displayPage = 7;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 2: // display mp game menu
                    processPrintCursor(&globalData, 4, GREEN, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                globalData.displayPage = 4;
                                printSelectGame(&globalData);
                                break;
                            case 1: // go to clue
                                globalData.displayPage = 5;
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                break;
                            case 2: // go to error
                                globalData.displayPage = 6;
                                printBSOD();
                                break;
                            case 3: // go to error
                                clean(BLACK);
                                prints(0, 35, WHITE, BLACK, "In Progress", 1);
                                globalData.displayPage = 7;
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 3: // build cards
                    processPrintCursor(&globalData, 4, RED, BLACK);
                    if (globalData.newDisplay == 1) {
                        globalData.newDisplay = 0;
                        switch (globalData.cursorPos) {
                            case 0: // go to monster game
                                buildCard(&globalData, 0);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 1: // go to clue
                                buildCard(&globalData, 1);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 2: // go to error
                                buildCard(&globalData, 2);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            case 3: // go to error
                                buildCard(&globalData, 3);
                                clean(BLACK);
                                prints(140, 35, BLACK, RED, "DONE", 1);
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                            default:
                                globalData.displayPage = 0;
                                printMainMenu(&globalData);
                                break;
                        }
                        globalData.cursorPos = 0;
                    }
                    break;
                case 4: // singleplayer monster
                    singlePlayer(&globalData);
                    break;
                case 5: // clue sp
                    break;
                case 6: // bsod
                    break;
                case 7: // in progress, b goes back
                    if (globalData.keyPress == 0x0B) {
                        globalData.displayPage = 0;
                        printMainMenu(&globalData);
                    }
                    break;
            }
        }


        //        if (!globalData.keyFlag) {
        //            keypad(&globalData);
        //        }

        //        mainMenu(&globalData);

        //
        //        if (globalData.keyFlag && !globalData.displayedKey) { // TODO this goes into a display function
        //            globalData.keyFlag = FALSE;
        //            globalData.displayedKey = TRUE;
        //
        ////            processDisplay(globalData);
        //
        //        }


#else
        //Doing an inventory command from the Build card menu
        if (globalData.readCard != 0) {

            //            globalData.getInventory = TRUE;
            //        }
            //        if (globalData.getInventory == TRUE) {
            // get the inventory of cards
            inventoryRFID();

            // Print out each on to the LCD
            for (i = 0; i < readerData.availableUIDs; i++) {
                if (readerData.readUID[i][0] != ',') {
                    // Get rid of commas
                    processUID(readerData.readUID[i]);
                    //                    printrs(0, 24 + 8 * i, BLACK, RED, readerData.readUID[i], 1); // print first UID
                }
            }

            // got inventory, tell frontend
            i2cData.dataOut[0] = CARD_CHANGE;
            i2cData.outLength = 1;
            globalData.sendI2C = TRUE;
            i2cData.transmissionNum = 0; // begin counting slots

            // Tell UID to be quiet - Works but needs to have at least one uid in this state
            // quietRFID(readerData.readUID[0]);

            //            if (readerData.availableUIDs > 0) {
            //
            //                // block 0 high bits being 0x0000 indicates factory card, not custom
            //                // block 0 high bits being 0x0001 indicates custom card
            //                // block 0 low bits indicate the game the card is for. 0x0001 is the monster game
            //                writeRFID(readerData.readUID[0], 0x00, 0x0000, 0x0001); // 7654 3210
            //                writeRFID(readerData.readUID[0], 0x01, 0x0010, 0x0001); // hex 7-5 are for level 0x001 is level 1
            //                // hex 4 is for type 0 1 2 3
            //                // 0x0 fire, 0x1 water, 0x3 earth
            //                // last 4 are monster ID
            //
            //                //writes 8 chars in 2 addresses of memory (0x02 and 0x03 here)
            //                char8RFID(readerData.readUID[0], 0x02, "FIREDUDE");
            //                writeRFID(readerData.readUID[0], 0x04, 0x0003, 0x0201); // Move list by id, has moves 03, 02, and 01
            //                readRFID(readerData.readUID[0], 0x00);
            //                printrs(0, 32, BLACK, RED, readerData.readData, 1); // print 1st block
            //                readRFID(readerData.readUID[0], 0x01);
            //                printrs(0, 40, BLACK, RED, readerData.readData, 1); // print 2nd block
            //                readRFID(readerData.readUID[0], 0x02);
            //                printrs(0, 48, BLACK, RED, readerData.readData, 1); // print 3rd block
            //                readRFID(readerData.readUID[0], 0x03);
            //                printrs(0, 56, BLACK, RED, readerData.readData, 1); // print 4th block
            //                readRFID(readerData.readUID[0], 0x04);
            //                printrs(0, 64, BLACK, RED, readerData.readData, 1); // print 5th block
            //            }
            //
            //
            //            readRFID(readerData.readUID[0], 0x01);
            //            // Print out block on to the LCD
            //            for (j = 0; j < readerData.availableUIDs; j++) {
            //                if (readerData.readUID[j][0] != ',') {
            //                    // Get rid of commas
            //                    printrs(0, 24 + 8 * i + 8 * j, BLACK, RED, readerData.readUID[j], 1); // print first UID
            //                }
            //            }
            //
            //            prints(0, H - 8, BLACK, RED, "Press B to go back.", 1);
            //            // Turn off inventory flag

            //            globalData.getInventory = FALSE;
            globalData.readCard = 0;
        }
#endif
    }
    return;


}