Learn › Coming from another tool

Learn

Coming from another tool

You may already describe systems with SysML v2, Capella, an interface spreadsheet, a requirements tool, or state machines written by hand in C. This page puts each one beside arche-lang. Each section has a table of words, one small example, and what arche-lang does not do that you may expect.

In every case, the model is text: .arche files, checked by archec. The diagrams are drawn from the text. You can edit in a diagram, in VS Code or in the Arche app, and the change is written back into the text.

SysML v2#

SysML v2 words in arche-lang#

In SysML v2 you write In arche-lang it is
package project (the outer one), package (inner ones)
A::B, import A::*;, import A::B; the same: A::B, import A::*, import A::B (packages)
part w : Wheel[2..4];, [1..*] part w: Wheel[2..4], [1..*]: a run uses the most, or the least when there is no most
part def component
part (a usage) part in a system
port def, port port-type, a port: in, out or inout
item def message
attribute def, enum def struct or type, enum
attribute in a part var
connect a.p to b.q a link: a.p -> b.q
exhibit state, transition … accept … then states { … }, A -> B on M [guard]
requirement, satisfy R by x, verify R requirement, satisfies R on the component, verifies R in a test case

The full table is in importing a SysML v2 model.

The same model in both#

A button switches a heater on and off. In SysML v2:

package Kettle {
  item def Press;
  port def ButtonPort { out item press : Press; }
  part def Button { port click : ButtonPort; }
  part def Heater {
    port cmd : ~ButtonPort;
    attribute power = 2000 [W];
    exhibit state heating {
      entry; then Off;
      state Off;
      state On;
      transition first Off accept Press then On;
      transition first On accept Press then Off;
    }
  }
  part def Kitchen {
    part button : Button;
    part heater : Heater;
    connect button.click to heater.cmd;
  }
  part kitchen : Kitchen;
}

archec import kettle.sysml -o kettle.arche writes this (its columns aligned here):

project "Kettle"
message Press
port-type ButtonPort

component Button {
  out click: ButtonPort sends Press
}

component Heater {
  in cmd:    ButtonPort receives Press
  var power: float64    = 2000 unit W
  states {
    state Off
    state On
    Off -> On on Press
    On -> Off on Press
  }
}

system Kitchen {
  part button: Button
  part heater: Heater
  button.click -> heater.cmd
}
Diagram: Kitchen
What archec draws from this code: Kitchen
Try it

The other way, archec sysml main.arche writes the architecture as SysML v2 text. archec api serve shows the model, read-only, through the SysML v2 API (the commands).

What arche-lang does not do for a SysML v2 user#

  • There is no SysML graphical notation. The diagrams are arche-lang's own: blocks, states, sequences.
  • The import does not read expressions or action steps. Use cases, calcs, constraints, analysis, allocations and views become comments, each with a note. See its limits.
  • archec sysml writes the architecture. It is not a full round trip of a SysML v2 model.
  • A name is known by its package, not by visibility: there is no private or public member, and an import brings names in for its package or its file, never further. A name two packages declare has its package in its id in the Arche project and the generated code (front::Sensor is Front_Sensor).
  • A name declared outside any package cannot be named from inside a package that declares the same name: there is no root qualifier ($::Sensor).

Capella#

Capella words in arche-lang#

In Capella you have In arche-lang it is
a level: Operational, System, Logical, Physical, EPBS a layer on each component
a component (logical, physical, a node) component, placed as a part in a system
a component port and a component exchange a port, and a link a.p -> b.q
an exchange item message
a function, its allocation, its ports system-function with allocated and in/out ports
a functional exchange function-flow a.p -> b.q, with carries
a functional chain, its control nodes function-chain, with step or { kind or }
a capability, what it involves use-case with involves
a property value a typed property (mass 1.5, prop certified = true), defined by property
a requirement requirement
a scenario scenario

The same model in both#

A component of the System level, and a function allocated to it:

layer system "System analysis"

message ORDER "Order" { speed: float32 }

component Pilot "Pilot" {
  layer system
  out stick: can sends ORDER
}

component Drone "Drone" {
  layer system
  in order: can receives ORDER
}

system Mission "Mission" {
  part pilot: Pilot
  part drone: Drone
  pilot.stick -> drone.order
}

