{
 "$schema": "../../lib/umlimator.schema.json",
 "schemaVersion": 2,
 "title": "Block definition diagram",
 "root": "ebike-blocks",
 "nodes": [
  { "id": "ebike-system", "type": "uml.Package", "label": "EBikeSystem" },
  { "id": "rental-vehicle", "type": "sysml.Block", "label": "RentalVehicle", "parent": "ebike-system",
   "members": [
    { "id": "rental-vehicle.fleetNumber", "type": "sysml.ValueProperty", "label": "fleetNumber", "props": { "valueType": "String" } },
    { "id": "rental-vehicle.checkOut", "type": "uml.Operation", "label": "checkOut", "props": { "returnType": "Boolean" } }
   ] },
  { "id": "ebike", "type": "sysml.Block", "label": "EBike", "parent": "ebike-system",
   "members": [
    { "id": "ebike.battery", "type": "sysml.PartProperty", "label": "battery", "props": { "valueType": "Battery", "multiplicity": "1" } },
    { "id": "ebike.motor", "type": "sysml.PartProperty", "label": "motor", "props": { "valueType": "Motor", "multiplicity": "1" } },
    { "id": "ebike.controller", "type": "sysml.PartProperty", "label": "controller", "props": { "valueType": "Controller", "multiplicity": "1" } },
    { "id": "ebike.lights", "type": "sysml.PartProperty", "label": "lights", "props": { "valueType": "Light", "multiplicity": "2" } },
    { "id": "ebike.dock", "type": "sysml.ReferenceProperty", "label": "dock", "props": { "valueType": "Dock", "multiplicity": "0..1" } },
    { "id": "ebike.capacity", "type": "sysml.ValueProperty", "label": "batteryCapacity", "props": { "valueType": "Energy" } },
    { "id": "ebike.share", "type": "sysml.ValueProperty", "label": "usableShare", "props": { "valueType": "Real", "default": "0.9" } },
    { "id": "ebike.range", "type": "sysml.ValueProperty", "label": "ecoRange", "props": { "valueType": "Distance" } },
    { "id": "ebike.usable", "type": "sysml.ConstraintProperty", "label": "usable", "props": { "valueType": "UsableEnergy" } },
    { "id": "ebike.eco", "type": "sysml.ConstraintProperty", "label": "eco", "props": { "valueType": "RangeEquation" } },
    { "id": "ebike.charge", "type": "sysml.Port", "label": "charge", "props": { "kind": "proxy", "valueType": "ChargeInterface" } }
   ] },
  { "id": "battery", "type": "sysml.Block", "label": "Battery", "parent": "ebike-system",
   "members": [
    { "id": "battery.capacity", "type": "sysml.ValueProperty", "label": "capacity", "props": { "valueType": "Energy" } },
    { "id": "battery.cellVoltage", "type": "sysml.ValueProperty", "label": "cellVoltage", "props": { "valueType": "Voltage", "multiplicity": "10" } },
    { "id": "battery.charge", "type": "sysml.Port", "label": "charge", "props": { "kind": "proxy", "valueType": "ChargeInterface" } },
    { "id": "battery.bus", "type": "sysml.Port", "label": "bus", "props": { "kind": "full", "valueType": "PowerBus" } },
    { "id": "battery.dc", "type": "sysml.FlowProperty", "label": "dc", "props": { "valueType": "DCPower", "direction": "out" } }
   ] },
  { "id": "motor", "type": "sysml.Block", "label": "Motor", "parent": "ebike-system",
   "members": [
    { "id": "motor.ratedPower", "type": "sysml.ValueProperty", "label": "ratedPower", "props": { "valueType": "Power", "default": "250" } },
    { "id": "motor.phases", "type": "sysml.Port", "label": "phases" },
    { "id": "motor.current", "type": "sysml.FlowProperty", "label": "phaseCurrent", "props": { "valueType": "Current", "direction": "in" } }
   ] },
  { "id": "controller", "type": "sysml.Block", "label": "Controller", "parent": "ebike-system",
   "members": [
    { "id": "controller.supply", "type": "sysml.Port", "label": "supply" },
    { "id": "controller.drive", "type": "sysml.Port", "label": "drive" },
    { "id": "controller.frames", "type": "sysml.FlowProperty", "label": "frames", "props": { "valueType": "CanFrame", "direction": "inout" } },
    { "id": "controller.setAssistLevel", "type": "uml.Operation", "label": "setAssistLevel", "props": { "parameters": [ { "name": "level", "valueType": "Integer" } ] } }
   ] },
  { "id": "light", "type": "sysml.Block", "label": "Light", "parent": "ebike-system",
   "members": [
    { "id": "light.power", "type": "sysml.Port", "label": "power" }
   ] },
  { "id": "dock", "type": "sysml.Block", "label": "Dock", "parent": "ebike-system",
   "members": [
    { "id": "dock.charge", "type": "sysml.Port", "label": "charge", "props": { "kind": "proxy", "valueType": "~ChargeInterface" } }
   ] },
  { "id": "power-bus", "type": "sysml.Block", "label": "PowerBus", "parent": "ebike-system" },
  { "id": "charge-interface", "type": "sysml.InterfaceBlock", "label": "ChargeInterface", "parent": "ebike-system",
   "members": [
    { "id": "charge-interface.dc", "type": "sysml.FlowProperty", "label": "dc", "props": { "valueType": "DCPower", "direction": "in" } },
    { "id": "charge-interface.soc", "type": "sysml.FlowProperty", "label": "stateOfCharge", "props": { "valueType": "Percent", "direction": "out" } },
    { "id": "charge-interface.handshake", "type": "uml.Operation", "label": "handshake", "props": { "returnType": "Boolean" } }
   ] },
  { "id": "usable-energy", "type": "sysml.ConstraintBlock", "label": "UsableEnergy", "parent": "ebike-system", "props": { "constraint": "usable = capacity * share" },
   "members": [
    { "id": "usable-energy.usable", "type": "sysml.ConstraintParameter", "label": "usable", "props": { "valueType": "Energy" } },
    { "id": "usable-energy.capacity", "type": "sysml.ConstraintParameter", "label": "capacity", "props": { "valueType": "Energy" } },
    { "id": "usable-energy.share", "type": "sysml.ConstraintParameter", "label": "share", "props": { "valueType": "Real" } }
   ] },
  { "id": "range-equation", "type": "sysml.ConstraintBlock", "label": "RangeEquation", "parent": "ebike-system", "props": { "constraint": "range = energy / consumption" },
   "members": [
    { "id": "range-equation.usable", "type": "sysml.ConstraintProperty", "label": "energyOf", "props": { "valueType": "UsableEnergy" } },
    { "id": "range-equation.range", "type": "sysml.ConstraintParameter", "label": "range", "props": { "valueType": "Distance" } },
    { "id": "range-equation.energy", "type": "sysml.ConstraintParameter", "label": "energy", "props": { "valueType": "Energy" } },
    { "id": "range-equation.consumption", "type": "sysml.ConstraintParameter", "label": "consumption", "props": { "valueType": "Real" } }
   ] },
  { "id": "energy", "type": "sysml.ValueType", "label": "Energy", "parent": "ebike-system", "props": { "unit": "Wh", "quantityKind": "energy" } },
  { "id": "voltage", "type": "sysml.ValueType", "label": "Voltage", "parent": "ebike-system", "props": { "unit": "V", "quantityKind": "voltage" } },
  { "id": "distance", "type": "sysml.ValueType", "label": "Distance", "parent": "ebike-system", "props": { "unit": "km", "quantityKind": "length" } }
 ],
 "edges": [
  { "id": "ebike-is-rental-vehicle", "type": "uml.Generalization", "from": "ebike", "to": "rental-vehicle" },
  { "id": "ebike-battery", "type": "uml.Association", "from": "ebike", "to": "battery", "props": { "ends": { "from": { "aggregation": "composite", "multiplicity": "1" }, "to": { "role": "battery", "multiplicity": "1" } } } },
  { "id": "ebike-motor", "type": "uml.Association", "from": "ebike", "to": "motor", "props": { "ends": { "from": { "aggregation": "composite", "multiplicity": "1" }, "to": { "role": "motor", "multiplicity": "1" } } } },
  { "id": "ebike-controller", "type": "uml.Association", "from": "ebike", "to": "controller", "props": { "ends": { "from": { "aggregation": "composite", "multiplicity": "1" }, "to": { "role": "controller", "multiplicity": "1" } } } },
  { "id": "ebike-lights", "type": "uml.Association", "from": "ebike", "to": "light", "props": { "ends": { "from": { "aggregation": "composite", "multiplicity": "1" }, "to": { "role": "lights", "multiplicity": "2" } } } },
  { "id": "ebike-dock", "type": "uml.Association", "from": "ebike", "to": "dock", "props": { "ends": { "from": { "multiplicity": "0..*" }, "to": { "role": "dock", "multiplicity": "0..1", "navigable": true } } } },
  { "id": "dock-uses-charge-interface", "type": "uml.Dependency", "from": "dock", "to": "charge-interface", "props": { "stereotypes": ["use"] } },
  { "id": "battery-uses-bus", "type": "uml.Dependency", "from": "battery", "to": "power-bus", "label": "feeds" }
 ],
 "views": [
  { "id": "ebike-blocks", "diagram": "sysml.block-definition", "title": "A city e-bike's blocks", "parent": null, "direction": "down", "subject": "ebike-system",
   "nodeIds": ["rental-vehicle", "ebike", "battery", "motor", "controller", "light", "dock", "power-bus", "charge-interface", "usable-energy", "range-equation", "energy", "voltage", "distance"],
   "edges": ["ebike-is-rental-vehicle", "ebike-battery", "ebike-motor", "ebike-controller", "ebike-lights", "ebike-dock", "dock-uses-charge-interface", "battery-uses-bus"] },
  { "id": "ebike-blocks-right", "diagram": "sysml.block-definition", "title": "The same blocks, laid out right", "parent": "ebike-blocks", "direction": "right", "subject": "ebike-system",
   "nodeIds": ["rental-vehicle", "ebike", "battery", "motor", "controller", "light", "dock", "power-bus", "charge-interface", "usable-energy", "range-equation", "energy", "voltage", "distance"],
   "edges": ["ebike-is-rental-vehicle", "ebike-battery", "ebike-motor", "ebike-controller", "ebike-lights", "ebike-dock", "dock-uses-charge-interface", "battery-uses-bus"] }
 ]
}
