自动售货机需求报告.docx

上传人:b****8 文档编号:27836868 上传时间:2023-07-05 格式:DOCX 页数:19 大小:260.29KB
下载 相关 举报
自动售货机需求报告.docx_第1页
第1页 / 共19页
自动售货机需求报告.docx_第2页
第2页 / 共19页
自动售货机需求报告.docx_第3页
第3页 / 共19页
自动售货机需求报告.docx_第4页
第4页 / 共19页
自动售货机需求报告.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

自动售货机需求报告.docx

《自动售货机需求报告.docx》由会员分享,可在线阅读,更多相关《自动售货机需求报告.docx(19页珍藏版)》请在冰豆网上搜索。

自动售货机需求报告.docx

自动售货机需求报告

VendingMachine

1-Objectives

Theobjectivesofthisexerciseareto:

∙BasedonTOODdesignapproach,propose2solutionsforthedesignarchitectureoftheVendingMachinepresentedinspecificationmodule:

∙Firstsolution:

sequential-withoutprocess.

Usingasequentialsolution,itisinterestingtoshowthanonemodeoftheStateTransitionDiagram(STD)cannotbereached:

“DispensingProduct”.

∙Secondsolution:

concurrent-withprocess(es).

Hypothesismustbemadeonthehardware.

2-ProblemOverview

ThisexampleisanextensionoftheproblempresentedattheForum”StructuredDevelopment”inSanFrancisco,inFebruary1986.

Theproblemstatementandtheresultingmodelswereinteractivelydevelopedanddescribedasadialoguebetweenthecustomerandtheanalyst.

Thecustomerstartedbyoutliningtotheanalystthatheisfacedwithcrooksascustomerswhotryputtingjunkintothecoinslotsofhisvendingmachineshopingtogetsomethingfornothing.Someeventrytoentercoin-likeslugstofoolthemachines.Theyalsotrytovandalizetheselectionregistertogetproductsfree.Thesearemajorproblemsforthevendingmachineoperatorsbecausetheydobusinessonanarrowmargin,whichdisappearsveryquickly.Themachineistodothefollowing:

-Acceptobjectsfromthecustomerinpaymentforhis/herpurchase.

-Checkeachobjecttomakesurethatitisnotaslug.Thisistobedonebyvalidatingthesize,weightandthickness.

-Acceptnickels,dimesandquarters.Anyothercoinsaretobetreatedasslugsandreturnedtothecustomer.

-Onlyinitiatepaymentcomputationorproductselectionprocessafteravalidatedcoinisdetected.

-Acceptproductselectionfromthecustomer.

-Checktoseewhethertheselectedproductisavailable,ifnotavailable,returncoinsautomaticallyandnotifycustomer.

-Acceptavarietyofproducts,whichwillchangefromtimetotime.Hence,theproductpricesshouldbechangeable.

-Returnthecustomer’spaymentonrequestifheorshedecidesnottomakeaselection.

-Dispensetheproducttothecustomerifitisavailableandtheamountissufficient.

-Returnthecorrectchangetothecustomeriftheamountdepositisgreaterthantheproductprice(initialconditions?

).

-Disabletheproductselectionaftertheproductisdispensedanduntilthenextvalidatedcoinisreceived.

Severalextrarequirementscouldbeaddedtothefirstlistofuser’srequirements,sinceweidentifiedsilences:

-Rejectcoinsasslugduringtheproductisdispensed.

-Haveavailablecoinstobeabletogivebackthechange(initialconditions).Forthat,thecoinsintroducedbythecustomerareaccumulatedinthecoinsstorage(Anywaywedon’tknowiftheinsertedcoinsareusedforgivingbackthechangeornot).

