// Independent worked listings. Load this chapter with vocabulary.sysml, not with other chapters. package Lappendixg_01 { private import CoffeeVocabulary::*; // ANCHOR: listing-1 package CrossExample { part def Device { part connectingHub : Hub[1]; } part def Hub { part connectedDevice : Device[*]; } connection def DeviceToHub { end part device : Device crosses hub.connectedDevice; end part hub : Hub crosses device.connectingHub; } } // ANCHOR_END: listing-1 } package Lappendixg_02 { private import CoffeeVocabulary::*; // ANCHOR: listing-2 package ResultExample { calc def RectangleArea { in width : ScalarValues::Real; in height : ScalarValues::Real; return area : ScalarValues::Real; width * height } } // ANCHOR_END: listing-2 } package Lappendixg_03 { private import CoffeeVocabulary::*; // ANCHOR: listing-3 package MessageExample { attribute def ControlSignal; part def Vehicle { part controller { event occurrence sendControl; } part engine { event occurrence receiveControl; } message throttleCmd of ControlSignal from controller.sendControl to engine.receiveControl; } } // ANCHOR_END: listing-3 } package Lappendixg_04 { private import CoffeeVocabulary::*; // ANCHOR: listing-4 package FlowPair { item def Fuel; part def FuelTank { out fuelOut : Fuel; } part def Engine { in fuelIn : Fuel; } flow def FuelFlow { ref item :>> payload : Fuel; end tank : FuelTank; end eng : Engine; } part def Vehicle { part tank : FuelTank; part eng : Engine; flow supply : FuelFlow from tank.fuelOut to eng.fuelIn; } } // ANCHOR_END: listing-4 }