Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

부록 A 예제 모델

본문에서 조각으로 나누어 설명한 배송 드론 모델을 package별로 모았습니다. package는 열다섯 개이고, package 하나가 텍스트 파일 하나에 해당합니다. 순서는 24장에서 설명한 층을 따릅니다. 공통 정의, 구조, 요구사항, 설계안, 평가와 기록의 순서이며, 뒤에 나오는 package가 앞에 나온 package를 import합니다.

package내용관련된 장
DeliveryTypes값의 type과 item7장, 8장
DroneAnnotationsmetadata와 사용자 정의 키워드23장
DroneInterfacesport와 interface10장
DroneCalculationscalculation과 constraint13장
DroneBehavioraction16장, 17장
DronePartspart, 그 사이의 연결, state8장 ~ 10장, 18장, 19장
DeliveryContext운용 환경과 통신8장, 19장
DroneRequirementsrequirement와 derivation14장, 21장
DroneDesign설계안과 satisfy8장, 14장
DroneProductLinevariation과 variant11장
DroneArchitecture논리 구조와 allocation21장
DroneEvaluationuse case, analysis case, verification case20장
FleetRecordsindividual과 snapshot15장
DroneHazards#hazard 키워드로 한 선언23장
DroneViewsview와 viewpoint22장

DeliveryTypes

여러 package가 함께 쓰는 값의 type과, 드론이 운반하거나 주고받는 item의 definition입니다.

package DeliveryTypes {
    private import ScalarValues::*;
    private import ISQ::*;

    attribute def Position {
        attribute latitude : Real;
        attribute longitude : Real;
        attribute altitude : LengthValue;
    }

    enum def FlightMode {
        manual;
        assisted;
        autonomous;
    }

    enum def ParcelSize {
        small;
        medium;
        large;
    }

    item def Parcel {
        attribute mass : MassValue;
        attribute size : ParcelSize;
        attribute destination : Position;
    }

    item def ElectricPower;

    item def FlightCommand {
        attribute target : Position;
        attribute mode : FlightMode;
    }

    item def LandingDetected;

    item def StatusReport {
        attribute position : Position;
        attribute chargeLevel : Real;
    }
}

DroneAnnotations

모델 요소에 붙이는 metadata와, 안전 분석의 용어를 키워드로 쓰기 위한 정의입니다.

package DroneAnnotations {
    private import ScalarValues::*;
    private import Metaobjects::SemanticMetadata;

    metadata def SafetyCritical;

    metadata def ReviewStatus {
        attribute approved : Boolean;
        attribute reviewer : String;
    }

    occurrence def Hazard {
        attribute severity : Natural;
    }

    occurrence hazards : Hazard[*] nonunique;

    metadata def <hazard> HazardMetadata :> SemanticMetadata {
        :>> baseType = hazards meta SysML::Usage;
    }
}

DroneInterfaces

part가 서로 만나는 지점인 port와, port를 잇는 interface의 definition입니다.

package DroneInterfaces {
    private import ISQ::*;
    private import DeliveryTypes::*;

    port def PowerPort {
        out item power : ElectricPower;
        attribute voltage : ElectricPotentialValue;
    }

    port def CommandPort {
        out item command : FlightCommand;
        in item status : StatusReport;
    }

    interface def PowerInterface {
        end supplier : PowerPort;
        end consumer : ~PowerPort;
    }

    interface def CommandLink {
        end sender : CommandPort;
        end receiver : ~CommandPort;
    }
}

DroneCalculations

여러 곳에서 다시 쓰는 계산식과 조건입니다.

package DroneCalculations {
    private import ISQ::*;

    calc def FlightTime {
        in capacity : EnergyValue;
        in averagePower : PowerValue;
        return : DurationValue;

        capacity / averagePower
    }

    calc def Range {
        in capacity : EnergyValue;
        in averagePower : PowerValue;
        in cruiseSpeed : SpeedValue;
        return : LengthValue;

        attribute flightTime : DurationValue = FlightTime(capacity, averagePower);
        flightTime * cruiseSpeed
    }

    constraint def MassLimit {
        in mass : MassValue;
        in limit : MassValue;

        mass <= limit
    }
}