-Toleranceforvalidatingthethickness,size&weight(doesn’thaveeffectonthearchitecturenoronthealgorithms.

-Rejectcoinsasslugifthereisnotenoughchangeandofcoursedoesn’tdelivertheproduct(dowehavetheinformationfromthehardware).

-Rejectcoinsasslugifthereisnospaceenoughinthereceivingbox(dowehavetheinformationfromthehardware).

3-Proposedcontextdiagram

Sincenoinformationonthehardwareisavailable,thefollowingcontextdiagramisproposed(asfunctionaldiagram;nolowlevelexchanges).3differentterminatorsareproposed:

-COINSSYSTEM:

thesystemforprocessingtheobjectsandcontainingthecoinscontainer,

-SELECTOR:

theinterfaceforthecustomer’sactionsandnotifications,

-PRODUCTDISPENSER:

theboxcontainingtheproducts.

SincethereisnoindicationoftheinitialnumberofproductsfromthePRODUCTDISPENSERandtheinitialnumberofcoinsfromtheCOINSSYSTEM,assumptionsmustbemaderegardingthelimitandinitialconditions.Thesevaluesaredefinedbycompilation(#defineofC).

-Eachvalidobjectissentdirectlytothechangecoinsstorage(ifspaceavailable)andwillbeusedaschangecoin.

-Onechangestorageisavailableforeachtypeofcoinandfullassoonasthevendingmachineisturnedon.ThemaximumvalueisMaxNbOfCoin,sameforeverystorage.

-ThenumberoftypeofproductisdefinedbyMaxTypeOfProductsandthemaximumnumberofproductforonetypeisdefinedbyMaxNbOfProducts.

-AssoonastheVendingMachineisturnedon,theproductstorageisconsideredfullforallproducts(typeandnumberfor1type).

-ThedataflowcalledslugisinfactacontrolflowbecauseaneventotheterminatorCOINSSYSTEM.

RecalloftheStateTransitionDiagram

4-Identificationofobjectsandclasses

4.1Classes

FromthetextbeforeandtheglobalSARTmodelpresentedinspecification,thefollowingobjects,classesandfunctionscanbeproposed.

EntityName

Attributes

Type

Object

Thickness(integer)

Size(integer)

Weight(integer)

T_Object

Coin

Object

Value

Type

T_Coin

Payment

Payment

Integer

Product

Identifier

Price(integer)

T_Product

Mode

Mode

T_Mode

4.2Instantiation

Theinstantiationofaclassbecomesanobject.Inthecaseofthevendingmachinethereare:

Coinsstorage=multipleinstantiationoftheclassCoin,

Productsstorage=multipleinstantiationoftheclassProduct,

CurrentPayment=singleinstantiationoftheclassPayment,

CurrentMode=singleinstantiationoftheclassMode.

4.3Externalinterfaces

1terminatoristranslatedin1TOODentitysuchasmachine,sub-applicationorprocess.InthecaseoftheSARTdiagramabove,3machinesareidentified.

5-Functionality

Entities

Function(methods)

Parameters

Coins

-Validate

-Input=object

-output=Value,status(coinorslug)

-Accumulate

-Input:

Coin

-Output:

status(full)

-ReturnCoins

-input:

Change

-Output:

Status(enough,notenough)

Payment

-Accumulate

-Input:

CoinValue

-Output:

none

-Get

-Input:

none

-Output:

Payment

-Clear

-Input:

none

-Output:

none

-Validate

-Input:

ProductPrice

-Output:

Status(enough)

Products

-Dispense

-Input:

ValidSelection

-Output:

Status(OK/NOK)

-GetPrice(Validation)

-Input:

Selection

-Output:

Price,Status(OK/NOK)

Mode

(Containedinthemaincontroller)

ADT_Object

-Initialize

(Questionforthestudents–why?

-Input:

Thickness,Size,Weight

-Output:

Object

-IsEqual

-Input:

Object1,Object2

-Ouput:

Status(Equal/NotEqual)

ADT_Coin

-GetValue

-Input:

Coin

-Output:

Value

-Validate

-Input:

Object,

-Output:

6-FirstProposedsolution:

sequentialcase

Note:

Theproposedsolutionhereafterisnottheonlyonepossible.Severalsolutionsexist,andthedesignerhastochoosethebestoneregardingtheencapsulation,abstraction,…Especially,theprocessofthinkingmakesusbeginwiththeresearchofthemostelementaryobjectsbeforegroupingthem.

Theprocessisbottom-up.

6.1Architecture

Figure1:

ApplicationArchitecture

2sub-applicationsappear:

Coins&Products.

Thesub-application“Coins”isverybigcomparedto“Products”andtothemachinesSELECTOR&Payment.Butthegroupingofrelatedentitiessuchasobject,coins,terminatorcoinssystemobligesthedesignertochoosethissolution.Ofcoursethebalanceofthedesignmustalsobestudiedandothersolutionscanbeproposed.Justificationsmustthenbegiven(worksharingforexample).

Thesub-application“Products”containsonly2entitiesthatareamachineforthestorageandanADTforthetypeproduct.WithTOOD,wecouldhaveonlyonemachinefor“Products”definingboththestorageandthetype(seetheGDLTOOD).But,ifwetakethecaseoftheC++language,itrequiresabsolutelyfirstthedefinitionoftheclassandsecondtheinstantiation(s)ofthisclass.AndanywaythetranslationfromSARTtoTOODproposestotranslatedataflowsintoAbstractDataTypes.

Note:

Fortheentity“Products”,thefunction“Validate”returnsthepriceoftheselectedproduct.Afunctioncouldexist(“GetPrice”)togetthisvalue.Itcanbeeasiertounderstand.

Note:

Anothersolutionistogroupalltheexternalinterfaceswithin1entitytomakeeasierthemaintenanceandbettertheportability.

6.2MachineMODE–Interfaces&Environment

ItisnotnecessarytodrawagainthediagrambecauseitwouldbeveryclosetoFigure1.

6.3Sub-application“Coins”

6.3.1Interfaces&Environment

6.3.2Bodyofthesub-application

Thebodyofthissub-applicationisrelatedtodetaileddesign,everyentitycomposingthesub-applicationbeingabasicone.

ADT_ObjectisusedbyADT_Coin(via“IsEqual”)andCOINSSYSTEM(via“Initialise”).Thequestion“Whydoweneedthisfunction?

”canbeaskedtothestudents.

6.4Sub-Application“Products”

6.5Machines“Payment”&“SELECTOR”

Wedon’tknowtheinterfacesoftheSELECTOR.

Thequestionsthatcanbeaskedare:

∙Isitpossibletoreadwithoutwaittheselection?

∙Whatisthehardwarefortheuser’slamp(notavailable),timeout,on/off?

6.6MainAlgorithm

/*ProposalofAlgorithmforthemain()*/

Mode=Wait_For_Coin

Payment.Clear()

while(true)do

wait1secondNotreallynecessaryinthatcasebecausetheCPUisdedicatedtothe

vendingmachine

if(GetValue(OutValue)==OK)

|Payment.Accumulate(InValue)

|Mode=Wait_For_Selection

endif

if(SELECTOR.AcceptSelection(OutSelection)==true)

|if(Mode!

=Wait_For_Selection)donothing

|else

||if(Products.GetPrice(InSelection,OutPrice)==AVAILABLE)

||if(Payment.Validate(InPrice,OutChange)==OK)

||if(Coins.ReturnCoins(InChange)==OK)

||Mode=Dispensing_Product

||Product.Dispense(InValidSelection)/*Returnedstatusnotused*/

||else

||Payment.Get(OutCurrentPayment)

||Coins.ReturnCoins(InCurrentPayment)

||endif

||Payment.Clear()

||Mode=

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1