130 likes | 306 Views
ECE 18-649 Soda Machine Example Status Update. March 26, 2010 Group 7 Justin Ray (other group member names would go here). Overview. ButtonControl Design Process Recap Use Case, Scenarios, Sequence Diagrams Requirements, Statecharts Implementation Unit Testing
E N D
ECE 18-649Soda Machine ExampleStatus Update March 26, 2010 Group 7 Justin Ray (other group member names would go here)
Overview • ButtonControl Design Process • Recap • Use Case, Scenarios, Sequence Diagrams • Requirements, Statecharts • Implementation • Unit Testing • Integration and Acceptance Testing • Design revisions • Project Statistics • Lessons Learned Justin Ray
Flashing light behavior indicates that a soda vend is in progress. Button Control Scenario/Sequence Diagram • Use Case U2. Customer pushes a soda button • Scenario/SD 2A: push button after paying Button Customer ButtonLight VendControl CoinControl ButtonControl CoinCount==2 mVend == False 1a. Button s pressed 1b. Button[s](true) 1c. mButton[s](true) 16pt 1d. mCoinCount(2) 2a. ButtonLight[s](false) 2b. ButtonLight[s](true) 2a and 2b repeat until 5a. Justin Ray
Requirements & Statechart • R2.4 If Button[s] True AND mEmpty[s] False AND mCoinCount equals SODA_COST AND mVend False, then • R2.4a. ButtonState shall be set to True. • R2.4b. ButtonLight[s] shall be commanded to blink with a period of 1s. S2.1 IDLE DO: ButtonLightOn mButton[s] False FlashCounter 0 S2.3 VEND T2.1 S2.4 FLASH_OFF DO: ButtonLightOff mButton[s] TRUE Increment FlashCounter T2.2 T2.6 T2.7 S2.2 EMPTY DO: ButtonLightOff mButton[s] False FlashCounter 0 T2.3 T2.4 T2.5 S2.4 FLASH_ON DO: ButtonLightOn mButton[s] TRUE Decrement FlashCounter T2.1 mButton[s] ← True AND mEmpty[s] ← False AND mVend ← False AND mCoinCount ← SODA_COST Justin Ray
State Action SC to Code Traceability Transition Implementation Implementation • Switch statements on state variable • Actions before transitions switch (currentState) { case IDLE: doIdle(); //#transition 'T2.1' if (localButton.pressed == true && mEmpty.getValue() == false && mVend.getVendState() == false && mCoinCount.getCoinCount() == SodaMachine.SODA_COST) { newState = State.VEND; //#transition 'T2.6' } else if (mEmpty.getValue() == true) { log("T2.6"); newState = State.EMPTY; } break; .... Justin Ray
Unit Testing • 3 Unit Tests for ButtonControl • 2 unit tests test T2.1 • Unit tests (all controllers) found 4 defects SC to Test Traceability Injections for Guard Condition ;#transition 'T2.1‘ 1.0s I EMPTY_PER N EMPTY_CAN_ID Empty 2 = false 1.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2 1.0s I VEND_PER N VEND_CAN_ID Vend = false 1.0s I BTN_PER F Button 2 = true ;#state 'S2.4 FLASH_OFF' 1.41s A F Light 2 : lighted == false 1.41s A N BUTTON_CAN_ID Button 2 : getButtonState == true Assertions for State Output Justin Ray
Integration and Acceptance Testing • 7 integration tests (1 per controller) • SD1C and SD2a integration test transition T2.1 • Integration tests (all controllers) found 2 defects • Acceptance Tests • Tests test T2.1 customers press buttons • All tests pass • One 10-customer test • Four 100-customer tests Justin Ray
Project Statistics Justin Ray
Lessons Learned & Open Issues • Problems that you have already solved • Nested statecharts • Keep the nested statecharts • Collapse states in implementation • CoinControl - CoinOut timing • Simulation framework wont always deliver one period pulse • Added RETURN_STRETCH and OVERPAY_STRETCH states • Strategies • Assign one person to integrate portfolio • Scripts to automate testing are very useful • Rerun the tests after every design change/bug fix • Open issues • None Justin Ray
Any Questions? Team 7 Justin ray – justinr2@ece.cmu.edu …
Statechart S2.1 IDLE DO: ButtonLightOn mButton[s] False FlashCounter 0 S2.3 VEND T2.1 S2.4 FLASH_OFF DO: ButtonLightOff mButton[s] TRUE Increment FlashCounter T2.2 T2.6 T2.7 S2.2 EMPTY DO: ButtonLightOff mButton[s] False FlashCounter 0 T2.3 T2.4 T2.5 S2.4 FLASH_ON DO: ButtonLightOn mButton[s] TRUE Decrement FlashCounter Justin Ray