Beispiel #1
0
MooseEnumBase::MooseEnumBase(std::string names, bool allow_out_of_range) :
    _out_of_range_index(allow_out_of_range ? INVALID_ID + 1 : 0)
{
  if (names.find(',') != std::string::npos)
  {
    mooseDeprecated("Please use a space to separate options in a MooseEnum, commas are deprecated\nMooseEnum initialized with names: \"" << names << '\"');
    fillNames(names, ",");
  }
  else
    fillNames(names);
}
std::vector<std::string> ColorGradientPreparation::names() const
{
    std::vector<std::string> result;

    fillNames(result);

    return result;
}
NameManager::NameManager() {
	setLoggingName("NameManager");

	initialize();

	profaneNames = new Vector<String>(55, 5); //based on the original number of banned words
	developerNames = new BannedNameSet();
	reservedNames = new BannedNameSet();
	fictionNames = new BannedNameSet();

	fillNames();

	setLogging(false);
}
Beispiel #4
0
void PeerData::updateNameDelayed(
		const QString &newName,
		const QString &newNameOrPhone,
		const QString &newUsername) {
	if (name == newName) {
		if (isUser()) {
			if (asUser()->nameOrPhone == newNameOrPhone
				&& asUser()->username == newUsername) {
				return;
			}
		} else if (isChannel()) {
			if (asChannel()->username == newUsername) {
				return;
			}
		} else if (isChat()) {
			return;
		}
	}

	++nameVersion;
	name = newName;
	nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
	refreshEmptyUserpic();

	Notify::PeerUpdate update(this);
	update.flags |= UpdateFlag::NameChanged;
	update.oldNameFirstChars = nameFirstChars();

	if (isUser()) {
		if (asUser()->username != newUsername) {
			asUser()->username = newUsername;
			update.flags |= UpdateFlag::UsernameChanged;
		}
		asUser()->setNameOrPhone(newNameOrPhone);
	} else if (isChannel()) {
		if (asChannel()->username != newUsername) {
			asChannel()->username = newUsername;
			if (newUsername.isEmpty()) {
				asChannel()->removeFlags(
					MTPDchannel::Flag::f_username);
			} else {
				asChannel()->addFlags(MTPDchannel::Flag::f_username);
			}
			update.flags |= UpdateFlag::UsernameChanged;
		}
	}
	fillNames();
	Notify::PeerUpdated().notify(update, true);
}
Beispiel #5
0
void TestDataSet::createCountTable() {
    fillGroup();
    fillNames();
    ct = new CountTable();
    
    for (map<string, string>::iterator itNameMap = nameMap.begin(); itNameMap !=nameMap.end(); itNameMap++) {
        string firstCol = itNameMap->first;
        string secondCol = itNameMap->second;
        vector<string> names;
        util.splitAtChar(secondCol, names, ',');
        
        //set to 0
        map<string, int> groupCounts;
        int total = 0;
        vector<string> Groups = gMap->getNamesOfGroups();
        ct->setNamesOfGroups(Groups);
        for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
        
        //get counts for each of the users groups
        for (int i = 0; i < names.size(); i++) {
            string group = gMap->getGroup(names[i]);
            
            map<string, int>::iterator it = groupCounts.find(group);
            
            //if not found, then this sequence is not from a group we care about
            if (it != groupCounts.end()) {
                it->second++;
                total++;
            }
        }
        
        if (total != 0) {
            vector<int> abunds;
            for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) { abunds.push_back(it->second); }
            ct->push_back(firstCol, abunds);
        }
    }
    delete gMap; gMap = NULL;
    nameMap.clear();
}
Beispiel #6
0
int ibis::selectClause::parse(const char *cl) {
    int ierr = 0;
    if (cl != 0 && *cl != 0) {
        clear();
        LOGGER(ibis::gVerbose > 5)
            << "selectClause::parse cleared existing content before parsing \""
            << cl << "\"";

        if (clause_.c_str() != cl)
            clause_ = cl;
        std::istringstream iss(clause_);
        ibis::util::logger lg;
        selectLexer lx(&iss, &(lg()));
        selectParser parser(*this);
        lexer = &lx;
#if DEBUG+0 > 2
        parser.set_debug_level(DEBUG-1);
#elif _DEBUG+0 > 2
        parser.set_debug_level(_DEBUG-1);
#endif
        parser.set_debug_stream(lg());
        ierr = parser.parse();
        lexer = 0;
        if (ierr == 0) {
            fillNames();
        }
        else {
            clear();
            LOGGER(ibis::gVerbose > 0)
                << "Warning -- selectClause::parse failed to parse string \""
                << cl << "\"";
#ifdef FASTBIT_HALT_ON_PARSER_ERROR
            throw "selectClause failed to parse the incoming string"
                IBIS_FILE_LINE;
#endif
        }
    }
    return ierr;
} // ibis::selectClause::parse
Beispiel #7
0
void menuUp1(uint8_t event)
{
	FRESULT fr ;
	struct fileControl *fc = &FileControl ;
  static uint8_t mounted = 0 ;
	static uint32_t state ;
	static uint32_t firmwareAddress ;
	uint32_t i ;
	uint32_t width ;
	 
	if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
	{
  	TITLE( "UPDATE BOOT" ) ;
	}
	else
	{
#ifdef PCBX9D
		if (UpdateItem == UPDATE_TYPE_SPORT_INT )
		{
  		TITLE( "UPDATE Int. XJT" ) ;
		}
		else
		{
  		TITLE( "UPDATE Ext. SPort" ) ;
		}
#endif

#ifdef PCBSKY
 #ifndef REVX
 		if (UpdateItem == UPDATE_TYPE_COPROCESSOR )
		{
  		TITLE( "UPDATE COPROC" ) ;
		}
		else
		{
  		TITLE( "UPDATE SPort" ) ;
		}
 #else
 		if (UpdateItem == UPDATE_TYPE_SPORT_EXT )
		{
  		TITLE( "UPDATE SPort" ) ;
		}
 #endif
#endif
	}
	switch(event)
	{
    case EVT_ENTRY:
			state = UPDATE_NO_FILES ;
			if ( mounted == 0 )
			{
#if defined(PCBTARANIS)
  			fr = f_mount(0, &g_FATFS_Obj) ;
#else				
  			fr = f_mount(0, &g_FATFS) ;
#endif
#ifdef PCBX9D
				unlockFlash() ;
#endif
			}
			else
			{
				fr = FR_OK ;
			}
			if ( fr == FR_OK)
			{
				mounted = 1 ;
			}
			if ( mounted )
			{
				fr = f_chdir( (TCHAR *)"\\firmware" ) ;
				if ( fr == FR_OK )
				{
					state = UPDATE_NO_FILES ;
					fc->index = 0 ;
					fr = f_opendir( &Dj, (TCHAR *) "." ) ;
					if ( fr == FR_OK )
					{
 						if ( (UpdateItem > 1 ) )
						{
							fc->ext[0] = 'F' ;
							fc->ext[1] = 'R' ;
							fc->ext[2] = 'K' ;
						}
						else
						{
							fc->ext[0] = 'B' ;
							fc->ext[1] = 'I' ;
							fc->ext[2] = 'N' ;
						}
						fc->ext[3] = 0 ;
						fc->index = 0 ;
						fc->nameCount = fillNames( 0, fc ) ;
						fc->hpos = 0 ;
						fc->vpos = 0 ;
						if ( fc->nameCount )
						{
							state = UPDATE_FILE_LIST ;
						}
					}
				}
			}
    break ;
    
		case EVT_KEY_FIRST(KEY_EXIT):
			if ( state < UPDATE_ACTION )
			{
      	chainMenu(menuUpdate) ;
    		killEvents(event) ;
			}
    break ;
	}

	switch ( state )
	{
		case UPDATE_NO_FILES :
			lcd_puts_Pleft( 4*FH, "\005No Files" ) ;
	    lcd_outdez( 21*FW, 4*FH, mounted ) ;
    break ;
		
		case UPDATE_FILE_LIST :
			SportVerValid = 0 ;
			if ( fileList( event, &FileControl ) == 1 )
			{
				state = UPDATE_CONFIRM ;
			}
    break ;
		case UPDATE_CONFIRM :
 			if ( (UpdateItem > UPDATE_TYPE_BOOTLOADER ) )
			{
#ifdef PCBX9D
 				if ( (UpdateItem == UPDATE_TYPE_SPORT_INT ) )
				{
					lcd_puts_Pleft( 2*FH, "Flash Int. XJT from" ) ;
				}
				else
				{
					lcd_puts_Pleft( 2*FH, "Flash Ext.SP from" ) ;
				}
				SportVerValid = 0 ;
#else
 #ifndef REVX
 				if ( (UpdateItem == UPDATE_TYPE_COPROCESSOR ) )
				{
					lcd_puts_Pleft( 2*FH, "Flash Co-Proc. from" ) ;
				}
				else
				{
					lcd_puts_Pleft( 2*FH, "Flash SPort from" ) ;
				}
				CoProcReady = 0 ;
 #else
				lcd_puts_Pleft( 2*FH, "Flash SPort from" ) ;
 #endif
#endif
			}
			else
			{
				lcd_puts_Pleft( 2*FH, "Flash Bootloader from" ) ;
			}
			cpystr( cpystr( (uint8_t *)FlashFilename, (uint8_t *)"\\firmware\\" ), (uint8_t *)Filenames[fc->vpos] ) ;
#if defined(PCBTARANIS)
			lcd_putsnAtt( 0, 4*FH, Filenames[fc->vpos], DISPLAY_CHAR_WIDTH, 0 ) ;
#else
			lcd_putsnAtt0( 0, 4*FH, Filenames[fc->vpos], DISPLAY_CHAR_WIDTH, 0 ) ;
#endif
			if ( event == EVT_KEY_LONG(KEY_MENU) )
			{
				state = UPDATE_SELECTED ;
			}
			if ( event == EVT_KEY_LONG(KEY_EXIT) )
			{
				state = UPDATE_FILE_LIST ;		// Canceled
			}
    break ;
		case UPDATE_SELECTED :
			f_open( &FlashFile, FlashFilename, FA_READ ) ;
			f_read( &FlashFile, (BYTE *)FileData, 1024, &BlockCount ) ;
			i = 1 ;
			if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
			{
				i = validateFile( (uint32_t *) FileData ) ;
			}
			if ( i == 0 )
			{
				state = UPDATE_INVALID ;
			}
			else
			{
				if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
				{
#ifdef PCBX9D
					firmwareAddress = 0x08000000 ;
#endif
#ifdef PCBSKY
					firmwareAddress = 0x00400000 ;
#endif
				}
#ifdef PCBSKY
 #ifndef REVX
				else if (UpdateItem == UPDATE_TYPE_COPROCESSOR )		// Bootloader
				{
					firmwareAddress = 0x00000080 ;
					if ( check_ready() == 0 )
					{
						CoProcReady = 1 ;
					}
				}
 #endif
#endif
				else
				{
// SPort update
					SportState = SPORT_START ;
					FirmwareSize = FileSize[fc->vpos] ;
					BlockInUse = 0 ;
					f_read( &FlashFile, (BYTE *)ExtraFileData, 1024, &XblockCount ) ;
				}
				BytesFlashed = 0 ;
				BlockOffset = 0 ;
				ByteEnd = 1024 ;
				state = UPDATE_ACTION ;
			}
    break ;
		case UPDATE_INVALID :
			lcd_puts_Pleft( 2*FH, "Invalid File" ) ;
			lcd_puts_Pleft( 4*FH, "Press EXIT" ) ;
			if ( event == EVT_KEY_FIRST(KEY_EXIT) )
			{
				state = UPDATE_FILE_LIST ;		// Canceled
    		killEvents(event) ;
			}
    break ;
		case UPDATE_ACTION :
			// Do the flashing
			lcd_puts_Pleft( 3*FH, "Flashing" ) ;
			if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
			{
				width = ByteEnd >> 9 ;
				if ( BytesFlashed < ByteEnd )
				{
					program( (uint32_t *)firmwareAddress, &((uint32_t *)FileData)[BlockOffset] ) ;	// size is 256 bytes
					BlockOffset += 64 ;		// 32-bit words (256 bytes)
					firmwareAddress += 256 ;
					BytesFlashed += 256 ;
				}
				else
				{
					if ( ByteEnd >= 32768 )
					{
						state = UPDATE_COMPLETE ;
					}
					else
					{
						f_read( &FlashFile, (BYTE *)FileData, 1024, &BlockCount ) ;
						ByteEnd += 1024 ;
						BlockOffset = 0 ;
					}
				}
			}

#ifdef PCBSKY
 #ifndef REVX
			else if (UpdateItem == UPDATE_TYPE_COPROCESSOR )		// CoProcessor
Beispiel #8
0
uint32_t fileList(uint8_t event, struct fileControl *fc )
{
	uint32_t limit ;
	uint32_t result = 0 ;
  uint8_t maxhsize ;
	uint32_t i ;
			 
	limit = 6 ;
	if ( fc->nameCount < limit )
	{
		limit = fc->nameCount ;						
	}
	maxhsize = 0 ;
	for ( i = 0 ; i < limit ; i += 1 )
	{
		uint32_t x ;
		uint32_t len ;
		len = x = strlen( Filenames[i] ) ;
		if ( x > maxhsize )
		{
			maxhsize = x ;							
		}
		if ( x > DISPLAY_CHAR_WIDTH )
		{
			if ( ( fc->hpos + DISPLAY_CHAR_WIDTH ) > x )
			{
				x = x - DISPLAY_CHAR_WIDTH ;
			}
			else
			{
				x = fc->hpos ;
			}
			len = DISPLAY_CHAR_WIDTH ;
		}
		else
		{
			x = 0 ;
		}
		lcd_putsn_P( 0, 16+FH*i, &Filenames[i][x], len ) ;
	}

#if !defined(PCBTARANIS)
	if ( event == 0 )
	{
extern int32_t Rotary_diff ;
		if ( Rotary_diff > 0 )
		{
			event = EVT_KEY_FIRST(KEY_DOWN) ;
		}
		else if ( Rotary_diff < 0 )
		{
			event = EVT_KEY_FIRST(KEY_UP) ;
		}
		Rotary_diff = 0 ;
	}
#endif

	if ( ( event == EVT_KEY_REPT(KEY_DOWN) ) || event == EVT_KEY_FIRST(KEY_DOWN) )
	{
		if ( fc->vpos < limit-1 )
		{
			fc->vpos += 1 ;
		}
		else
		{
			if ( fc->nameCount > limit )
			{
				fc->index += 1 ;
				fc->nameCount = fillNames( fc->index, fc ) ;
			}
		}
	}
	if ( ( event == EVT_KEY_REPT(KEY_UP)) || ( event == EVT_KEY_FIRST(KEY_UP) ) )
	{
		if ( fc->vpos > 0 )
		{
			fc->vpos -= 1 ;
		}
		else
		{
			if ( fc->index )
			{
				fc->index -= 1 ;
				fc->nameCount = fillNames( fc->index, fc ) ;
			}
		}
	}
	if ( ( event == EVT_KEY_REPT(MKEY_RIGHT)) || ( event == EVT_KEY_FIRST(MKEY_RIGHT) ) )
	{
		if ( fc->hpos + DISPLAY_CHAR_WIDTH < maxhsize )	fc->hpos += 1 ;
	}
	if ( ( event == EVT_KEY_REPT(MKEY_LEFT)) || ( event == EVT_KEY_FIRST(MKEY_LEFT) ) )
	{
		if ( fc->hpos )	fc->hpos -= 1 ;
	}
	if ( ( event == EVT_KEY_LONG(KEY_MENU) ) || ( event == EVT_KEY_BREAK(BTN_RE) ) )
	{
		// Select file to flash
		killEvents(event);
		result = 1 ;
	}
	if ( ( event == EVT_KEY_FIRST(KEY_EXIT) ) || ( event == EVT_KEY_LONG(BTN_RE) ) )
	{
		// Select file to flash
		result = 2 ;
	}
	if ( event == EVT_KEY_BREAK(KEY_MENU) )
	{
		// Tag file
		result = 3 ;
	}
#if defined(PCBTARANIS)
	lcd_filled_rect( 0, 2*FH+FH*fc->vpos, DISPLAY_CHAR_WIDTH*FW, 8, 0xFF, 0 ) ;
#else
	lcd_char_inverse( 0, 2*FH+FH*fc->vpos, DISPLAY_CHAR_WIDTH*FW, 0 ) ;
#endif
	return result ;
}
Beispiel #9
0
int main()
{
  uint8_t index = 0;
  uint8_t maxhsize = DISPLAY_CHAR_WIDTH;
  FRESULT fr;
  uint32_t state = ST_START;
  uint32_t nameCount = 0;
  uint32_t vpos = 0;
  uint32_t hpos = 0;

#if defined(PCBTARANIS)
  wdt_reset();
  RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; 		// Enable portA clock
#endif

  pwrInit();

#if defined(PCBSKY9X)
  MATRIX->CCFG_SYSIO |= 0x000000F0L;		// Disable syspins, enable B4,5,6,7
#endif

#if defined(PCBSKY9X)
  init_SDcard();
  PIOC->PIO_PER = PIO_PC25;		// Enable bit C25 (USB-detect)
  start_timer0();
#endif

  lcdInit();
#if defined(PCBSKY9X)
  extern uint8_t OptrexDisplay;
  OptrexDisplay = 1;
#endif
  lcd_clear();
  lcd_putsLeft(0, BOOTLOADER_TITLE);
  lcd_invert_line(0);
  lcdRefresh();
#if defined(PCBSKY9X)
  OptrexDisplay = 0;
  lcdRefresh();
#endif

#if defined(PCBTARANIS)
  keysInit();
  I2C_EE_Init();
  init_hw_timer();
#endif

  __enable_irq();
  init10msTimer();

#if defined(PCBSKY9X)
  EblockAddress = -1;
  init_spi();
#endif

#if defined(PCBSKY9X)
  LockBits = readLockBits();
  if (LockBits) {
    clearLockBits();
  }
#endif

#if defined(PCBTARANIS)
  // SD card detect pin
  sdInit();
  usbInit();
  usbStart();
#endif

  for (;;) {
    wdt_reset();

    if (Tenms) {

      if (EE_timer) {
        if (--EE_timer == 0) {
#if defined(PCBSKY9X)
          writeBlock();
#endif
        }
      }

      Tenms = 0;

      lcd_clear();
      lcd_putsLeft(0, BOOTLOADER_TITLE);
      lcd_invert_line(0);

      uint8_t event = getEvent();

      if (state != ST_USB) {
        if (usbPlugged()) {
          state = ST_USB;
          if (!unlocked) {
            unlocked = 1;
            unlockFlash();
          }
          usbPluggedIn();
        }
      }

      if (state == ST_START) {
        lcd_putsLeft(2*FH, "\010Write Firmware");
        lcd_putsLeft(3*FH, "\010Restore EEPROM");
        lcd_putsLeft(4*FH, "\010Exit");
        lcd_invert_line(2+vpos);
        lcd_putsLeft(7*FH, INDENT "Or plug in a USB cable for mass storage");
        if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
          vpos == 2 ? vpos = 0 : vpos = vpos+1;
        }
        else if (event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
          vpos == 0 ? vpos = 2 : vpos = vpos-1;
        }
        else if (event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          switch (vpos) {
            case 0:
              state = ST_FLASH_MENU;
              break;
            case 1:
              state = ST_RESTORE_MENU;
              break;
            default:
              state = ST_REBOOT;
          }
        }
      }

      if (state == ST_USB) {
        lcd_putsLeft(4*FH, "\026USB Connected");
        if (usbPlugged() == 0) {
          vpos = 0;
          if (unlocked) {
            lockFlash();
            unlocked = 0;
          }
          state = ST_START;
        }
#if defined(PCBSKY9X)
        usbMassStorage();
#endif
      }

      if (state == ST_FLASH_MENU || state == ST_RESTORE_MENU) {
        sdInit();
        memoryType = (state == ST_RESTORE_MENU ? MEM_EEPROM : MEM_FLASH);
        state = ST_DIR_CHECK;
      }

      else if (state == ST_DIR_CHECK) {
        fr = f_chdir(getBinaryPath());
        if (fr == FR_OK) {
          state = ST_OPEN_DIR;
        }
        else {
          lcd_putsLeft(2*FH, INDENT "Directory is missing!");
          if (event == EVT_KEY_BREAK(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
            vpos = 0;
            state = ST_START;
          }
        }
      }

      if (state == ST_OPEN_DIR) {
        index = 0;
        fr = f_opendir(&Dj, ".");
        if (fr == FR_OK) {
          state = ST_FILE_LIST;
          nameCount = fillNames(0);
          hpos = 0;
          vpos = 0;
        }
      }

      if (state == ST_FILE_LIST) {
        uint32_t limit = 6;
        if (nameCount < limit) {
          limit = nameCount;
        }
        maxhsize = 0;
        for (uint32_t i=0; i<limit; i++) {
          uint32_t x;
          x = strlen(Filenames[i]);
          if (x > maxhsize) {
            maxhsize = x;
          }
          if (x > DISPLAY_CHAR_WIDTH) {
            if (hpos + DISPLAY_CHAR_WIDTH > x) {
              x = x - DISPLAY_CHAR_WIDTH;
            }
            else {
              x = hpos;
            }
          }
          else {
            x = 0;
          }
          lcd_putsnAtt(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0);
        }

        if (event == EVT_KEY_REPT(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
          if (vpos < limit - 1) {
            vpos += 1;
          }
          else {
            if (nameCount > limit) {
              index += 1;
              nameCount = fillNames(index);
            }
          }
        }
        else if (event == EVT_KEY_REPT(BOOT_KEY_UP) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
          if (vpos > 0) {
            vpos -= 1;
          }
          else {
            if (index) {
              index -= 1;
              nameCount = fillNames(index);
            }
          }
        }
#if !defined(PCBTARANIS)
        else if (event == EVT_KEY_REPT(BOOT_KEY_RIGHT) || event == EVT_KEY_FIRST(BOOT_KEY_RIGHT)) {
          if (hpos + DISPLAY_CHAR_WIDTH < maxhsize) {
            hpos += 1;
          }
        }
        else if (event == EVT_KEY_REPT(BOOT_KEY_LEFT) || event == EVT_KEY_FIRST(BOOT_KEY_LEFT)) {
          if (hpos) {
            hpos -= 1;
          }
        }
#endif
        else if (event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          // Select file to flash
          state = ST_FLASH_CHECK;
          Valid = 0;
        }
        else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
          state = ST_START;
          vpos = 0;
        }

        lcd_invert_line(2 + vpos);
      }

      else if (state == ST_FLASH_CHECK) {
        int result = menuFlashFile(vpos, event);
        FirmwareSize = FileSize[vpos] - BOOTLOADER_SIZE;
        if (result == 0) {
          // canceled
          state = ST_FILE_LIST;
        }
        else if (result == 1) {
          // confirmed
          firmwareAddress = FIRMWARE_ADDRESS + BOOTLOADER_SIZE;
          firmwareWritten = 0;
          eepromAddress = 0;
          eepromWritten = 0;
          state = ST_FLASHING;
        }
      }

      else if (state == ST_FLASHING) {
        // commit to flashing
        lcd_putsLeft(4*FH, "\032Writing...");
        
        if (!unlocked && (memoryType == MEM_FLASH)) {
          unlocked = 1;
          unlockFlash();
        }
        
        int progress;
        if (memoryType == MEM_FLASH) {
          writeFlashBlock();
          firmwareWritten += sizeof(Block_buffer);
          progress = (200*firmwareWritten) / FirmwareSize;
        }
        else {
          writeEepromBlock();
          eepromWritten += sizeof(Block_buffer);
          progress = (200*eepromWritten) / EESIZE;
        }

        lcd_rect( 3, 6*FH+4, 204, 7);
        lcd_hline(5, 6*FH+6, progress, FORCE);
        lcd_hline(5, 6*FH+7, progress, FORCE);
        lcd_hline(5, 6*FH+8, progress, FORCE);

        fr = f_read(&FlashFile, (BYTE *)Block_buffer, sizeof(Block_buffer), &BlockCount);
        if (BlockCount == 0) {
          state = ST_FLASH_DONE; // EOF
        }
        if (firmwareWritten >= FLASHSIZE - BOOTLOADER_SIZE) {
          state = ST_FLASH_DONE; // Backstop
        }
        if (eepromWritten >= EESIZE) {
          state = ST_FLASH_DONE; // Backstop
        }
      }

      if (state == ST_FLASH_DONE) {
        if (unlocked) {
          lockFlash();
          unlocked = 0;
        }
        lcd_putsLeft(4*FH, "\024Writing Complete");
        if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          state = ST_START;
          vpos = 0;
        }
      }

      if (event == EVT_KEY_LONG(BOOT_KEY_EXIT)) {
        state = ST_REBOOT;
      }

      lcdRefresh();

      if (PowerUpDelay < 20) {	// 200 mS
        PowerUpDelay += 1;
      }
      else {
        sdPoll10ms();
      }
    }

    if (pwrCheck() == e_power_off && state != ST_FLASHING && state != ST_USB) {
      pwrOff();
      for (;;) {
        // Wait for power to go off
      }
    }

    if (state == ST_REBOOT) {
      if ((~readKeys() & 0x7E) == 0) {
        NVIC_SystemReset();
      }
    }
  }

  return 0;
}
Beispiel #10
0
int main()
{
  uint8_t index = 0;
  uint8_t maxhsize = DISPLAY_CHAR_WIDTH;
  FRESULT fr;
  uint32_t state = ST_START;
  uint32_t nameCount = 0;
  uint32_t vpos = 0;
  uint32_t hpos = 0;

#if defined(PCBTARANIS)
  wdt_reset();
  RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | KEYS_RCC_AHB1Periph | LCD_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph | I2C_RCC_AHB1Periph | SD_RCC_AHB1Periph, ENABLE);
  RCC_APB1PeriphClockCmd(LCD_RCC_APB1Periph | BACKLIGHT_RCC_APB1Periph | INTERRUPT_5MS_APB1Periph | I2C_RCC_APB1Periph | SD_RCC_APB1Periph, ENABLE);
  RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph, ENABLE);