DroneBehavior

드론이 하는 일입니다. 배송은 이륙, 순항, 하역, 귀환의 네 단계로 이루어집니다.

package DroneBehavior {
    private import ISQ::*;
    private import SI::*;
    private import DeliveryTypes::*;

    action def TakeOff {
        in targetAltitude : LengthValue;
    }

    action def Cruise {
        in destination : Position;
        out arrival : Position;
    }

    action def DropOff {
        in item cargo : Parcel;
        in location : Position;
    }

    action def ReturnHome {
        in destination : Position;
    }

    action def PreflightCheck {
        first start;
        then fork;
            then checkBattery;
            then checkRotors;
            then checkRadio;

        action checkBattery;
            then allChecked;
        action checkRotors;
            then allChecked;
        action checkRadio;
            then allChecked;

        join allChecked;
        then done;
    }

    action def DeliverParcel {
        in item parcel : Parcel;
        in home : Position;

        action takeOff : TakeOff {
            in targetAltitude = 100 [m];
        }
        then action cruise : Cruise {
            in destination = parcel.destination;
        }
        then action dropOff : DropOff {
            in cargo = parcel;
            in location = cruise.arrival;
        }
        then action returnHome : ReturnHome {
            in destination = home;
        }
    }
}

DroneParts

드론을 이루는 부분의 definition과, 그 부분들이 드론 안에서 이어지는 방식입니다.

package DroneParts {
    private import ScalarValues::*;
    private import ISQ::*;
    private import SI::*;
    private import DeliveryTypes::*;
    private import DroneInterfaces::*;
    private import DroneCalculations::*;
    private import DroneBehavior::*;
    private import DroneAnnotations::*;

    part def Airframe {
        attribute mass : MassValue;
    }

    part def Battery {
        @SafetyCritical;

        attribute capacity : EnergyValue;
        attribute mass : MassValue;
        attribute chargeLevel : Real;
        port powerOut : PowerPort;

        assert constraint chargeRange { chargeLevel >= 0.0 and chargeLevel <= 1.0 }
    }

    part def HighCapacityBattery :> Battery;

    part def Motor {
        attribute ratedPower : PowerValue;
    }

    part def Rotor {
        attribute diameter : LengthValue;
        part motor : Motor;
    }

    part def FlightController {
        @SafetyCritical;
        @ReviewStatus {
            approved = true;
            reviewer = "김지우";
        }

        port powerIn : ~PowerPort;
        port commandIn : ~CommandPort;
    }

    part def Radio {
        port uplink : ~CommandPort;
        port commandOut : CommandPort;
    }

    part def Camera;

    part def Drone {
        attribute emptyMass : MassValue;
        attribute maxPayload : MassValue;
        attribute hoverPower : PowerValue;
        attribute cruiseSpeed : SpeedValue;
        derived attribute maxTakeoffMass : MassValue = emptyMass + maxPayload;
        derived attribute endurance : DurationValue = FlightTime(battery.capacity, hoverPower);
        derived attribute range : LengthValue = Range(battery.capacity, hoverPower, cruiseSpeed);

        part airframe : Airframe;
        part battery : Battery;
        part rotors : Rotor[4..8];
        part flightController : FlightController;
        part radio : Radio;
        ref item cargo : Parcel[0..1];

        perform action deliver : DeliverParcel;

        attribute position : Position;
        attribute missionCount : Natural := 0;

        exhibit state operation {
            entry; then standby;

            state standby;
            accept FlightCommand via commandPort
                if battery.chargeLevel >= 0.3
                do assign missionCount := missionCount + 1
                then flying;
            accept when battery.chargeLevel < 0.3
                then charging;

            state flying {
                entry action spinUpRotors;
                do deliver;
                exit action stopRotors;
            }
            accept LandingDetected
                do send new StatusReport(position, battery.chargeLevel) via commandPort
                then standby;

            state charging;
            accept after 40 [min]
                then standby;
        }

        event occurrence commandReceived;
        event occurrence reportSent;

        port commandPort : ~CommandPort;
        bind commandPort = radio.uplink;

        interface powerLine : PowerInterface
            connect battery.powerOut to flightController.powerIn;
        interface commandLine : CommandLink
            connect radio.commandOut to flightController.commandIn;
        connection rotorControl
            connect [1] flightController to [4..8] rotors;
        flow of ElectricPower
            from battery.powerOut.power to flightController.powerIn.power;
    }

    part def Quadcopter :> Drone {
        part redefines rotors[4];
    }

    part def Hexacopter :> Drone {
        part redefines rotors[6];
    }
}

