/
MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModel MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModel

MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModel - PDF document

min-jolicoeur
min-jolicoeur . @min-jolicoeur
Follow
375 views
Uploaded On 2016-08-15

MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModel - PPT Presentation

MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModelsImplicitBridgingbyMikaelLofqvistRegnrLiTHIDADSEX07004SESupervisorErikWedinExaminerErikLarssonLinkopingApril162007 ID: 447437

MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModels-ImplicitBridgingbyMikaelLofqvistRegnr:LiTH-IDA/DS-EX{07/004SESupervisor:ErikWedinExaminer:ErikLarssonLinkopingApril16 2007.

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "MastersThesisOpenCodeTranslationfromExe..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModels-ImplicitBridgingbyMikaelLofqvistRegnr:LiTHIDA/DSEX07/004SELinkoping2007 MastersThesisOpenCodeTranslationfromExecutableandTranslatableUMLModels-ImplicitBridgingbyMikaelLofqvistRegnr:LiTH-IDA/DS-EX{07/004SESupervisor:ErikWedinExaminer:ErikLarssonLinkopingApril16,2007. AbstractWhenobject-orientedprogrammingbecameasuccess,theneedformethodstosupportsoftwaredevelopmentfollowed.Inthebeginningofthe1990smorethan50methodsandmodelinglanguageswereavailable,andagrowingproblembecame ndingasinglelanguagetoful ltheneedsofmanydi erentpeopleandprojects.Inthemid-1990s,themodelinglanguagesstartedtoincorporatethebestfeaturesofpreviouslanguages,andfewlanguagesgainedprominenceoverthe eld.TheseincludedOOSE(Object-OrientedSoftwareEngineering),OMT(ObjectModelingTechnique),andBooch.Eachofthesemethodshaditsownnotation,processandtools.TheUni edModelingLanguage,UML,wasadoptedunanimouslybythemembershipoftheOMGasastandardinNovember1997touniformthemodelinglanguages.ExecutableandTranslatableUML(xtUML)isthenextabstractionlevelinsoftwaredevelopment,wherebothprogramminglanguageandsoftwarearchitecturehavebeenabstractedaway.ExecutableandTranslatableUMLisawellde nedUMLpro le,extendedwithpreciseactionsemantics.Thisallowsthedeveloperstode neaproblemarea,domain,insuchadetailthatitcanbeexecuted.Byde ningthesystemwithxtUML-models,domains,thesystemfunctionalitycanbeveri edearlyinthedevelopmentprocess.ExecutableandTranslatableUMLmodelscanwithoutchangebetranslatedintodi erentsoftwareenvironments.Translationtocodecanbedoneindi erentwaysandthisworkwillbeperformedinanenvironmentwherecodeisautomaticallygeneratedwithamodelcompiler.Thegoalwithadomainisthatitshouldbeindependentofotherdomains,reusedwithoutmodi cationandexchangedwithanotherdomainsolvingthesameprob-lem.Howeveradomaincanmakeassumptionsthatcertainfunctionalityisavailableandtheseassumptionsarerequirementsforanotherdomain.Toful lthesegoalstheremustbeaminimalcouplingbetweenthedomains.ThiscanbesolvedwiththetechniqueImplicitBridging,wherethebridgedependencybetweendomainsisde nedinabridge.Thedependencyisintheformofmap-pings/couplingbetweenelementsinbothdomains.Byde ningabridgeinterfaceforaserverdomainaclientdomaincanusetheresourceso eredbytheserverdomain.Theresourcesthataclientdomainwishestousearedeclaredinabridge leandthis leisuniqueforeveryclient-serverpair.Ifanolddomainisexchangedi withanewdomainonlythebridge leneedstobereplaced.TheworkperformedshowshowanimplementationofImplicitBridgingcouldberealizedbyapplyingthetechniqueinamicrowaveovensystem.Fromthesys-temdesign vedi erentmappingtypeshavebeenimplemented.Theapplicabilityandthequalityoftheimplementationhavebeenveri edbytestingthegener-atedsystemfunctionalityandalsoverifyingthegoals,exchangeabilityandreuseofdomains,ofthesystem.Keywords:ExecutableandTranslatableUML,xtUML,Implicit/ExplicitBridg-ing,ModelCompilers,Domains,ModelDrivenDevelopment,CodeTransla-tion,Ada95.ii SammanfattningMeddenobjektorienteradeprogrammeringensframganguppkomettbehovavmetoderforattstodjadennatypavmjukvaruutveckling.Iborjanav1990-taletfannsdetett50-talmetoderochmodelleringsspraktillgangliga.Medokningenavantaletmetoderokadeavenproblemetatthittaenmetodsomkundeuppfyllabehovetforbademanniskorochprojekt.Imittenpa1990-taletborjadedenyametodernaanvandasigavdebastadelarnafransinaforegangare,vilketresulteradeiattettfatalmetoder ckovertaget,tillexempelOOSE(Object-OrientedSoftwareEngineering),OMT(ObjectModelingTechnique),andBooch.Dessametoderhadevarochensinegennotation,processochverktyg.ForattenamodelleringssprakenantogsUML,theUni edModellingLanguage,somstandardavOMG1997.ExecutableandTranslatableUML(xtUML)arnastaabstraktionsnivainommjuk-varuutvecklingen,darbadeprogramsprakochmjukvaruarkitekturharabstraheratsbort.xtUMLarenvalde nieradpro linomUML,utokadmedenaktionsemantik.Dettatillaterutvecklarnaattde nieraproblemomraden,domaner,isadande-taljattdekanexekveras.Genomattde nierasittsystemmedxtUML-modeller,domaner,kanmanpaetttidigtstadiumveri erasystemetsfunktionalitet.xtUMLkanoversattastillolikamjuvaruplattformarutanattnagraandringarimodellernabehovsgoras.Oversattningtillprogramkodkangoraspa\rerasattochdettaar-betekommerattutforasienmiljodarkodautomatisktgenererasmedhjalpavenmodellkompilator.Maletmeddomanerarattdeskavaraoberoendeavvarandra,kunnaateranvandasutanmodi kationochersattasmedenannandomansomlosersammaproblem.Daremotkanendomangoraantagandenattenvissfunktionalitet nnsatttillgaochdessaantagandenarkravforenannandoman.Forattmaletskakunnauppfyllasmastedomanernahaenminimalkopplingmellansig.DettakanlosasmedhjalpaventekniksomheterImplicitBridging,darmande nierarberoendetmellandomaneriensakalladbrygga.Beroendetariformavkopplingar(mappningar)mellanelementidebadadomanerna.Genomattde nieraettservergranssnittforentjanstedomankanmanlataeneller\reraklientdomaneranvandaderesursersomtjanstedomanenerbjuder.Deresursermanvillanvandadeklarerasienbrygg lsomarunikforvarjeklient-serverpar.Ommanskulleviljabytautendomansaardetbaraattersattadengamladomaneniii ochskrivaennybrygg l.DetarbetesomutfortsvisarhurenimplementationavImplictBridgingkangenom-forasgenomatttillampateknikeniettsystemforenmikrovagsugn.Utifransystemetsdesignharfemolikatyperavmappningarimplementerats.Teknikenstillampbarhetochimplementeringenskvalitetharveri eratsgenomatttestadetgenereradesystemetsfunktionalitet,samtattmaletmedattenkeltkunnabytaut,ateranvandaellertabortdomanerisystemetuppfylls.Nyckelord:ExecutableandTranslatableUML,xtUML,Implicit/ExplicitBridg-ing,ModelCompilers,Domains,ModelDrivenDevelopment,CodeTransla-tion,Ada95.iv AcknowledgmentFirstofall,IwouldliketothankmysupervisorErikWedinforhissupport,myexaminerErikLarssonandbothAndersErikssonandStefanWidingfortheirhelpmakingthingswork.Secondly,IwouldliketothankJohanBorgforhisfeedbackaboutthisreport.Finally,Iwouldliketothankmywife,Ulrika,forherpatienceandkindness.v vi Contents1Introduction31.1Background................................31.2Objective.................................31.3Environment...............................41.4Goal....................................51.5Delimitation................................51.6Literature.................................51.7Convention................................51.8Terminology................................51.8.1CommonTerms..........................61.9ThesisOutline..............................62Background72.1ExecutableandTranslatableUML...................72.1.1WhyUseExecutableandTranslatableUML(xtUML)?...82.1.2Model-DrivenArchitecture...................82.1.3Domains..............................82.1.4ExecutableandTranslatableUMLMetamodel........92.2Bridging..................................102.2.1ExplicitBridging.........................112.2.2ImplicitBridging.........................113AutomaticCodeGeneration133.1VisualLanguages.............................133.2VisualProgramingEnvironments....................13vii viiiContents 3.3DesignModels..............................143.3.1StructuralApproach.......................143.3.2BehaviouralApproach......................143.3.3TranslativeApproach......................153.4CodeTranslation.............................173.4.1CodeGeneration.........................173.4.2ModelCompilers.........................183.4.3OpenTranslation.........................183.4.4TranslationProcess.......................194MicrowaveOvenSystem214.1Purpose..................................214.2Functionality...............................224.2.1Domains..............................234.2.2MicrowaveOven.........................234.2.3UserInterface...........................234.2.4Test................................234.2.5GraphicalUserInterface.....................235AnalysisforImplicitBridging275.1Howtheimplementedmappingswerefound..............275.2CounterpartObjectMapping......................295.2.1Description............................295.2.2DesignDecisions.........................295.3CounterpartEventMapping.......................325.3.1Description............................325.3.2DesignDecisions.........................335.4CounterpartAttributeMapping.....................365.4.1Description............................365.4.2DesignDecisions.........................365.5StateToAttributeValueMapping...................395.5.1Description............................395.5.2DesignDecisions.........................395.6NewStateTransitionToAttributeValueMapping..........40 Contentsix 5.6.1Description............................405.6.2DesignDecisions.........................416ImplementationofImplicitBridging436.1MicrowaveOvenSystem.........................436.1.1MicrowaveOven.........................436.1.2UserInterface...........................436.1.3Test................................446.1.4GraphicalUserInterface.....................456.2HowtheMappingswereImplemented.................466.3MappingImplementation........................486.3.1CounterpartObjectMapping..................486.3.2CounterpartEventMapping...................516.3.3CounterpartAttributeMapping................526.3.4StateToAttributeValueMapping...............536.3.5NewStateTransitionToAttributeValueMapping......546.4HowtheMappingInformationisStored................566.5HowtheMappingInformationisUsed.................576.6MappingLimitations...........................586.6.1TranslationProcess.......................587Evalutation617.1Veri cationofImplementation.....................617.1.1ImplementedMappings.....................617.1.2Systemgeneration........................617.1.3Veri cationoffunctionality...................617.2EarlierImplementation..........................637.2.1Functionality...........................637.2.2Comparison............................637.3ImplicitBridgingWork\row.......................657.4ErrorManagement............................668Summary678.1Conclusion................................67 xContents 8.2FutureWork...............................698.2.1FutureMappings.........................698.2.2ErrorManagement........................69ABridgeMetamodel71BMicrowaveModel75CUserInterfaceModel77DTestModel81EMicrowaveSystem-DomainChart83 Contents1 ListofFigures2.1Domaintypes...............................92.2Aclientandserverdomaindependency.................102.3Bridgemappings..............................103.1Translationprocess............................194.1Thegraphicaluserinterface........................224.2Thedoorisopen..............................244.3Themicrowaveoveniscooking......................244.4Themicrowaveovenisidle........................255.1TheCounterpartObjectMapping....................295.2ACOMbetweentwoobjects.......................305.3ACOMbetweenseveralobjects.....................305.4ACOMsequence.............................315.5AcyclicCOMsequence..........................315.6PossibleCounterpartEventMapping..................325.7Cycliceventgeneration..........................335.8ACEMwithmorethanonecounterpartevents.............345.9ACEMsequencewithmorethantwocounterpartevents.......345.10ApossibleCounterpartAttributeMapping...............365.11Possibleattributetypemappings.....................375.12Tabelofalloweddatatypestobemapped................385.13AStateToAttributeValueMapping..................395.14TwoNSTTAVMstothesameattribute................405.15TwoNSTTAVMstothesameattribute................416.1Thetestsequence.............................456.2AbridgemodelfortheSTAVM.....................466.3AhalftablefortheSTAVM........................476.4Theclientandserver lemodel.....................586.5Translationprocess............................59 2Contents Chapter1IntroductionThegoalofthischapteristogivethereaderanintroductiontothethesisanditsbackground.Thestructureofthethesisispresentedandnecessarydelimitationsareexplained.1.1BackgroundThismaster'sthesiswaswrittenasa nalyearprojectforcompletionofaMasterofScienceinComputerScienceandEngineeringatLinkopingUniversity,Swe-den.ThisworkwasperformedinthedepartmentofSoftwareArchitectureandDevelopmentatSAABBoforsDynamics(SBD),Linkoping.SincesomeyearsbackastudyinmodelbaseddevelopmentandautomaticcodegenerationhasbeenperformedatSBD.ThisprojectisacontinuationofthisstudyandthepurposeistoinvestigateandimplementthetechniqueImplicitBridg-ingbetweendomainsinExecutableandTranslatableUML(xtUML).Inshortthismeansthattwoindependentdomains(xtUML-models)aremappedtogetherwith-outchangingtheircontents.Whengeneratingcodethesemappingsareusedtogeneratecodethatisamixtureofbothdomains.1.2ObjectiveTheobjectivesofthisthesisaretoinvestigateandimplementthetechniqueImplicitBridging.ThethesisisacontinuationofastudyinmodelbaseddevelopmentandopencodetranslationthathasbeenperformedatSBDsince2001.Tomakeuseofthisdevelopmentprocessanditsbene tsitisveryimportantthattheImplicitBridgingtechniqueisused.Thistechniquesolvestheproblemswithreduceddo-mainindependencybyminimizingthecouplingbetweendomains.Thisisdoneby3 4Introduction removingexplicitreferencesbetweendomainsinterfacesinthemodelsandinsteadlettheArchitecture(ModelCompiler)insertnecessaryinformation.Thereisnostraightforwardimplementationforimplicitbridginganditisstronglycoupledtothearchitecturewereitisimplemented.Animplementationiseitherveryexpensivetobuyoritisinhousedeveloped.Thereforetheavailabilityofinformationthatdescribesthetechniqueandspeciallyimplementationdetailsisverylimited.Thereexistsonepreviousimplementationofimplicitbridginginthecurrentarchi-tecture.Thisimplementationistosomeextentlimitedandthemainreasonfortheimplementationistoshedlightonthetechnique.Thethesisworkwillnotbebasedonthisimplementationmainlybecauseanewapproachiswanted.Thethesisworkwasdividedintoatheorypartandapracticalpart.Inthetheorypartthetechniquewasinvestigatedandinthepracticalparttheinvestigationresultedinanimplementation.Thetheorypartwasfurtherdividedintotwosubparts:ExecutableandTranslatableUMLBridgingandSBDxtUML/Adamodelcompiler.Boththesepartsareimportantconceptstofullyunderstandtheproblemand ndingasolutionforit.Thepracticalpartwasdividedintofoursubparts:ConstructxtUML-models(applicationandserverdomains)toperformbridg-ingbetweenCreateaBridgingMetamodelDevelopmentofArchetypesforcodegenerationGenerationofasystemfromxtUML-modelstoAdabyapplyingthedevel-opedarchetypesontheconstructeddomains.1.3EnvironmentThethesisworkwillbedesignedandimplementedonanexistingapplicationdo-main,amicrowaveoven.Thereasonforchoosingthisdomainasafoundationisbecauseitisapedagogicexample.Everyoneunderstandsthefunctionalityofamicrowaveovenanditiseasytoconstructauserinterfacemodelforit.Thethesisworkwillbediscussedandimplementedwiththesemodelsasfoundation.Themappingstobeimplementedarethosethatareusefulinthisenvironment.Therewillalsobeathirddomainthatwillperformasatestdomain.Themainpurposewiththisdomainistoverifytheimplementedfunctionalitybydemonstratinghoweasyitistoinclude/excludedomainsusingimplicitbridging. 1.4Goal5 1.4GoalThegoalswiththethesisworkarepresentedinthefollowinglist:Fromthesystemde nedin1.3 ndandanalyseusefulmappings.Implementfoundmappingsusingimplicitbridging.Generateafullyfunctionalsystemusingimplementedmappings.VerifytheadvantagesofthetechniqueusingtheTest-domain.Withafullyfunctionalsystemmeansthatitwillful litspurposeandtherewillbenolimitationsbecauseoftheimplicitbridgingimplementation.Theadvan-tagesthatwillbeveri edusingimplicitbridgingaredomainreuseanddomainexchangeability.1.5DelimitationThedelimitationsaredependentonwhichmappingscouldbefoundandimple-mentedinthesystemde nedin1.3.1.6LiteratureThemainsourceforinformationistheInternet.Therehasalsobeenalotofdiscussionwithmysupervisor,whohasgreatknowledgeinthisarea.Othersourcesforinformationarebooksandarticlesdiscussingthistopic,seebibliography.1.7ConventionThroughoutthisthesisdi erenttypefacesareusedtodi erentiatebetweenthethesisregulartextandtools,code,andsoforth.Generaltextisinromanfont.Termsusedforthe rsttimeisinitalicfont.Amonospacedfontindicatescode,softwaretools,datatypes,variables,otheridenti ersandotherspecialitems.1.8TerminologyTheaudiencesforthisthesisareatleastthosewithanundergraduatedegreeinComputerScience.Thethesisisbasedontheterminologyusedinthebooks[1]and[2].Tocomprehendthisthesisitisenoughtoreadthischapter,butforthosereaderswhowantsdeeperknowledgeinthisareaitisrecommendedthatthebook[1]isreadinadditiontothischapter. 6Introduction 1.8.1CommonTermsConceptsawordsrelatedtothethesiswillbeexplainedhere.OOAObjectOrientedAnalysismodel.OOAofOOATheExecutableandTranslatableUMLmetamodelforOOA.AnalystAnengineerbuildingmodels.ArchitectsAnengineerbuildingthearchitecture.TargetDomainThedomaininwhichtheresultofthemappingisapplied.SourceDomainThedomaininwhichanmappingisinitiated.ClientDomainThedomainthatisdependentonotherdomainstofunctionprop-erly.ServerDomainThedomaino eringservicesrequiredbyotherdomains.1.9ThesisOutlineThestructureofthesisisasfollows:IntroductionThischapterintroducestheobjectiveanddelimitationsforthethe-sis.BackgroundThischapterintroducesandexplainsconceptsandterminologyusedthroughoutthethesis.MicrowaveOvenSystemThischaptergivesanthoroughexplanationoftheMicrowaveOvenSystemanparticipatingdomains.AnalysisforImplicitBridgingThischaptergivesanthoroughanalysisforthewhichmappingstoimplement.Italsodiscussesdesigndecisionsandproblemsforeachofthesemappings.ImplementationofImplicitBridgingThischapterexplanationstheimplemen-tationofthemappings.EvaluationThischaptergivesanevaluationoftheimplementation.Itveri esthefunctionalityandcomparestheimplementationagainstapreviousversion.SummaryThischapterdiscussestheimplementationandconclusionsdrawn.Italsoaddressesfuturework,suchasfurtherdevelopmentintheareaofImplicitBridging.InappendixAtoDthedomainclassdiagramcanbefound. Chapter2BackgroundThischapterintroducesthereadertonotations,conceptsandotherimportantsubjectmattersthatisneededtofullycomprehendthethesis.2.1ExecutableandTranslatableUMLExecutableandTranslatableUML(xtUML)[9]isawell-de nedpro leofUML,extendedwithpreciseactionsemantics.Thisallowsthedevelopertode nesubjectmatter,domains,insuchadetailthattheycanbeexecuted.AsystemconsistsofseveralexecutableUMLmodels,eachrepresentingasubjectmattersuchastheapplication,auserinterfaceandotherservices.AnxtUML-modelisthesameasanexecutablesystemspeci cation[12].xtUMLisusedtobuildthesespeci cationsgraphically.Thespeci cationconsistsofclass,stateandactionmodels.Unliketraditionalspeci cationstheseexecutablespeci- cationscanbeexecuted,tested,debuggedandpro led.Whenthespeci cationful lstherequirementsitcanbetranslatedintocode.Thetranslationprocessistheprocessweremodelelementsaremappedtoim-plementationunits.Themodelscanbetranslatedintodi erentimplementationtechnologiesdependingonhowmanyarchitecturesthataresupported.Thetrans-lationprocesswillbediscussedinsection3.4.ExecutableandTranslatableUMLisamongotherthingssuitableforspeci cationofcomplexreal-timedistributedandembeddedsystems.7 8Background 2.1.1WhyUseExecutableandTranslatableUML(xtUML)?Thelargestprobleminsoftwaredevelopmentisnotwritingthecode,thatistheeasypart.Thehardpartistode netheproblemandthisisespeciallytrueoflargeandcomplexsystems.Bybuildingthespeci cationswithxtUML-models,thesystemspeci cationisfullyexecutableconsistingofclass,stateandactionmodelsthatrunlikeaprogram.2.1.2Model-DrivenArchitectureOneoftheadvantageswithxtUMListhepossibilitytodevelopSWandHWplatform-independentspeci cationsoftheproblem.ItsupportstheObjectMan-agementGroup(OMG)initiative,Model-DrivenArchitecture(MDA)[3].Thegoalwiththeinitiativeistoallowdeveloperstocomposecompletesystemsfrommodelsandothercomponents.MDAcapturesthesystemfunctionalityinaPlatformIndependentModel(PIM),thedesignandimplementationiscapturedinaPlatformSpeci cModel(PSM).ThePIMcanbecompleteandspeci cenoughtoenableearlyexecutionandtestoftheapplication,independentofdesignandimplementationspeci cs.Produc-tiveautomationofaMDAapproachprovidestheopportunityfordramaticdefectreduction,accelerateddevelopment,large-scalereuse,andeasyplatformmigrationofapplications.2.1.3DomainsAdomainisasubjectmatter,aproblemarea[5].Thedomainsareautonomousinthewaythattheycanbeunderstoodwithoutknowledgeaboutotherdomains,buttheyrelyonotherdomainstofunctionproperly.Theseparationofdomainsmakesiteasiertoreuseorexchangedomains.Thereforeitisveryimportanttolimitthecouplingbetweenthem.Thedomainchartin gure2.1showsanexampleofvariousdomainsrequiredtobuildasystem.Theapplicationdomaincaptureswhattheapplicationdoes.Theservicedomainscontainfunctionalitybasedontheassumptionsmadebytheapplicationdomain.Forexampleanassumptionfromtheapplicationcouldbethatitassumesthatthereexistssometypeofbuttonpanelforinteraction.Thedesignandfunctionalityofthebuttonpanelisembeddedintheservicedomainimplementingthebuttonpanel.TheArchitecturedomainde nesthetranslationrulesthatwillbeappliedtothemodelsattranslationtime.Adomaincanalsoberealizedascodeanddon'tneedanymodeling.Thisusuallyreferredtoasarealizeddomain.In gure2.1thefunctionaldomainsdescribewhattheapplicationdomaindoes,withhelpfromtheservicedomains.Thisiscompletelyseparatedfromtheim- 2.1ExecutableandTranslatableUML9 Figure2.1.Domaintypes.plementationanddesigndetailsspeci edbytheimplementationandarchitecturedomains.ThiscreatesaseparateanddistinctapplicationPIM,andsoftwarear-chitecturePSM.ThePSMfullydescribesthetargetplatform,andtheapplicationPIMcompletelyde neswhattheapplicationdoes.Thekey-goalswithdomainsare:Re-usewithoutmodi cationReplaceadomainwithanewthatsolvesthesameproblem.2.1.4ExecutableandTranslatableUMLMetamodelAmetamodeldescribesthestructureofamodelandisexpressedusingamod-elinglanguage.ThemetamodelofxtUMLde neshowthextUML-modelsareconstructedanditisalsousedtocreatethestructureofagenerationdatabase.AgenerationdatabaseistherepositorywherethextUML-modelsarestoredduringthetranslationprocess.WhenimplementingImplicitBridgingthextUML-metamodelhastobeextendedwithbridginginformation.Byextendingthemetamodelvariousbridginginfor-mationcanbestoredwhendeclaringthebridgesandaccessedwhengeneratingbridgingcode. 10Background 2.2BridgingThede nitionofabridge[1]isthatitisalayeringdependencybetweendomains.Onedomainmakesassumptionsandotherdomainstakethoseassumptionsasrequirements. Figure2.2.Aclientandserverdomaindependency.Thebridgecontainsmappingsbetweenelementsinonedomaintoelementsinanotherdomain.Amappingisanamedconnectionbetweentwodomains. Figure2.3.Bridgemappings. 2.2Bridging11 Inthemicrowaveexamplethemicrowaveovenapplicationmakesassumptionsthatauserinterfacewillbepresentedtotheuserinsomeway.Theuserinterfaceservicedomaintakesthoseassumptionsasrequirements.Thedependencyisasymmetricbecausetheserverdomaindoesnotrelyontheapplicationdomaintofunctionproperly.2.2.1ExplicitBridgingWhenabridgecallisinvokedinamodel,anexplicitreferencetoaninterfacede nedbyanotherdomainisperformed.Thisiscalledexplicitbridging.ExplicitBridgingisbotheasytounderstandandeasytouse.Thisisbecausetheyareusedmuchlikeordinaryfunctioncalls.TheproblemwithExplicitBridgingisthatitcausescouplingbetweendomainsandthecouplingincreaseseverytimeanexplicitinterfaceiscalled.Thecouplingmakesitmorediculttoreplaceadomainagainstanotherone.2.2.2ImplicitBridgingImplicitBridging[8][10]techniquewherenoexplicitreferencesfromonemodeltoanothermodelisperformed.Insteaditissolvedbylettingthetranslator/architectureinsertnecessarybridginginformation.Thisconcentratesthecouplinginoneplace,thebridge,anditcaneasilybecon guredandthecouplingbetweenthedomainsisminimized. 12Background Chapter3AutomaticCodeGenerationThischapterwilldiscussdi erentapproachestoautomaticcodegenerationandhowthisisperformedinxtUML.Codecanbegeneratedinmanydi erentways[11][6]andinthehistoryofsoftwaredevelopmentautomaticcodegeneratorshavebeenaroundsincetheoriginofcompilers[4].Thischapterpresentscommonapproachestogeneratecode.3.1VisualLanguagesInavisuallanguagetheprogramsaredesignedgraphically.Theprogramisde-velopedbyusingpicturesorformsandthesourcecodeisnotaccessibletotheprogrammer.AnexampleofavisuallanguageisLabVIEWbyNationalInstru-ments.Visuallanguagesareveryusefulforprototypingandwhenthegraphicaluserinter-faceisanimportantpartofthesystem.Insystemswithhighsecurityandwherethecodeneedstobemanuallyveri edavisuallanguagecouldnotbeused.3.2VisualProgramingEnvironmentsAvisualprogrammingenvironment(VPE)usesobjectstovisualrepresentthesoftware.ExamplesofvisuallanguagesareVisualBasicandVisualC++.Inthisprogramminglanguagesoftwareisdevelopedandgeneratedusingagraphicaluserinterface.Onlythegraphicaluserinterfaceisgeneratedandthecoreoftheprogramneedstobehandcoded.Thegeneratedsourcecodeisaccessibletotheprogrammerandifneededitcanbeformallyinspected.13 14AutomaticCodeGeneration 3.3DesignModelsModel-basedcodegenerationproducessourcecodeautomaticallyfromgraphicalmodels.Themodel(design)de nesthesystembehaviourorarchitecture.Oneadvantageofmodel-baseddevelopmentistoraisethelevelofabstractionforthedevelopers.Thedesign(model)becomestheprogram,andthereisnoneedtomaintainthegeneratedsourcecode.Forobject-orientedsystems,therearethreeapproachestomodel-basedcodegeneration:structural,behavioural,andtransla-tive.Foramorethoroughexplanationsee[2].3.3.1StructuralApproachInthestructuralapproachthemodelsarebasedonanobjectstructure.Thecodegeneratedfromthesesmodelsbuildstheframeworkfortheapplication.Thedy-namicbehaviourmustbemanuallyprogrammedinthetargetlanguages.Thisap-proachistypicallyusedwhenthedesignandcodeisincrementallydevelopedfromtheanalysismodel,thisisreferredtoas"elaborative"development.MethodthatsupportstructuralcodegenerationistheUni edModelingLanguage(UML)[7].Themodelobjectstructureisconstructssuchasclasses,attributes,types,andassociations.Thegeneratedcodevariesbetweentools,sometoolsuseatranslationengineandtemplatesthatspecifymappingstotargetsourcecode.Thetemplates(scripts)translatethemodelstocodestructures,suchasclassheadersorfunctionstubs.Translatorsusuallysupportmarking(coloring)optionssuchaswhichRTOS,objectsornumberofprocessestogeneratecodefor.Inthestructuralapproach,thereisnocodegenerationforobjectbehaviour.Thebehaviourismodeledasstatemachineswithoutexecutablesemantics.Thedy-namicofthesystemmustexplicitlybeprogrammed,thisincludesembeddedcon-structs,suchasinterrupthandling.Thehandcodeisintegratedwiththeassociatedcodestructurethatisgenerated.Structuralcodegenerationdoesnotgenerateacompletesystem,butitprovidesanimplementationframeworkconsistentwiththemodels.Manytoolvendors,forexampleRational,supportstructuralcodegeneration.3.3.2BehaviouralApproachThebehaviouralapproachisbasedonstate-machinesextendedwithactionspec-i cations.Insomemethodsthatmodelbehaviourwithstate-machinescode(forexampleC++)canbeaddedtorepresentactionswhenastatetransitionoccurs.Thistechniqueenablestoolstogeneratecodefortheentireapplicationmodel.Oneoftheadvantagesofthistechniqueistheabilitytoexecuteandverifysystembehaviourbasedonthemodelsbeforecodeisgenerated.MethodthatsupportsbehaviouralcodegenerationisUML. 3.3DesignModels15 Inthestatediagrams,usersspecifytheexplicitcodeforhandlingtransitionevents.Thecodeiswritteninthetargetlanguage.Translatorsuseapre-codedexecutioncontrolforthestatemachines,eitheraslibraryroutinesorbuiltintothetranslator.Thisexecutioncontrolimplementsstates,transitions,andcommunicationwithotherstate-machines.Translatorsintegrateevent-handlingcodewiththeexecutioncontrol.Incontrasttothestructuralapproach,behaviouralcodingisperformedduringob-jectmodeling.Inthebehaviouralapproach,programmingisreducedtospecifyingeventhandlersandobjectsthatarehand-coded.Eventhandlerscanimplementembeddedrequirements,forexamplehardwareaccess,interruptsetc.Thedevel-operhasonlyalittlecontrolofthearchitecture.Whenamodeliscompletelydesigneditcanbesimulatedfortestinganddebugging.3.3.3TranslativeApproachThetranslativeapproachisbasedonapplicationandarchitecturemodelsthatareindependentofoneanother.Acompleteapplicationmodelofobjectstructure,be-haviour,andcommunicationiscreatedusingtheObject-OrientedAnalysis(OOA)method,developedbyShlaerandMellor.Likethebehaviouralapproach,develop-erscansimulatesystembehaviorbeforegeneratingcode.Anarchitecturemodelisdevelopedwithatoolthatsupportsthisapproach.Atranslationenginethengeneratescodefortheapplicationaccordingtothemappingrulesinthearchi-tecture.Thetranslativeapproacho erssigni cantreusebecausetheapplicationandarchitecturemodelsareindependent.See3.4formoreinformationaboutthetranslationapproach.Thesystemisde nedusingasetofdomains.Themodelhasobjectmodels,statemodelsforeachobject,andactionspeci cationsforeachstate.Actionspeci ca-tionsarewritteninanactionlanguage.Theactionlanguageisspeci cforthetoolvendor.Simulationisperformedbyinterpretingtheactionspeci cations.Thisallowstheapplicationmodeltobeveri edbeforecodegeneration.Thereisalotofworkinbuildinganarchitecturemodel.Translationmappingsarewritteninascriptinglanguage.Thesemappingshavetypicalprogrammingconstructs:literalstringoutput,substitutionofspeci cmodelobjectsforvariablesofthetranslationrules,anditerationandselectionoftranslationrules.Thetranslativeapproachproducesanapplicationallatonce,incontrasttothestructuralapproachwheretheapplicationmodeliselaboratedintodesignandcode.Thedevelopmentoftheapplicationmodel,whichisaPIM,andthear-chitecturemodel,whichisaPSMcouldbeindependentlyofoneanother.Whentheapplicationandarchitecturemodelsareputtogether,translationgeneratesanapplication.Whiletheapplicationmodelcanbeveri edbysimulation,thearchi-tecturemodelisveri edmainlybysuccessfultranslationsandifpossiblebycodeinspection.Theirindependenceallowsapplicationmodelstobereusedwithdif- 16AutomaticCodeGeneration ferentarchitecturesandarchitecturestotranslateotherapplicationmodels.Withthetranslativeapproach,theapplicationmodel,insteadofsourcecode,becomestheprincipalsoftwareartefact. 3.4CodeTranslation17 3.4CodeTranslationThetranslationprocessistheprocessweremodelelementsaremappedtoimple-mentationunits.Thetranslationprocesscanbemanual,automatedoramixtureofboth.Thissectionwilldiscusstheautomatedapproach,translation.Formoreinformationaboutcodegenerationsee3.ThetranslationprocessgeneratescodefromthextUML-modelwithoutalteringthemodel.Forfullautomationofthetranslationamodelcompilerisneeded.Theseparationofthemodelsandtheimplementationreducestheriskofloosingeverythingifforinstancetheimplementationisbad.Theimplementationcouldbethrownoutandanewdesigncouldbestartedwiththesamemodels.3.4.1CodeGenerationCodegenerationisthetechniquewherecodeisgeneratedfromtheOOA-model,basedonanautomaticrule-basedtranslationscheme.Themajoradvantageswithcodegenerationare:SeparationofthemodelingandtheimplementationConsistencybetweenmodel,codeanddocumentationCodeconstructsarethesamesystemwideAbilitytoapplycodeconstructssystemwidePossibilityforplatformindependentdevelopment.Asmentionedbeforethetranslationprocessleavesthemodelsintactandthishasalotofadvantages.Themodelscanbeseparatelymaintainedandwhenchangeshasbeenmadetoamodel,thesystemisretranslated.Ifthereisanoptimizationchangeinanalgorithmthemodelcompilerwillbeupdatedandwhenthesystemisretranslatedthebene tsoftheoptimizationwillbeusedinthewholesystem.Model-basedmaintenanceeitheraddressesto:1.Applicationbehaviourissues2.Performance-basedissues.Forapplicationbehaviourissuestheapplicationmodelismodi edandthecodeisregenerated.Forperformance-basedissuesthearchitecturemodelismodi edandthecodeisregenerated.Oneimportantconclusionisthatgeneratedcodeshallneverbemodi ed. 18AutomaticCodeGeneration 3.4.2ModelCompilersAmodelcompilertakesoneormorextUML-modelsandtranslatesthemintoarunningsystem.Howthetranslationisperformeddependsonthetranslationpat-ternembeddedinsidethemodelcompileranddecisionsaboutthetargethardwareandsoftwareenvironment.Therearemanydi erentmodelcompilersdependingonthesystemarchitecture.EachmodelcompilercancompileanyxtUML-modelintoanimplementation.Themaincomponentsofamodelcompilerare:MechanismsArchetypesColors.Mechanismarelibrarycomponentsthatprovidesthemodelcompilerwithimple-mentationdetailsfortheelementsinxtUML.Mechanismsprovidetheexecutionenginewitheventhandling,executioncontrolandmore.Archetypesisacombinationofcodepatternsandtranslationrules.Thearchetypesproducetheoutputofthemodelcompileranditcanbeinanytraditionalprogram-minglanguage(orinassembly).ThearchetypeshasaccesstothextUML-modelsthatarestoredinthegenerationdatabase.Coloringistheprocesswheredesignspeci cdecisionsareaddedtothemodels.Itcouldbespecifyingifsomecodewillbeexecutedonaspeci cCPUorspecifyingmaximumnumberofinstancesforaclass.Thecoloringisappliedtothemodelsduringtranslationanditdoesnotmodifythemodels.3.4.3OpenTranslationOpentranslationallowsarchitectstoadjustthetranslationprocess,thearchitectisinfullcontrolofhowtheresultingcodeperformsandlookslike.Thisisimpor-tantforensuringthatgeneratedcodeiscustomizedtothehardwareandsoftwareenvironmentitrunin.Thisisespeciallyimportantforembeddedreal-timesystems. 3.4CodeTranslation19 3.4.4TranslationProcessThetranslationprocessisdescribedin gure3.1.TheBridgePointModelBuilderistheapplicationwherethextUML-modelsaredeveloped[13].Whenamodelis nisheditisexportedfromthemodelbuildertoaSQL- le.Whenthecodegenerationbeginsitcreatesagenerationdatabasewiththestructurede nedintheExecutableandTranslatableUMLmetamodelandOODArchitecture.Theexportedmodelsarereadintothisdatabaseandcolored,designspeci cdecisionsareaddedtothemodels,beforethecodeisgenerated.Theimplictbridgingimplementationwillbeintegratedintothisprocess. Figure3.1.Translationprocess. 20AutomaticCodeGeneration Chapter4MicrowaveOvenSystemInthischaptertheMicrowaveOvenSystem(MOS)isdescribed.4.1PurposeTheMOSwillbeusedasanexampleforhowimplicitbridgingcouldbeapplied.Thesystemisdesignedaroundthreedomains:AMicrowaveOvenapplicationdomain(MO)AnUserInterfaceservicedomain(UI)AGraphicalUserInterfaceservicedomain(GUI).TheMOandUIdomainarextUML-modelsandtheGUIisarealizeddomain.TheMOdomaincontainsthefunctionalityofamicrowaveoven.TheUIdomaincontainsbuttons,lampsandotheruserinterfacecomponents.TheMOandUIareseparatedbecausetheMOdomaindoesnotneedtoknowhowtheusersinteractionwiththemicrowaveovenisimplemented.Insteadofbuttonstherecouldbeavoicepanelforinteractingwiththemicrowaveoven.ImplicitbridgingwillbeappliedbetweentheMOandUIdomains.TheGUIdomainwillpresentaGUIwhereinteractionswiththesystemispossible.Therewillalsobeafourthdomain,atestdomain,anditwillbeusedwithimplicitbridgingagainstboththeUIandMOdomains.Thepurposeofthisdomainistoverifytheimplicitbridgingimplementationbyshowingifdomainseasilycanbeaddedorremovedinthesystem,withoutchangingthextUML-models.Itwillalsoshowthatwhendomainsareindependentofeachother,theycanbereusable.21 22MicrowaveOvenSystem 4.2FunctionalityWhenstartingthemicrowavesystem,agraphicaluserinterfaceispresentedtotheuser.Alltheparticipatingdomainsareinitializedandthesystemwaitsforsysteminteraction.TheGUIletstheusersetthecookingtimeopen/closethedoorstart/stopacookingpresentcurrentstatusFigure4.1explainsthedi erentpartsoftheGUI. Figure4.1.Thegraphicaluserinterface. 4.2Functionality23 4.2.1DomainsThedomainchartdescribingthedomainsinthesystemcanbeviewedinappendixE.4.2.2MicrowaveOvenThemicrowaveovendomaincontainsthefunctionalityofamicrowaveoven.Ithasanoven,abeeper,adoorandothercommonmicrowaveovenobjects.TheclassdiagramforthemicrowaveovenmodelcanbeviewedinappendixB.ThemicrowaveovenxtUML-modelusedinthethesisworkwasdeliveredwithBridgePointModelBuilder,developedbyProjectTechnology1.4.2.3UserInterfaceTheuserinterfacedomaincontainsfunctionalityforcomponentslikebuttons,lampsandsoforth.ItisseparatedfromtheMOdomainbecauseitcontainsfunctionalitythatisofnousefortheMOdomain.ItwillbecloselycoupledtotheGUIdomain.TheclassdiagramfortheuserinterfacemodelcanbeviewedinappendixC.4.2.4TestThepurposeofthetestdomainistoverifythefunctionalityoftheimplicitbridgingimplementation.ItwillbeusedtoshowthatthedomainsareindependentandreusablebymappingboththeUIandtheMOdomainsontoit.Itwillalsobeusedtoverifythatitissimpletoadd/removedomainsinthesystemusingtheImplicitBridgingtechnique.4.2.5GraphicalUserInterfaceThegraphicaluserinterfacedomainisrealizedinTcl/Tkandhastheappearanceofamicrowaveoven.Itwillbeusedbytheusertooperatethemicrowaveoven.Figures4.2,4.3and4.4showsthemicrowaveovenGUIindi erentstates. 1www.projtech.com 24MicrowaveOvenSystem Figure4.2.Thedoorisopen. Figure4.3.Themicrowaveoveniscooking. 4.2Functionality25 Figure4.4.Themicrowaveovenisidle. 26MicrowaveOvenSystem Chapter5AnalysisforImplicitBridgingThischaptergivesananalysisofthesystemandwhichmappingstoimplement.Italsodiscussesdesigndecisionsforeachmapping.5.1HowtheimplementedmappingswerefoundWhichmappingstoimplementweredecidedbyanalyzingthesystem,MOS,weretheywillbeused.OneofthegoalswiththesystemistobeabletocompilethemodelsMOandUIintoafunctionalsystemwithoutusinganyexplicitbridgingbetweenthem.BetweentherealizedGUIdomainandUImodeltherewillbeexplicitbridging.MainlybecausethereisnorequirementforimplementingimplicitbridgingbetweenaxtUML-modelandarealizeddomain.ThesystemisonlyusefuliftheusercaninteractwiththesystemandthisimpliesthattheUIandMOdomainsmustinteractwitheachother.BecausethereisnoexplicitcouplingbetweenthemodelsUIandMO,allinteractionsmustbeimplicitlymapped.ThemicrowavesystemGUImustbeabletosetthecookingtime,start/stopacookingsession,open/closethemicrowavedoor,presentthecurrentstatusofanarbitraryobjectintheMOdomain.27 28AnalysisforImplicitBridging WhenabuttonintheGUIisclickeditwillgenerateaneventintheUIdomain.ThiseventmustbemappedtoanelementintheMOdomain.ThemostintuitiveistomapthebuttonclickedeventtoaneventintheMOdomain,acounterpartevent.ThereforetheCounterpartEventMappingwillbeimplemented.Theeventsthataremappedtogetherarestatemodeleventsandtheybelongtoanobjectineachdomain.Thismeansthatitmustbepossibleto ndaknowninstanceofanobjectinaremotedomain.ThereforetheCounterpartObjectMappingwillbeimplemented.ThecookingtimethatispresentedintheGUIshouldalwayshavethesametimeasthetimerintheovenobjectintheMOdomain.ThereforetheCounterpartAttributeMappingwillbeimplemented.ThestatusofanyarbitraryobjectintheMOdomainwillbepresentedintheGUIusingoneofthelamps.Thestatusisthecurrentstateofanobjectanditchangeswhenevertheobjectchangesstate.Thisresultsintwomappings,the rstiswhenanobjectstateismappedtoanelementintheotherdomain.InthiscaseitwillbemappedtoanattributevalueandthisistheStateToAttributeValueMapping.Thesecondmappingiswhenanobjectexitsastate,thenasbeforeavalueintheotherdomainisset.ThisistheNewStateTransitionToAttributeValueMappingandboththesewillbeimplemented. 5.2CounterpartObjectMapping29 5.2CounterpartObjectMapping5.2.1DescriptionACounterpartObjectMapping(COM)betweentwoobjectsmeansthatifanyofthethesetwoobjectsiscreatedsoisalsothecounterpartobject.Ifanyofthesestwoobjectsisdeletedsoisalsothecounterpartobject.Thismappingiscommutative,thatisvalidinbothdirections. Figure5.1.TheCounterpartObjectMapping.Figure5.1showsasequencediagramwhereaCOMisinvokedwhenaninstanceoftheDoorclassiscreated.TheCOMinvokesthecreatefunctioninthecounterpartobjectandaninstanceofthecounterpartisalsocreated.The gurealsoshowsthattheCOMisinvokedwhenanobjectisdeleted.5.2.2DesignDecisionsWhendesigningthefunctionalityoftheCOMfollowingthingshadtobetakenintoconsideration:1.Avoidcyclicbehaviourwhencreating/deletingtheobjects.2.Maponeobjectagainstmorethanoneobject.3.Mappingsequencelargerthantwo.4.Mappingagainstmorethanonedomain.5.Thepossibilitytomakethemappingunidirectional,non-commutative.The rstproblemappearswhenoneobjectiscreatedanditinitsconstructorcallstheconstructorinthecounterpartobject.Becausethemappingiscommutativethe 30AnalysisforImplicitBridging calledobjectwillhavesimilarcodeinitsconstructorthatwillcallitscounterpartobject,se gure5.2,andsoforth.Theproblemissimilarwhenanobjectisdeleted. Figure5.2.ACOMbetweentwoobjects.ThesecondproblemisifthereshouldbepossibletohaveCOMsfromoneob-jecttomorethanoneobject.ThisaddsalittlemorecomplexitytothepreviousproblemsinceanobjectmustknowfromwhichCOMthecreationwasinitiated.Somehowthecounterpartmustbeabletodistinguishbetweenthedi erentcoun-terpartobjectssothatthecounterpartobjectthatinitiatedthecreationwontbecreatedagain. Figure5.3.ACOMbetweenseveralobjects.The gure5.3showsthattheDoorobjecthaveCOMtoboththeLampandButtonobject.ItshouldbepossiblefortheLamptopresentthecurrentstateoftheDoor.ItshouldalsobepossibletoopenandclosetheDoorthroughaButton.Thereforeitisimportantthatthereisapossibilitytode neCOMfromoneobjecttooneormoreobjects.ThethirdproblemisifthereshouldbealimitoranarbitrarylengthonaCOMsequence.In gure5.4aCOMsequenceoflengthtwoappearsbecauseoftheCOMbetweenDoorandOpen ButtonandtheCOMbetweenOpen ButtonandTest Object.ThecomplexityandriskforcyclicobjectcreationincreaseswhentheCOMse-quenceincreases.Theproblemisshowin gure5.5,whereboththeDoorandOpen ButtonobjectsarecounterparttotheTestobject. 5.2CounterpartObjectMapping31 Figure5.4.ACOMsequence. Figure5.5.AcyclicCOMsequence.Thediscussioninsection4.2.4aboutthepurposeoftheTestdomainandthatitshouldbepossibletoconnectaTest ObjecttooneoftheButtonobjectsandsimulateabuttonclickedeventtochangethestateoftheOvenobject.Thisfunc-tionalityimpliesthataCOMsequencelargerthanonemustbeallowed.TosimplifytheCOM,anobjectcouldbelimitedtoonlybeabletode neCOMstooneotherdomain.ThislimitationmakesthepreviousdiscussedfunctionalityimpossibleandthereforeitshouldbepossibletoperformCOMbetweentwoormoredomains.InsomecasesitwouldbeusefultobeabletoperformunidirectionalCOM.ForexamplewhenperformingaCOMbetweenasourceobjectinsomearbitrarydo-mainagainstatargetobjectinsometestdomain.Whenthesourceobjectinthearbitrarydomainiscreateditautomaticallycreates,viatheCOM,aninstanceofantestobjectinthetestdomain.Thetestobjecttheninitializesatestsequenceonthecounterpartobjectandwhenthetestsequenceis nishedthetestobjectisdeleted.Theunidirectionalmappingensuresthatthesourceobjectnotisdeleted.IntheMOSthereisnorequirementforunidirectionalCOMfunctionalityandthereforethisfunctionalitywillonlybeimplementedifthetimeallowsitattheendoftheproject. 32AnalysisforImplicitBridging 5.3CounterpartEventMapping5.3.1DescriptionACounterpartEventMapping(CEM)iswhenagenerationofaneventinasourcedomainautomaticallycausesagenerationofaneventinatargetdomain.Figure5.6showsanexamplewhenaCEMcouldbeused. Figure5.6.PossibleCounterpartEventMapping.The gureshowspartsofthestatediagramsfortheDoorobjectintheMOdomainandtheOpen ButtonintheUIdomain.HereaCEMbetweentheOpen ButtoneventOpen Button ClickedandtheDooreventreleasecouldbede ned.EverytimetheOpen Button ClickedisgenerateditautomaticallygeneratesthereleaseeventintheDoorobject. 5.3CounterpartEventMapping33 5.3.2DesignDecisionsWhendesigningCEMfollowingthingshadtobetakenintoconsideration:1.Avoidcycliceventgeneration.2.Maponeeventtomorethanoneevent.3.Mappingsequencelargerthantwo.4.Mappingagainstoneormoreotherdomains.5.Thepossibilitytomakethemappingunidirectional,non-commutative.6.Thepossibilitytohaveeventparameters.ThedesignproblemsareverysimilartothoseintheCOM.The rstproblemistoavoidcycliceventgeneration.Theproblemoccursifaneventgeneratesacounterparteventandthecounterpartcausesaregenerationofthepreviousevent.Figure5.7showstheproblemwhentheOpen Button Clickedisgenerated.Itgeneratesitscounterparteventandsoforth. Figure5.7.Cycliceventgeneration.Thereshouldbepossibletomaponeeventtomorethatonecounterpartevents.IntheMOStheOveneventStart Cookingismappedtotwocounterpartevents,see gure5.8 34AnalysisforImplicitBridging Figure5.8.ACEMwithmorethanonecounterpartevents. Figure5.9.ACEMsequencewithmorethantwocounterpartevents.Theremustalsobepossibletohaveamappingsequencelargerthattwo.IntheMOSthereexistsequenceslargerthantwo,see gur5.9.Thereshouldnotbealimitationofthenumberofdomainsthatcouldbemappedbetween. 5.3CounterpartEventMapping35 Itshouldalsobepossibletode neunidirectionalmappings.Intheexamplede-scribedinsection5.3.1whencreatingCEMbetweentheOpen Button Clickedeventandthereleaseeventitwouldbepreferabletohaveanundirectedmap-ping.Thisisbecauseitwillnevergenerateareleaseeventiftherehasnotbeenanopenbuttoneventinitiatingit.Itshouldalsobepossibletohaveeventparameters.ThemappedeventStart B-utton Clickedhasaperiodtimeasparameter. 36AnalysisforImplicitBridging 5.4CounterpartAttributeMapping5.4.1DescriptionACounterpartAttributeMapping(CAM)iswhentwoattributesaremappedto-gether.Whenreadingthesourceattributethetargetattributeisreturned.Whenwritingtothesourceattributethetargetismodi ed.Thismappingisnotcom-mutativebecausethevalueneedstobestoredinoneoftheattributes.The gure5.10showsanexampleofaCAM. Figure5.10.ApossibleCounterpartAttributeMapping.In gure5.10theremaining timeattributeisthesourceattributeandtheremainin-g cooking timeisthetargetattribute.5.4.2DesignDecisionsFollowingthingshadtobetakenintoconsiderationwhendesigningtheCAM:1.betweenwhichattributetypescouldmappingbeapplied,2.shouldtherebeapossibilitytospecifyreadandwritepropertiesand3.betweenwhichdatatypescouldamappingbede ned.Thereexisttwoattributetypes,derivedandstored.Thederivedattributereturnthevalueofafunctionanditisnotwritable.Thestoredattributeisaregularattribute,whichmeansthatitcouldbereadandwrittento. 5.4CounterpartAttributeMapping37 Figure5.11showspossibleattributemappings.Themostimportantisthatthedo-mainsshouldnottakeanythingregardingotherdomainsintoconsideration.There-forethemappingfromastoredattributetoaderivedattributeshouldbeforbidden.Alltheotherattributetypemappingsarevalid. Figure5.11.Possibleattributetypemappings.TheattributetypemappingsthatwillbeperformedintheMOSarederivedtoderivedandstoredtostored.The rstofthetwomappingsmappingisbetweenthederivedattributes,CurrentTimerValueintheUITimerobjectandCurrentOvenTimerValueintheOvenobject.ThesecondmappingisbetweenthestoredattributesTimeintheStartButtonobjectintheUIdomainandtheremainingcookingtimeintheOven.Thestoredtostoredattributemappingistheonlywherewritingtothetargetattributeispossible.Thismappingwillnotbeusedinthecurrentimplementation;thereforeonlyreadpropertieswillnotbeimplemented.ThethirddecisionistodecidebetweenwhichdatatypesaCAMcouldbeper-formed.Theproblemoccurswhenthesourceandtargetattributeisnotofthesametypeandsomeformofconversionisneeded.Theconversioncouldbeper-formedbyasimpletypeconversionorusingamorecomplexconvertingfunction.IntheMOStheattributesthataremappedtogetherareofthesametype.Sim-pletypeconversionwillbeimplementedand gure5.12showbetweenwhichdatatypesmappingisallowed.Theattributemappingbetweenattributesoftheenumerationdatatypewillnotbeimplemented,mainlybecausethereisnoneedforitintheMOSsystem.Thesecondreasonisthatitisacomplexanddicultmappingtoimplement.ForexamplehowshouldamappingbetweenanenumerationattributeObject State,withthevaluesOn,O ,toanenumerationattributeButton State,withthevaluesState 1,State 2,State 3,looklike.ShouldState 1bemappedontoOnandtheotherstatevaluestoO orshouldonlyoneoftheotherstatesbemappedtothe 38AnalysisforImplicitBridging Figure5.12.Tabelofalloweddatatypestobemapped.O value.Thesearesomeofthethingsthatmustbetakenintoconsiderationwhenimplementingattributemappingfortheenumerationdatatype.Itissimilartotheproblemwhenmappingbetweendi erentdatatypesandsomekindofconversionfunctionisneeded. 5.5StateToAttributeValueMapping39 5.5StateToAttributeValueMapping5.5.1DescriptionAStateToAttributeValueMapping(STAVM)iswhenanobjectstateismappedtoanattributevalue.Whentheobjectentersthemappedstateitcausesthemappedattributevaluetobemodi ed.Thevalueisaconstantgivenatthedeclarationofthemapping. Figure5.13.AStateToAttributeValueMapping.Figure5.13showshowaSTAVMcouldbeused.TheopenstateismappedontothevariableLamp Status.5.5.2DesignDecisionsThemaindecisionforthismappingweredecidewhichdatatypestheattributevaluecouldhave.IntheMOSthemappingisusedtomaptheovenstatetooneofthelampsintheUIdomain.Thisissolvedbyusingastringvariable. 40AnalysisforImplicitBridging 5.6NewStateTransitionToAttributeValueMap-ping5.6.1DescriptionANewStateTransitionToAttributeValueMapping(NSTTAVM)iswhentheexitfromanobjectstatewithaspeci ctransitionismappedtoanattributeinanotherdomain.Whentheobjectexitsthemappedstatewithaspeci edtransitionincausesthemappedattributevaluetobemodi ed. Figure5.14.TwoNSTTAVMstothesameattribute.Figure5.14showsanexamplewheretheNSTTAVMcouldbeapplied.Thismap-pingwouldmapallexitstatesfromtheCookingstatetotheLamp StatusattributeintheRight Lampobject.AnimportantnoticeisthatthiscouldalsobesolvedwiththeSTAVM,butonlyifbothmappingsde nesthesameattributevalue.Insteadofmappingeachtransitionthestatewherethetransitionleadstoismapped.Toclarifythedi erencebetweenthesetwomappingtypes, gure5.15illustratesanexamplewhereNSTTAVMscouldbeusedtode neonemappingforeachtransitiontotheerrorstate.Whendoingsotheattributevaluebesettodi erentvaluesdependingonfromwhichstatethenewstatetransitionwasactivated.Thiscouldnotbede nedusingtheSTAVMbecauseitcouldonlymaponeattributevaluefortheerrorstate. 5.6NewStateTransitionToAttributeValueMapping41 Figure5.15.TwoNSTTAVMstothesameattribute.5.6.2DesignDecisionsThedesigndecisionsthatweremadeforthismappingwaswhichdatatypestheattributecouldhave.IntheMOSthemappingisinonecaseusedtosetthecolouroftheRight LampwhentheOvenexitsthecookingstate.Thisissolvedbyusingastringvariable. 42AnalysisforImplicitBridging Chapter6ImplementationofImplicitBridgingInthischaptertheimplementationdetailswillbepresented.6.1MicrowaveOvenSystem6.1.1MicrowaveOvenThereweresomechangesthathadtobedonetoadaptthisdomaintotheim-plementation.TheremainingcookingtimewillbepresentedintheGUIanditwillbesetusinganCAMbetweenanattributeintheUIdomainanattributeintheMOdomain.Theattributeremaining cooking timeintheOvenclassholdstheremaingtimewhentheovenstateisnotintheCookingstate.ThereforetheCurrent Oven Timer Valueattributehadtobeaddedandthismappedattributereturnstheremainingcookingtimewhenitisread.Theremaining cooking timeattributewillbeusedimplicitlytosetthecookingtimeusingaCAM.6.1.2UserInterfaceTheUIdomainisaservicedomainanditiscloselycoupledtotheGUIdomain.ThemainfunctionalityistoactasamiddledomainforinteractionbetweentheGUIandMOdomain.ItwillactasaneventhandlerwhenabuttonintheGUIisclickedandimplicitlygeneratecounterparteventsintheMOdomain.ItwillupdatetheGUItimerbycontinuallypollingtheUI TimerandimplicitlyreceiveavaluefromacounterpartattributeintheMOdomain.TheLampclassholdsastringvaluerepresentingthestatusontheobjectthatismappedontoit.Thestatusattributeinthiscasewillbeusedtosetthecolorofthelamps.43 44ImplementationofImplicitBridging AlllogicalUIcomponentshasanhandlerclassthatforexamplewaitsforancre-ationoftheobjecttohandle,handlestheobjectbypollingavalueorstateandupdatingtheGUIdependingonthevalues.6.1.3TestTheTestdomainde nesatestsequencethatgenerateseventstoanumberoftestobjects.Itwillpresentaserverinterfacethatmakesitpossibletomapobjectsandbelongingeventstothesetestobjects.Whenthetestsequenceisinitiateditwillforeachtestobjectgeneratethecor-respondingeventandthiswillautomaticallycausethecounterparteventtobegenerated.ItcanbeusedtogetherwithanydomaininthemicrowavesystemandfortestpurposesitwillbeusedtogetherwithboththeUIandtheMOdomains.Inthe rstdomaincon gurationtheUIdomainwillbemappedontointotheTestdomainandalldomainsinthemicrowavesystemwillparticipate.Inthesecondcon gurationtheUIandGUIdomainwillberemovedandtheMOdomainwillbemappedontotheTestdomain.ThiswillshowthattheMOdomainisnotdependentontheotherdomainstoexecuteandwhenusingimplicitbridgingthedomainsarereusable.ItwillalsoshowthereisnoneedtomakeanychangesinthexUML-modelswhenremoving/switchingdomainsusingimplicitbridging.Allfunctionalityisde nedinthebridges.Thetestsequenceispresentedin gure6.1.The gureisanextractionofanstateinthestatemodelfortheTest Sequenceobject.ThetestsequencefortheUIdomain:1.Testevent1willgenerateaclosebuttoneventtotheCloseButtonobject.2.Testevent2willgenerateastartcookingeventtotheStartButtonobject.3.Testevent3willgenerateanopenbuttoneventtotheOpenButtonobject.4.Testevent4willgenerateaclosebuttoneventtotheCloseButtonobject.ThetestsequencefortheMOdomain:1.Testevent1willgenerateaclosebuttoneventtotheDoorobject.2.Testevent2willgenerateastartcookingeventtotheOvenobject.3.Testevent3willgenerateanopenbuttoneventtotheDoorobject.4.Testevent4willgenerateaclosebuttoneventtotheDoorobject. 6.1MicrowaveOvenSystem45 Figure6.1.Thetestsequence.6.1.4GraphicalUserInterfaceTheGUIdoesnotshoweverythingbydefault.Whatisshowndependsonthebridgingcon guration.Forexample,alampisonlyshowniftheLampobjectintheUIdomainhavebeenmappedtoacounterpartobject.Thecolourofthemappingisalsocon guredinthebridge.Thesameappliesforthebuttons. 46ImplementationofImplicitBridging 6.2HowtheMappingswereImplementedEachmappingmustbede nedbyextendingtheOOAofOOA,theextensionisusedtostorebridginginformation.TheextensionisplacedinanmetamodelnamedtheBridgingMetamodel,seeappendixA.WhenthesystemistranslatedtocodetheBridgingMetamodelistranslatedintoSQLstatementsandthesestatementsareusedtostoreandaccessbridginginformationduringthetranslation.Figure6.2showsanexampleonhowanextensioncouldbede ned.InthisexampletheState To Attribute Value Mappingisthebridgemodelde ningabridgebetweentheOOAelementsAttributeandStateModelState.TheBridgingMetamodelwasconstructedusinghalftables.Ahalftableisatableconstructedwithtwohalves,onehalfspecifyingelementsintheclientdomainandtheotherhalfspecifyingelementsintheserverdomain.TheelementsarethejoinpointsineachdomainandconsistofonlyOOAofOOAelements.Figure6.3showsthehalftablefortheSTAVMde nedinthebridgemodel6.2. Figure6.2.AbridgemodelfortheSTAVM. 6.2HowtheMappingswereImplemented47 Figure6.3.AhalftablefortheSTAVM.Whenimplementingamappingthe rststepistoimplementitinthesourcecode.Whenitworksasthespeci cationitcanbetransformedintoanarchetypethatgeneratestheimplementedcode. 48ImplementationofImplicitBridging 6.3MappingImplementation6.3.1CounterpartObjectMappingThismappingisusedfornavigationpurposebetweendomainsandallothermap-pingstobeimplementedwilldependonit,seeappendixA.ThefollowingfunctioninvocationcreatesaCOMbetweentheDoorandLeft Lampobjects.Thisfunctionisimplementedinthearchitectureandisinvokedwhende ningthebridge,seesection6.4..invokeCounterpart_Object_Mapping(Impl_Bridge_Ref,``Door_To_Left_Lamp_Mapping'',Microwave_Oven,Door,User_Interface,Left_Lamp)Themappingimplementationconsistsmainlyofplacingcodeinthoseplaceswhereobjectsarecreatedanddeleted.ThefollowingcodeshowsthegeneratedCreatefunctionintheDoorobject.ThebridgingcodeconsistsofafunctioncalltothecreatefunctionintheLeft Lampcounterpartobjectandrelationshipcreationfornavigationpurposes.withUI.Left_Lamp;...packagebodyMO.Doorsi...procedureCreate(Instance:outInstances.Identification)is...--BridgingcodeLeft_Lamp_Id:UI.Left_Lamp.Instances.Identification;--begin...--CounterpartObjectCreationUI.Left_Lamp.Create_Counterpart_To_Door(Left_Lamp_Id);MO_To_UI_Bridge.Door_To_Left_Lamp_Mapping.Relate(Instance,Left_Lamp_Id);MO_To_UI_Bridge.Left_Lamp_To_Door_Mapping.Relate(Left_Lamp_Id,Instance);--endCreate;...endMO.Door;Fromtheanalysisfollowingproblemshadtobetakenintoconsideration.1.Avoidcyclicbehaviourwhencreating/deletingtheobjects.2.Maponeobjectagainstmorethanoneobject.3.Mappingsequencelargerthantwo.4.Mappingagainstmorethanonedomain.5.Thepossibilitytomakethemappingunidirectional,non-commutative. 6.3MappingImplementation49 The rstdesignproblemissolvedbyaddinganewcreatefunctionforeachcoun-terpartmapping.Thisfunctionwillnotincludefunctioncallstothecounterpartobjectthatcallsit.ThecodeaboveshowstheCreatefunctionintheDoorobject.WhencreatinganinstanceofthecounterpartobjectLeft Lamp,thenewfunctionCreate Counterpart To Dooriscalled.ThisfunctiondoesnotincludefunctioncallsbacktotheDoorobject.ThesolutiontothesecondproblemistohavefunctioncallstoallCOMsinthecreatefunction.ThefollowingcodeshowsthattheDoornowiscounterparttoLeft Lamp,Open ButtonandClose Button.withUI.Left_Lamp;withUI.Open_Button;withUI.Close_Button;...packagebodyMO.Dooris...procedureCreate(Instance:outInstances.Identification)is...--BridgingcodeLeft_Lamp_Id:UI.Left_Lamp.Instances.Identification;Open_Button_Id:UI.Open_Button.Instances.Identification;Close_Button_Id:UI.Close_Button.Instances.Identification;--begin...--CounterpartObjectCreationUI.Left_Lamp.Create_Counterpart_To_Door(Left_Lamp_Id);MO_To_UI_Bridge.Door_To_Left_Lamp_Mapping.Relate(Instance,Left_Lamp_Id);MO_To_UI_Bridge.Left_Lamp_To_Door_Mapping.Relate(Left_Lamp_Id,Instance);UI.Open_Button.Create_Counterpart_To_Door(Open_Button_Id);MO_To_UI_Bridge.Door_To_Open_Button_Mapping.Relate(Instance,Open_Button_Id);MO_To_UI_Bridge.Open_Button_To_Door_Mapping.Relate(Open_Button_Id,Instance);UI.Close_Button.Create_Counterpart_To_Door(Close_Button_Id);MO_To_UI_Bridge.Door_To_Close_Button_Mapping.Relate(Instance,Close_Button_Id);MO_To_UI_Bridge.Close_Button_To_Door_Mapping.Relate(Close_Button_Id,Instance);--endCreate;...endMO:Door;Tomapagainstmorethanonedomainispossible.ThefollowingcodeshowstheCreatefunctioninStart ButtonandthatitiscounterpartwithOvenintheMOdomainandtheTest Object 2intheTestdomain.withTest.Test_Object_2;withMO.Oven;...packageUI.Start_Buttonis...procedureCreate(Instance:outInstances.Identification)is...--Bridgingcode 50ImplementationofImplicitBridging Oven_Id:MO.Oven.Instances.Identification;Test_Object_2_Id:Test.Test_Object_2.Instances.Identification;--begin...--CounterpartObjectCreationMO.Oven.Create_Counterpart_To_Start_Button(Oven_Id);MO_To_UI_Bridge.Start_Button_To_Oven_Mapping.Relate(Instance,Oven_Id);MO_To_UI_Bridge.Oven_To_Start_Button_Mapping.Relate(Oven_Id,Instance);Test.Test_Object_2.Create_Counterpart_To_Start_Button(Test_Object_2_Id);UI_To_Test_Bridge.Start_Button_To_Test_Object_2_Mapping.Relate(Instance,Test_Object_2_Id);UI_To_Test_Bridge.Test_Object_2_To_Start_Button_Mapping.Relate(Test_Object_2_Id,Instance);--endCreate;...endUI.Start_ButtonisThereisnolimitintheimplementationonthesizeofaCOMsequence.InthecodepresentedaboveasequencewilloccurifforinstancetheOveniscreated rst.ThecreatefunctioninStart ButtonwillbecalledfromthecreatefunctionintheOvenobject.ThecreatefunctionintheStart ButtonobjectwillcallthecreatefunctionfortheTest Object 2.ThesolutiontoavoidcycliccreationandallowmorethanoneCOMinasequenceistoforeachcounterpartobjectde neaspecialcreatesfunction.Thisfunctionwillonlybecalledbythecounterpartobjectitisde nedforandiftheobjecthasmorethanoneCOMde nedthesewillbecalledfromthisfunction.ThefollowingcodeshowstheCreate Counterpart To Ovenfunctionde nedintheStart Buttonobject.ThisfunctionwillbecalledfromtheCreatefunctionintheOvenobject.ItwillinturncalltheCreate Counterpart To Start ButtoninTest Object 2.withTest.Test_Object_2;withMO.Oven;...packageUI.Start_Buttonis...procedureCreate_Counterpart_To_Oven(Instance:outInstances.Identification)is...--BridgingcodeTest_Object_2_Id:Test.Test_Object_2.Instances.Identification;--begin...--CounterpartObjectCreationTest.Test_Object_2.Create_Counterpart_To_Start_Button(Test_Object_2_Id);UI_To_Test_Bridge.Start_Button_To_Test_Object_2_Mapping.Relate(Instance,Test_Object_2_Id);UI_To_Test_Bridge.Test_Object_2_To_Start_Button_Mapping.Relate(Test_Object_2_Id,Instance);-- 6.3MappingImplementation51 endCreate_Counterpart_To_Oven;...endUI.Start_Button;Theimplementationofthedeletionofcounterpartswasdoneinthesamewayasforcreationofcounterpartobjects,butinsteadtheinstancesaredeleted.TheunidirectionalCOMfunctionalitywasnotimplemented,duetotimelimita-tions.6.3.2CounterpartEventMappingTheimplementationoftheCEMissimilartotheCOMimplementation.ThefollowingfunctioninvocationscreatesCEMsbetweentheStart ButtoneventsStart Button ClickedandStart Button Clicked TestandtheOveneventStart Cooking.Thelastparameter,True,declaresthatthemappingisunidirectional.Thismeansthatthemappingwillonlybevalidinonedirection.TheStart Button ClickedeventwillgenerateanStart Cookingevent,butnotviceversa..invokeCounterpart_Event_Mapping(COM_Ref,Start_Button,Start_Button_Clicked,Oven,Start_Cooking,True).invokeCounterpart_Event_Mapping(COM_Ref,Start_Button,Start_Button_Clicked_Test,Oven,Start_Cooking,True)Thefollowingcodeisgeneratedfromtheabovede nedmapping.ItshowstheGeneratefunctionintheStart Buttonobject.withMO.Oven;...packageStart_Buttonis...procedureGenerateis...--GenerateCounterpartEventscaseEvent.NameiswhenStart_Button_Clicked=�MO.Oven.Generate_Counterpart_Event_To_Start_Button(Event=�(MO.Oven.Start_Cooking,Oven_Event_Data),To_Instance=�Oven_Id);whenStart_Button_Clicked_Test=�MO.Oven.Generate_Counterpart_Event_To_Start_Button(Event=�(MO.Oven.Start_Cooking,Oven_Event_Data),To_Instance=�Oven_Id);whenothers=�null; 52ImplementationofImplicitBridging endcase;---...endGenerate;...endStart_Button;ToavoidcycliceventgenerationanewgenerationfunctioniscreatedforeachCEM.InthiscasethefunctionGenerate Counterpart Event To Start ButtonisgeneratedintheOvenobject.ItwillcontaineverythingthattheoriginalGeneratefunctioncontainsexceptagenerationtothecounterparteventcallingit.Thereisnoproblemwithhavinganeventmappedtomorethanoneeventandtohaveseveraleventsinonesequence.TheproblemwithcycliceventgenerationisstillapossibilitywhenhavingaCEMsequence.Thisproblemishardtosolveintheimplementationandmustbetakenintoconsiderationwhende ningtheCEMs.TheStart ButtonhastwoCEMsde ned.BotharemappedtotheStart CookingeventintheOven.WhenaneventisgeneratedintheStart Buttonitischeckedinthecasestatementandiftheeventisamappedeventitwillgeneratethecoun-terpartevent.BecauseseveraloftheperformedCEMsintheMOSonlyneededtobeunidirec-tionalthisfunctionalitywasimplemented.6.3.3CounterpartAttributeMappingThefollowingfunctioncreatesaCAMbetweenthestoredattributesTimeinStart ButtonandRemaining Cooking TimeinOven..invokeCounterpart_Attribute_Mapping(UI_Timer_Is_Oven.Ctrpt_Object_Ref,Start_Button,Time,Oven,Remaining_Cooking_Time)ACAMcanonlybedeclaredbetweenthevalidattributetypesdiscussedinsection5.4.2.Theattributetypecheckisperformedinthisandifthemappingnotisvalidanerrorisgenerated.Thefollowingcodeshowsthegeneratedcodefromtheabovede nedmapping.TheTimefunctionreturnsthecurrentvalueoftheTimeattribute.AsaconsequenceofthemappingtheTimefunctionreturnsthevalueofthecounterpartattribute.IntheSet Timefunctionthecounterpartattributeisset.withMO.Oven;...packageUI.Start_Buttonis...functionTime(Instance:inInstances.Identification) 6.3MappingImplementation53 returnIntegerisOven_Id:MO.Oven.Instances.Identification;Oven_Tmp:Integer;beginOven_Id:=MO_To_UI_Bridge.Start_Button_To_Oven_Mapping.Select_One(Instance);Oven_Tmp:=MO.Oven.Instances.Instance_Attributes(Oven_Id).Remaining_Cooking_Time;returnOven_Tmp;endTime;...procedureSet_Time(Instance:inInstances.Identification;Time:inInteger)isOven_Id:MO.Oven.Instances.Identification;beginOven_Id:=MO_To_UI_Bridge.Start_Button_To_Oven_Mapping.Select_One(Instance);MO.Oven.Instances.Instance_Attributes(Oven_Id).Remaining_Cooking_Time:=Time;endSet_Time;...endUI.Start_Button;IftheRemining Cooking Timehadbeenofa\roattypeinsteadthefollowingcodeshowshowthecastingisimplemented.functionTime(Instance:inInstances.Identification)returnIntegerisOven_Id:MO.Oven.Instances.Identification;Oven_Tmp:Integer;beginOven_Id:=MO_To_UI_Bridge.Start_Button_To_Oven_Mapping.Select_One(Instance);Oven_Tmp:=Integer(MO.Oven.Instances.Instance_Attributes(Oven_Id).Remaining_Cooking_Time);returnTmp;endTime;6.3.4StateToAttributeValueMappingThefollowingfunctioncreatesanSTAVMbetweenCookingstateinOvenandLamp StatusinLeft Lamp.Themappingvalueis\Yellow"..invokeState_To_Attribute_Value_Mapping(Ctrpt_Mapping,Oven,Cooking,Left_Lamp,Lamp_Status,``Yellow'')Themappingwasimplementedbyaddingcodetotheactionprocedurethatisexecutedwhentheobjectentersamappedstate.Thefollowingcodeshowsthegeneratedcodefromthemappingde nedabove.withUI.Left_Lamp; 54ImplementationofImplicitBridging ...packageMO.Ovenis...procedureCooking_Action(The_Event:inInstance_Event;Instance:inoutInstances.Identification)isRight_Lamp_Id:UI.Right_Lamp.Instances.Identification;begin....Right_Lamp_Id:=MO_To_UI_Bridge.Oven_To_Right_Lamp_Mapping.Select_One(Instance);UI.Right_Lamp.Instances.Instance_Attributes(Right_Lamp_Id).Lamp_Status:=Ada.Strings.Unbounded.To_Unbounded_String("Yellow");...endCooking_Action;...endMO.Oven;Theimplementationislimitedtoattributesofthestringtype.6.3.5NewStateTransitionToAttributeValueMappingThefollowingfunctioninvocationcreatestwoNSTAVMs.The rstfunctionde- nesthatwhenaCooking Period OvertransitionisperformedwhentheOvenobjectisinthestateCookingtheLamp StatusattributeintheRight Lampissetto\white".ThesecondfunctionsetsthesameattributetothesamevaluebutwhenaCancel Cookingtransitionisperformed..invokeNew_State_Transition_To_Attribute_Value_Mapping(Ctrpt_Object_Mapping,Oven,Cooking,Cooking_Period_Over,Right_Lamp,Lamp_Status,``white'').invokeNew_State_Transition_To_Attribute_Value_Mapping(Ctrpt_Object_Mapping,Oven,Cooking,Cancel_Cooking,Right_Lamp,Lamp_Status,``white'')Thefunctionsabovede nethesamebehaviourinthewaythattheysetthesameattributetothesamevaluewhenleavingthesamestate.ThereforethefollowingfunctionhasbeenimplementedintheArchitecturethatforagivenobjectandstateinvokestheabovefunctionsforallexittransitionsthatarede nedinthestate.Allmappingswillbemappedtothesametargetobjectattributeandwiththesamevalue..functionExit_State_To_Attribute_Value_Mapping(Ctrpt_Object_Mapping, 6.3MappingImplementation55 Oven,Cooking,Right_Lamp,Lamp_Status,``white'')TheimplementationfortheNSTTAVMistoaddcodeinthoseplaceswherethemappedobjectstatereceivesstatetransitions.Thefollowingcodeshowsthegeneratedcodefortheaboveinvokedfunctions.withUI.Right_Lamp;...packageMO.Ovenis...procedureState_Event_Matrix(Instance_State:inoutState;Transition_Event:inInstance_Event;State_Transition_Occurred:outBoolean;Instance:inInstances.Identification)isRight_Lamp_Id:UI.Right_Lamp.Instances.Identification:=MO_To_UI_Bridge.Oven_To_Right_Lamp_Mapping.Select_One(Instance);beginState_Transition_Occurred:=True;caseInstance_StateiswhenAwaiting_Cooking_Request=�caseTransition_Event.NameiswhenStart_Cooking=�Instance_State:=Ensuring_Safe_To_Cook;whenothers=�State_Transition_Occurred:=False;--EventIgnoredendcase;whenCooking=�caseTransition_Event.NameiswhenCooking_Period_Over=�Instance_State:=Signalling_Cooking_Period_Over;UI.Right_Lamp.Instances.Instance_Attributes(Right_Lamp_Id).Lamp_Status:=Ada.Strings.Unbounded.To_Unbounded_String("White");whenCancel_Cooking=�Instance_State:=Cooking_Suspended;UI.Right_Lamp.Instances.Instance_Attributes(Right_Lamp_Id).Lamp_Status:=Ada.Strings.Unbounded.To_Unbounded_String("White");whenothers=�State_Transition_Occurred:=False;--EventIgnoredendcase;endcase;endState_Event_Matrix;...endMO.Oven; 56ImplementationofImplicitBridging 6.4HowtheMappingInformationisStoredTheArchitecture,ormodelcompiler,wereextendedwithfunctionsthatareusedtopopulatethegenerationdatabasewithbridginginformation.Anexampleofafunctionforpopulatingthegenerationdatabase:.functionCounterpart_Object_Mapping.paraminst_refIB#ImplicitBridge.paramstringCtrpt_Mapping_Name.paramstringSrc_Domain_Name.paramstringSrc_Obj_Name.paramstringTgt_Domain_Name.paramstringTgt_Obj_Name.//.createobjectinstanceCtrpt_Obj_MapofBR_COM.assignattr_Ctrpt_Obj_Ref=Ctrpt_Obj_Map.//.//.selectoneSrc_DomainrelatedbyIB-�S_DOM[R109]where(selected.Name==Src_Domain_Name).selectoneTgt_DomainrelatedbyIBe-�S_DOM[R110]where(selected.Name==Tgt_Domain_Name).//.if(emptySrc_Domain).selectoneSrc_DomainrelatedbyIB-�S_DOM[R110]where(selected.Name==Src_Domain_Name).selectoneTgt_DomainrelatedbyIB-�S_DOM[R109]where(selected.Name==Tgt_Domain_Name).endif.//.selectoneSrc_ObjrelatedbySrc_Domain-�S_SS[R1]-�O_OBJ[R2]where(selected.Name==Src_Obj_Name).selectoneTgt_ObjrelatedbyTgt_Domain-�S_SS[R1]-�O_OBJ[R2]where(selected.Name==Tgt_Obj_Name).//.assignCtrpt_Obj_Map.BR_COM_ID="{info.unique_num}".assignCtrpt_Obj_Map.Src_Obj_ID=Src_Obj.Obj_ID.assignCtrpt_Obj_Map.Tgt_Obj_ID=Tgt_Obj.Obj_ID.assignCtrpt_Obj_Map.Mapping_Name=Ctrpt_Mapping_Name.assignCtrpt_Obj_Map.BR_IB_ID=IB.BR_IB_ID.//.endfunction 6.5HowtheMappingInformationisUsed57 6.5HowtheMappingInformationisUsedWhenthecodegenerationbeginsallthebridginginformationmustavailableinthegenerationdatabase.Whende ningaCOMbetweentwoobjectstheabovefunctionmustbeinvoked.AnexampleforcreatingaCOMbetweentheDoorandtheLeft Lampobjects:.invokeCounterpart_Object_Mapping(Impl_Bridge,Door_To_Left_Lamp,MO,Door,UI,Left_Lamp)Theinvocationoftheabovefunctionstoresinformationaboutthismappinginthegenerationdatabase.Whenthecodegenerationbeginsthebridginginformationcreatedabovewillbeavailablebyinvokingthefollowingstatement.selectmanyCtrpt_Objectsrelatedbycurrent_object-�BR_COM[R101].foreachCtrpt_ObjectinCtrpt_Objects{Ctrpt_Object.Name}.Create_Counterpart_To_{curren_object.Name}({Ctrpt_Object.Name}_Id).endfor 58ImplementationofImplicitBridging 6.6MappingLimitationsTheabovediscussedmappinginvocationsareorganizedintotwo lestypesthebridge leandtheserverinterface le.Theserverinterface lecontainsaninterfaceforwhichmappingsthatareavailableforitsclients.Thefunctionsde nedintheinterface leinturninvokethebridgefunctionsintheextendedArchitecture. Figure6.4.Theclientandserver lemodel.Whentheclientwantstocreateamappingitinvokestheappropriatefunctionintheserverinterface.Allinvocationsarede nedinthebridge leandthis leisuniqueforeachbridge.Hencethebridge lecontainstheservicestheclientdomainrequiresfromtheserverdomain.6.6.1TranslationProcessIn gure6.5themodi cationstothetranslationprocesscanbeseen.Thenewcomponentinthe gureisthebridgingmetamodel.Themainimplementationwereperformedinthemodelcompilerwerethearchetypesforimplicitbridgingarede ned. 6.6MappingLimitations59 Figure6.5.Translationprocess. 60ImplementationofImplicitBridging Chapter7EvalutationThischapterevaluatestheimplementationandcomparesittoanearlierimple-mentation.7.1Veri cationofImplementationThefollowingsectionwilldiscusstheresultofthethesisworkandrelateittothegoalsofthework,see1.47.1.1ImplementedMappingsTheMOSwereanalysedanditresultedinasetofmappingsthatallwereimple-mented.7.1.2SystemgenerationTheMOScansuccessfullybegeneratedandcompiledintoarunningsystem.Allimplementedmappingsdescribedinthepreviouschapterareimplementedandworking.7.1.3Veri cationoffunctionalityTheindependencybetweentheparticipatingdomainsiseasytoshowbyremovinganyofthebridging lesduringthetranslation.ToevaluatetheimplicitbridgingfunctionalitynotonlythefunctionalmappingintheMOScanbetakenintocon-sideration.Itisimportanttoshowthatitissimpletoadd/removedomainsin61 62Evalutation thesystem.Thisfunctionalitywasveri edbyusingtheTestdomain.TheTestdomainwasusedintwocases:1.Whenusingalldomains,maptheUIdomainontotheTestdomain2.RemovingtheUIandGUIdomainsandmaptheMWdomainontotheTestdomain.Bothtestcasesweresuccessfulandwasasexecutedwithoutanyproblems.ThisshowedthesimplicitytoaddadomainwithoutchangingthextUML-modelanditalsoshowedthatwhendomainsareindependentofeachothertheycanbere-used. 7.2EarlierImplementation63 7.2EarlierImplementationTherehasbeenanearlierimplementationofimplicitbridgingintheADAmodelcompiler.Thisimplementationonlysupportedonemapping,the\AttributeToMessageWordMapping".Thissolutionhasnotbetakenintoconsiderationwhenimplementingthenewfunctionality.Thisreasonfornotdoingthatisthatitiseasytobecoloredbyanexistingimplementationandthatmakesitharderto ndnewsolutions.7.2.1FunctionalityThefunctionalityoftheAttributeToMessageWordMappingisthatthecurrentvalueofanattributeintheclientdomainismappedtoaninstanceofanobjectinaserverdomain.Theserverobjectisawordinamessage. 7.2.2ComparisonThemaindi erenceisthattheearlierimplementationdoesnothaveanydynamicbehaviour.Themappingsisperformedonanpre-existinginstanceoftheword 64Evalutation object.Thisimplementationcouldbeusefulwhenimplementingmappingtopre-existinginstanceinthenewimplicitbridgingimplementation.Themappingsaredi erentbecauseitusesbridgedelementsinsteadofelementsintheOOAtomapbetween.Otherwisebothapproachesaresimilar. 7.3ImplicitBridgingWork\row65 7.3ImplicitBridgingWork\rowTheimplementationofimplicitbridgingandspeciallythemappingscanbestruc-turedintoanstepbystepwork\row.Thisapproachwasusedwhenimplementingthemappingsdescribedinthisthesis.Step1Thoroughlyanalysethemappingbeforeimplementation.Thisisimportantbecauseoftheoverheadofanimplementation.Step2ExtendtheBridgingMetamodelbyconstructingthehalftablesforthenewmap-ping.Thehalftableasdescribedinchapter3hasuniqueelementsfrombothsourceandtargetdomains.Step3Doanmanualimplementationofthemappingthatistobeimplemented.Thishelpsalotwhencreatinganarchetypegeneratingthesamecode.Step4Writethearchetypebasedontheimplementedcodeinstep3.Step5De neanserverinterfaceusingthenewmappingandgeneratethesystem. 66Evalutation 7.4ErrorManagementAllmappingsshouldhavesomeformoferrormanagement.Themappingsimple-mentedinthisthesisworkincludeserrorcheckingfunctionality.Theerrorchecksthatareperformedarebridgescannotbecreatedtothesamedomain,existenceofmappingelements,typechecking.De ningabridgetothesamedomainshouldnotbepossible.Ifthisisneededthesystemisinneedofare-design.Thismeansthatfunctionalitythatbelongstoonedomainwillbehiddeninthebridge.Tocheckforexistenceofelementsisimportanttoreducethepossibilityforrun-timeerrors.Thisishelpfulifamisspellorsimilarshouldhappedwhendeclaringanmapping.Typecheckingisimportantwhenusingthecounterpartattributemapping.Thismappingonlypermitsalimitednumberoftypecombinations.Whenanerrorisdiscoveredwhenperformingthebridgingthecompilationishaltedandanerrormessageispresentedtotheuser. Chapter8SummaryThischapterwillgiveasummaryofthethesiswork.Itwillalsodiscusshowtheimplicitbridgingtechniquecouldbeusedinfutureimplementations.8.1ConclusionThegoalwiththisthesisworkwastoinvestigateandimplementthetechniqueimplicitbridging.Theimplementedmappingsarefullyfunctionalandthefunc-tionalityhasbeenveri edbyapplyingthemintheMOS.Thethesisworkshowedthatthereissomeoverheadinimplementingamapping.Eachmappingmustbethoroughlyanalystbeforeitisimplemented.Importantthingstotakeintoconsiderationarethatamappingmustsavetimecomparedtothetimeittakestoswitchdomainswhenusingexplicitbridging.Thismeansthatmappingsthatcausesalotofcouplingbetweendomainsshouldhavehigherprioritytobeimplementedcomparedtothosecausinglesscoupling.WhenthethesisworkstartedIhadalmostnoknowledgeaboutthistopicanditwashardtofullyunderstandthecomplexityoftheproblemarea.Thisareaisinthefrontendofsoftwaredevelopmentanditcanbedicultto ndmaterialdescribingthetopic.AftersomeweeksandalotofreadinganddiscussionwithmysupervisorIrealizedthecomplexityoftheproblem.ThedecisiontobuildtheimplementationaroundtheMOSwasveryhelpful.Itresultedinagroundfounda-tionforunderstandingtheproblemandresultedinwhichmappingtoimplement.Thiswasoneoftheimportantstepsthatshowedthatitisveryimportanttohaveagreatknowledgeofthesysteminwitchimplicitbridgingshallbeapplied.Theimplementedmappingsareonlyanexampleofhowthetechniquecouldbeused.Therearemanymoretypesofmappingsthatcouldbeapplied.Especiallymap-pingstopre-existinginstances,aninstanceiscreatedwhenthesystemstarted,wouldbeveryusefulwhenmappingtotheTestdomain.Therearemanymore67 68Summary mappingsthatcouldbeexplainedbuttheimplementedmappingsarefullyfunc-tionaleventhoughsomeofthemshallnotbeused.TheresultingimplementationcancompileseveralxtUML-modelsintoanrunningsystemanduseimplicitbridg-ingtode nethebehaviourbetweenthedomains.Theimplicitbridgingtechniquehasbeenshowntobeveryhelpfulwhenadding/removing/switchingdomain.ThetestdomainwasimplicitlybridgedbothtotheUIandtheMOdomainsusingthesameinterface.Thisshowthatthedomainscanbereusedwithoutchangingthemodels. 8.2FutureWork69 8.2FutureWorkTheimplementedmappingswereallbasedontheMOS.Thesemappingscanbeusedinothersystemsbuttherewillalsoberequirementsfornewmappings.Thisthesisworkisafoundationforimplicitbridgingandwillbeanimportantaidwhenaddingmoremappingsinthefuture.8.2.1FutureMappingsHereisadiscussionaboutsomemappingsthatwerenotimplementedbutfoundtobeveryusefulorextensionsoftheimplementedmappings.Thesemappingproposalsshouldbetakenintoconsiderationwhenextendingtheimplicitbridgingfunctionality.Amappingthatwasdiscoveredtobeveryusefulwastheobjecttopre-existinginstancemapping.Itwouldbeveryusefulwhenforexampleperformingtestononedomain.Thecounterparteventmappingcouldtakeadvantageofthismapping.Relatedtothetestdomaindiscussedinpreviouschapteritwouldeliminatetheneedfortestobjects.InsteadtheonlyneededobjectintheTestdomainistheTestSequenceobject.Itwouldbeapre-existinginstanceandotherobjectscouldmapontoit.ItwouldthenbeenoughtocreatecounterparteventstotheeventsintheTestSequence.Thecounterpartattributemappingshouldincludethepossibilitytohaveancon-vertingfunction.Thepurposeofthefunctionistoconvertthemappedvalueintoavaluethatiswantedbythesourcedomain.AnexampleiswhenanvalueisalatitudevalueitwouldsometimebeusefultoconvertitintoancoordinateThecounterpartobjectmappingshouldsupportunidirectionalfunctionality.8.2.2ErrorManagementIntheimplementationthereisnocheckforcycliccreationofobjects.Thereforeitisuptothedesignerthatde nesthebridgestakesthisproblemintoconsideration.Asimplesolutiontothisproblemistoimportthemappedobjectsintoagraph. 70Summary AppendixABridgeMetamodel71 72BridgeMetamodel 73 74BridgeMetamodel 75 76MicrowaveModel AppendixBMicrowaveModel is housed inR1houses 11illuminatesR2is illuminated by 1is located inR3features 11is accessed viaR4provides access to 11occupiesR5has OvenID : unique_id {I}TubeID : unique_id {R1}LightID : unique_id {R2}BeeperID : unique_id {R3}DoorID : unique_id {R4}TurntableID : unique_id {R5}Current_Oven_Timer_Value : integer {M} TubeID : unique_id {I} LightID : unique_id {I} BeeperID : unique_id {I} DoorID : unique_id {I} TurntableID : unique_id {I} AppendixCUserInterfaceModel77 78UserInterfaceModel 79 80UserInterfaceModel AppendixDTestModel81 82TestModel AppendixEMicrowaveSystem-DomainChart 83 84MicrowaveSystem-DomainChart Bibliography[1]M.BalcerandS.Mellor.ExecutableUML:AFoundationforModelDrivenArchitecture.Addison-Wesley,1stedition,2002.[2]R.Bell.Codegenerationfromobjectmodels.Internetpublication,1998.Lastvisited2007/02/11.[3]T.Cottenier,A.vandenBerg,andT.Elrad.Modelweaving:Bridgingthedividebetweenelaborationistsandtranslationists.2006.[4]B.Davison,T.Ruckle,S.Swanson,andB.Winkelhake.Automatedcodegenerators.Internetpublication,2006.Lastvisited2007/02/11.[5]S.Flint,H.Gardner,andC.Boughton.Executable/translatableumlincom-putingeducation.InACE,2004.[6]S.Flint,H.Gardner,andC.Boughton.Executable/translatableumlincom-putingeducation.InRaymondListerandAlisonL.Young,editors,SixthAustralasianComputingEducationConference(ACE2004),volume30ofCR-PIT,pages69{75,Dunedin,NewZealand,2004.ACS.[7]I.JacobsonJ.RumbaughandG.Booch.TheUni edModelingLanguageReferenceManual.Addison-WesleyProfessional,1stedition,1998.InEnglish.[8]C.McCausland.Implicitbridging:Fromtheoryintopractice.InSMUG2001,2001.[9]C.McCausland.Executableandtranslatableuml.Internetpublication,2003.Lastvisited2004/03/14.[10]S.Mellor.Aframeworkforaspect-orientedmodeling.InUML2003,2003.[11]I.AzimNiazandJ.Tanaka.Anobject-orientedapproachtogeneratejavacodefromumlstatecharts.2005.[12]L.Starr.ExecutableUML:HowtoBuildClassModels.PrenticeHallPTR,1stedition,2002.85 86MicrowaveSystem-DomainChart [13]E.Wedin.xtumlandmdaatsaabboforsdynamics.2005.Lastvisited2007/03/14. Detta dokument hålls tillgängligt på Internet – eller dess framtida ersättare – under en längre tid från publiceringsdatum under förutsättning att inga extra-ordinära omständigheter uppstår. Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstaka kopior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervisning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. All dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säkerheten och tillgängligheten finns det lösningar av teknisk och administrativ Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eform eller i sådant sammanhang som är kränkande för upphovsmannens litterära eller konstnärliga anseende eller egenart. För ytterligare information om Linköping University Electronic Press se http://www.ep.liu.se/ The publishers will keep this document online on the Internet - or its possible replacement - for a considerable time from the date of publication barring exceptional circumstances. The online availability of the document implies a permanent permission for anyone to read, to download, to print out single copies for your own use and to -commercial research aSubsequent transfers of copyright cannot revoke this permission. All other uses of the document are conditional on the consent of the copyright owner. The publisher has taken technical and administrative measures to assure authenticity, According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement. For additional information about the Linköping University Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its WWW home page: