Upload
truongkhuong
View
215
Download
0
Embed Size (px)
Citation preview
November 20th, 2011 Dr. Andrew Rawicz School of Engineering Science Simon Fraser University Burnaby, British Columbia V5A 1S6 Re: ENSC 440 Design Specification for an RFID Smart Fridge Dear Dr. Rawicz: The document attached outlines the design specification for Cyber-Flux Innovations’ RFID Smart Fridge. Our team is designing a smart refrigerator which will keep track of its contents and provide useful information to customers through a website and mobile phone application. Our design specification document applies to the proof-of-concept prototype we are currently developing. Design improvements for future models of the RFID Smart Fridge are discussed, but will not be implemented in this stage of development. This document will direct the development and testing process of the prototype. Our team is comprised of four talented undergraduate students from Simon Fraser University: Lead Integration Manager: Damir Jungic (Electronics stream), Lead Hardware Design: Mitchell Joblin (Biomedical stream), Lead Software Design: Steven Verner (Computer stream), and Lead Project: Renato Pagliara (Biomedical stream). If you have any questions or concerns regarding our functional specifications, please do not hesitate to contact us at [email protected]. Sincerely,
Renato Pagliara Renato Pagliara Project Lead Cyber-Flux Innovations Enclosure: RFID Smart Fridge Functional Specification
RFIDSMARTFRIDGE
DESIGNSPECIFICATION
Project Team: Damir Jungic Mitchell Joblin Steve Verner Renato Pagliara
Contact Person: Renato Pagliara
Submitted to: Dr. Andrew Rawicz – ENSC 440 Mike Sjoerdsma – ENSC 305 School of Engineering Science Simon Fraser University
Issued Date: November 20th, 2011
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
3
EXECUTIVESUMMARY
The design specification of the RFID Smart Fridge provides a set of detailed descriptions of the design and development of our proof-of-concept prototype system. The design specifications in this document apply solely to the proof-of-concept prototype. While the specifications in this document might deviate from the features of the system as described in the document RFID Smart Fridge Functional Specification (Pagliara, Jungic, Joblin, & Verner, 2011), we have added features which were not previously described which address key issues of power and performance. We have integrated a temperature and humidity sensor into the in-Fridge hardware to provide users with the ability to monitor the conditions inside the fridge in real-time. At the same time, the addition of a reel switch located on the fridge’s door allows us to maintain the power consumption of the system to a minimum while ensuring we keep basic network functions running. This document outlines the design of the RFID Smart Fridge and provides justification for our design decisions. The RFID Smart Fridge System development has been divided into four modules as well as system integration: In-Fridge Hardware, Backend Server, Server Features and Smartphone App. The in-Fridge hardware located within the fridge reads RFID tags inside of the fridge using a RFID reader/writer unit. The reading of the fridge’s contents is triggered by the closing of the fridge door. The information from the tags is then sent to the server through a Local Area Network (LAN) using a WiFi module. This process, together with the temperature/humidity readings from the sensor, is coordinated through an Arduino microcontroller. The Backend Server saves tag information received from the Hardware Unit. The server then extracts the barcode information from each tag and runs it through a database to obtain the products’ name and nutritional information. Once the information from the products has been obtained, the user can observe the contents of their fridge through either a web browser or through their iPhone. As well, users can automatically generate a grocery list based on the history of their fridge’s contents and consumption prediction algorithms. Finally, nutrition models, calculated from the nutritional information retrieved from a product catalogue database, will allow the users to quantify the level of nutrition for each item inside the fridge. The iPhone will leverage all the processing power of the backend server and will work as a web client which will help costumers navigate through the many features offered by the Smart Fridge System. Design decisions, including selection of hardware, are justified throughout this document. General software program process flow is also included. Further, a description of the test plan for the system and its subcomponents is included. Finally, a discussion about the safety of RFID technology is presented to ensure this critical aspect of product development is not overlooked. The expected completion date for the RFID Smart Fridge project is December 06, 2011.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
4
ACRONYMS&ABBREVIATIONS
1‐D One‐Dimensional
App Application
HTML HyperTextMarkupLanguage
HTTP HyperTextTransferProtocol
ISO InternationalOrganizationforStandardization
LAN LocalAreaNetwork
LED Light‐emittingDiode
MB Megabyte
RFID RadioFrequencyIdentification
Temp Temperature
UID UniqueHardwareIdentification
UML UnifiedModelingLanguage
UPC UniversalProductcode
WiFi Wireless‐Fidelity
GLOSSARY
Radiofrequencyidentificationsystem:Anautomaticidentificationanddatacapturesystemcomprisedofoneormorereader/interrogatorsandoneormoretranspondersinwhichdatatransferisachievedbymeansofsuitablymodulatedinductiveorradiatingelectromagneticcarriers(AIMGlobal,2010).
Transponder:AnelectronicTRANSmitter/resPONDER,commonlyreferredtoasaTag[sameasabove].
UniqueHardwareIdentification(UID):throughoutthisdocument,wewilldefineUIDasaneight
hexadecimalcharacterslongnumberwhichuniquelyidentifiesatransponder.
UniversalProductCode(UPCorEAN):barcodesymbologywidelyusedinNorthAmerica,fortrackingtradeitemsinstores.Itsmostcommonform,theUPC‐A,consistsof12numericaldigits,whichare
uniquelyassignedtoeachtradeitem.AlongwiththerelatedEANbarcode,theUPCistheonlybarcodeallowedforscanningtradeitemsatthepointofsale,perGS1standards(GS1,2011).
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
5
TABLEOFCONTENTS
ExecutiveSummary ..................................................................................................................................... 3
Acronyms&Abbreviations .......................................................................................................................... 4
Glossary ....................................................................................................................................................... 4
Tableofcontents ......................................................................................................................................... 5
Listoffigures ............................................................................................................................................... 7
1 Introduction......................................................................................................................................... 7
Scope........................................................................................................................................................ 8
IntendedAudience................................................................................................................................... 8
2 SystemSpecifications .......................................................................................................................... 8
RFIDTechnology....................................................................................................................................... 9
RFIDTechnologyandSafety................................................................................................................... 10
3 OverallSystemDesign ....................................................................................................................... 10
4 In‐FridgeHardware............................................................................................................................ 13
RFIDreader/writer: ................................................................................................................................ 14
Microcontroller ...................................................................................................................................... 15
WiFiModule........................................................................................................................................... 16
Temperature/Humiditysensor .............................................................................................................. 16
ISO15693RFIDProtocol ......................................................................................................................... 16
Microcontroller‐RFIDreader/writerCommunication ............................................................................ 16
Power ..................................................................................................................................................... 17
Casing ..................................................................................................................................................... 17
5 BackendServer .................................................................................................................................. 18
ObjectHierarchy .................................................................................................................................... 18
AddingandRemovingItems .................................................................................................................. 20
Serialization............................................................................................................................................ 22
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
6
Client’sResponsibilities.......................................................................................................................... 23
6 ProductCatalog ................................................................................................................................. 24
7 Communication ................................................................................................................................. 25
BackendServices.................................................................................................................................... 26
In‐FridgeHardwaretoBackendServerCommunication........................................................................ 28
MobileApptoBackendServerCommunication .................................................................................... 29
WebServertoBackendServerCommunication .................................................................................... 30HTMLAssembly ................................................................................................................................. 30Time‐DependentContent .................................................................................................................. 30Plotting .............................................................................................................................................. 31
8 SoftwareSystem................................................................................................................................ 31
Auto‐GeneratedGroceryList ................................................................................................................. 31AlgorithmInterface............................................................................................................................ 31Component1 ..................................................................................................................................... 32Component2 ..................................................................................................................................... 32Component3 ..................................................................................................................................... 32Component4 ..................................................................................................................................... 33Component5 ..................................................................................................................................... 33Summary............................................................................................................................................ 33
NutritionMetricSystem......................................................................................................................... 36NutritionalProfilingModel ................................................................................................................ 36SystemDescription ............................................................................................................................ 36NutritionItemClass ........................................................................................................................... 36NutritionMetricsClass ...................................................................................................................... 36ConstructNutritionItem ................................................................................................................... 36TopFiveLists...................................................................................................................................... 37AverageNutritionalValueofList ....................................................................................................... 37ItemsInRange ................................................................................................................................... 37NutritionalValueversusTime ........................................................................................................... 37
9 MobileApplication ............................................................................................................................ 41
Overview ................................................................................................................................................ 38
MobileAppSystemDesign .................................................................................................................... 40
10 Testing ............................................................................................................................................... 41
SimulatedFridgeSystem........................................................................................................................ 41
CommunicationTesting ......................................................................................................................... 43BackendServerTesting...................................................................................................................... 43
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
7
In‐FridgeHardwaretoBackendServerCommunicationTesting....................................................... 44iPhoneApplicationtoBackendServerCommunicationTesting........................................................ 44WebServertoBackendServerCommunicationTesting ................................................................... 44
11Conclusion.......................................................................................................................................... 44
12References ......................................................................................................................................... 45
LISTOFFIGURES
Figure1:SystemOverview .......................................................................................................................... 9Figure2:SystemOverview ........................................................................................................................ 11Figure3:In‐FridgeHardwarelocationwithinthefridge ........................................................................... 13
Figure4:In‐FridgeHardwaresubsystemdiagram..................................................................................... 14Figure5:GeneralISO15693request.......................................................................................................... 16Figure6:UMLDiagramofCoreBackendServerClasses ........................................................................... 20
Figure7:AddingtotheInFridgeSetProcessFlow ..................................................................................... 21Figure8:JavaXMLBinding(JAXB)Workflow ............................................................................................ 22Figure9:CommunicationOverview .......................................................................................................... 26
Figure10:AutoGeneratedGroceryListAlgorithm .................................................................................. 35Figure11:NutritionalMetricStructure ..................................................................................................... 38Figure12:MobileApplication‐InMyFridgeView ..................................................................................... 39
Figure13:MobileAppClassHierarchy ...................................................................................................... 40
LISTOFTABLES
Table1:RFIDcommerciallyavailablereader/writerunitsandtheircharacteristics(Ward&vanKranenburg,2006) ..................................................................................................................................... 15
Table2:DescriptionofItemTypeFields .................................................................................................... 18Table3:PathsMadeAvailablebyServer................................................................................................... 26Table4:PathsandtheirQueries ............................................................................................................... 27
LISTOFLISTINGS
Listing1:SimpleUPCRequestExample..................................................................................................... 25Listing2:SimpleUPCResponseExample ................................................................................................... 25
Listing3:ExampleofXMLSentfromIn‐FridgeHardwaretoBackendServer ........................................... 28
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
8
1 INTRODUCTION
TheRFIDSmartFridgeisasmarthomeappliancewhichbesidesfunctioningasaregularfridge,itkeeps
trackofitemstaggedwithRFIDtranspondersplacedinsidethefridgeandprovidescustomerswithextrainformationabouttheirproducts,theirnutritionalfactsandtheirfridge’scontentshistory.ThisdocumentdescribesthetechnicaldetailsbehindtheSmartFridgesystem.Theinformationhasbeen
dividedintothesystem’sfourmaincomponents:in‐Fridgehardware,backendserver,serverfeaturesandsmartphoneapp.Thedocumentalsoincludesatestplanfortheintegrationofallfourcomponentsintothesystem.
ScopeThisdocumentspecifiesthedesignoftheRFIDSmartFridgesystemandexplainstowhatdegreehave
thefunctionalrequirementsasdescribedinRFID Smart Fridge Functional Specification(Pagliara,Jungic,Joblin,&Verner,2011)beenmet.Atthesametime,newfeaturesnotlistedinthepreviouslymentioneddocumenthavebeenaddedtothesystemandareexplainedindetailinthisdocument.The
designspecificationencompassestherequirementsfortheproof‐of‐conceptsystemandapartialsetofrequirementsforaproductionmodel.
IntendedAudienceThedesignspecificationisintendedforusebythemembersofCyber‐FluxInnovations.Leadengineerswillrefertothespecificationsasguidelinesforthedevelopmentofthesystembutin
casetheydeemitnecessarytheywillmodifythesespecificationstoensureallrequirementsaremetinthefinalproduct.Thisproductwillalsobeusedduringthetestingphasetoensuretoconfirmthe
correctbehaviouroftheSmartFridgesystem.
2 SYSTEMSPECIFICATIONS
TheRFIDSmartFridgewillconsistofamodifiedfridgethatdetectsitemsbeingputinortakenoutvia
theirRFIDtag(usinganRFIDreader).ThereaderthensendsthetaginformationtoaserverviaaLANwheretheinformationwillbeprocessedandmadeavailabletotheuserthroughasimplemobileapplicationandwebsiteasseeninthediagrambelow.Theserverwillprocessthislargeamountof
informationandmakeitavailableinasimple,convenient,usefulmannerthroughitsinterfacestogivetheuseralistofthefridge’scurrentcontents,alistoffoodswhichwillexpiresoon,anautomaticallygeneratedgrocerylistbasedontheuser’seatinghabitsandsomesimpleandrelevantnutritional
informationaboutthefridge’scontentsandrecenthistory.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
9
Figure1:SystemOverview
RFIDTechnologyRadioFrequencyIdentification(RFID),asitsnameimplies,makesuseofradiowavestotransferinformationfromatransponder(inourcase,atag)toareader,withthepurposeofidentifyingthetransponderandthustheobjectitisattachedto.AnRFIDsystemconsistsofthreeelements:an
antenna,atransceiverwithadecodertointerpretthedataandatransponderthathasbeenprogrammedwithinformation.Theantennaemitsradio‐frequencysignalsinarelativelyshortrange.TheRFradiationprovidesameanofcommunicatingwiththetransponder(theRFIDtag)andprovides
theRFIDtagwiththepowernecessarytocommunicate(inthecaseofpassivetransponders).
ThankstothetransmissionofpowerthroughtheRF‐signals,RFIDtagsdonotneedtocontainbatteries,andremainusableforyears.WhenanRFIDtagpassesthroughthefieldofthescanningantenna,itdetectstheactivationsignalfromtheantenna.That"wakesup"theRFIDchip,andittransmitsthe
informationonitsmicrochiptobepickedupbythescanningantenna.RFIDtagscanbeeitheractiveorpassive.ActiveRFIDtagshavetheirownpowersource;thismeansthat
thereadercanbemuchfartherawayandstillgetthesignal.PassiveRFIDtags,however,donotrequirebatteries,andcanbemuchsmallerandhaveavirtuallyunlimitedlifespan.RFIDtagscanbereadinawidevarietyofcircumstances,wherebarcodesorotheropticallyreadtechnologiesareuseless.Thetag
neednotbeonthesurfaceoftheobject(andisthereforenotsubjecttowear).Thereadtimeistypicallylessthan100milliseconds.DependingontheRFIDreader,largenumbersoftagscanbereadatonce.Forsimplercheaperreaders,itemsshouldbereaditembyitem(technovelgy.com,2010).
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
10
RFIDTechnologyandSafetyThesafetyofunderlyingtechnologiesplaysakeyroleinhigh‐leveldesigndecisions.Indeed,theveryplausibilityoftheSmartFridgeSystemrequiresthattheunderlyingtechnologynotharmpeopleorthe
foodthatthesystemcomesintocontactwith.Itisnecessarytoconsidertwoprimarysafetyissues:doesRFIDtechnologyinterferewithfoodanddoesitinterferewithpacemakersorsimilarelectricalmedicaldeviceswornusers.
IthasbeenobservedthatRFIDtagsoperatingatlowfrequenciescanaffecttheoperationofpacemakers
(USFoodandDrugAdministration,2010).However,thelargerreadrangeofhigh‐frequencyreadersmakethempreferablefortheSmartFridgeSystem.Higher‐frequencysignalsareroutinelyfilteredbywornmedicaldevices,andthereforeposenoknownrisktodevicebehaviour.TheSmartFridgeSystem
willthereforenotharmuserswhorelyonwornorimplantedmedicaldevices.
StudiesobservingtheeffectsofNon‐IonizingFields,suchasthosecreatedbyRFIDreaders,onlydemonstrateshort‐termeffects(suchasheating)(RFID4SMEandtheEuropeanUnion,2008).Further,itisworthnotingthatanElectro‐MagneticField(EMF)isonlypresentwithinthefridgewhiletheRFID
readerisreadingtags.Tagsareonlyreadafterthefridgedoorisclosed.Further,thereadingthecontentsoftheentirefridgeonlytakesseconds.TheexposureofthefoodwithinthefridgetoanEMFisthereforeextremelyminimal.TheSmartFridgeSystemthereforeisnotharmfultothefoodwithwhichit
comesintocontactwith.
3 OVERALLSYSTEMDESIGN
Ahigh‐leveloverviewoftheSmartFridgeSystemispresentedinFigure2.Fromthepointofviewof
costumers,theRFIDSmartFridgesolutionhasthreemaincomponents:theIn‐FridgeHardware,theBackendServerandtheSmartphoneApp.Eventhoughtheproductcatalogueisnotpartoftheserver(itisastandalonesoftwareserviceavailablethroughtheweb),fromcostumer’spointofviewitappearsas
iftheserverisperformingtheserviceswhichbelongtotheproductcatalogue.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
11
Figure2:SystemOverview
TheIn‐FridgeHardwareisinstalledwithinthefridgeandisinchargeofobtaininginformationabouttheproductsplacedinsidethefridgethroughtheRFIDtags.Theservertakesthatinformationand,uponrequestfromtheuserthroughthewebpage,allowsuserstocheckthecontentsofthefridge,generate
grocerylistsandcheckthenutritionalvalueofpresentandpastproductswithinthefridge.Inthesameway,theusercanaccessthesethreefeaturesthroughtheSmartphoneApp.Finally,theSmartphoneAppoffersafourthfeaturewherecostumerswillbeabletoenteritemsintothesystemthatdonothave
anRFIDtagbyeitherenteringthenameoftheproduct(forleftovers)orbyscanningtheUPCbarcode(forproductswhichdonothaveanRFIDtag)andattachingaRFIDread/writetagtotheproduct.
Thesystemthus,hastwogeneralcases:
Productswithabuilt‐inRFIDtag:
Inthiscasetheinformationflowsinalinearfashionthroughthesystem.Whenthedoorofthefridgecloses,thein‐FridgehardwarescansthefridgeforRFIDtags.Afterreadingallthetagswithinthefridge,
theinformationisenclosedinamessageandsenttotheserver.
ProductswithoutaRFIDtag:
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
12
InthiscasetheuserstartstheflowofinformationbyenteringthenameorscanningtheUPCbarcodeoftheitemthroughtheSmartphoneApp.TheuserthenattachesaRFIDtagtotheproduct/leftoverand
insertsitintothefridge.Theflowofinformationfromthereonwardsisthesameasinthefirstcase.
ThisdocumenthasbeendividedintosectionsdedicatedtotheexplanationofthemainsubsystemswithintheSmartFridgesolution.ThedesignoftheIn‐FridgeHardware,BackendServer,ProductCatalogue,SoftwareSystemandtheSmartphoneAppcomponentsofthesystemareexplainedinthe
followingsections.Inaddition,asectiondedicatedtocommunicationwilldescribetheinteractionsofthevarioussubsystems.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
13
4 IN‐FRIDGEHARDWARE
Figure3:In‐FridgeHardwarelocationwithinthefridge
Figure3illustratesthelocationoftheIn‐FridgeHardwarewithinthefridge.Thislocationwasselectedtomaximizethereadingrangeandthustobeabletoreadanyproductlocatedinsidethefridge.TheIn‐
FridgeHardwareunitconsistsofaRFIDreader/writer,amicrocontroller,aWiFimoduleandatemperature/humiditysensor.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
14
Figure4:In‐FridgeHardwaresubsystemdiagram
RFIDreader/writer:Sincethereader/writerunitisanintegralpartoftheproject,therewereseveralrequirementstakenintoaccount,suchas:
• Radiowavesfrequency
• Communicationrange• DataTransferRate• PowerConsumption
• RFIDprotocolcompatibility• Price
RFIDtechnologyisusedin3mainfrequencies,LowFrequencyLF,HighFrequencyHF,andUltraHighFrequencyUHF.ItfollowsthatallotherrequirementsfortheRFIDreader/writerunitdependonthe
frequencyofthereaderasshowninTable1.Giventherequirementsoftheprojectandthesmallbudget,itwasdecidedthattheSmartFridgeprototypewouldusetheAPSX‐RW310RFIDreader/writerunit.Thisunithasarangeofapproximately25cmaboveandbelowthebuilt‐inantenna(rectangular
shape,dimensions:25cmx10cm)andapproximately8cmtothesideswithcreditcardsizeRFIDtags.TheunitcommunicatestoexternaldevicesthroughaUARTSerialport.ThefourthcolumninTable1showsthecharacteristicsoftheunit.Aswell,theprototypeSmartFridgeusestheISO15693RFID
communicationsprotocol,whichissupportedbytheAPSXreader/writerunitchosen.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
15
Table1:RFIDcommerciallyavailablereader/writerunitsandtheircharacteristics(Ward&vanKranenburg,2006)
LOWFREQUENCY HIGHFREQUENCY ULTRAHIGHFREQUENCY
APSX‐RW310
FrequencyRange 30‐300kHz 3‐30MHz 300MHz‐3GHz NATypicalworking
frequency125‐134kHz 13.56MHz 433MHzor
865–956MHz2.45GHz
13.56kHz
ApproximateCommunication
Range
Lessthan0.5m Upto1.5m 433MHz=upto100
metres865‐956MHz=
0.5to5metres
0.1‐0.25m
TypicalDataTransferRate
Lessthan1kbit/s Approximately25kbits/s
433–956=30kbit/s
2.45=100kbit/s
19.2kbits/s
Powerconsumption
Low Low High 20mA/5V
Characteristics Short‐range,lowdatatransfer
rate,penetrateswaterbutnot
metal.
Higherranges,reasonabledatarate,penetrateswaterbutnot
metal.
Longranges,highdatatransfer
rate,concurrentread
of<100items,cannot
penetrateswaterormetals.
Short‐range,reasonable
datatransferrate,
penetrateswaterbutnotmetal.
TypicalUse AnimalID,carimmobilizer
Smart‐Labels,contactlesstravelcards,Access&
Security
Specialistanimaltracking,Logistics
NA
Price Lowest Low High Affordable
MicrocontrollerThemicrocontrollerisinchargeofsendingcommandtotheRFIDreader/writerunit,temporarilystoreinformationofRFIDtags,preparingthemessagestobesenttothebackendserverandcommunicatingwiththeWiFimoduleandtemperature/humiditysensor.Themicrocontroller‐backendserver
communicationdetailsareprovidedinthecommunicationsectionofthisdocument.
TheArduinoUNOmicrocontrollerwasselectedfortheSmartFridgeprototypeduetoitssimplicityofuse,librariessupportandpreviousexperienceofsomeofthemembersoftheteamwiththedevice.Aswell,theArduinoUNOcomeswithreceiveandtransmitUARTserialportswhileallowingforthecreation
ofextrasoftwareserialportsifnecessary.TheArduinoUNOmicrocontrollerrequires7‐12Vand40mAcurrentperI/Opin.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
16
WiFiModuleInordertotransmittheinformationfromtheRFIDtagstotheserver,itisnecessarytoconnectthemicrocontrollertotheserverthroughaLANusingWiFi.WiFiwasselectedoverBluetooth,XBee,ANT
andotherwirelessprotocolssinceitisthenativelanguageoftheserver,ithasthelongestrangeanditprovidesextrafeaturesthatallowforbettercontrolandmanagementoverthecommunication.Forthisprototype,theAsyncLabsWiFishieldofferedgoodqualityatalowpricewhileprovidingbasic
transmissioncontrolprotocolsupport.ThisunitcommunicatestothemicrocontrollerthroughUARTserial.TheWiFimodulerequires250μAofcurrentand5Vtofunction.
Temperature/HumiditySensorGiventhatthemainfeatureofanyfridgesystemistheabilitytomaintainfoodproductsatalowtemperaturetoprolongtheirediblelife,theSmartFridgeprototypemonitorsthetemperatureand
humidityinsidethefridgeandreportsthevaluestotheserver.TheSHT15temperatureandhumiditysensorfromSensirioncomesalreadycalibratedandprovidesextremelyhighprecisiontemperatureandhumidityreadingswhichmakesitidealfortheSmartFridgeprototype.Thisunitisalsolowpower(30
µW/2.4‐3.6V),hasatemperaturerangeof‐40°Cto123.8°C(±0.3°Cat25°C)andrelativehumidity(RH)rangeof0‐100%RH(±2%RH).ThissensorcommunicatestoexternaldevicesthroughInter‐IC(I2C).
ISO15693RFIDProtocolTheselectedprotocolforcommunicationbetweentheRFIDtags,theRFIDreader/writerandthe
microcontrolleristheISO15693.ThisprotocolisthemostwidelyusedRFIDprotocolanditcanbefoundinmostRFIDproducts.ThisprotocolrequiresexternaldevicesattemptingtocommunicatetoRFIDtagstodosothroughbytesofdatarepresentingtherequestforinformationtothedevice.Thegeneral
formatoftheISO15693commandisthefollowing:
StartOfFile(SOF)(Nbytes)
Flags(1byte)
Command(1byte)
Parameters(0‐Nbytes)
ChecksumCRC
(2bytes)
EndOfFile(EOF)(Nbytes)
Figure5:GeneralISO15693request
WheretheflagsrepresentdifferentparametersthatdealwiththedatatransferrateandthetransmissionofthecommandtoonespecificRFIDtransponderortoalltransponderswithintheread
range,thecommandrepresentstherequestedactionandtheparametersistheinformationnecessarytoprocesstherequestedaction.
TheSOFandEOFprotocolisusuallydependantontheRFIDreader/writerunitselected.InthecaseoftheAPSX‐RW310,theSOFisequaltothenumberofbytesenclosedinthemessage(notcountingthe
SOFbyte)andtheEOFisnotspecified(thismeans,themessageisconsideredcompleteafterthechecksumbytesaresent).
MicrocontrollerRFIDreader/writerCommunicationThecommunicationbetweenthemicrocontrollerandtheRFIDreader/writerunitwasdesignedforefficiencyandeasydebugging.Numerousfunctionswereimplementedwithinthemicrocontrollercode
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
17
whichallowsthemicrocontrollertotransmitthenecessarybytestotheRFIDreader/writertorequestforspecificinformationfromaspecificRFIDtransponderwithinthereadingrange.
Atthemostsimplelevel,afunctionhasthetasktosendonerequestintheISO15693formattotheRFID
reader/writerunit.ThefunctionisalsoinchargeofprocessingtheresponsefromtheRFIDunitandtosavetherelevantinformationintoglobalvariablesthatcanthenbeaccessedbyotherfunctionsfordataprocessing.
Forexample,ifthemicrocontrollerneedstorequesttheRFIDreader/writerunittoreadtheUIDofall
transponderswithinthereadingrange,thenthemicrocontrollercallsasetoffunctionsthatperformsimplespecifictasks:first,themicrocontrollercallsafunctionwhichreadsoneUIDofatransponderpresentinthereadrange.TheUIDinformationisthenstoredinavariable“tagUID”.Then,thisvariable
ispassedasafunctionparametertoanotherfunctionwhichsetsthattransponderinasleepingmodeinwhichthetransponderdoesnotreactanymoretorequests.Finally,thisprocessisrepeateduntilnotranspondersreacttotherequest.
PowerThevoltageandcurrentnecessarytopowertheRFIDreader/writerunit,theWiFimodule,andthe
temperature/humiditysensorcanallbeprovidedbytheArduinoUNOmicrocontroller.Themicrocontrollerrequiresasteadypowersupplyof7‐12V.Themicrocontrollerwilldrawpowerfromthepowersupplyofthefridge.Inordertodothis,a120V‐to‐12Vregulatorwillbeplacedinparallelwiththe
powersupplyforthefridge.
Toreducetheamountofpowerconsumedbythein‐Fridgehardware,areelswitchandamagnetwillbeplacedonthefridge’sdoor.ThisswitchwillcontrolthepowertotheRFIDreader/writerunit.Theswitch
willconnecta5Voutputpintooneoftheinterruptpins,bothinthemicrocontroller.Theinterruptissettobetriggeredwhenthesignalchangesfromlowtohigh.Hence,whenthefridgedoorandtheswitchopen,theinterruptwillnotreportachange.Theinterruptwillbetriggeredwhenthedoorclosesand
thesignalgoesto5V,thussignallingthemicrocontrollerthattheitemsetwithinthefridgemighthavechanged.Themicrocontrollerwillthenreadalltheitemswithinitsrangeandreportthenewitemsettotheserver.
CasingThein‐Fridgehardwarewillbeplacedwithinaplasticcase.Thecasewillprotecttheelectronicsinsideit
fromdamagewithoutanyinterferewiththeradiowaves.Thetemperature/humiditysensorwillbeplacedontheoppositesidetothemicrocontrollerandWiFimodulestoreduceanypossibletemperatureandhumidityerrorresultingfromtheheatemanatedbytheelectronicdevices.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
18
5 BACKENDSERVER
TheBackendServerwasbuiltusingtheJavaProgrammingLanguage.Javawaschosenduetoits
popularity,platformindependence,andtheextensiveavailabilityoflibraries,APIsanddocumentation.Afull‐featuredprogramminglanguagewaschosenoveraserver‐sidescriptinglanguageduetothespeedofcomputationandflexibilityoftheformer.Thesystemoftenneedstodealwithlargedatasets(ie.a
fullhistoryofproductsthathavebeeninsidetheuser’sfridge),somethingthattheinterpretednatureofserver‐sidescriptingdoesnothandlewell.
ObjectHierarchyItemswithinthefridge,suchasacanofCokeoracontainerofleftoverpizza,arerepresentedwithintheBackendServerasItemTypeobjects.TheItemTypeclassisabstract–nothingcanbejustanItemType.
ThefieldsofanItemTypeobjectandtheirmeaningsarepresentedinTable2.
Table2:DescriptionofItemTypeFields
Field Descriptionid hardwareIDoftheRFIDtagattachedtothisitem
expiry_date thedateatwhichtheitemwillexpire
fridgeTimeStamps.entry_time thetimetheitementeredthefridge
fridgeTimeStamps.exit_time thetimeatwhichtheitemleftthefridge(forgood)
consumingTimeStamps alistofentrytime&exittimepairsthatdescribeeverytime
theitemwastakenoutofthefridgeandputbackin.
TherearetwoclassesthatextendItemType:LeftoverItemTypeandProductItemType.
ALeftoverItemTypeobjectrepresentsacontainerthatwasRFIDtaggedbyauser.Inadditiontoallthe
fieldsofanItemType,aLeftoverItemTypecontainsa“name”fieldthatservesasauser‐specifiedlabelofthecontentsofthecontainer.
ObjectsoftypeProductItemTyperepresentitemswithUPCcodes.ProductItemTypeobjectshaveanadditionalfieldcalled“upc”whichspecifiestheirUPC.Itisworthnotingthatthe“upc”fieldisoftype
String,despitealwayshavinganumericvalue.ThisisnecessarybecauseleadingzerosaresignificantwhenspecifyingaUPC(readbelowaboutserializationtoseewhyaxml‐primitivetypeisnecessaryinsteadofamoresophisticatedobjecttype).Forexample,twocansofCokeconstitutetwoobjectsof
typeProductItemType–bothwiththesamevalueofthe“upc”field.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
19
TheSmartFridgeSystemattemptstopullinformation(includingbrand,description,apicture,nutritionalinformation,etc)fromtheProductCatalogue(discussedbelow)wheneveranew
ProductItemTypeobjectisaddedtotheInFridgeSet.TheinformationpulledfromthecatalogueisidenticalforallproductswiththespecifiedUPC.Therefore,toavoidstoringmultiplecopiesofthesameinformationthisinformationisnotattachedtotheProductItemType,butisratherturnedintoanew
objectoftypeProductType.
AProductTypeisaUPCbarcodeandallofitsassociatedinformation,includingdescription,brand,pictureURL,andpotentiallynutritionalinformation.Thisobjectisintendedtocontainalltheinformationthatdoesn’tchangefromoneinstanceofaproducttoanother.Forexample,twocartonsof
milkwiththesameUPCcodecanhavedifferentexpirydates,whichiswhythisinformationiscontainedintheItemType(eachcartonwillhaveitsownItemTypeobject).However,bothcartonshavethesamebrandname,description,nutritionalinformation,andsoon.Boththe“info”(includingbrandname,
descriptionetc)andthenutritionalinformationarestoredashashtables,sincetheUPCcatalogserviceweareinterfacingwith(SimpleUPC)canreturndifferentamountsofinformationdependingontheUPCthatisqueried.
Theremainingobjectsserveascontainersforthosedescribedabove.Therearethreecontainersfor
ItemTypeobjects:
• InFridgeSet–containsallitemsthatarecurrentlyinthefridge.• HistorySet–containsallitemsthatwereonceinthefridge(ithasyettobedecidedifthisset
willonlycontainitemsforacertainperiodoftime).Onceanitemisremovedfromthe
InFridgeSet,itisaddedtotheHistorySet.Ifanitemistakenoutofthefridgeandthenputback,itleavestheHistorySetandreenterstheInFridgeSet.
ThereisalsoaProductCachethatstorestheresultsreceivedfromSimpleUPC.Inthisway,thenumberof
queriessenttotheserviceisreducedandrequestscanberespondedtomorequickly.Byseparatingthisstoreofinformation,sophisticatedcachingtechniquesbecomepossibleinordertoreduceuserwaittimeandserverbandwidth.
AFridgeSystemobjectcontainsoneofeachofthesethreesets:anInFridgeSet,HistorySetand
ProductCache.Thisisthecompletedescriptionofasystem.
AlltheobjectrelationshipsexplainedthusfararepresentedintheUMLdiagraminFigure6.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
20
Figure6:UMLDiagramofCoreBackendServerClasses
AddingandRemovingItemsOneofthecorefunctionsthattheBackendServermustperformistheaddingandremovingofItemTypeobjectstoandfromtheInFridgeSetandtheHistorySet.TheflowchartpresentedinFIGURE
described
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
21
Figure7:AddingtotheInFridgeSetProcessFlow
Whenanentersthefridge,itisnecessarytodeterminewhetherthisistheitem’sfirsttimeenteringthe
fridge,orifitisbeingputbackafterhavingaportionconsumed.Ifitthesystem’sfirsttimeseeinganitemwiththisUPC(ifthereisnoentryintheProductCachewiththisUPC),itisnecessarytopullinformationfromtheProductCatalogue.IftheproductisnotavailablethroughtheProductCatalogue,
anentrywithdescription“unknown”isaddedtotheProductCache.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
22
NotethateventswhichtriggerHTMLgenerationarenotincludedintheaboveFigure7,asitonlypertainstoitemtracking.
TheprocessofremovingitemsfromtheInFridgeSetismuchsimplerthanaddingthem.First,theitemmusthaveitsexit_datesettothecurrenttime.Theitemisthenremovedfromthe
List<ItemType>withintheInFridgeSetandaddedtotheList<ItemType>withintheHistorySet.
SerializationItisfrequentlynecessarytotransmitcompleteobjects–thisistheroleofserialization.Arigorousmappingismadebetweenobjectfieldsandabinaryformat(inourcase,XMLtext).Inthisway,objects
utilizedbythesystemcanbewrittentofilesortransmittedeasilyandcompletely.
TheBackendServerutilizestheJava‐XMLBinding(JAXB)inordertoserializeobjects.AviablealternativetoXML‐basedserializationisJavaScriptObjectNotation(JSON).Bothformatsarepopular,withXMLbeingmoreestablishedbutJSONreceivingincreasingamountofattention.Ultimately,eitherwould
haveserverourpurposes.JAXBwaschosenduetoitsmatureandwellestablishedcodebaseandtheabilityofExtensibleStylesheetLanguageTransformation(XSLT)totransformXMLintoHTML(GlassFish,2011).ItisalsoworthmentioningthatDatabaseObjectBindingisalsoapotentialmeansofpersistent
storage,thoughitisingeneralmorecumbersome.
TheentireserializationmechanismutilizedbytheSmartFridgeSystemispresentedinFigure8.
Figure8:JavaXMLBinding(JAXB)Workflow
AnXMLschemaiswrittentospecifythefieldsofobjects.AbindingcompilerthentransformsthisXML
schemaintojavasourcefilesthatdefinethesameobjectsasdescribedwithintheschema(s).TheseobjectscanthenbeusedinanyJavacode,identicallytoanyotherobjects.ObjectsgeneratedbythismechanismcanthenbetransformedintoXMLthroughaprocesscalled“marshaling.”Forexample,the
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
23
XML‐representationofanobjectcanbewrittentoafilethroughacalltothemarshal()function.Thesesavedobjectscanthenberetrievedbyarunningprogramthroughtheunmarshal()function,whichreceivesXMLdataasanargument.
AlloftheclassesdescribedaboveweregeneratedbyJAXBinthemannerdescribedabove,including:ItemType,ProductItemType,LeftoverItemType,ProductType,InFridgeSet,HistorySet,FridgeSystem.
TheSmartFridgeSystemreliesonXMLserializationforseveralcriticalpurposes:
• Crashrecovery• Datatransmission
• HTMLgeneration• Testing
Firstly,retrievingthestateofthesystemthroughreadingfilesprovidesamechanismforcrashrecovery.Onstartup,theSmartFridgeSystemloadsobjectsfromXMLfiles.Duringexecution,thesefilesare
periodicallywrittento,astriggeredbyaconfigurabletimer.Inthisway,minimaldataislostshouldtheserverbeterminatedforwhateverreason,andoperationisautomaticallyresumedwhenevertheserverisrelaunched.
Secondly,whenamobileclientrequestsinformation(say,thesetofallitemsinsidethefridge),the
requestedobjectsonlyneedtobemarshaledontotheOutputStreamoftheresponseobject.Further,theclientknowstheexactformoftheresponse‐theXMLschemasthatwereinitiallyusedtogeneratetheJavasourcefilesofthetransmittedobjectsspecifytheformat.
Next,XSLThastheabilitytotransformthedatapresentinanXMLdocumentintoHTML.XSLTis
essentiallyaprogramminglanguagethatisexecutedusingXMLdocumentsasinput,performingsomesortoftransformation.ForthepurposesoftheSmartFridgeSystem,wetransformtheXMLthatrepresentstheInFridgeSet(asdefinedabove)intoHTML.ThisHTMListhenmadeavailablethroughthe
webserver.
Finally,objectserializationallowsformuchsimplerandmorethoroughtesting.BecausethesystemstateisloadedfromanXMLfile,itispossibletomanuallyeditthisfileinordertocreateanydesirable
teststate.Further,aclientwascreatedinordertoaddItemTypeandProductTypeobjectstotheserver.Inthisway,theclientisabletoverifyallthefunctionalityoftheserver,includingItem/Productmanagementandnetworkfunctionality.
ForanexactdescriptionoftheXMLrepresentationofobjects,seetheXMLschemaswithinthe“FridgeSystem/schema/”folder.
Client’sResponsibilitiesNotethattheclientiscompletelyresponsibleforhowdataispresentedtotheuser,andthattheBackendServeronlytransmitsrawdata.IfweagainconsidertwocartonsofmilkwiththesameUPC
code,theusershouldlikelybeinformedthattheyhavetwocartonsofmilk.Thatis,theseitemsshould
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
24
notbetodistinctentriesthelistofitemsthatarewithintheuser’sfridge,butratherasingleentrythatindicatestwoinstancesofthesameproduct.Furtherstill,theclientmightstillwishtoindicatethatthe
milksmighthavetodifferentexpirydates.ClearlythepresentationdecisionsoftheclientneednotdirectlyreflecttheobjectmodelthattheBackendServerrelieson.
NotealsothattheclientneedstobindthedatabetweenaProductItemTypeandaProductTypeasrequired.Forexample,iftheclienthasaparticularProductItemTypethatisinthefridgeandwouldlike
toshowitsimage,theclientmustfindtheassociatedProductType(thatis,theProductTypewiththesameUPCastheProductItemType),andlookinsidethe“info”hashtableforthevaluewithkey“imageThumbURL.”TheFridgeSystem.xmlfilecanbeusedasareferencewhendeterminingwhich
key‐valuepairsareavailableinthe“info”and“nutrition”hashtables,butnotethisinformationisn’t
necessarilyavailable(sinceitispulledfromSimpleUPC).
6 PRODUCTCATALOG
TheProductCatalogueisresponsibleforprovidingbrandnames,descriptions,pictures,andnutritionalinformation.TheBackendServerqueriestheProductCataloguebyUPC,andstorestheresulting
informationwithintheProductCache(seeObjectHierarchy).OurcurrentimplementationoftheSmartFridgeSystemutilizesSimpleUPCasaProductCatalogueservice(SimpleUPC,2010).
SimpleUPCwaschosenastheProductCatalogueforourcurrentimplementation.Theygrantedfreeaccessforthefullfour‐monthdevelopmentperiod.TheserviceprovidesanAPIforaccessingthe
followinginformationbyUPC:
• Manufacturer• Brand• Description
• SizeandWeight• Image• Ingredients
• NutritionalInformation
Further,itispossibletosearchtheSimpleUPCdatabasebykeyword.Whilethisfeaturemightbeusedtosuggestalternativestoproducts,thematchinghasabsolutelynocontextandthereforeisnotveryusefulinthisusage.Forexample,searching“yogurt”mightreturnproductssuchasyogurt‐coveredpretzels
andyogurtcoveredpretzels.Clearlythesearenotviablealternativesforaparticularbrandofyogurt.Whenimplementingthesystem,weusedthissearchfunctionalityinordertosimulateahistoryofproducts,allofwhichhavenutritionalinformation.Wewerethenabletorunouralgorithmstoensure
thattheyproducedusefulresults.
ThesystemisqueriedviaeitherXMLorJSON,andresponsesarereceivedinthesameformat.TheSmartFridgeSystemqueriesSimpleUPCthroughXML,forconsistencywithotherimplementationdecisions(namely,serialization).AnexamplerequesttoSimpleUPCispresentedinListing1,andanexample
responseispresentedinListing2.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
25
<request> <auth>API Key</auth> <method>FetchProductByUPC</method> <params> <upc>073731001059</upc> <params> </request>
Listing1:SimpleUPCRequestExample
<?xml version="1.0" encoding="UTF-8"?> <response> <success>true</success> <usedExternal>false</usedExternal> <result> <brand>Mission</brand> <manufacturer><![CDATA[Mission Foods]]></manufacturer> <container>Box</container> <description><![CDATA[18 Ct Taco Shells]]></description> <size><![CDATA[6.75]]></size> <category><![CDATA[Mexican Dinner Mixes, Tortillas, Corn Shells]]></category> <units>Oz</units> <upc>073731001059</upc> <ProductHasImage>true</ProductHasImage> <ProductHasNutritionFacts>true</ProductHasNutritionFacts> </result > </response >
Listing2:SimpleUPCResponseExample
ItisworthnotingthattheSmartFridgeSystemwasdesignednottorelyonaparticularProduct
Catalogue.AninterfaceexistsfromwhichaProductTypeobjectsisreceived.Inthisway,codewrittentointerfacewithanyotherservicethatprovidesthenecessaryinformationcanbeutilizedaslongasitadherestothisinterface.Further,sincethesystemonlyeverpullsinformationfromtheProductCache,
thereisalayerofabstractionbetweeninformationusedbythesystemandwheretheinformationiscomingfrom.ThisdesigndecisionissignificantsincethenutritionalfeaturesprovidedbytheSmartFridgeSystemrelyheavilyontheProductCatalogue.Shouldamorecomprehensiveorfeature‐rich
cataloguebeavailable,theSmartFridgeSystemneedsonlytobeadjustedslightlyinordertoleveragethesuperiorcatalogue.
7 COMMUNICATION
SeveralcomponentsoftheSmartFridgeSystemexchangeinformation.Eachofthesecommunication
exchangesispresentedinFigure9andexpandedinthefollowingsubsections.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
26
Figure9:CommunicationOverview
AsobserverinFigure9,allinter‐componentcommunicationgoesthroughtheBackendServer.TheservicesprovidedbytheBackendServerarethereforefirstdiscussed,andthenhowthevariouscomponentsutilizetheseservicesisexpandeduponinsubsequentsections.
ItisimportanttonotethattheHypertextTransferProtocol(HTTP)playstwodistinctroleswithinthe
SmartFridgeSystem:astandardrolewhenwebclientssendrequeststothewebservertofetchHTMLfiles,andacustompurposewhentheIn‐FridgeHardwareormobileappsendandrequestinformationtoandfromtheserver.OurcustomusageoftheHTTPprotocolisspecifiedinthefollowingsubsections.
ForthedefinitionofHTTP,see(Fielding,Gettys,&Mogul,1999).
BackendServicesAllcommunicationtotheBackendServerisfacilitatedbyHTTP.ClientssendrequeststodifferentUniversalResourceIdentifiers(URIs)inordertoperformdifferenttasks.ForHTTP,URIshavethefollowingformat:
http://<server_ip>:<server_port>/<path>?<query>
HTTPwaschosenasamessageformatformanyreasons.Firstly,testingisfacilitatedtheabilitytouseanybrowserasaclient.Further,HTTPisaveryestablishedprotocolforwhichtherearelibrariesonessentiallyallmodernplatforms.Anarbitrarymessageformatcouldhaveeasilybeendecidedon,but
theubiquityofHTTPlibraries(andasaprotocolingeneral)leftlittlereasonforacustom‐designedprotocol.
ForthepurposesoftheBackendServer,the<path>portionoftheURIcanhaveoneofthevalues
describedinTable3(notethatthesevaluesarecasesensitive).
Table3:PathsMadeAvailablebyServer
Path DescriptionSHOW RetrievesinformationfromtheserverinXMLformatasdefinedin
FridgeServer/schema.ThequeryportionoftheURI(discussedbelow)specifieswhatinformationisreturned,butmostcommonlyitwillbethecurrent
In‐FridgeHardware
HTTP:/ADD_ITEMSBackendServer
MobileClient(iPhoneApp)
HTTP:
/SHOW/ADD_OBJECT
WebServer
WebClient(Browser)
PHP
HTTP(standardfetch)
HTTP:
/GENERATE_HTML/PLOT_DATA
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
27
contentsofthefridge.Nocontentisnecessarywithintherequestbody.
SAVE Allowsclientstocausetheservertosaveitscurrentstate.Afilenamecanoptionallybeincludedwithintherequestbody,otherwiseadefaultfilenameisused.
ADD_OBJECT Allowsclientstoaddfully‐formedXMLobjectstotheserver,andisthereforeusedprimarilyfortesting.CurrentlysupportedobjectsincludeItemTypesandProductTypes.TheobjecttobeaddedmustappearwithintheHTTPrequestbodyintheXMLformatspecifiedinFridgeServer/schema.ThequeryportionoftheURIallowsuserstospecifywhichsetobjectswillbeaddedto,asdiscussedbelow.
ADD_ITEMS The“real”pathusedbytheIn‐FridgeHardwareunit.TheHTTPmessagebodyincludesXMLthatdefinesthesetofallitemscurrentlyinthefridge.Theserverthencomparesthisincomingsettothe“current”setinordertodeterminewhichitemshavebeenremovedandadded.
GENERATE_HTML UsedtogeneratetheHTMLrepresentationofinformationthatismadeaccessiblethroughthewebserver.ThisHTMLisgeneratedthroughXSLTransformations.TheexactHTMLthatcanbegeneratedispresentedinTable4.
PLOT_DATA Providesasetofpointswithintheresponsebody,havingtheformat:“[[0,0],[1,1],…]”.Thedataavailablethroughthispathisusedbythewebserverandmobileapptopresentgraphicalinformation.TheexactinformationthatisavailableispresentedinTable4.
IfarequestwithapathotherthanthosespecifiedinTable3isreceived,theserversendsaHTTPResponseHeaderwithcode404(NotFound).IfanentrydoesnothavearesponsespecifiedinTable3,
theserverwillrespondwithonlyaResponseHeaderwithcode200(indicateeverythingisOK).
The<query>portionoftheURIcontainsasetofkey‐valuepartsseparatedby‘&’symbols.For
example,avalidrequesttotheBackendServerwoulduseaURIsuchas:
http://127.1.1.8:8278/SHOW?target=SYSTEM
TheresponsebodywillthenhavealltheinformationaboutthecurrentFridge‐SysteminXMLformat(includingInFridgeSet,HistorySetandProductCache).However,clientswilltypicallynotneedadescriptionoftheentirefridgesystem,butratherjusttheInFridgeSet.Completedescriptionsofthekey‐
valuepairsthatarerequireorpossibleforeachURIpathispresentedinTable4.
Table4:PathsandtheirQueries
Path Query Description
SHOW
target={SYSTEM|INFRIDGE|HISTORY}
Optional.Specifieswhichsetisreturnedinthebodyoftheresponse.
SAVE None
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
28
ADD_OBJECT target={INFRIDGE|HISTORY}casesensitive
MandatoryifItemTypeisbeingadded,unnecessaryforProductTypes.Specifieswhichsettheobjecttobeaddedshouldgointo.
ADD_ITEMS None GENERATE_HTML target={INFRIDGE|
HISTORY|TIME_SENSITIVE}
Mandatory.SpecifieswhatHTMLwillbegenerated.IfINFRIDGEorHISTORYissupplied,theHTMLrepresentationofthatsetisgeneratedintothestandardHTML(web/html)folder.IfthevalueisettoTIME_SENSITIVE,theHTMLthatrepresentstheexpiringsoon,alreadyexpiredandrecentlyremoveditemsareallgenerated.
PLOT_DATA target={EXPIRY_HISTORY|<upc_value>}
Mandatory.SupplyingtheEXPIRY_HISTORYtargetreturnsx‐valuesrepresentingmonthsandy‐valuesrepresentingthenumberofitemswhichexpiredbeforebeingremovedforthatmonth.IfthetargetsuppliedisaUPCnumber,thex‐valuescorrespondtomonthsandthey‐valuesindicatehowmanytimestheproductwaspurchasedinthatmonth.
Important:AllrequestsmadetotheBackendServermustusetheGETmethodofHTTP.
Shouldamalformedquerybereceivedbytheserver,aresponsecodeof400(BadRequest)willbesentandtherequestwillbeignored.
InFridgeHardwaretoBackendServerCommunicationAsmentionedbrieflyabove,theIn‐FridgeHardwareunitreliesonHTTPtocommunicatetotheBackendServer.Thein‐FridgehardwaresendstwodifferentHTTPmessagestypestothebackendserver.Thefirst
messageissentevery60secanditcontainsthetemperatureandhumidityreadingsfromthetemperature/humiditysensorinaXMLformat.
Toindicatethecurrenttemperatureandhumidityoftheinsideofthefridge,theIn‐FridgeHardwareunitwouldsendarequesttoaURIoftheform:
http://<server_ip>:<port>/TEMP_HUM
TheHTTPrequestbodythencontainsXMLthatdefinesthecurrenttemperatureandhumidityinsidethefridge.AnexampleofthisXMLisdefinedinListing3.
<temperature>10.1254</temperature>
<humidity>78.9034</humidity>
Listing3:ExampleofXMLSentfromIn‐FridgeHardwaretoBackendServer
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
29
InthesecondmessagetypeTheIn‐FridgeHardwareunitsendsanXMLrepresentationofalloftheitemscurrentlyinthefridge.ItisthentheBackendServer’sresponsibilitytodeterminewhichitemswereremovedoraddedtothefridge.
Toindicatetheitemscurrentlyinthefridge,theIn‐FridgeHardwareunitwouldsendarequesttoaURI
oftheform:
http://<server_ip>:<port>/ADD_ITEMS
TheHTTPrequestbodythencontainsXMLthatdefinesthesetofitemscurrentlyinsideofthefridge.AnexampleofthisXMLisdefinedinListing4.
<itemset>
<item>
<id>0000110101</id>
<upc>20202020202</upc> <expiry_date>20-08-2011<expiry_date>
</item>
<item> <id>00222222</id>
<upc>333030303</upc>
<expiry_date>20-08-2011<expiry_date>
</item> </itemset>
Listing4:ExampleofXMLSentfromIn‐FridgeHardwaretoBackendServer
TheIn‐FridgeHardwaredoesnotexpectanyresponsefromtheserverbeyondthestandardHTTP
ResponseHeaderwithcode200(indicatingeverythingisok).ShouldtheIn‐FridgehardwaresendmalformedXML,theserverwillresponsewitha400errorcode(BadRequest).
MobileApptoBackendServerCommunicationInordertopresenttheitemscurrentlyinthefridge,theiPhoneapplicationmustreceivethisinformationfromtheBackendServer.ThisinformationisretrievedbyanHTTPrequestwiththe
followingURI:
http://<server_ip>:<port>/SHOW?target=INFRIDGE
TheHTTPResponseBodythencontainstheXMLdefinitionoftheInFridgeItemSet(asdefinedinthe
ObjectHierarchySectionabove).ForafulldefinitionoftheXMLformatofobjects,seetheschemaswithinthe“FridgeSystem/schema/”folder.AfterreceivingtheXMLrepresentationofthecurrent
fridgecontents,theapplicationparsesthisdataandpresentsittotheuserinanaccessibleformat.
TheiPhoneapplicationalsosendsinformationtotheBackendServerwhenauserhasmanuallytaggedanitemwithaUPCoraleftovercontainer.Ineithercase,theiPhoneapplicationsendstheinformationwithintherequestbodyofanHTTPmessagetoaURIsuchas:
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
30
http://<server_ip>:<port>/ADD_OBJECT
Inthecaseofamanually‐taggeditemwithaUPC,therequestbodycontainsthevalueoftheUPCcode.
Ifaleftoveritemwasadded,thelabelsuppliedbytheuserissentintherequestbody.TheservertheninterpretsthenextitementeringthefridgewithoutaUPCcodeashavingthevalue(UPCorname)asreceivedfromtheiPhoneapplication.IfthemessagebodydoesnotspecifyalabeloraUPC,therequest
isignoredbytheserver.
WebServertoBackendServerCommunicationAstandardwebserver(suchasApache)isutilizedinordertoprovidetheweb‐accessiblecontentoftheSmartFridgeSystem.TheservermusthavePHPinstalledinorderforthewebcontenttobepresented.Further,theWebServerandtheBackedServermustresideonthesamephysicalmachine:theBackend
ServerproducesHTMLfilesthatmustresidewithintheWebServer’srootwebdirectory(asspecifiedbytheDocumentRootpropertyinApache).Inthisway,theWebServermakesthefilesgeneratedbythe
BackendServerwebaccessible.
HTMLAssemblyThePHPrunningthroughthewebservercollectsandpresentstheHTMLgeneratedbytheBackendServer.TheBackendservergeneratedper‐UPCHTMLfragmentsthatareamalgamatedintoasinglewebpagebyaPHPscript.Forexample,thefile“web/html/inFridge/011161133971.html”containsontheHTMLtorepresentallitemswiththeUPCof011161133971.Allofthefileswithinthe“web/html/inFridge/”directoryareassembledintoasingleHTMLfile,whichthenrepresentsallUPCscurrentlyinthefridge.Inthisway,wheneveritemsareaddedtoorremovedfromthefridge,only
HTMLfragmentsneedtobegenerated–avoidingredundantgenerationoftheHTMLrepresentationsofallthefilesthatdidnotchange.ThoughthismechanismaddscomplexitytothePHPrunningonthewebserver,itsignificantlyreducestheamountofXSLTprocessingrequiredontheBackendServer.
TimeDependentContentItissometimesnecessarytoregeneratecertainHTMLfiles.Forexample,thetablethatpresentswhich
itemsareexpirysoonorthepagepresentingitemsthatwereremovedrecentlymustberegeneratedinorderforthetransientnotionof“soon”toremainvalid.InordertotriggerthisHTMLgeneration,thewebserverusesaPHPscriptthatsendsanHTTPrequesttoaURIsuchas:
http://<server_ip>:<port>/GENERATE_HTML?target=TIME_SENSITIVE
Thisrequestissenteverytimeauseropensanyofthefollowingwebpages:
• InFridge.php• Expiry.php• RecentlyRemoved.php
Itisthereforeensuredthatalltime‐sensitivedatapresentonthewebsiteisuptodate.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
31
PlottingThewebserveralsopresentsplotstotheuser.Theplotmayshowhowmanyitemswereexpiredbeforebeingremovedfromthefridge(indicatingpotentialwaste)orhowoftenaparticularproductwaspurchasedwithinthepastyear.ThoughtheplotisultimatelypresentedusingJavaScriptandCSS
libraries,thedatapresentedontheplotmustbefetchedfromtheBackendServer.
DataisreceivedwithinthemessagebodyofaresponsetoaURIsuchas:
http://<server_ip>:<port>/PLOT_DATA?target=EXPIRY_HISTORY
Thex‐valuesofthedatarepresentmonthsandthey‐valuerepresentsthenumberofitemsthatwere
expiredwhentheywereremovedfromthefridgeofthatmonth.ThesepointsarethenpassedintoaPHPscriptthatplotsthedataonagraphusingFlotrlibraries(Solutaire,2011).
8 SOFTWARESYSTEM
AutoGeneratedGroceryListTheauto‐generatedgrocerylistfeatureusesanintelligentalgorithmthatmonitorsnumerous
parametersinordertoautomaticallyselectthemostappropriateitemstobeplacedonagrocerylistfortheuser.Recordingofusagepatternsgivesthealgorithmthenecessaryinformationtomakeinformed
decisionsaboutwhichitemsshouldbeaddedtothegrocerylist.Thedynamicnatureofauser’sgroceryisaproblemwehaveconsideredinthedesignofthisalgorithm.Forexample,ausermaybuyanitemoneortwoweeksinarowthenloseinterestnolongerhavingadesireforthatitem.Toachieveaccurate
resultswemusthavesomemeasureofdesirabilityforeachitem.Thecentralassumptionthathasbeenmadeisthatanitemwhichhasnotbeenpurchasedinalongtimeisassociatedwithlowdesirabilityandshouldnotbeplacedonthegrocerylist.Thealgorithmdesignincorporatesatypeoflearningthatyields
moreaccurateresultsthelongeryouusethesmartfridgesystem.Thealgorithmcomponentswillnowbediscussedindetail.
AlgorithmInterfaceThealgorithmrequiresanumberofinputparametersinordertogainanunderstandingoftheusagepatternsinadditiontothecurrentstateoftheuser’sfridge.Aseriesofitemlistsareusedforthispurpose.TheSmartFridgeSystemkeepsarecordofwhatitemsarecurrentlyinsidethefridgeatany
giventime.Thiscurrentitemlistreflectsthepresenttimestateofthefridgecontents.Inadditiontothecurrentstateofthefridgeweneedinformationaboutthehistoryofitemspassinginandoutofthefridge.Thisinformationisgainedthroughthehistoryitemlistwhichnotonlykeepstrackofwhatitems
passedintoandoutofthefridgebutalsothetimesinwhichtheseeventsoccurred.Thethirdandlastparameternecessaryismasteritemlist.ThemasteritemlistcontainsasingleinstanceofeveryitemwhichhasevenbeenrecognizedbytheSmartFridgeSystem.Thepurposeofthislististoserveasa
referenceofallknownitemsirrespectiveofbeinginthefridgecurrentlyorinthepast.Themasteritemlistisalsousedtokeeptrackofuserspecifiedparametersonanitemperitembasis.Tosummarize
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
32
threeinputparametersareused,thecurrentitemlist,thehistoryitemlistandthemasteritemlist.Uponcompletionofthealgorithmanitemlistisproducedcontainingthegrocerylistitems.
Component1Certainitemscanbespecifiedbytheusertoalwaysbeontheirgrocerylist.Irrespectiveofallotherfactorsanitemflaggedas“alwayson”willalwaysappearonthegrocerylistifthatitemisnotcurrently
insidethefridge.Itemslabelledas“alwayson”arespecifiedinthemasteritemlistbytheuser.Thealgorithmsearchesthemasterlistforthe“alwayson”flagset,thencomparesthisitemwiththecurrentitemlist.Iftheitemisnotfoundinthecurrentitemlistitwillimmediatelybeaddedtothegrocerylist.
Component2Thiscomponentattemptstopredicthowdesirableaparticularitemisbaseduponthetimesinceitwas
lastpurchased.Thegeneralassumptionisitemswhichhavenotbeenpurchasedrecentlyarenotlikelytobeofinteresttotheuseranylongerandshouldnotbeplacedonthegrocerylist.Thecomponentfunctionsinthefollowingway.First,alistisgeneratedthatrepresentsitemswhichhavehighbuying
potential.Thislistisobtainedbysubtractingtheitemsappearinginthecurrentitemlistformthehistoryitemlist.Forthepurposedofthiscomponentweassumetheuserwouldn’twantanyitemsthatarestillinsidetheirfridge.Thegeneratedlististhensearched.Eachiteminthelisthasanattributecontaining
thepermanentexittimefromthefridge(i.e.timeofbeingentirelyconsumed).Theexittimestampiscomparedagainstapre‐determinedthresholdvalue.Ifthedifferencebetweenthepresenttimeandexittimeisbelowapredeterminedthresholdthentheitemisaddedtothegrocerylist.Ifthedifferenceis
greaterthanthethresholdthenweassumetheuserisnolongerinterestedinthisitemanditisnotadded.Achallengingfactorwastodetermineasuitablethresholdperiod.Toolongofaperiodwouldmeanthattoomanyitemsareaddedtothelist,manyofwhichmaynotbeofinteresttotheuserany
longer.Ontheotherhandtooshortofperiodwouldresultinitemsofinterestnotbeingadded.Specialconsiderationwasgiventofindthemostappropriatecompromise.Thethresholdwasdecidedtobe14day.Thisdecisionwasbasedonanaverageshoppingperiodofonceaweek.Iftheuserdidnotpurchase
theitemwithintwogrocerytripsweassumedtheywerenolongerinterestedinpurchasingthisitem.
Component3Oneofthemorechallenginginsightstohaveregardingthecontentsofyourfridgeistheapproachingexpirationdates.TheSmartFridgeSystemisabletomonitoreachitemsexpirationdateandusethisinformationtoinitiateapre‐emptivepurchase.Basedonouroriginalassumptionwecanassumethat
itemswhicharecurrentlyinthefridgeareofhighinteresttotheuser.Thealgorithmsearchesthroughthecurrentitemlistcomparingeachexpirationdatetothepresentdate.Ifthedifferencebetweenthecurrentdateandexpirationdateisbelowapre‐determinedthresholdtheitemisaddedtothegrocery
list.Againthechallengeoffindasuitablethresholdvalueisseen.Thethresholdforthiscomponentwassetat7days.Thedecisionwasbaseduponanaveragegroceryshoppingscheduleofonceperweek.Witha7daythresholdtheitemisensuredtobepurchasedonthelastgroceryshoppriortoexpiration.
Ideallywewouldliketheitemtobeaddedonlyonthelastgroceryshopbeforeexpiring.Ifthethresholdweresettoohighthenthepre‐emptivepurchasewouldoccurtoosoon.Theresultcouldbewastingof
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
33
foodastheexpirationdateofthepre‐emptivelyboughtitemwouldbeearlierthanifwehadwaiteduntilthelastmoment.
Component4Thefourthcomponentisusedtopredictwhenanitemisnearingtheendofitscontents.Thisportionofthealgorithmisadaptiveandlearns,theSmartFridgeSystemyieldseverimprovingresultsastime
progresses.TheSmartFridgeSystemassignstoeachitemanentrytimeandanexittime.Theentrytimeisthetimeforwhichtheitemwasfirstplacedinthefridgewhiletheexittimeiswhentheitemwaspermanentlyremovedfromthefridge.Bytakingthedifferencebetweenexitandentrytimeswecan
gaininsighttotheconsumptiontimeofthisitem.Astheusergoesthroughrepeatedcyclesofbuyingaparticularitemandconsumingit,wecanaverageoveralltheseindividualconsumptiontimes.Asthe
numberofcyclesincrease,theaverageconsumptiontimebecomesabetterestimateoftheactuallyconsumptiontime.Inadditiontotheaverageconsumptiontime,acurrentconsumptiontimemustbecalculated.Foreveryiteminthefridge,acurrentconsumptiontimeiscalculatedbytakingthe
differencebetweenpresenttimeandentrytime.Thisnumberrepresentstheamountoftimetheuserhasbeenconsumingtheitem.Tocompletethedecisionofwhetherornottoaddtheitemagainathresholdfactorisneeded.Thethresholdvalueforthiscomponentisapercentageoftotal
consumption.Forexample,wemighthavecalculatedthecurrentconsumptiontimeis90%oftheaveragetotalconsumptiontimeforthisitem.Wewouldthenchoosetoaddtheitembecausethereisagoodchancethatitisnearlyentirelyconsumed.Aswithpriorthresholdvaluesacompromiseisseen.If
thethresholdissettoolowthenitemswouldbeaddedtothegrocerylisttooearlyandmightresultinwastingoffood.Similartothepriorsituationwithexpirationdates.Theusermaynotbeabletoconsumetherestofthepreviousitemandthenewitembeforethenewitemsexpirationdate.Onthe
otherhandifthethresholdissettoohighthentheitemmaybeconsumedbeforetheuserhasareasonablechancetopurchasetheitemduringtheirnexttriptothegrocerystore.Thedecisionwasmadetosetthisthresholdto90%.
Component5Thefinalcomponentofthealgorithmallowsanotheruserspecifiedvaluetocontrolwhatisaddedtothegrocerylist.Someusersmaywanttheoptiontospecifyaquantityofanitemtheywouldalwayslike
tohaveinthefridge.Forexample,theusermaysayIwouldliketohave3bottlesofapplejuiceinthefridgeatalltimes.Thealgorithmwillsearchthecurrentitemlistandmakesurethisrequirementissatisfied.Ifthequantityofanitemislessthantheuserspecifiedquantitythenitgetsaddedtothe
grocerylist.Thedifferencebetweentheuserspecifiedquantityandthecurrentquantityisthevalueaddedtothegrocerylist.Iftheitemcannotbefoundinthecurrentitemlistitthenitgetsaddedtothegrocerylistwiththeuserspecifiedquantity.
SummaryThesmartfridgeauto‐generatedgrocerylistfeatureusesanintelligentmultivariablealgorithm
illustratedbelow.Anumberofimportantfactorsareconsideredusingrecordedusagepatternsinadditiontouserspecifiedinformation.Wehavefocusedourattentiontofivemaincomponentswebelievetoyieldthemostaccurategrocerylistpossible.Thefirstcomponentgivestheusercontrolto
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
34
makesureaparticularitemisneverforgottenirrespectiveofanyotherfactors.Thesecondcomponentpredictsthedesirabilityofanitembasedonhistoryusagepatterns.Thethirdcomponentpre‐emptively
identifiesitemswhichhaveexpirationdatesinthenearfuture.Thefourthcomponentidentifiesitemswhichhaveahighprobabilityofbeingconsumedentirelyinthenearfuture.Thefifthandfinalcomponentallowstheusertoensureaspecifiedquantityofanitemisalwaysavailableinthefridge.The
culminationofallfivecomponentsgivesacomprehensiveimageofwhatitemstheuserismostlikelytohaveontheirgrocerylistiftheyweretomanuallywriteitthemselves.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
35
Figure10:Auto‐generatedGroceryListAlgorithm
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
36
NutritionMetricSystemIdentifyingthenutritionalvalueofafooditemisadifficulttaskformostofthepopulation.TheSmartFridgeSystemincorporatesanutritionalmetricssystemusedtopresentnutritionalinformationina
concise,easytounderstandformat.Thenutritionalvalueofanitemischallengingtopresentbecausenutritionalvalueisrepresentedbynumerousparameters.Forexample,theamountoffat,cholesterol,carbohydrates,protein,vitaminsetc.allmustbeconsideredtogainperspectiveabouthownutritiousan
itemis.TheSmartFridgeSystemusesamathematicalmodeltoreducethismultivariableproblemtoasinglenumberthatrepresentsthenutritionalvalue.Themodelisdescribedbelow.
NutritionalProfilingModelThemodelweusedintheSmartFridgeSystemwasbaseduponaconceptcallednutritionalprofiling.Theideaistoconsiderthemaincomponentsofafood,namelyfats,protein,carbohydratesetc.and
quantifytheentirenutritionalvaluewithasinglenumber.Wechosetouseamodeldiscussedinapapercalled“ModelingExpertOpinionsonfoodHealthiness:ANutritionalMetric.”InthispapertheysurveyedtheleadingU.Snutritionexpertsaboutthehealthinessofsamplefoodandbeverageproducts.Each
expertwasgivenanumberofsamplefoodstogetherwithcorrespondingnutritionalinformation.Aftergiventimetoanalyzethesample,theexpertwasrequestedtoprovideascorebetween‐5to5.‐5representedextremelyunhealthywhile5representedextremelyhealth.Afteralltheexpertshadmade
judgementsonalltheitemsalinearregressionwasuseddevelopanequationfortheresults.Theequationconsidersthe12parametersprovidedbyastandardnutritionalfactslabel.Usingthismodelwewereabletoquantifythenutritionalvalueofasingleitem.
SystemDescriptionThenutritionmetricsystemreliesontwoclassesforitsfunctionality.TheNutritionItemclassisusedtorepresentthenutritionaldataofanitemwhiletheNutritionMetricsclassoperatesontheNutrition
Itemobject.Thetwoclassesaredescribedinfurtherdetailbelow.
NutritionItemClassThenutritionitemisaclassusedtorepresentthenutritionallyrelevantinformationaboutaparticularitem.Attributesincludeallinformationpresentonastandardnutritionalfactslabelinunitsofpercentdailyvalue.Thenutritionprofilingmodelisimplementedinthisclassasamethod.Afewothermethods
werenecessarytoconvertpercentdailyvaluestounitsofgrams.Theunitconversionwasnecessaryfortheuseofournutritionalprofilingmodel.
NutritionMetricsClassThenutritionmetricsclassiscomposedofanumberoffunctionsthatusethenutritionitemclasstoprovidethecorefunctionalityofthesystem.
ConstructNutritionItemTheitemlistsusedtorecordthecurrentandhistoryoftheSmartFridgeSystemdiscussedintheprevioussectiondonostorenutritionalinformationaboutthoseitems.Thisdecisionwasmadeto
conservespacebypreventingtheduplicatestorageofnutritionaldataabouteachitem.TheProductCachelistisusedtostoreasingleinstanceofanitemtogetherwithitsnutritionalinformation
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
37
storedinsideahashtable.Nutritionalinformationisrecalledfromthishashtableusingkeyvaluepairs.Thekeyisthenameofthenutrientwhilethevalueisthepercentdailyvalueofthatnutrient.The
getNurtritionItemfunctionprovidestheconstructionofanutritionitemobjectgivenanitemfromthecurrentitemorhistoryitemlists.Thefunctionidentifiestheitemintheproductcacheandgetsnutrientinformationviathehashtable.Thenutrientitemisthenreturnfromthefunction.
TopFiveListsThetopfivelistsfunctionisusedtoidentifythe5mostand5leastnutritiousitemsinalist.Itusesasingleinputparameter,alistofitems.Thiscouldbeusedforthecurrentitemlisttoconstructatopfive
listofitemscurrentlyinsidethefridge.Inaddition,itcouldbeusedonthehistoryitemlisttoseethemosthealthyandleasthealthyitemseverconsumed.Thefunctionoperatesbycalculatinganutritional
valueforeachitemintheinputlistandstoringthevalueinanarray.Thearrayisthensearchedforamaximumandminimumnutritionalvalue,recodingtheindexinthearray.Theitemwiththisindexisthenaddedtothetopfivelistarray.Theitemjustaddedarethenremovedandtheprocessisrepeated
tofindthenextmaximumandminimumvalues.Thisprocessiscarriedonuntilthetop5mostandleastnutritiousitemsareidentifiedandstoredintheoutputarray.
AverageNutritionalValueofListThisfunctionisusedtocalculatetheaveragenutritionalvalueofanentireitemlist.Thefunctiontakesasingleinputparameter,anitemlist,andreturnstheaveragenutritionalvalueofthelist.Thecalculationisaccomplishedinthefollowingway.Foreveryiteminthelistconstructanutritionitemobject.Next,
callthemethodtocalculatethenutritionalvalueforeachonthenewlycreatednutritionitemobjects.Takethesumofallnutritionalvaluesanddividedbythenumberofitemsinthelisttogettheaveragenutritionalvalue.Theaveragevalueisthenreturned.
ItemsinRangeThisfunctionwasnecessaryasahelpertoaccomplishothercalculationsinthesystem.Theinput
parametersarealistofitemsandtwodates.Thetwodatesrepresentastartdateandanenddate.Thefunctionsearchesthroughtheitemlistforitemswhichhaveanexitfridgetimethatoccursinbetweenthestartandenddates.Thefunctionreturnsalistofitemsthathaveexittimesthatfallwithinthe
specifiedtimespan.Sincetheexittimerepresentsthetimeinwhichanitempermanentlyleftthefridgethisfunctioncanbeusedtoidentifywhatitemswereentirelyconsumedwithinatimespan.
NutritionalValueversusTimeThefinalfunctionisusedtogenerateaplotofnutritionvalueofconsumeditemsovertime.Theinputparametersarealistofitems,normallythehistorylist,andanintegerrepresentingthenumberofweeksintothepasttobeanalyzed.Theoutputisgivenanarray,eachindexstorestheaverage
consumeditemnutritionalvalueforasingleweek.Wedecidedtouseasingleweekresolution,becausethisensuresahighprobabilityofatleastafewitemsbeingconsumedwithinthattimeperiod.Iftheresolutionwastobeasingledaythendayswherenofoodwasconsumedwouldhaveanaverage
nutritionalvalueofzero.Thecalculationisaccomplishedinthefollowingway.Thespecifiedtimeperiodisbrokenupintosingleweeksintothepast.Foreachweek,asearchisperformedtoidentifyallitemswhichwereconsumedwithinthatweek.The“itemsinrange”functiondescribedabovewasusedfor
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
38
thistask.Oncealistofitemsconsumedfortheweekwasconstructedwecalculatedtheaveragenutritionalvalueofthatlist.Anormalizationfactorwasusedtoaccountforhowlongittooktoconsume
anitem.Forexample,anunhealthyitemmayhavebeenconsumedonlyveryslowlyandshouldthereforeholdlessweightintheaveragingcalculation.Incontrastanitemconsumedveryquicklyshouldholdahigherweightintheaveragingcalculation.Oncetheaveragenutritionalvalueiscalculated
itgetsaddedtotheoutputarray.Theprocessiscompletedforeveryweekspecifiedbytheinputparameterweekvalue.Uponcompletionthearrayisreturned.Eacharrayindexholdstheaveragenutritionalvalueforallitemsconsumedinthatgivenweek.
Figure11:NutritionalMetricsSystemStructure
9 MOBILEAPPLICATION
OverviewThemobileappwasdesignedusingtheObjectiveCprogramminglanguagetorunexclusivelyonthe
iPhone3GSandtheiPhone4.Thepurposeofthemobileappistoprovideaclear,useful,easytouseuserinterfacefortheusertoaccessinformationfromtheirRFIDSmartFridge.Thefivemaincomponentsofthemobileappare“InmyFridge,”“Expiring,”“GroceryList,”“EatHealthy,”and“Scan
Barcode”asdenotedbythefiveiconsalongthebottomofthescreeninthefigurebelow.Theusercanswitchbetweenthesedisplayseasilybysimplyclickingortappingthescreenoverthedesiredicon.“InmyFridge”displaysaninventoryoftheitemscurrentlyinthefridgeorganizedbycategory,asseenin
thefigurebelow.Whentheuserclickson“Expiring”asimilardisplayshowingalltheitemscurrentlyinthefridgeandtheirexpirydate,organizedfromtheitemswhichwillexpiresoonesttolatest.Clickingthegrocerylistwilldisplayagrocerylistpredictedfortheindividualuserbasedontheirconsumption
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
39
history(seetheAuto‐GeneratedGroceryListSectionunderSoftwareSystem).The“EatHealthy”displaywilldisplaythefridge’scurrenttemperatureandhumidityatthetopofthescreen.Thiswillbe
followedbyalistofthetopfivemostnutritiousandtopfiveleastnutritiousitemsinthefridge(seeTopFiveListssectionunderNutritionMetrics).Fromtheretheusercanscrolldowntoseeagraphoftheaveragehealthinessofalltheitemsconsumedfromtheirfridgeversustime(seeNutritionalValue
versusTimesectionunderNutritionMetrics).Finally,the“ScanBarcode”displaywillshowabuttoncalledScan.OnceScanisclickedtheappwillbringupthecameraandamessagewhichaskstheuserto“adjustthecamerasothebarcodeoftheitemtobeaddedisinviewthentapthescreen”.Oncethe
usertapsandthebarcodeisverifiedamessageto“pleaseadditemwithreusableRFIDtagtofridge”aswellasacancelbuttonwillbedisplayeduntiltheuseraddstheitemtothefridgeofclickscancel.
Figure12:MobileApp‐InMyFridgeDisplayScreen
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
40
MobileAppSystemDesign
TheapplicationisinitializedatthetopbytheAppDelegateclasswhichinstantiatestheobjecttabBarControlleroftypeUITabBarController.ThisobjectcontrolsthetabbarseenatthebottomofthescreeninFigure12(above),aswellaseachview(alsoobjects)associatedwiththetabs.The
AppDelegatethenproceedstoinstantiatefiveviewobjectsfromeachoftheclassesInFridgeView,ExpireView,ShoppingListView,EatHealthyView,andBarCodeController.TheAppDelegatethenassociatestheseviewstabBarController,suchthatthesefiveclassesrespectivelycontroltheviewsof
eachofthefivetabsseenatthebottomofFigure12fromlefttoright.
ThefourviewcontrollerobjectscreatedfromtheclassesInFridgeView,ExpireView,ShoppingListView,andEatHealthyVieweachdisplaydifferentdata(describeintheOverviewsectionabove)drawnfromthebackendserver.Theyeachcreateanobject,connectToServer,usingtheclassConnectToServer
which,whenthatparticularviewisbeingdisplayed,sendsarequest(seeMobileApptoBackendServerCommunicationsection)everythirtysecondscheckingforupdateddata.Thebackendserverthenreturnsanxmlfilecontainingtherequestedlistofitems.Forinstancethe“InMyFridge”viewwould
sendarequesttotheserverandwouldreceiveanxmlfilecontaininginformationoneachoftheitemscurrentlyinthefridge.ThesexmlfilesarethenparsedbyeachviewcontrollerobjectusingtheclassXMLParseandthedataforeachitemisstoredinobjectscreatedfromtheclassFridgeItem.Theview
controllerobjectsthendisplaythisdatainatablecreatedfromtheclassUITableView.Eachofthefourviewcontrollerobjectscustomizestheirtable.
InFridgeViewcustomizesthetableitdisplaystoshoweachitemcurrentlyinthefridgeandhowlongithasbeeninthefridge,aswellasitemsthathavebeenrecentlyremovedfromthefridge(withinthepast
twentyminutes)andhowlongagotheywereremoved.TheseitemsarearrangedaccordingtocategoryasdescribedintheirUPCcode.ExpireViewshowseachiteminthefridgeandtheirexpirydates
arrangedfromtheitemthatwillexpireintheshortestperiodtotheitemthatwillexpireinthelongest
Figure13:MobileAppClassHierarchy
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
41
periodoftime.ShoppingListViewwilldisplayanauto‐generatedgrocerylist(seetheAuto‐GeneratedGroceryListsectionunderSoftwareSystem).FinallyEatHealthyViewwillhaveatablecontainingthetop
fivehealthiestandleasthealthyfoodsaswellasthefridge’scurrenttemperature,humidity,andagraphoftheaveragehealthinessoftheitemsinthefridgevstime.ThisgraphwillbegeneratedwithintheEatHealthyViewclass.
TheBarCodeControllerclasscreatestheviewdescribeintheOverviewsection(above)wheretheuser
pressesthe“scan”buttontoscanabarcodeofanitemwithoutanRFIDtagusingtheiPhone’scamera.TheBarCodeControllerclassthenusestheZBarSDKlibrarytoanalyzetheimageofthebarcodeanddetermineitsassociatedUPCcode,whichisanumericalvalue.ThisUPCisthensenttothebackend
server(seeMobileApptoBackendServersectionunderCommunication).Thebackendserverthenassociatesthisitem’sUPCcodewiththenextreusableRFIDtagthatitdetectsbeingaddedtothefridgeandaddsthisitemtoitsinventory.
10 TESTING
SimulatedFridgeSystemInordertorigorouslytesttheSmartFridgeSystemweneededawaytogenerateayearofusagedata.
Thistaskwasdifficultfornumerousreasons.Theprimarychallengewastodevelopamethodforgeneratinganitemhistorythatwouldaccuratelyrepresentanaverageperson’susagepatternsoftheSmartFridgeSystem.Intheidealsituationwewouldhavemonitoredseveralpeople’sfridgesoverthe
courseofayearandtakennoteofeveryitempassinginandoutofthefridgealongwithexpirationdatesofeachitem.Unfortunatelythislongresearchprocesseswouldnotbepracticalforthefourmonthdurationofourproject.Thealternativewastodevelopamethodtogenerateayearlonghistoryofitems
withoutexplicitlyspecifyingeveryparametermanually.
Generatingayear’sworthofgroceryitemsbyhandwouldbeadauntingandtedioustask.First,youmustselecteverysingleitemthatwouldappearinthehistory.Theitemmustbechosenappropriatelybaseduponwhatelseincurrentlyinthefridge.Forexample,itdoesn’tmakesensetohaveafridgefull
ofjustmeatorcondiments.Ateachinstanceintimethefridgeshouldcontainareasonablyrealisticbalanceofitems.Next,theentryandexittimesoftheitemmustbeexplicitlyspecifiedandcarefully
chosentorepresentareasonableamountoftimespentinsidethefridge.Theexpirationdatemustalsobespecifiedandchosenappropriatelybaseduponwhentheitementeredthefridge.Oneofthemostdifficultchallengesittohaveabalanceofitemstemporallyasitemsareconstantlybeingaddedand
consumed.Thisnecessityofbalanceisessentialtotestingthesmartfridgenutritionalmetricssystem.Withoutabalancedsetofitemstherewouldbenowayofknowinghowwellthenutritionalmetricssystemperformsastheresultswouldappearerratic.Inthecaseofafridgefullofcondimentsthe
nutritionalmetricwouldclassifythefridgeasextremelyunhealthy.Yetthissituationisobviouslynotusefulasmostlypeopledon’thaveafridgefullofcondiments.Clearly,handcraftingthehistoryitemlistwouldbeadifficulttask.Ratherthanexplicitlysettingallthenecessaryparameterswedecidedtomake
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
42
somegeneralizedrequirementsthatmustbesatisfiedandthenusedrandomnumbergenerationtogetreasonablevalues.
Achievingarealisticsetofitemswithoutmanuallyspecifyingeachvaluerequiredasignificantamountof
thoughtanddesign.Weneedawaytosetsomegeneralguidelinesforwhatwasexpectedoutofthehistorylistandthenuserandomnumbergenerationtoexplicitlysetthevalues.Beforewecouldattempttofindasolutionweneededtoidentifywhatmadeahistoryitemlistrealistic.Wefirstbeganto
researchwhatapersonshouldbeconsumingiftheyhadarelativelybalanceddiet.Duringtheresearchphase,onnumerousoccasions,thesourcesspecifiedadietonaweekbyweekbasis.Thedecisionwasthenmadetohandconstructafewsetsofdatathatwouldconstituteaweek’sworthofgroceryitems.
Thiswaywecouldensurethateveryweekcontainedawell‐balancedsetofitems.Thefurtherassumptionwasthenmadethatgrocerieswouldbeboughtonaweeklybasis.Oncetheweeklyitemlistswereconstructedarandomnumbergeneratorwasusedtorandomlyselectaweek’sworthof
groceriestobeaddedtothehistorylist.Oncealltheitemswereputintothehistorylistthenexttaskwastospecifytheentryandexittimesandexpirationdates.
Entrydateswasadrasticallysimplifiedbythedesignsinceweagreedthataweek’sworthofgrocerieswouldbeboughtweekly.Therefore,everyconsecutiveweek’sworthofitemshadanentrydate7days
apartfromthepreviousweek’sworthofitems.Thenextparametertospecifywastheexittimeoftheitem.Thetimeofexitwasmoredifficulttospecifythantheentrytimesincethiswouldbedifferentforeveryitem.Intuitionwouldtellusthatifwewerebuyinggroceriesonaweeklybasisthentheitems
wouldbeconsumedonaweeklybasisalso.ItwouldbereasonabletoassumetheconsumptionoftheitemswouldfollowaGaussiandistribution.Itemswouldbemostlikelytobeconsumedpartwaythroughtheweek,withlessitemsbeingconsumedmuchearlierorlater.Ifwesetthemeanofthe
Gaussiandistributionto5daysaftertheentrytimewewouldthenseesomeitemswouldbeconsumedbeforeandafterthe5thday.Itfollowsthatasmallerpercentageofitemswouldbeconsumedverysoon
aftertheentrytimeandverylongafterthe5thday.ThisagreeswithourchoicetomodelthisbehaviorwithaGaussiandistribution.InordertodetermineareasonablestandarddeviationfortheGaussiandistributionweassumedthatmostoftheitemsshouldbeconsumedbythe11thdayaftertheentry
time.Withastandarddeviationof3wewouldensurethat95%oftheitemsareconsumedwithintheentrytimeand11thdayfromtheentrytime.Againthischoiceagreedwellwiththesituationweweretryingtomodel.Thethirdandfinalparameterweneededtospecifywastheexpirationdate.The
expirationdatewashandledinasimilarmannertotheexitdate.Theexpirationdateassumptionwasalittlemoreunrealisticthantheexittimesincetheexpirationdataisheavilydependentonthetypeofitem.Forexample,frozenfoodswouldlastmuchlongerthanunfrozenvegetables.Forourpurposeswe
arepreparedtoacceptthisparticularshortcomingofthemodel.Thesinglerequirementwemustsatisfyishavingsomeitemsexpirepriortoexitingthefridge.Weneededthisparticularsituationinordertotestalgorithmsusedtodetectexpireditemsinthefridge.Tosatisfythisrequirementwe
neededtodeterminetheappropriatemeanandstandarddeviationoftheGaussiandistribution.ThemeanandstandarddeviationoftheGaussiandistributionfortheexpirationdatesshouldhavesomeoverlapwiththeGaussiandistributionusedfortheexitdates.Wewantedtheupper2.5percentofthe
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
43
exitdatestofallwithinthelowest2.5percentoftheexpirationdates.Toachievethis,themeanwaschosentobe21daysfromentrytimewithastandarddeviationof3.
Throughresearchandunderstandingofthecharacteristicsinabalancedgrocerylistandhuman
behaviourwewereabletoavoidatedioustaskwithamoreelegantsolution.Recognizinghowtomodeltherandomnessofthesituationtogetherwithguidelinesandrestrictionswewereabletoaccuratelysimulateayearlonghistoryofgroceryitemsforanindividual.
Usingthismodelwewillbeabletodevelopanumberofdifferentrandomconsumptionhistorieswhich
wewillthenartificiallyinsertintotheserverfortestingpurposes.Theseartificialhistorieswillbeusedtotestthemobileappandthewebsite.Weplantotesteachofthefeaturesofboththewebsiteandthemobileapp(seeWebPresentationandMobileAppsectionsinourRequirementsDocumentor
MobileAppandWebServertoBackendServerCommunicationssectionsinthisdocument)usingatleasttwentydifferentartificialhistoriesinordertomakesurethatallofthedesiredinformationintheseexamplehistoriesiscommunicatedaccuratelyandeffectivelytotheuser.
AfurtherseriesoftestswillbeconductedusingtheentireRFIDSmartFridgesystemwhereRFIDtagged
itemswillbeplacedinandremovedfromthefridgebyourteammembersoverthecourseofseveraldayswiththeentiresystemupandrunning.Awrittenlogwillbekeptofallitemsaddedandremovedfromthefridge.Attheendofthetestperiodthisdatawillbecomparedwiththedatafoundinthe
serverandthedatadisplayedbythemobileappandthewebsitetoinsurethatthesystemisworkingasspecified.
Inaddition,aseriesofunexpectedbutpossibletestcases(listedbelow),suchasmalformedrequestbeingsentfromthemobileapptothebackendserver,willbetestedinordertoinsurethatthesystem
willnotcrashunderanycircumstances.
Finally,ausabilitytestwillbedevelopedbasedonthefinalRFIDSmartFridgeproductandtestsubjectsunfamiliarwiththeRFIDSmartFridgewillbeaskedtousetheproductandgivefeedback.Thiswill
insurethatourengineersdon’toverlookanyusabilityissuesbecausetheyaretoofamiliarwiththesystem.WewillanalyzethisuserfeedbackanduseittoinsurethatallaspectsoftheRFIDSmartFridgeareeasyandconvenienttouseandunderstand.
CommunicationTestingIntegrationtestingwasperformedthroughverifyingprocessesthatinvolvecross‐component
communication.Alltestsoutlinedbelow:
BackendServerTesting• Allpathsweretested(Table3)
o Server‐sidebehaviorverifiedo Responsebehaviorverified
• Non‐existentpathsweretested
o Errorresponsebehaviorverified
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
44
InFridgeHardwaretoBackendServerCommunicationTesting• Sendingsetsofitems,verifyingresponse(HTTPcode200–OK)andserveraction
o Testhandlingofsetsofvarioussizes: Emptyset
Singleitemset Multipleitemset(10)
• SendingHTTPrequeststoaninvalidpath,verifyingresultingerrorresponse
iPhoneApplicationtoBackendServerCommunicationTesting• iPhonesendsaSHOWrequesttotheserver,parsesresponse
• iPhonesendsmalformedrequesttoserver,handleserror• iPhonesendsaleftoverlabelthroughaADD_OBJECTrequest,receivescode200(OK)response• iPhonesendsaUPCcodethroughaADD_OBJECTrequest,receivescode200(OK)response
• iPhonesendsmalformedADD_OBJECTrequest,receives400(BadRequest)response
WebServertoBackendServerCommunicationTesting• Verifytime‐sensitivewebpagesareupdated(dateschangeaccordingtothecurrentdate)• Verifyplotdataasseenonthewebpageiscorrectlypopulated• EnsurewebpagesupdateafterHTMLisregenerated(updated)asaresultofBackendServer
events
11 CONCLUSION
This document describes in detailed the proposed design for the RFID Smart Fridge. This design will be adhered to as closely as possible during the development of the RFID Smart Fridge prototype system. This will insure that all parts of the design are coherent and that no aspect is overlooked. The test plan will insure that all desired functionality of the RFID Smart Fridge is achieved and that no bugs exist in the software. This design provides clear goals for the development of the RFID system and prototype and will allow us to complete the system on schedule by December 7, 2011.
CYBER‐FLUXINNOVATIONS’SMART‐FRIDGEFUNCTIONALSPECIFICATIONSNov2011
45
12 REFERENCES
[1] RPagliara,DJungic,MJoblin,andSVerner,"RFIDSmartFridgeFunctionalSpecifications,"ENSC305,2011.
[2] AIMGlobal.(2010)RFIDGlossary.[Online][lastaccessedNov.20th,2011].http://www.aimglobal.org/technologies/rfid/rfid_Glossary.asp
[3] GS1.(2011)EANUPCbarcode.[Online][lastaccessedNov.20th,2011].http://www.gs1us.org/standards/barcodes/ean_upc
[4] technovelgy.com.(2010)HowRFIDworks.[Online][lastaccessedNov.20th,2011].http://www.technovelgy.com/ct/Technology‐Article.asp?ArtNum=2
[5] USFoodandDrugAdministration.(2010,Jan)FDAstudydeterminesRFIDeffectsonimplantedcardiacdevices.[Online][lastaccessedNov.20th,2011].http://www.rfidnews.org/2010/01/07/u‐s‐
food‐and‐drug‐conduct‐study‐to‐determine‐rfid‐effects‐on‐pacemakers‐and‐implanted‐cardiac‐devices
[6] RFID4SMEandtheEuropeanUnion,"IsRFIDsafeattheworkplace?,"EuropeanRFIDPlatform,Brussels,2008.
[7] MWardandRvanKranenburg,"RFID:Frequency,standards,adoptionandinnovation,"JISCTechnologyStandardsWatch,2006.
[8] GlassFish.(2011)JAXBReferenceImplementation.[Online][lastaccessedNov.20th,2011].jaxb.java.net
[9] SimpleUPC.(2010)SimpleUPC‐ProductLookup.MadeSimple.[Online][lastaccessedNov.20th,2011].simpleupc.com
[10] RFielding,JGettys,andJMogul.(1999)HypertextTransferProtocol‐‐HTTP/1.1.[Online][last
accessedNov.20th,2011].http://www.w3.org/Protocols/rfc2616/rfc2616.html
[11] Solutaire.(2011)FlotrLibraries.[Online][lastaccessedNov.20th,2011].http://solutoire.com/flotr/
[12] Gson.(2011)GsonRoadMap.[Online][lastaccessedNov.20th,2011].https://sites.google.com/site/gson/gson‐roadmap