DeliveryContext

드론이 운용되는 환경입니다. 드론 밖에 있는 시설과 사람을 정의하고, 이들과 드론을 한 part 안에 모읍니다.

package DeliveryContext {
    private import DroneParts::*;
    private import DroneInterfaces::*;
    private import DeliveryTypes::*;

    part def ChargingStation {
        item spareBatteries : Battery[0..4];
        ref part dockedDrone : Drone[0..1];
    }

    part def GroundStation {
        port commandPort : CommandPort;

        event occurrence commandSent;
        event occurrence reportReceived;

        action dispatch {
            in target : Position;

            send new FlightCommand(target, FlightMode::autonomous) via commandPort;
            then accept report : StatusReport via commandPort;
        }
    }

    part def Operator;

    part def Customer;

    part def DeliveryService {
        part drones : Drone[1..*];
        part groundStation : GroundStation;
        part chargingStations : ChargingStation[1..*];
        part operators : Operator[1..*];

        interface commandLinks : CommandLink
            connect [1] groundStation.commandPort to [1..*] drones.commandPort;

        message command of FlightCommand
            from groundStation.commandSent to drones.commandReceived;
        message report of StatusReport
            from drones.reportSent to groundStation.reportReceived;
    }
}

DroneRequirements

드론이 충족해야 하는 요구사항입니다. definition은 요구사항의 틀이고, droneRequirements가 값을 정한 요구사항의 묶음입니다.

package DroneRequirements {
    private import ISQ::*;
    private import SI::*;
    private import DroneParts::*;
    private import RequirementDerivation::*;

    requirement def PayloadRequirement {
        doc /* 드론은 정해진 질량 이상의 화물을 운반할 수 있어야 한다. */

        subject drone : Drone;
        attribute requiredPayload : MassValue;

        require constraint { drone.maxPayload >= requiredPayload }
    }

    requirement def EnduranceRequirement {
        doc /* 화물의 질량이 최대 적재 질량 이하이면,
             * 드론은 정해진 시간 이상 비행할 수 있어야 한다. */

        subject drone : Drone;
        attribute cargoMass : MassValue;
        attribute requiredEndurance : DurationValue;

        assume constraint { cargoMass <= drone.maxPayload }
        require constraint { drone.endurance >= requiredEndurance }
    }

    requirement def TakeoffMassRequirement {
        doc /* 드론의 최대 이륙 질량은 한도를 넘지 않아야 한다. */

        subject drone : Drone;
        attribute massLimit : MassValue;

        require constraint { drone.maxTakeoffMass <= massLimit }
    }

    requirement droneRequirements {
        subject drone : Drone;

        requirement <'REQ-01'> payload : PayloadRequirement {
            attribute :>> requiredPayload = 2.0 [kg];
        }

        requirement <'REQ-02'> endurance : EnduranceRequirement {
            attribute :>> cargoMass = 2.0 [kg];
            attribute :>> requiredEndurance = 20 [min];
        }

        requirement <'REQ-03'> takeoffMass : TakeoffMassRequirement {
            attribute :>> massLimit = 9 [kg];
        }
    }

    requirement <'REQ-04'> batteryCapacity {
        doc /* 배터리 용량은 400 Wh 이상이어야 한다. */

        subject battery : Battery;

        require constraint { battery.capacity >= 400 [W*h] }
    }

    #derivation connection {
        end #original ::> droneRequirements.endurance;
        end #derive ::> batteryCapacity;
    }
}