system-function steer "Steer" {
  allocated Mission.drone
  in order "Order" receives ORDER
}
Diagram: Mission
What archec draws from this code: Mission
Try it

archec capella main.arche -o project.zip writes a Capella 6.1 project, checked against Capella's metamodel. archec capella model.capella -o model/ reads one back. See Capella.

What arche-lang does not do for a Capella user#

  • It works with Capella 6.1 files. It does not run inside Capella.
  • An export lists what Capella has no place for, such as a derives between two requirements.
  • On a round trip, an unchanged model keeps all its Capella ids. An element you change so that it no longer sits in the same place, with the same name and the same links, gets a new id. See Round trip.
  • The diagrams are not Capella's. The import keeps the .aird layout for the Arche app's canvas.

An interface spreadsheet (ICD)#

ICD words in arche-lang#

In the spreadsheet In arche-lang it is
a row of the message list a message
a signal: name, type, unit, range a field: speed: float32 unit km/h range 0...250
the cycle time period 10ms on the message
the start bit, length, factor, offset at, bits, scale, offset on the field
the sender and the receivers out … sends M and in … receives M ports, and a link
an interface, a connector interface, a port that provides or requires it

The same rows in both#

Message Signal Type Unit Range Cycle From To
WHEEL_SPEED speed float32 km/h 0–250 10 ms Wheel sensor Brake ECU
WHEEL_SPEED valid bool 10 ms Wheel sensor Brake ECU
message WHEEL_SPEED "Wheel speed" {
  period 10ms
  speed: float32 unit km/h range 0...250
  valid: bool
}

interface WheelData "Wheel data" {
  messages WHEEL_SPEED
}

component WheelSensor "Wheel sensor" {
  out wheel: can provides WheelData sends WHEEL_SPEED
}

component BrakeEcu "Brake ECU" {
  in wheel: can requires WheelData receives WHEEL_SPEED
}

system Car "Car" {
  part sensor: WheelSensor
  part brake:  BrakeEcu
  sensor.wheel -> brake.wheel { latency 2ms }
}
Diagram: Car
What archec draws from this code: Car
Try it

archec checks that the other end of each link receives what one end sends. archec gen main.arche --target icd writes the ICD back as Markdown: the ports, the links, each message's fields and its byte layout (the icd target). --target dbc writes a CAN DBC, and --target wire the codecs.

What arche-lang does not do for an ICD user#

  • It does not read the spreadsheet. A CAN DBC file can be imported (a CAN DBC); a message list in Excel has to be written as message blocks.
  • archec import table reads a CSV file, but its rows become elements of a kind, not messages. An .xlsx workbook is not read.
  • The ICD it writes is Markdown, not a spreadsheet.

A requirements tool: DOORS or Polarion#

Requirements words in arche-lang#

In the requirements tool In arche-lang it is
a requirement object, its ID and text requirement SYS-REQ-42 "Title" { text "…" }
priority, verification method priority high, method test
a custom attribute attr status = "approved"
a "satisfied by" link satisfies SYS-REQ-42, written on the component
a "verified by" link verifies SYS-REQ-42, written in the test case
a parent requirement derives, refines
a baseline, a sign-off archec baseline, archec approve

The same requirement in both#

In the tool, an object with its attributes and links:

ID Text Priority Method Satisfied by Verified by
SYS-REQ-42 The brake controller shall start braking within 20 ms of a stop command. High Test Brake controller TC-STOP-01

In arche-lang, each link is written on the thing that meets or checks the requirement:

requirement SYS-REQ-42 "Stop on command" {
  text "The brake controller shall start braking within 20 ms of a stop command."
  priority high
  method test
  attr status = "approved"
}

message STOP_CMD: bool "Stop"

component Panel "Panel" {
  out stop: can sends STOP_CMD
}

component Brake "Brake controller" {
  satisfies SYS-REQ-42
  in stop:   can     receives STOP_CMD
  var speed: float32 = 0 unit km/h
  states {
    state Idle
    state Braking
    Idle -> Braking on STOP_CMD [speed > 0.0]
    Braking -> Idle on "after 2s"
  }
}

system Car "Car" {
  part panel: Panel
  part brake: Brake
  panel.stop -> brake.stop
}

