Exemple #1
0
oe::simulation::Simulation* InstrumentPanel::getSimulation()
{
   oe::simulation::Simulation* s = nullptr;
   oe::simulation::Station* sta = getStation();
   if (sta != nullptr) s = sta->getSimulation();
   return s;
}
oe::simulation::Simulation* TestDisplay::getSimulation()
{
   oe::simulation::Simulation* s = nullptr;
   oe::simulation::Station* sta = getStation();
   if (sta != nullptr) s = sta->getSimulation();
   return s;
}
Exemple #3
0
oe::simulation::Player* InstrumentPanel::getOwnship()
{
   oe::simulation::Player* p = nullptr;
   oe::simulation::Station* sta = getStation();
   if (sta != nullptr) p = sta->getOwnship();
   return p;
}
//------------------------------------------------------------------------------
// Simulation access functions
//------------------------------------------------------------------------------
oe::simulation::Player* TestDisplay::getOwnship()
{
   oe::simulation::Player* p = nullptr;
   oe::simulation::Station* sta = getStation();
   if (sta != nullptr) p = sta->getOwnship();
   return p;
}
//------------------------------------------------------------------------------
// Simulation access functions
//------------------------------------------------------------------------------
Simulation::Player* Display::getOwnship()
{
    Simulation::Player* p = nullptr;
    Simulation::Station* sta = getStation();
    if (sta != nullptr) p = sta->getOwnship();
    return p;
}
Simulation::Simulation* Display::getSimulation()
{
    Simulation::Simulation* s = nullptr;
    Simulation::Station* sta = getStation();
    if (sta != nullptr) s = sta->getSimulation();
    return s;
}
Exemple #7
0
// Step ownship key
bool InstrumentPanel::onStepOwnshipKey()
{
   SimStation* ts = dynamic_cast<SimStation*>(getStation());
   if ( ts != nullptr ) {
      ts->stepOwnshipPlayer();
   }
   return true;
}
// Step ownship key
bool TestDisplay::onStepOwnshipKey()
{
   TestStation* ts = dynamic_cast<TestStation*>(getStation());
   if ( ts != nullptr ) {
      ts->stepOwnshipPlayer();
   }
   return true;
}
// The simulation
Simulation* DataRecorder::getSimulationImp()
{
   if (sim == nullptr) {
      Station* p = getStation();
      if (p != nullptr) sim = p->getSimulation();
   }
   return sim;
}
Simulation::Aircraft* MapDisplay::getOwnship()
{
   Simulation::Aircraft* p = 0;
   Simulation::Station* sta = getStation();
   if (sta != 0) {
      p = dynamic_cast<Simulation::Aircraft*>(sta->getOwnship());
   }
   return p;
}
Simulation* MultiActorAgent::getSimulation()
{
   Simulation* sim = nullptr;
   Station* s = getStation();
   if (s != nullptr) {
      sim = s->getSimulation();
   }
   return sim;
}
oe::models::Aircraft* MapDisplay::getOwnship()
{
   oe::models::Aircraft* p {};
   oe::simulation::Station* sta = getStation();
   if (sta != nullptr) {
      p = dynamic_cast<oe::models::Aircraft*>(sta->getOwnship());
   }
   return p;
}
Simulation::Aircraft* AdiDisplay::getOwnship()
{
   Simulation::Aircraft* pA = 0;
   Simulation::Station* sta = getStation();
   if (sta != 0) {
      pA = dynamic_cast<Simulation::Aircraft*>(sta->getOwnship());

      //const unsigned int ffrate = 5;    //LDB
      //sta->setFastForwardRate(ffrate);  //LDB
   }
   return pA;
}
void ViewSimple2D::activateStation()
{
	// Do fx for this station?
	switch (getStation()) {
		case FREEZER_NDX:
			if ( (m_game->getFreezerUsage()) ||
				(m_game->getPumpkin(FREEZER_NDX).m_type != EMPTY) ) {
				emitParts( 150, calcPosFromNdx( FREEZER_NDX ), PART_FROST );
			}
	}
	GameView::activateStation();
}
Exemple #15
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
StationLocation Inventory::stationLocation(const std::string& networkCode,
                                           const std::string& stationCode,
                                           const Core::Time& time) const {
	if ( _inventory == NULL )
		throw Core::ValueException("inventory is empty");

	DataModel::Station* station = getStation(networkCode, stationCode, time);
	
	if ( station == NULL )
		throw Core::ValueException("station [" + networkCode + "." + stationCode + "] not found");

	return StationLocation(station->latitude(),
	                       station->longitude(),
	                       station->elevation());
}
Exemple #16
0
void UI_task(void)
{

	UINT8 keypressed = 0xFF;
	UINT8 i;
	UINT8 duration, scancode;
	UINT8 uimsg;

 	UINT8 material[] = "MATERIAL";
 	UINT8 safety[] = "SAFETY";

	if(GetDataFromKeypadBuffer(&scancode, &duration) == FALSE)			//Check whether key has been pressed
	{
		return;
	}

	
	keypressed = mapKey(scancode,duration);				//Map the key

	if( keypressed == 0xFF)
	{
		return;
	}


	switch(ui.state)
	{

		case UI_IDLE:
		if( keypressed == '\x0E')
		{
				setUImsg(UI_MSG_LOGIN_LOGOUT);
				clearUIBuffer();
				clearUIInput();
				ui.prevState = ui.state;
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='0';
				ui.state = UI_LOGIN;
				ui.prevState = UI_IDLE;
				rawWriteCommandToLcd(DISPLAY_ON_CUR_BLINK_BIG);
				
		}
		
		
		break;


		case UI_LOGIN:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 2 )
					ui.inputIndex--;
			}
			else
			{
				if( ui.prevState == UI_IDLE)
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					rawWriteCommandToLcd(DISPLAY_ON_CUR_OFF);
					ui.state = ui.prevState;
				}
			}
		}
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				setUImsg(UI_MSG_PASSWORD);
	
				clearUIBuffer();
				ui.input[ui.inputIndex++] = '\0';
				ui.prevState = UI_LOGIN;
				ui.state = UI_PASSWORD;
				
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.input[ui.inputIndex++]= keypressed;
			ui.bufferIndex++;
		}
		break;
		
		case UI_LOGOUT:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 2 )
					ui.inputIndex--;
			}
			else
			{
				if( ui.prevState == UI_STATION)
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = ui.prevState;
				}
			}
		}
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				setUImsg(UI_MSG_PASSWORD);
	
				clearUIBuffer();
				ui.prevState = UI_LOGOUT;
				ui.state = UI_PASSWORD;
				
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.input[ui.inputIndex++]= keypressed;
			ui.bufferIndex++;
		}
		break;		

		case UI_STATION:

		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 0 )
					ui.inputIndex--;
			}
			else 
			{
				setUImsg(UI_MSG_PASSWORD);	
				clearUIBuffer();
				clearUIInput();
				ui.prevState = UI_STATION;
				ui.state = UI_PASSWORD;
			}
		}
		else if( keypressed == '0')
		{
			if(ui.bufferIndex > 0 )
			{
				ui.buffer[ui.bufferIndex] = keypressed;
				putCharToLcd(ui.buffer[ui.bufferIndex]);
				ui.bufferIndex++;
			}
			else 
			{
				IAS_getAcknowledgedIssue(&ackIssue);
				if(ackIssue.ID != - 1)
				{
					showUImsg(ackIssue.tag);
					clearUIBuffer();
					clearUIInput();
					ui.state= UI_ISSUE_RESOLVE;
				}

			}
		}

		else if( keypressed == '\x0D')
		{
				IAS_getOpenIssue(&openIssue);
				if(openIssue.ID != - 1)
				{
					showUImsg(openIssue.tag);
					clearUIBuffer();
					clearUIInput();
					ui.state= UI_ISSUE_ACK;
				}
		}
		else if( keypressed == '\x0E')
		{
			if( ui.bufferIndex == 0 )
			{
				setUImsg(UI_MSG_LOGIN_LOGOUT);
				clearUIBuffer();
				clearUIInput();
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='0';
				ui.prevState = ui.state;
				ui.state = UI_LOGOUT;
			}
				
		}		
		
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				setUImsg(UI_MSG_ISSUE);
				getStation();
				clearUIBuffer();
				ui.state = UI_ISSUE;
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.bufferIndex++;
		}

		break;

	
		case UI_ISSUE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		else
		{

			for(i = 1 ; i <= MAX_DEPARTMENTS ; i++)
			{
				if( (i + '0') == keypressed)
				{
					putUIdept(i);
		
					ui.input[ui.inputIndex]  = i + '0' ;
					ui.inputIndex++;
		
					ui.state = UI_BRK_QUA_MS;
					break;	
				}				
			}

		}
		break;


		case UI_BRK_QUA_MS:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_ISSUE);
			clearUIBuffer();
			ui.state = UI_ISSUE;
			ui.inputIndex = 2;
		}

		else if( keypressed == '\x0A')
		{
			if( strcmp(ui_department[ui.input[ui.inputIndex - 1] - '0'] , material ) == 0 )
			{

				setUImsg(UI_MSG_PART_NO);
				clearUIBuffer();
				ui.state = UI_PART_NO;

			}
			else if( strcmp(ui_department[ui.input[ui.inputIndex - 1] - '0'] , safety ) == 0 )
			{
				setUImsg(UI_MSG_CLASS);
				clearUIBuffer();
				ui.state = UI_CLASS;

			}

			else
			{

					getData();
					IAS_raiseIssues( ui.input,0);
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;
			
			}
		}

		break;

		case UI_CLASS:
		if( keypressed == '\x08')
		{

			setUImsg(UI_MSG_ISSUE);
			clearUIBuffer();
			ui.inputIndex = 2;
			ui.state = UI_ISSUE;
			

		}
		else if( keypressed == '\x0A')
		{
			if( ui.bufferIndex > 0 )
			{
	
				getData();
				IAS_raiseIssues( ui.input , 2);
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
		}
		else
		{
			switch(keypressed)
			{
	
				case '1':
				putUIclass(UI_MSG_MAJOR_INJURY_FATALITY);
	
				ui.input[ui.inputIndex]  = '1';
				ui.inputIndex++;
				ui.bufferIndex ++;

				break;


				case '2':
				putUIclass(UI_MSG_MINOR_INJURY);
	
				ui.input[ui.inputIndex]  = '2';
				ui.inputIndex++;
				ui.bufferIndex ++;

				break;


				case '3':
				putUIclass(UI_MSG_PROPERTY_DAMAGE);
	
				ui.input[ui.inputIndex]  = '3';
				ui.inputIndex++;
				ui.bufferIndex ++;
	
				break;

				case '4':
				putUIclass(UI_MSG_NEAR_MISS);
	
				ui.input[ui.inputIndex]  = '4';
				ui.inputIndex++;
				ui.bufferIndex ++;
	
				break;

				
			}

		}

		break;



		case UI_PART_NO:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;

			}
			else
			{
				setUImsg(UI_MSG_ISSUE);
				clearUIBuffer();
				ui.state = UI_ISSUE;
				ui.inputIndex = 2;
			}

		}
		else if( keypressed == '\x0A')
		{
			if( ui.bufferIndex > 0 )
			{
				getData();
				IAS_raiseIssues( ui.input , 1);
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
		}

		else
		{
			if(scancode == ui.prevcode)
			{
				if(duration < MIN_KEYPRESS_DURATION)
				{
					ui.bufferIndex--;
					ui.buffer[ui.bufferIndex] = keypressed;
					putCharToLcd('\x08');
					putCharToLcd(ui.buffer[ui.bufferIndex]);
					DelayMs(20);
					ui.bufferIndex++;
				}
				else
				{
					ui.buffer[ui.bufferIndex] = keypressed;
					putCharToLcd(ui.buffer[ui.bufferIndex]);
					DelayMs(20);
					ui.bufferIndex++;
				}
			}
			else
			{
				ui.buffer[ui.bufferIndex] = keypressed;
				putCharToLcd(ui.buffer[ui.bufferIndex]);
				DelayMs(20);
				ui.bufferIndex++;
			}
			ui.prevcode = scancode;
		}
		break;

		case UI_ISSUE_ACK:

		if( keypressed == '\x0D')
		{
			IAS_getOpenIssue(&openIssue);
			if( openIssue.ID != -1 )
			{
				showUImsg(openIssue.tag);
			}
		}

		else if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '\x0A')
		{
			IAS_acknowledgeIssues(openIssue.ID);
			openIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;




		case UI_ISSUE_RESOLVE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '0')
		{
			IAS_getAcknowledgedIssue(&ackIssue);
			if( ackIssue.ID != -1 )
			{
				showUImsg(ackIssue.tag);
			}
		}

		else if( keypressed == '\x0A')
		{
			IAS_resolveIssues(ackIssue.ID);   // 	IAS_resolveIssues( &ackIssue.ID); 
			ackIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;




		case UI_CLEAR_ISSUE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			ui.state = UI_STATION;

		}

		else if( keypressed == '\x0A')
		{
			IAS_clearIssues();
			clearUIBuffer();
			clearUIInput();
			setUImsg(UI_MSG_STATION);
			ui.state = UI_STATION;
		}

		break;

		case UI_PASSWORD:

		if( keypressed == '\x08')
		{
			if( ui.prevState == UI_LOGIN)
			{
				setUImsg(UI_MSG_IDLE);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_IDLE;
				rawWriteCommandToLcd(DISPLAY_ON_CUR_OFF);
			}
			else if( ui.prevState == UI_LOGOUT || ui.prevState == UI_STATION)
			{
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}

		}

		else if( keypressed == '\x0A')
		{
			ui.buffer[ui.bufferIndex] = '\0';
			if( ui.prevState == UI_LOGIN)
			{
				BOOL result = FALSE; 
				result = IAS_login(ui.buffer,ui.input);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					rawWriteCommandToLcd(DISPLAY_ON_CUR_BLINK_BIG);
					ui.state = UI_STATION;

				}
				else
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_IDLE;

				}

			}
			else if( ui.prevState == UI_LOGOUT)
			{
				BOOL result = FALSE; 
				result = IAS_logout(ui.buffer,ui.input);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					rawWriteCommandToLcd(DISPLAY_ON_CUR_OFF);
					ui.state = UI_IDLE;

				}
				else
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;

				}		
				
			}
			else if( ui.prevState == UI_STATION )
			{
				BOOL result = FALSE; 
				result = IAS_checkPassword(ui.buffer);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_ADMIN_ACTIVITY);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_ADMIN_ACTIVITY;
				}
				else
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;

				}
			}	
		}

		else 
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd('*');
			ui.bufferIndex++;
		}
			
		break;		

		case UI_ADMIN_ACTIVITY:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
			
		}


		else if( keypressed == '0')
		{
			setUImsg(UI_MSG_CLEAR_ISSUES);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_CLEAR_ISSUE;
		}


		break;
	
		default:
		break;


	}

}
Exemple #17
0
Station Trajectory::getLastStation() const
{
    if(this->isEmpty())
        return Station();
    return getStation(this->length() - 1);
}
Exemple #18
0
Station Trajectory::getFirstStation() const
{
    if(this->isEmpty())
        return Station();
    return getStation(0);
}
Exemple #19
0
void setDistanceMatrix() {
    int i, j;
    for (i = 0; i < sSize; i++) {
        /*
         * set 0 to self distance
         */
        SD[i][i] = 0;
        SP[i][i] = i;
    }

    for (i = 0; i < sSize; i++) {
        /*
         * set left station relation
         */
        if (S[i]->left != -1) {
            SD[i][i + S[i]->left] = 1;
            SP[i][i + S[i]->left] = i;
        } else {
            if (i > 0 && S[i - 1]->route == S[i]->route) {
                SD[i][i - 1] = 1;
                SP[i][i - 1] = i;
            }
        }
        /*
         * set right station relation
         */
        if (S[i]->right != -1) {
            SD[i][i - S[i]->right] = 1;
            SP[i][i - S[i]->right] = i;
        } else {
            if (i < sSize - 1 && S[i]->route == S[i + 1]->route) {
                SD[i][i + 1] = 1;
                SP[i][i + 1] = i;
            }
        }
    }

    int m, n, x, k;
    /*
     * merge interchange station set
     */
    for (m = 0; m < ICRowSize - 1; m++) {
        for (i = 0; i < ICColSize[m]; i++) {
            for (n = m + 1; n < ICRowSize; n++) {
                for (j = 0; j < ICColSize[n]; j++) {
                    if (IC[m][i]->route == IC[n][j]->route && IC[m][i]->name == IC[n][j]->name) {
                        for (x = 0; x < ICColSize[n]; x++) {
                            IC[m][ICColSize[m]++] = IC[n][x];
                        }
                        ICColSize[n] = 0;
                    }
                }
            }
        }
    }
    /*
     * set interchange station path
     */
    for (k = 0; k < ICRowSize; k++) {
        for (i = 0; i < ICColSize[k] - 1; i++) {
            for (j = i + 1; j < ICColSize[k]; j++) {
                int m = getStation(IC[k][i]->route, IC[k][i]->name);
                int n = getStation(IC[k][j]->route, IC[k][j]->name);

                if (DEBUG) {
                    printf("set %c%c to %c%c\n", S[m]->route, S[m]->name, S[n]->route, S[n]->name);
                }
                SD[m][n] = 3;
                SP[m][n] = m;
                SD[n][m] = 3;
                SP[n][m] = n;
            }
        }
    }
}
void UI_task(void)
{

	UINT8 keypressed = 0xFF;
	UINT8 i;
	UINT8 duration, scancode;
	UINT8 uimsg;

	if(KEYPAD_read(&scancode, &duration) == FALSE)			//Check whether key has been pressed
	{
		return;
	}

	
	keypressed = mapKey(scancode,duration);				//Map the key

	if( keypressed == 0xFF)
	{
		return;
	}


	switch(ui.state)
	{
		case UI_STATION:

		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				LCD_putChar(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 0 )
					ui.inputIndex--;
			}

		}

		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				getStation() ;
				setUImsg(UI_MSG_ISSUE);
				clearUIBuffer();
				ui.state = UI_ISSUE;
				

			}
		}

		else if( keypressed == '\x13')
		{


			setUImsg(UI_MSG_PASSWORD);

			clearUIBuffer();

			ui.state = UI_PASSWORD;
				
			
		}

		else if( keypressed == '\x0C')
		{
			APP_getAcknowledgedIssue(&ackIssue);
			if(ackIssue.ID != - 1)
			{
				showUImsg(ackIssue.tag);
				clearUIBuffer();
				clearUIInput();
				ui.state= UI_ISSUE_RESOLVE;
			}
		}	

		else if( keypressed == '\x0B')
		{
			APP_getOpenIssue(&openIssue);
			if(openIssue.ID != - 1)
			{
				showUImsg(openIssue.tag);
				clearUIBuffer();
				clearUIInput();
				ui.state= UI_ISSUE_ACK;
			}
		}		
		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			LCD_putChar(ui.buffer[ui.bufferIndex]);
			ui.bufferIndex++;
		}

		break;


	


		case UI_ISSUE:

		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				LCD_putChar(keypressed);
				ui.bufferIndex--;

			}
		
			else
			{
				
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}

		}

		else
		{
			switch( keypressed )
			{
	
				case '1':
				putUImsg(UI_MSG_SAFETY);
	
				ui.input[ui.inputIndex]  = '1';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;


				case '2':
				putUImsg(UI_MSG_BREAKDOWN);
	
				ui.input[ui.inputIndex]  = '2';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;


				case '3':
				putUImsg(UI_MSG_QUALITY);
	
				ui.input[ui.inputIndex]  = '3';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;

				case '4':
				putUImsg(UI_MSG_METHODS);
	
				ui.input[ui.inputIndex]  = '4';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;


				case '5':
				putUImsg(UI_MSG_PRODUCTION);
	
				ui.input[ui.inputIndex]  = '5';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;


				case '6':
				putUImsg(UI_MSG_MATERIAL);
	
				ui.input[ui.inputIndex]  = '6';
				ui.inputIndex++;
	
				ui.state = UI_BRK_QUA_MS;
				break;
	
				default:
				break;
	
			}
		}
		
		break;

		case UI_PART_NO:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				LCD_putChar(keypressed);
				ui.bufferIndex--;

			}

			else
			{

				setUImsg(UI_MSG_ISSUE);
				clearUIBuffer();
				ui.inputIndex = 2;
				ui.state = UI_ISSUE;
			}

			ui.prevcode = 0xFF;
			ui.keyIndex = 0;
		}
		else if( keypressed == '\x0A')
		{
			if( ui.bufferIndex > 0 )
			{
	
				getData();
				APP_raiseIssues( ui.input);
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
			ui.prevcode = 0xFF;
			ui.keyIndex = 0;
		}

		else
		{
			if(scancode == ui.prevcode )
			{
				if(duration < MIN_KEYPRESS_DURATION)
				{
					ui.bufferIndex--;
					ui.buffer[ui.bufferIndex] = keypressed;
					LCD_putChar('\x08');
					LCD_putChar(ui.buffer[ui.bufferIndex]);
					//DelayMs(20);
					ui.bufferIndex++;
				}
				else 
				{
					ui.buffer[ui.bufferIndex] = keypressed;
					LCD_putChar(ui.buffer[ui.bufferIndex]);
					//DelayMs(20);
					ui.bufferIndex++;
					ui.prevcode = 0xFF;
					ui.keyIndex = 0;
				}
			}
			else
			{
				ui.buffer[ui.bufferIndex] = keypressed;
				LCD_putChar(ui.buffer[ui.bufferIndex]);
				//DelayMs(20);
				ui.bufferIndex++;
				ui.prevcode = scancode;
			}
		ui.prevcode = scancode;	
		}
		break;



		case UI_BRK_QUA_MS:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_ISSUE);
			clearUIBuffer();
			ui.inputIndex = 2;
			ui.state = UI_ISSUE;

		}

		else if( keypressed == '\x0A')
		{
			if( ui.input[ui.inputIndex-1] == '6' )
			{
			
				setUImsg(UI_MSG_PART_NO);
				clearUIBuffer();
				//clearUIInput();
				ui.state = UI_PART_NO;
			}
			else
			{
				getData();
				APP_raiseIssues( ui.input);
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
		}

		break;



		case UI_ISSUE_ACK:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '\x0B')
		{
			APP_getOpenIssue(&openIssue);
			if( openIssue.ID != -1 )
			{
				showUImsg(openIssue.tag);
			}

		}
		else if( keypressed == '\x0A')
		{
			
			APP_acknowledgeIssues(openIssue.ID);
			openIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;



	case UI_ISSUE_RESOLVE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '\x0C')
		{
			APP_getAcknowledgedIssue(&ackIssue);
			if( ackIssue.ID != -1 )
			{
				showUImsg(ackIssue.tag);
			}

		}
		else if( keypressed == '\x0A')
		{
			APP_resolveIssues(ackIssue.ID);
			ackIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;

	

		case UI_CLEAR_ISSUE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			ui.state = UI_STATION;

		}

		else if( keypressed == '\x0A')
		{
			APP_clearIssues();
			clearUIBuffer();
			clearUIInput();
			setUImsg(UI_MSG_STATION);
			ui.state = UI_STATION;
		}

		break;

		


		case UI_PASSWORD:
		if( keypressed == '\x08')
		{
		
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
		
		

		}

		else if( keypressed == '\x0A')
		{
			BOOL result = FALSE;
			ui.buffer[ui.bufferIndex] = '\0';
	
		
			 
			result = APP_checkPassword(ui.buffer);	
			if( result == TRUE )
			{
				setUImsg(UI_MSG_ADMIN_ACTIVITY);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_ADMIN_ACTIVITY;
			}
			else
			{
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
		
		
		}

		else 
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			LCD_putChar('*');
			ui.bufferIndex++;
		}
			
		break;		

		case UI_ADMIN_ACTIVITY:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
			
		}

		else if( keypressed == '0')
		{
			setUImsg(UI_MSG_CLEAR_ISSUES);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_CLEAR_ISSUE;
		}

		break;
	
		default:
		break;


	}



}
Exemple #21
0
void UI_task(void)
{

	UINT8 keypressed = 0xFF;
	UINT8 i;
	UINT8 duration, scancode;
	UINT8 uimsg;

	if(GetDataFromKeypadBuffer(&scancode, &duration) == FALSE)			//Check whether key has been pressed
	{
		return;
	}

	
	keypressed = mapKey(scancode,duration);				//Map the key

	if( keypressed == 0xFF)
	{
		return;
	}


	switch(ui.state)
	{
		case UI_IDLE:
		if( keypressed == '\x0B')
		{
				setUImsg(UI_MSG_LOGIN_LOGOUT);
				clearUIBuffer();
				clearUIInput();
				ui.prevState = ui.state;
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='0';
				ui.state = UI_LOGIN;
				
		}
		
		
		break;


		case UI_LOGIN:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 2 )
					ui.inputIndex--;
			}
			else
			{
				if( ui.prevState == UI_IDLE)
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					ui.state = ui.prevState;
				}
			}
		}
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				setUImsg(UI_MSG_PASSWORD);
	
				clearUIBuffer();
				ui.input[ui.inputIndex++] = '\0';
				ui.prevState = UI_LOGIN;
				ui.state = UI_PASSWORD;
				
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.input[ui.inputIndex++]= keypressed;
			ui.bufferIndex++;
		}
		break;
		
		case UI_LOGOUT:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 2 )
					ui.inputIndex--;
			}
			else
			{
				if( ui.prevState == UI_STATION)
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = ui.prevState;
				}
			}
		}
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				setUImsg(UI_MSG_PASSWORD);
	
				clearUIBuffer();
				ui.prevState = UI_LOGOUT;
				ui.state = UI_PASSWORD;
				
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.input[ui.inputIndex++]= keypressed;
			ui.bufferIndex++;
		}
		break;		



		case UI_STATION:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;
				if( ui.inputIndex > 0 )
					ui.inputIndex--;
			}
			else 
			{
				IAS_getAcknowledgedIssue(&ackIssue);
				if(ackIssue.ID != - 1)
				{
					showUImsg(ackIssue.tag);
					clearUIBuffer();
					clearUIInput();
					ui.state= UI_ISSUE_RESOLVE;
				}

			}
		}
		else if( keypressed == '0')
		{
			if(ui.bufferIndex > 0 )
			{
				ui.buffer[ui.bufferIndex] = keypressed;
				putCharToLcd(ui.buffer[ui.bufferIndex]);
				ui.bufferIndex++;
			}
			else 
			{
				IAS_getOpenIssue(&openIssue);
				if(openIssue.ID != - 1)
				{
					showUImsg(openIssue.tag);
					clearUIBuffer();
					clearUIInput();
					ui.state= UI_ISSUE_ACK;
				}

			}
		}
		else if( keypressed == '\x0B')
		{
			if( ui.bufferIndex == 0 )
			{
				setUImsg(UI_MSG_LOGIN_LOGOUT);
				clearUIBuffer();
				clearUIInput();
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='9';
				ui.input[ui.inputIndex++]='0';
				ui.prevState = ui.state;
				ui.state = UI_LOGOUT;
			}
				
		}
		else if( keypressed == '\x0C')
		{
			IAS_getOpenIssue(&openIssue);
			if(openIssue.ID != - 1)
			{
				showUImsg(openIssue.tag);
				clearUIBuffer();
				clearUIInput();
				ui.state= UI_ISSUE_ACK;
			}
		}		
		
		else if( keypressed == '\x0A')
		{
			if(ui.bufferIndex > 0)
			{
				if(getStation() == 0 )
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;
				}
				else
				{
					setUImsg(UI_MSG_ISSUE);
	
					clearUIBuffer();
	
					ui.state = UI_ISSUE;
				}
			}
		}

		else
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd(ui.buffer[ui.bufferIndex]);
			ui.bufferIndex++;
		}




		break;

	
		case UI_ISSUE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		switch( keypressed )
		{

			case '1':
			putUImsg(UI_MSG_BREAKDOWN);

			ui.input[ui.inputIndex]  = '1';
			ui.inputIndex++;

			ui.state = UI_BRK_QUA_MS;
			break;


			case '2':
			putUImsg(UI_MSG_QUALITY);

			ui.input[ui.inputIndex]  = '2';
			ui.inputIndex++;

			ui.state = UI_BRK_QUA_MS;
			break;

			case '3':
			putUImsg(UI_MSG_MATERIAL_SHORTAGE);

			ui.input[ui.inputIndex]   = '3';
			ui.inputIndex++;

			ui.state = UI_BRK_QUA_MS;
			break;

			case '4':
			putUImsg(UI_MSG_OTHERS);

			ui.input[ui.inputIndex]   = '4';
			ui.inputIndex++;

			ui.state = UI_BRK_QUA_MS;
			break;


			default:
			break;

		}
		break;


		case UI_BRK_QUA_MS:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_ISSUE);
			clearUIBuffer();
			ui.state = UI_ISSUE;
			ui.inputIndex = 2;
		}

		else if( keypressed == '\x0A')
		{
			if( ui.input[2] == '3' )
			{
				setUImsg(UI_MSG_PART_NO);
				clearUIBuffer();
				ui.state = UI_PART_NO;
			}
			else
			{

					getData();
					IAS_raiseIssues( ui.input);
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;
			
			}
		}

		break;


		case UI_PART_NO:
		if( keypressed == '\x08')
		{
			if(ui.bufferIndex > 0 )
			{
				putCharToLcd(keypressed);
				ui.bufferIndex--;

			}
			else
			{
				setUImsg(UI_MSG_ISSUE);
				clearUIBuffer();
				ui.state = UI_ISSUE;
				ui.inputIndex = 2;
			}

		}
		else if( keypressed == '\x0A')
		{
			if( ui.bufferIndex > 0 )
			{
				getData();
				IAS_raiseIssues( ui.input);
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}
		}

		else
		{
			if(scancode == ui.prevcode)
			{
				if(duration < MIN_KEYPRESS_DURATION)
				{
					ui.bufferIndex--;
					ui.buffer[ui.bufferIndex] = keypressed;
					putCharToLcd('\x08');
					putCharToLcd(ui.buffer[ui.bufferIndex]);
					DelayMs(20);
					ui.bufferIndex++;
				}
				else
				{
					ui.buffer[ui.bufferIndex] = keypressed;
					putCharToLcd(ui.buffer[ui.bufferIndex]);
					DelayMs(20);
					ui.bufferIndex++;
				}
			}
			else
			{
				ui.buffer[ui.bufferIndex] = keypressed;
				putCharToLcd(ui.buffer[ui.bufferIndex]);
				DelayMs(20);
				ui.bufferIndex++;
			}
			ui.prevcode = scancode;
		}
		break;

		case UI_ISSUE_ACK:

		if( keypressed == '0')
		{
			IAS_getOpenIssue(&openIssue);
			if( openIssue.ID != -1 )
			{
				showUImsg(openIssue.tag);
			}
		}

		else if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '\x0A')
		{
			IAS_acknowledgeIssues(openIssue.ID);
			openIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;




		case UI_ISSUE_RESOLVE:

		if( keypressed == '\x08')
		{
			IAS_getAcknowledgedIssue(&ackIssue);
			if( ackIssue.ID != -1 )
			{
				showUImsg(ackIssue.tag);
			}
		}

		else if( keypressed == '0')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
		}

		else if( keypressed == '\x0A')
		{
			IAS_resolveIssues(ackIssue.ID);   // 	IAS_resolveIssues( &ackIssue.ID); 
			ackIssue.ID = -1;
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;

		}

		break;




		case UI_CLEAR_ISSUE:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			ui.state = UI_STATION;

		}

		else if( keypressed == '\x0A')
		{
			IAS_clearIssues();
			clearUIBuffer();
			clearUIInput();
			setUImsg(UI_MSG_STATION);
			ui.state = UI_STATION;
		}

		break;

		case UI_PASSWORD:
		if( keypressed == '\x08')
		{
			if( ui.prevState == UI_LOGIN)
			{
				setUImsg(UI_MSG_IDLE);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_IDLE;
			}
			else if( ui.prevState == UI_LOGOUT || ui.prevState == UI_STATION)
			{
				setUImsg(UI_MSG_STATION);
				clearUIBuffer();
				clearUIInput();
				ui.state = UI_STATION;
			}

		}

		else if( keypressed == '\x0A')
		{
			ui.buffer[ui.bufferIndex] = '\0';
			if( ui.prevState == UI_LOGIN)
			{
				BOOL result = FALSE; 
				result = IAS_login(ui.buffer,ui.input);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;

				}
				else
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_IDLE;

				}

			}
			else if( ui.prevState == UI_LOGOUT)
			{
				BOOL result = FALSE; 
				result = IAS_logout(ui.buffer,ui.input);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_IDLE);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_IDLE;

				}
				else
				{
					setUImsg(UI_MSG_STATION);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_STATION;

				}		
				
			}
			else if( ui.prevState == UI_STATION )
			{
				BOOL result = FALSE; 
				result = IAS_checkPassword(ui.buffer);	
				if( result == TRUE )
				{
					setUImsg(UI_MSG_ADMIN_ACTIVITY);
					clearUIBuffer();
					clearUIInput();
					ui.state = UI_ADMIN_ACTIVITY;
				}
			}
		
		}

		else 
		{
			ui.buffer[ui.bufferIndex] = keypressed;
			putCharToLcd('*');
			ui.bufferIndex++;
		}
			
		break;		

		case UI_ADMIN_ACTIVITY:

		if( keypressed == '\x08')
		{
			setUImsg(UI_MSG_STATION);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_STATION;
			
		}


		else if( keypressed == '0')
		{
			setUImsg(UI_MSG_CLEAR_ISSUES);
			clearUIBuffer();
			clearUIInput();
			ui.state = UI_CLEAR_ISSUE;
		}


		break;
	
		default:
		break;


	}



}