DroneDesign

검토할 설계안입니다. Quadcopter가 열어 둔 값을 확정하고, 이 설계안이 요구사항을 충족한다고 주장합니다.

package DroneDesign {
    private import ISQ::*;
    private import SI::*;
    private import DroneParts::*;
    private import DroneRequirements::*;

    part deliveryDrone : Quadcopter {
        attribute :>> emptyMass = 5.2 [kg];
        attribute :>> maxPayload = 2.5 [kg];
        attribute :>> hoverPower = 1200 [W];
        attribute :>> cruiseSpeed = 15 [m/s];

        part :>> battery : HighCapacityBattery {
            attribute :>> capacity = 600 [W*h];
            attribute :>> mass = 1.8 [kg];
        }

        part :>> rotors {
            attribute :>> diameter = 380 [mm];
            part :>> motor {
                attribute :>> ratedPower = 350 [W];
            }
        }
    }

    satisfy droneRequirements by deliveryDrone;
}

DroneProductLine

제품군입니다. 고를 수 있는 자리를 variation으로 표시하고, 그 가운데 한 구성을 골라 둡니다.

package DroneProductLine {
    private import DroneParts::*;

    part def ConfigurableDrone :> Drone {
        variation part :>> battery {
            variant part standardBattery : Battery;
            variant part extendedBattery : HighCapacityBattery;
        }

        variation part :>> rotors {
            variant part quad[4];
            variant part hexa[6];
        }

        assert constraint {
            rotors == rotors::hexa implies battery == battery::extendedBattery
        }
    }

    part longRangeDrone : ConfigurableDrone {
        part :>> battery = battery::extendedBattery;
        part :>> rotors = rotors::hexa;
    }
}

DroneArchitecture

구현 방식을 정하지 않은 논리 구조와, 그 구조를 설계안의 부품에 배정하는 allocation입니다.

package DroneArchitecture {
    private import DroneParts::*;
    private import DroneDesign::*;

    part def LogicalDrone {
        part energyStorage;
        part flightControl;
        part communication;
    }

    part logicalDrone : LogicalDrone;

    allocation def LogicalToPhysical {
        end part logical : LogicalDrone;
        end part physical : Drone;

        allocate logical.energyStorage to physical.battery;
        allocate logical.flightControl to physical.flightController;
        allocate logical.communication to physical.radio;
    }

    allocation droneAllocation : LogicalToPhysical
        allocate logical ::> logicalDrone to physical ::> deliveryDrone;
}

DroneEvaluation

설계를 평가하는 case입니다. 배송 서비스의 use case, 체공 시간 해석, 두 설계안의 비교, 적재 능력 시험을 담습니다.