#endif

  pwrInit();
  delaysInit();               //needed for lcdInit()
  lcdInit();
  backlightInit();

  lcd_clear();
  lcd_putsn(0, 0, (const char *)bootloaderVersion, 0); // trick to avoid bootloaderVersion to be optimized out ...
  lcd_putsLeft(0, BOOTLOADER_TITLE);
  lcd_invert_line(0);
  lcdRefresh();

  keysInit();
  i2cInit();

  __enable_irq();
  init10msTimer();

#if defined(PCBTARANIS)
  // SD card detect pin
  sdInit();
  usbInit();
#endif

  for (;;) {
    wdt_reset();

    if (Tenms) {
      Tenms = 0;

      lcdRefreshWait();
      lcd_clear();
      lcd_putsLeft(0, BOOTLOADER_TITLE);
      lcd_invert_line(0);

      uint8_t event = getEvent();

      if (state != ST_USB) {
        if (usbPlugged()) {
          state = ST_USB;
          if (!unlocked) {
            unlocked = 1;
            unlockFlash();
          }
          usbPluggedIn();
        }
      }

      if (state == ST_START) {
        lcd_putsLeft(2*FH, "\010Write Firmware");
        lcd_putsLeft(3*FH, "\010Restore EEPROM");
        lcd_putsLeft(4*FH, "\010Exit");
        lcd_invert_line(2+vpos);
        lcd_putsLeft(7*FH, INDENT "Or plug in a USB cable for mass storage");
        if (event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
          vpos == 2 ? vpos = 0 : vpos = vpos+1;
        }
        else if (event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
          vpos == 0 ? vpos = 2 : vpos = vpos-1;
        }
        else if (event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          switch (vpos) {
            case 0:
              state = ST_FLASH_MENU;
              break;
            case 1:
              state = ST_RESTORE_MENU;
              break;
            default:
              state = ST_REBOOT;
          }
        }
      }

      if (state == ST_USB) {
        lcd_putsLeft(4*FH, "\026USB Connected");
        if (usbPlugged() == 0) {
          vpos = 0;
          if (unlocked) {
            lockFlash();
            unlocked = 0;
          }
          state = ST_START;
        }
#if defined(PCBSKY9X)
        usbMassStorage();
#endif
      }

      if (state == ST_FLASH_MENU || state == ST_RESTORE_MENU) {
        sdInit();
        memoryType = (state == ST_RESTORE_MENU ? MEM_EEPROM : MEM_FLASH);
        state = ST_DIR_CHECK;
      }

      else if (state == ST_DIR_CHECK) {
        fr = f_chdir(getBinaryPath());
        if (fr == FR_OK) {
          state = ST_OPEN_DIR;
        }
        else {
          lcd_putsLeft(2*FH, INDENT "Directory is missing!");
          if (event == EVT_KEY_BREAK(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
            vpos = 0;
            state = ST_START;
          }
        }
      }

      if (state == ST_OPEN_DIR) {
        index = 0;
        fr = f_opendir(&Dj, ".");
        if (fr == FR_OK) {
          state = ST_FILE_LIST;
          nameCount = fillNames(0);
          hpos = 0;
          vpos = 0;
        }
      }

      if (state == ST_FILE_LIST) {
        uint32_t limit = 6;
        if (nameCount < limit) {
          limit = nameCount;
        }
        maxhsize = 0;
        for (uint32_t i=0; i<limit; i++) {
          uint32_t x;
          x = strlen(Filenames[i]);
          if (x > maxhsize) {
            maxhsize = x;
          }
          if (x > DISPLAY_CHAR_WIDTH) {
            if (hpos + DISPLAY_CHAR_WIDTH > x) {
              x = x - DISPLAY_CHAR_WIDTH;
            }
            else {
              x = hpos;
            }
          }
          else {
            x = 0;
          }
          lcd_putsnAtt(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0);
        }

        if (event == EVT_KEY_REPT(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) {
          if (vpos < limit - 1) {
            vpos += 1;
          }
          else {
            if (nameCount > limit) {
              index += 1;
              nameCount = fillNames(index);
            }
          }
        }
        else if (event == EVT_KEY_REPT(BOOT_KEY_UP) || event == EVT_KEY_FIRST(BOOT_KEY_UP)) {
          if (vpos > 0) {
            vpos -= 1;
          }
          else {
            if (index) {
              index -= 1;
              nameCount = fillNames(index);
            }
          }
        }
#if !defined(PCBTARANIS)
        else if (event == EVT_KEY_REPT(BOOT_KEY_RIGHT) || event == EVT_KEY_FIRST(BOOT_KEY_RIGHT)) {
          if (hpos + DISPLAY_CHAR_WIDTH < maxhsize) {
            hpos += 1;
          }
        }
        else if (event == EVT_KEY_REPT(BOOT_KEY_LEFT) || event == EVT_KEY_FIRST(BOOT_KEY_LEFT)) {
          if (hpos) {
            hpos -= 1;
          }
        }
#endif
        else if (event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          // Select file to flash
          state = ST_FLASH_CHECK;
          Valid = 0;
        }
        else if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT)) {
          state = ST_START;
          vpos = 0;
        }

        lcd_invert_line(2 + vpos);
      }

      else if (state == ST_FLASH_CHECK) {
        int result = menuFlashFile(vpos, event);
        FirmwareSize = FileSize[vpos] - BOOTLOADER_SIZE;
        if (result == 0) {
          // canceled
          state = ST_FILE_LIST;
        }
        else if (result == 1) {
          // confirmed
          firmwareAddress = FIRMWARE_ADDRESS + BOOTLOADER_SIZE;
          firmwareWritten = 0;
          eepromAddress = 0;
          eepromWritten = 0;
          state = ST_FLASHING;
        }
      }

      else if (state == ST_FLASHING) {
        // commit to flashing
        lcd_putsLeft(4*FH, "\032Writing...");
        
        if (!unlocked && (memoryType == MEM_FLASH)) {
          unlocked = 1;
          unlockFlash();
        }
        
        int progress;
        if (memoryType == MEM_FLASH) {
          writeFlashBlock();
          firmwareWritten += sizeof(Block_buffer);
          progress = (200*firmwareWritten) / FirmwareSize;
        }
        else {
          writeEepromBlock();
          eepromWritten += sizeof(Block_buffer);
          progress = (200*eepromWritten) / EESIZE;
        }

        lcd_rect( 3, 6*FH+4, 204, 7);
        lcd_hline(5, 6*FH+6, progress, FORCE);
        lcd_hline(5, 6*FH+7, progress, FORCE);
        lcd_hline(5, 6*FH+8, progress, FORCE);

        fr = f_read(&FlashFile, (BYTE *)Block_buffer, sizeof(Block_buffer), &BlockCount);
        if (BlockCount == 0) {
          state = ST_FLASH_DONE; // EOF
        }
        if (firmwareWritten >= FLASHSIZE - BOOTLOADER_SIZE) {
          state = ST_FLASH_DONE; // Backstop
        }
        if (eepromWritten >= EESIZE) {
          state = ST_FLASH_DONE; // Backstop
        }
      }

      if (state == ST_FLASH_DONE) {
        if (unlocked) {
          lockFlash();
          unlocked = 0;
        }
        lcd_putsLeft(4*FH, "\024Writing Complete");
        if (event == EVT_KEY_FIRST(BOOT_KEY_EXIT) || event == EVT_KEY_BREAK(BOOT_KEY_MENU)) {
          state = ST_START;
          vpos = 0;
        }
      }

      if (event == EVT_KEY_LONG(BOOT_KEY_EXIT)) {
        state = ST_REBOOT;
      }

      lcdRefresh();

      if (PowerUpDelay < 20) {	// 200 mS
        PowerUpDelay += 1;
      }
      else {
        sdPoll10ms();
      }
    }

    if (state != ST_FLASHING && state != ST_USB) {
#if defined(REV9E)
      if (pwrPressed()) {
#else
      if (pwrCheck() == e_power_off) {
#endif
        lcdOff(); // this drains LCD caps
        pwrOff();
        for (;;) {
          // Wait for power to go off
        }
      }
    }

    if (state == ST_REBOOT) {
      if (readKeys() == 0) {
        lcd_clear();
        lcdRefresh();
        lcdRefreshWait();
        RCC->CSR |= RCC_CSR_RMVF;   //clear the reset flags in RCC clock control & status register
        NVIC_SystemReset();
      }
    }
  }

  return 0;
}
Sorter::Sorter(std::vector<PersonIntrinsic *> & toCopy){
	fillNames();		//fills name of categories
	//used to process all records into their intrinsic score
	for (int counter = 0; counter < toCopy.size(); counter++){
		//gets the next object
		PersonIntrinsic * temp = toCopy.at(counter);

		//checks to see if it faculty
		if(temp->getRole() == "Faculty"){
			/*
				from this point on the basic structure is the same
				gets the category and then checks to see if it is 
				positive, negative or neutral then adds to appropriate value

				hindsight makes realize there is a more efficient way to do this
			*/
			int powerVar = temp->getPower();
			if(powerVar == 0)
				staffValues[1]++;
			else if (powerVar > 0)
				staffValues[0]++;
			else if (powerVar < 0)
				staffValues[2]++;

			int independenceVar =  temp->getIndepedence();
			if(independenceVar == 0)
				staffValues[4]++;
			else if (independenceVar > 0)
				staffValues[3]++;
			else if (independenceVar < 0)
				staffValues[5]++;

			int curiosityVar = temp->getCuriosity();
			if(curiosityVar == 0)
				staffValues[7]++;
			else if (curiosityVar > 0)
				staffValues[6]++;
			else if (curiosityVar < 0)
				staffValues[8]++;

			int acceptanceVar = temp->getAcceptance();
			if(acceptanceVar == 0)
				staffValues[10]++;
			else if (acceptanceVar > 0)
				staffValues[9]++;
			else if (acceptanceVar < 0)
				staffValues[11]++;

			int orderVar = temp->getOrder();
			if(orderVar == 0)
				staffValues[13]++;
			else if (orderVar > 0)
				staffValues[12]++;
			else if (orderVar < 0)
				staffValues[14]++;

			int savingVar = temp->getSaving();
			if(savingVar == 0)
				staffValues[16]++;
			else if (savingVar > 0)
				staffValues[15]++;
			else if (savingVar < 0)
				staffValues[17]++;

			int honorVar = temp->getHonor();
			if(honorVar == 0)
				staffValues[19]++;
			else if (honorVar > 0)
				staffValues[18]++;
			else if (honorVar < 0)
				staffValues[20]++;

			int idealismVar = temp->getIdealism();
			if(idealismVar == 0)
				staffValues[22]++;
			else if (idealismVar > 0)
				staffValues[21]++;
			else if (idealismVar < 0)
				staffValues[23]++;

			int socialContactVar = temp->getSocialContact();
			if(socialContactVar == 0)
				staffValues[25]++;
			else if (socialContactVar > 0)
				staffValues[24]++;
			else if (socialContactVar < 0)
				staffValues[26]++;

			int familyVar = temp->getFamily();
			if(familyVar == 0)
				staffValues[28]++;
			else if (familyVar > 0)
				staffValues[27]++;
			else if (familyVar < 0)
				staffValues[29]++;

			int statusVar = temp->getStatus();
			if(statusVar == 0)
				staffValues[31]++;
			else if (statusVar > 0)
				staffValues[30]++;
			else if (statusVar < 0)
				staffValues[32]++;

			int vengeanceVar = temp->getVengeance();
			if(vengeanceVar == 0)
				staffValues[34]++;
			else if (vengeanceVar > 0)
				staffValues[33]++;
			else if (vengeanceVar < 0)
				staffValues[35]++;

			int eatingVar = temp->getEating();
			if(eatingVar == 0)
				staffValues[37]++;
			else if (eatingVar > 0)
				staffValues[36]++;
			else if (eatingVar < 0)
				staffValues[38]++;

			int physicalActivityVar = temp->getPhysicalActivity();
			if(physicalActivityVar == 0)
				staffValues[40]++;
			else if (physicalActivityVar > 0)
				staffValues[39]++;
			else if (physicalActivityVar < 0)
				staffValues[41]++;

			int tranquilityVar = temp->getTranquility();
			if(tranquilityVar == 0)
				staffValues[43]++;
			else if (tranquilityVar > 0)
				staffValues[42]++;
			else if (tranquilityVar < 0)
				staffValues[44]++;
		}
		//checks to see if the role is a student
		else if (temp->getRole() == "Student"){
			/*
				from this point on the basic structure is the same
				gets the category and then checks to see if it is 
				positive, negative or neutral then adds to appropriate value

				hindsight makes realize there is a more efficient way to do this
			*/
			int powerVar = temp->getPower();
			if(powerVar == 0)
				studentValues[1]++;
			else if (powerVar > 0)
				studentValues[0]++;
			else if (powerVar < 0)
				studentValues[2]++;

			int independenceVar =  temp->getIndepedence();
			if(independenceVar == 0)
				studentValues[4]++;
			else if (independenceVar > 0)
				studentValues[3]++;
			else if (independenceVar < 0)
				studentValues[5]++;

			int curiosityVar = temp->getCuriosity();
			if(curiosityVar == 0)
				studentValues[7]++;
			else if (curiosityVar > 0)
				studentValues[6]++;
			else if (curiosityVar < 0)
				studentValues[8]++;

			int acceptanceVar = temp->getAcceptance();
			if(acceptanceVar == 0)
				studentValues[10]++;
			else if (acceptanceVar > 0)
				studentValues[9]++;
			else if (acceptanceVar < 0)
				studentValues[11]++;

			int orderVar = temp->getOrder();
			if(orderVar == 0)
				studentValues[13]++;
			else if (orderVar > 0)
				studentValues[12]++;
			else if (orderVar < 0)
				studentValues[14]++;

			int savingVar = temp->getSaving();
			if(savingVar == 0)
				studentValues[16]++;
			else if (savingVar > 0)
				studentValues[15]++;
			else if (savingVar < 0)
				studentValues[17]++;

			int honorVar = temp->getHonor();
			if(honorVar == 0)
				studentValues[19]++;
			else if (honorVar > 0)
				studentValues[18]++;
			else if (honorVar < 0)
				studentValues[20]++;

			int idealismVar = temp->getIdealism();
			if(idealismVar == 0)
				studentValues[22]++;
			else if (idealismVar > 0)
				studentValues[21]++;
			else if (idealismVar < 0)
				studentValues[23]++;

			int socialContactVar = temp->getSocialContact();
			if(socialContactVar == 0)
				studentValues[25]++;
			else if (socialContactVar > 0)
				studentValues[24]++;
			else if (socialContactVar < 0)
				studentValues[26]++;

			int familyVar = temp->getFamily();
			if(familyVar == 0)
				studentValues[28]++;
			else if (familyVar > 0)
				studentValues[27]++;
			else if (familyVar < 0)
				studentValues[29]++;

			int statusVar = temp->getStatus();
			if(statusVar == 0)
				studentValues[31]++;
			else if (statusVar > 0)
				studentValues[30]++;
			else if (statusVar < 0)
				studentValues[32]++;

			int vengeanceVar = temp->getVengeance();
			if(vengeanceVar == 0)
				studentValues[34]++;
			else if (vengeanceVar > 0)
				studentValues[33]++;
			else if (vengeanceVar < 0)
				studentValues[35]++;
			int eatingVar = temp->getEating();
			if(eatingVar == 0)
				studentValues[37]++;
			else if (eatingVar > 0)
				studentValues[36]++;
			else if (eatingVar < 0)
				studentValues[38]++;

			int physicalActivityVar = temp->getPhysicalActivity();
			if(physicalActivityVar == 0)
				studentValues[40]++;
			else if (physicalActivityVar > 0)
				studentValues[39]++;
			else if (physicalActivityVar < 0)
				studentValues[41]++;

			int tranquilityVar = temp->getTranquility();
			if(tranquilityVar == 0)
				studentValues[43]++;
			else if (tranquilityVar > 0)
				studentValues[42]++;
			else if (tranquilityVar < 0)
				studentValues[44]++;
		}
		//checks to see if the role set to neither
		else if (temp->getRole() == "Neither"){
			/*
				from this point on the basic structure is the same
				gets the category and then checks to see if it is 
				positive, negative or neutral then adds to appropriate value

				hindsight makes realize there is a more efficient way to do this
			*/
			int powerVar = temp->getPower();
			if(powerVar == 0)
				neitherValues[1]++;
			else if (powerVar > 0)
				neitherValues[0]++;
			else if (powerVar < 0)
				neitherValues[2]++;

			int independenceVar =  temp->getIndepedence();
			if(independenceVar == 0)
				neitherValues[4]++;
			else if (independenceVar > 0)
				neitherValues[3]++;
			else if (independenceVar < 0)
				neitherValues[5]++;

			int curiosityVar = temp->getCuriosity();
			if(curiosityVar == 0)
				neitherValues[7]++;
			else if (curiosityVar > 0)
				neitherValues[6]++;
			else if (curiosityVar < 0)
				neitherValues[8]++;

			int acceptanceVar = temp->getAcceptance();
			if(acceptanceVar == 0)
				neitherValues[10]++;
			else if (acceptanceVar > 0)
				neitherValues[9]++;
			else if (acceptanceVar < 0)
				neitherValues[11]++;

			int orderVar = temp->getOrder();
			if(orderVar == 0)
				neitherValues[13]++;
			else if (orderVar > 0)
				neitherValues[12]++;
			else if (orderVar < 0)
				neitherValues[14]++;

			int savingVar = temp->getSaving();
			if(savingVar == 0)
				neitherValues[16]++;
			else if (savingVar > 0)
				neitherValues[15]++;
			else if (savingVar < 0)
				neitherValues[17]++;

			int honorVar = temp->getHonor();
			if(honorVar == 0)
				neitherValues[19]++;
			else if (honorVar > 0)
				neitherValues[18]++;
			else if (honorVar < 0)
				neitherValues[20]++;

			int idealismVar = temp->getIdealism();
			if(idealismVar == 0)
				neitherValues[22]++;
			else if (idealismVar > 0)
				neitherValues[21]++;
			else if (idealismVar < 0)
				neitherValues[23]++;

			int socialContactVar = temp->getSocialContact();
			if(socialContactVar == 0)
				neitherValues[25]++;
			else if (socialContactVar > 0)
				neitherValues[24]++;
			else if (socialContactVar < 0)
				neitherValues[26]++;

			int familyVar = temp->getFamily();
			if(familyVar == 0)
				neitherValues[28]++;
			else if (familyVar > 0)
				neitherValues[27]++;
			else if (familyVar < 0)
				neitherValues[29]++;

			int statusVar = temp->getStatus();
			if(statusVar == 0)
				neitherValues[31]++;
			else if (statusVar > 0)
				neitherValues[30]++;
			else if (statusVar < 0)
				neitherValues[32]++;

			int vengeanceVar = temp->getVengeance();
			if(vengeanceVar == 0)
				neitherValues[34]++;
			else if (vengeanceVar > 0)
				neitherValues[33]++;
			else if (vengeanceVar < 0)
				neitherValues[35]++;

			int eatingVar = temp->getEating();
			if(eatingVar == 0)
				neitherValues[37]++;
			else if (eatingVar > 0)
				neitherValues[36]++;
			else if (eatingVar < 0)
				neitherValues[38]++;

			int physicalActivityVar = temp->getPhysicalActivity();
			if(physicalActivityVar == 0)
				neitherValues[40]++;
			else if (physicalActivityVar > 0)
				neitherValues[39]++;
			else if (physicalActivityVar < 0)
				neitherValues[41]++;

			int tranquilityVar = temp->getTranquility();
			if(tranquilityVar == 0)
				neitherValues[43]++;
			else if (tranquilityVar > 0)
				neitherValues[42]++;
			else if (tranquilityVar < 0)
				neitherValues[44]++;
		}
		//all others will be caught here
		else{
			/*
				from this point on the basic structure is the same
				gets the category and then checks to see if it is 
				positive, negative or neutral then adds to appropriate value

				hindsight makes realize there is a more efficient way to do this
			*/
			int powerVar = temp->getPower();
			if(powerVar == 0)
				otherValues[1]++;
			else if (powerVar > 0)
				otherValues[0]++;
			else if (powerVar < 0)
				otherValues[2]++;

			int independenceVar =  temp->getIndepedence();
			if(independenceVar == 0)
				otherValues[4]++;
			else if (independenceVar > 0)
				otherValues[3]++;
			else if (independenceVar < 0)
				otherValues[5]++;
			int curiosityVar = temp->getCuriosity();
			if(curiosityVar == 0)
				otherValues[7]++;
			else if (curiosityVar > 0)
				otherValues[6]++;
			else if (curiosityVar < 0)
				otherValues[8]++;

			int acceptanceVar = temp->getAcceptance();
			if(acceptanceVar == 0)
				otherValues[10]++;
			else if (acceptanceVar > 0)
				otherValues[9]++;
			else if (acceptanceVar < 0)
				otherValues[11]++;

			int orderVar = temp->getOrder();
			if(orderVar == 0)
				otherValues[13]++;
			else if (orderVar > 0)
				otherValues[12]++;
			else if (orderVar < 0)
				otherValues[14]++;

			int savingVar = temp->getSaving();
			if(savingVar == 0)
				otherValues[16]++;
			else if (savingVar > 0)
				otherValues[15]++;
			else if (savingVar < 0)
				otherValues[17]++;

			int honorVar = temp->getHonor();
			if(honorVar == 0)
				otherValues[19]++;
			else if (honorVar > 0)
				otherValues[18]++;
			else if (honorVar < 0)
				otherValues[20]++;

			int idealismVar = temp->getIdealism();
			if(idealismVar == 0)
				otherValues[22]++;
			else if (idealismVar > 0)
				otherValues[21]++;
			else if (idealismVar < 0)
				otherValues[23]++;

			int socialContactVar = temp->getSocialContact();
			if(socialContactVar == 0)
				otherValues[25]++;
			else if (socialContactVar > 0)
				otherValues[24]++;
			else if (socialContactVar < 0)
				otherValues[26]++;

			int familyVar = temp->getFamily();
			if(familyVar == 0)
				otherValues[28]++;
			else if (familyVar > 0)
				otherValues[27]++;
			else if (familyVar < 0)
				otherValues[29]++;

			int statusVar = temp->getStatus();
			if(statusVar == 0)
				otherValues[31]++;
			else if (statusVar > 0)
				otherValues[30]++;
			else if (statusVar < 0)
				otherValues[32]++;

			int vengeanceVar = temp->getVengeance();
			if(vengeanceVar == 0)
				otherValues[34]++;
			else if (vengeanceVar > 0)
				otherValues[33]++;
			else if (vengeanceVar < 0)
				otherValues[35]++;

			int eatingVar = temp->getEating();
			if(eatingVar == 0)
				otherValues[37]++;
			else if (eatingVar > 0)
				otherValues[36]++;
			else if (eatingVar < 0)
				otherValues[38]++;

			int physicalActivityVar = temp->getPhysicalActivity();
			if(physicalActivityVar == 0)
				otherValues[40]++;
			else if (physicalActivityVar > 0)
				otherValues[39]++;
			else if (physicalActivityVar < 0)
				otherValues[41]++;
			int tranquilityVar = temp->getTranquility();
			if(tranquilityVar == 0)
				otherValues[43]++;
			else if (tranquilityVar > 0)
				otherValues[42]++;
			else if (tranquilityVar < 0)
				otherValues[44]++;
		}
	}
	//this adds the name of the group and its value to a map, allowing it to be autosorted from high to low
	for (int counter= 0; counter < 45; counter++){
		student.insert(std::pair<int, std::string>(studentValues[counter], namesOfValues[counter]));
		staff.insert(std::pair<int, std::string>(staffValues[counter], namesOfValues[counter]));
		neither.insert(std::pair<int, std::string>(neitherValues[counter], namesOfValues[counter]));
		other.insert(std::pair<int, std::string>(otherValues[counter], namesOfValues[counter]));
	}
}
Sorter::Sorter(){
	fillNames();
}
int RemoveGroupsCommand::execute(){
	try {
		
		if (abort == true) { if (calledHelp) { return 0; }  return 2;	}
		
		//get groups you want to remove
		if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups);  }
		
		if (groupfile != "") {
			groupMap = new GroupMap(groupfile);
			groupMap->readMap();
			
			//make sure groups are valid
			//takes care of user setting groupNames that are invalid or setting groups=all
			vector<string> namesGroups = groupMap->getNamesOfGroups();
			vector<string> checkedGroups;
            for (int i = 0; i < Groups.size(); i++) {
                if (m->inUsersGroups(Groups[i], namesGroups)) { checkedGroups.push_back(Groups[i]); }
                else {  m->mothurOut("[WARNING]: " + Groups[i] + " is not a valid group in your groupfile, ignoring.\n"); }
            }
            
            if (checkedGroups.size() == 0) { m->mothurOut("[ERROR]: no valid groups, aborting.\n"); delete groupMap; return 0; }
			else {
                Groups = checkedGroups;
                m->setGroups(Groups);
            }
            
			//fill names with names of sequences that are from the groups we want to remove 
			fillNames();
			
			delete groupMap;
		}else if (countfile != ""){
            if ((fastafile != "") || (listfile != "") || (taxfile != "")) { 
                m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
            }
            CountTable ct;
            ct.readTable(countfile, true, false);
            if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; }
            
            vector<string> gNamesOfGroups = ct.getNamesOfGroups();
            SharedUtil util;
            util.setGroups(Groups, gNamesOfGroups);
            vector<string> namesOfSeqs = ct.getNamesOfSeqs();
            sort(Groups.begin(), Groups.end());
            
            for (int i = 0; i < namesOfSeqs.size(); i++) {
                vector<string> thisSeqsGroups = ct.getGroups(namesOfSeqs[i]);
                if (m->isSubset(Groups, thisSeqsGroups)) { //you only have seqs from these groups so remove you
                    names.insert(namesOfSeqs[i]);
                }
            }
        }

				
		if (m->control_pressed) { return 0; }
		
		//read through the correct file and output lines you want to keep
		if (namefile != "")			{		readName();		}
		if (fastafile != "")		{		readFasta();	}
		if (groupfile != "")		{		readGroup();	}
        if (countfile != "")		{		readCount();	}
		if (listfile != "")			{		readList();		}
		if (taxfile != "")			{		readTax();		}
		if (sharedfile != "")		{		readShared();	}
        if (designfile != "")		{		readDesign();	}
		
		if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {	m->mothurRemove(outputNames[i]); } return 0; }
				
		if (outputNames.size() != 0) {
			m->mothurOutEndLine();
			m->mothurOut("Output File names: "); m->mothurOutEndLine();
			for (int i = 0; i < outputNames.size(); i++) {	m->mothurOut(outputNames[i]); m->mothurOutEndLine();	}
			m->mothurOutEndLine();
			
			//set fasta file as new current fastafile
			string current = "";
			itTypes = outputTypes.find("fasta");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
			}
			
			itTypes = outputTypes.find("name");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
			}
			
			itTypes = outputTypes.find("group");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
			}
			
			itTypes = outputTypes.find("list");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
			}
			
			itTypes = outputTypes.find("taxonomy");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
			}
			
			itTypes = outputTypes.find("shared");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
			}
            
            itTypes = outputTypes.find("design");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setDesignFile(current); }
			}
            
            itTypes = outputTypes.find("count");
			if (itTypes != outputTypes.end()) {
				if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); }
			}
		}
		
		return 0;		
	}
	
	catch(exception& e) {
		m->errorOut(e, "RemoveGroupsCommand", "execute");
		exit(1);
	}
}