test-plan TP-STOP "Stopping" {
  case TC-STOP-01 "A stop command starts braking" {
    verifies SYS-REQ-42
    at 0ms do brake.speed = 50.0
    at 10ms do send panel.stop STOP_CMD(true)
    within 20ms expect brake.state == Braking
  }
}
Diagram: Car
What archec draws from this code: Car
Try it

archec test runs the case in the simulator. archec reports a requirement that nothing satisfies or nothing verifies, and archec status shows what proves each one (what proves each requirement).

To exchange with the tool:

  • archec reqif main.arche -o reqs.reqif writes ReqIF 1.2, which DOORS, Polarion and Jama read. archec reqif in.reqif -o reqs.arche reads one.
  • archec polarion pull and archec polarion push talk to a Polarion server (Polarion).

What arche-lang does not do for a requirements tool user#

  • There is no live link to DOORS. The exchange with DOORS is a ReqIF file.
  • archec is not a database with users and access rights. The requirements are text files: their history, reviews and branches are your git repository's.
  • A ReqIF file brings requirements, their text and their figures. The satisfies and verifies links are written in the model.

Hand-written C state machines#

C words in arche-lang#

In your C you write In arche-lang it is
enum { IDLE, HEATING, DONE } state; state Idle, state Heating, state Done in states { }
switch (state) { case IDLE: … } the transitions: Idle -> Heating on START
if (ev == EV_START && water > 0) a trigger and a guard: on START [water > 0.0]
code run when a state is entered or left on-enter, on-exit
a timer that fires an event on "after 2s"
an event from an interrupt or a queue a message on a port, or an event

The same machine in both#

In C:

typedef enum { IDLE, HEATING, DONE } state_t;
static state_t state = IDLE;
static float water;
static bool heater;

void kettle_step(event_t ev) {
  switch (state) {
  case IDLE:
    if (ev == EV_START && water > 0.0f) { heater = true; state = HEATING; }
    break;
  case HEATING:
    if (ev == EV_BOILED) { heater = false; state = DONE; }
    else if (ev == EV_STOP) { heater = false; state = IDLE; }
    break;
  case DONE:
    if (ev == EV_START) { state = IDLE; }
    break;
  }
}

In arche-lang:

message START: bool "Start"
message STOP:  bool "Stop"
event boiled "The water boils"

component Kettle "Kettle" {
  in buttons: can     receives START, STOP
  var water:  float32 = 0 unit l
  var heater: bool    = false
  states {
    state Idle
    state Heating {
      on-enter ```arche
        heater = true
      ```
      on-exit ```arche
        heater = false
      ```
    }
    state Done
    Idle -> Heating on START [water > 0.0]
    Heating -> Done on boiled
    Heating -> Idle on STOP
    Done -> Idle on START
  }
}
Diagram: Kettle
What archec draws from this code: Kettle

archec checks the machine: a state nothing reaches, a state with no way out, a trigger nothing fires. The simulator runs it, and test cases check it. archec gen --target c writes the C back, with USER CODE regions for your own code that each new run keeps (regenerating code).

Two machines in one module#

A C module often keeps two state variables side by side: the power and the link of a radio, each with its own switch. In arche-lang the component keeps both, as two named machines:

message POWER_ON:  bool "Power on"
message POWER_OFF: bool "Power off"
message CONNECT:   bool "Connect"
message LOST:      bool "Link lost"

component Radio "Radio" {
  in cmd: can receives POWER_ON, POWER_OFF, CONNECT, LOST
  states Power {
    state Off
    state On
    Off -> On on POWER_ON
    On -> Off on POWER_OFF
  }
  states Link {
    state Down
    state Up
    Down -> Up on CONNECT [Power.state == On]
    Up -> Down on LOST
    Up -> Down on POWER_OFF [state == Off]
  }
}
Diagram: Radio
What archec draws from this code: Radio

Each machine is in a state of its own. A message is offered to each machine in turn, in the order written: on POWER_OFF the power goes Off first, and the link, whose guard then reads Off, goes Down. The generated C has one radio_state_t and a field per machine, state and state_link (the example).

What arche-lang does not do for a C user#

  • It does not read your C state machines. archec recover reads the includes of C files and groups the files into parts. It does not read a switch (from code to model).
  • The generated C is written in its own way. It will not match your naming or layout line by line.

Where next#