package DroneEvaluation {
    private import ScalarValues::*;
    private import ISQ::*;
    private import SI::*;
    private import DroneParts::*;
    private import DroneCalculations::*;
    private import DeliveryContext::*;
    private import DroneRequirements::*;
    private import DroneDesign::*;
    private import DroneProductLine::*;

    use case def RequestDelivery {
        subject service : DeliveryService;
        actor customer : Customer;
    }

    use case def DispatchDrone {
        subject service : DeliveryService;
        actor operator : Operator;
    }

    use case def ReceiveParcel {
        subject service : DeliveryService;
        actor customer : Customer;
    }

    use case def DeliverToCustomer {
        subject service : DeliveryService;
        actor customer : Customer;
        actor operator : Operator;
        objective {
            doc /* 고객이 주문한 화물을 지정한 위치에서 받는다. */
        }

        first start;
        then include use case request : RequestDelivery;
        then include use case dispatch : DispatchDrone;
        then include use case receive : ReceiveParcel;
        then done;
    }

    analysis def EnduranceAnalysis {
        subject drone : Drone;
        objective {
            doc /* 드론의 체공 시간을 구한다. */
        }

        return endurance : DurationValue =
            FlightTime(drone.battery.capacity, drone.hoverPower);
    }

    analysis deliveryDroneEndurance : EnduranceAnalysis {
        subject drone = deliveryDrone;
    }

    analysis droneTradeStudy : TradeStudies::TradeStudy {
        subject : Drone = (deliveryDrone, longRangeDrone);
        objective : TradeStudies::MaximizeObjective;

        calc :>> evaluationFunction {
            in part candidate : Drone :>> alternative;
            return :>> result : Real = candidate.range / 1 [km];
        }

        return part :>> selectedAlternative : Drone;
    }

    part def TestRig;

    verification def PayloadLiftTest {
        private import VerificationCases::*;

        subject testDrone : Drone;
        actor rig : TestRig;
        objective {
            verify droneRequirements.payload;
        }
        metadata VerificationMethod {
            kind = VerificationMethodKind::test;
        }

        action loadWeights;
        then action measureLift {
            out liftedMass : MassValue;
        }

        return verdict : VerdictKind = PassIf(measureLift.liftedMass >= 2.0 [kg]);
    }

    verification payloadLiftTest : PayloadLiftTest {
        subject testDrone = deliveryDrone;
    }
}

FleetRecords

특정한 기체 한 대의 기록입니다. 일련번호 42번 기체가 출발한 시점과 돌아온 시점의 배터리 잔량을 적습니다.

package FleetRecords {
    private import DroneParts::*;

    individual part def Drone42 :> Quadcopter;

    individual part drone42 : Drone42 {
        snapshot part atDispatch {
            part :>> battery {
                attribute :>> chargeLevel = 1.0;
            }
        }
        snapshot part atReturn {
            part :>> battery {
                attribute :>> chargeLevel = 0.35;
            }
        }

        first atDispatch then atReturn;
    }
}

DroneHazards

DroneAnnotations가 정의한 #hazard 키워드로 선언한 위험 요인입니다.

package DroneHazards {
    private import DroneAnnotations::*;

    #hazard occurrence def MidAirCollision {
        attribute :>> severity = 4;
    }

    #hazard occurrence def BatteryFire {
        attribute :>> severity = 3;
    }

    #hazard occurrence lossOfLink;
}

DroneViews

모델에서 필요한 부분을 골라 보여 주는 view입니다. 분해 구조를 보려는 관심사, 그 관심사에 답하는 viewpoint, viewpoint를 충족하는 view를 담습니다.

package DroneViews {
    private import Views::*;

    part def Engineer;

    concern def StructureConcern {
        doc /* 시스템이 어떤 부분으로 이루어지는지 알고 싶다. */

        subject model;
        stakeholder engineer : Engineer;
    }

    viewpoint def StructureViewpoint {
        frame concern structure : StructureConcern;

        require constraint {
            doc /* view는 지정한 part에서 시작하는 분해 구조를 계층으로 보여 주어야 한다. */
        }
    }

    view def PartStructureView {
        viewpoint structure : StructureViewpoint;

        filter @SysML::PartUsage;
        render asTreeDiagram;
    }

    view deliveryDroneStructure : PartStructureView {
        expose DroneDesign::deliveryDrone::**;
    }

    view deliveryDroneWiring : StandardViewDefinitions::InterconnectionView {
        expose DroneDesign::deliveryDrone::**;
    }
}