Functional analysis
Say who uses the system and what for, what it must do as functions, and how those functions hand work to each other. Each function is then allocated to the parts that perform it, so a chain of functions with a time budget is measured on the parts when their tests run.
These declarations are the functional extension: actors, missions, use cases,
system functions and their flows and chains, operating modes, workflows,
deliverables and verification means. They are outside the 1.0 core
(archec check --core names each), and the example
examples/functional-chain uses all of them on
a baggage line.
A first analysis#
A doorbell: a visitor presses a button, and the owner's phone is told within half a second. Write it top down, from who uses it to the parts that do it:
project Doorbell "Doorbell" { edition "1.2" }
// Who uses it, and what for
actor visitor "Visitor" { description "Presses the bell at the door." }
actor owner "Owner" { description "Is told on the phone." }
mission answer-door "Every visitor is answered" { involves visitor, owner }
/// A press at the door reaches the owner's phone.
use-case UC-RING "Ring the bell" {
involves visitor, owner, SF-RING, FC-RING
}
requirement REQ-RING "Ring in time" {
text "The owner's phone shall be told within 500 ms of a press."
}
// What the system does, and what flows between its functions
system-function SF-RING "Announce a visitor" {
system-function SF-SENSE "Sense the press" {
allocated Home.button
out press "Press" sends RING
}
system-function SF-NOTIFY "Notify the owner" {
allocated Home.hub
in press "Press" receives RING
out note "Note" sends NOTIFY
}
}
function-flow SF-SENSE.press -> SF-NOTIFY.press as fl-press { name "Button pressed" }
function-chain FC-RING "Press to phone" {
functions SF-SENSE, SF-NOTIFY
budget "500 ms"
satisfies REQ-RING
}
// The parts that perform the functions
message PUSH: bool
message RING: bool
message NOTIFY: bool
component Button "Button" {
power 0.2W
in finger: data receives PUSH { handler PUSH -> pressed }
out press: data sends RING
fn pressed() { send press RING(true) }
}
component Hub "Hub" {
power 1.5W
in press: data receives RING { handler RING -> relay }
out phone: data sends NOTIFY
var sent: uint32 = 0
fn relay() {
sent += 1
send phone NOTIFY(true)
}
}
component Phone "Phone" {
in note: data receives NOTIFY
}
system Home "Home" {
part button: Button
part hub: Hub
part phone: Phone
button.press -> hub.press
hub.phone -> phone.note
}
// The modes it runs in
operating-mode DAY "Day" {
initial
components button, hub
to NIGHT on RING
budget power 2W
}
operating-mode NIGHT "Night" {
components hub
to DAY on PUSH
budget power 2W
}
test-plan TP-RING "Ring" {
case TC-RING "A press reaches the phone" {
verifies REQ-RING
at 0ms do send button.finger PUSH(true)
within 1s expect hub.sent == 1
}
}Then run it:
archec check main.arche # every name resolves, the budget is a duration
archec sim main.arche --test # TC-RING runs FC-RING and measures it
archec diagram main.arche FC-RING # the chain as Mermaid
archec diagram main.arche SF-RING --format svg -o functions.svg
archec doc main.arche # the missions, actors and modes in the document
Who uses it: actors, missions, use cases#
- An
actoris someone or something outside the system: a person, another system, the weather. - A
missionis what the system is for, and the actors it serves (involves). - A
use-caseis one thing an actor does with it. Itinvolvesactors, components, functions, chains and scenarios by name.includes,extendsandgeneralizesrelate it to other use cases.
archec check resolves every name these write: an actor a mission involves
that does not exist is an error (Unknown actor 'ownr'. Did you mean 'owner'?), and so is a name in a use case's involves.
What it does: system functions#
A system-function is something the system does, independent of how. A
function written inside another is one of its parts. Its in and out ports
say what it receives and sends, with the messages of the model.
allocated names the part, or parts, that perform it, as a path from the
system (Home.hub). A path that names no part is an error. kind marks a
function that only moves work around: duplicate, gather, route, select
or split.
A function-flow is what goes from one function to another, from port to
port: function-flow SF-SENSE.press -> SF-NOTIFY.press. Its id comes after
as, its name after name, and carries lists what it carries when that is
more than one message.
archec diagram main.arche SF-RING draws a function's parts and the flows
between them. --format svg and --format d2 draw it in other formats.
Function chains and their budget#
A function-chain is a path through the functions, with its end-to-end time
as budget. Write it as a list when it is one path:
function-chain FC-RING "Press to phone" {
functions SF-SENSE, SF-NOTIFY
budget "500 ms"
}
Write it as steps and edges when it branches. A step runs one function, or is
a control node (kind or, kind and, kind iterate). An edge may name the
flow it carries after :, and when says on what condition it is taken:
function-chain FC-ANY-TAG "Bag to its lateral, any tag" {
budget "10 s"
step identify { function SF-IDENTIFY }
step read { kind or }
step code { function SF-CODE }
step screen { function SF-SCREEN }
edge identify -> read
edge read -> screen : fl-read { when "the tag is read" }
edge read -> code : fl-no-read { when "no read" }
edge code -> screen : fl-keyed
}
Each path from a step no edge reaches to a step no edge leaves is one path of
the chain. A budget that is not a duration is an error (chain-budget).
The budget is checked in two places:
On a run.
archec sim --testmeasures the chain on each case that runs it. The chain starts when the part the first function is allocated to receives a message itsinports receive. It ends when the part of the last function sends a message on one of itsoutports, caused by that start. A case where that took longer than the budget fails:✗ TP-RING TC-RING A press reaches the phone within 0.000 ms..500.000 ms: FC-RING end to end within its budget, 500 ms (function-chain) — never soOn a deployment.
archec analyze(andarchec check) bound the chain through the parts its functions are allocated to: their@wcet, their threads and the links between them, as for a deployment's chain. It is a lower bound, since what a state machine waits for (aftertimers) is not in it. A lower bound already over the budget is a warning (e2e-budget).
A chain or flow that names a function the model does not have, an edge
between steps the chain does not have, or a flow end on a port its function
does not have is a warning (unknown-function). A chain with such a name
is not measured, so the warning says why.
Operating modes#
An operating-mode is a mode the whole system is in: day, night, standby.
initialmarks the mode it starts in.componentsnames the parts active in it, from the top of the system; none named means all of them.requirementsnames the requirements that apply in it.to NIGHT on RINGis a mode it goes to, and on what. A guard may follow in brackets:to TRACKING on TRACK [a service is offered].budget power 2Wadds up thepowerof the parts active in it, and warns when they draw more (budget-over).set radio.power = 8Wgives a part another number in this mode.
A mode's numbers are what profiles over time add up phase by
phase. archec doc lists the modes in a table: the parts active in each, its
requirements and where it goes.
Workflows#
A workflow is a process people or teams follow: who does what, in which
order. Its lanes are blocks of the model (a team is a block too), and each
line is an activity in one lane or a hand-off between two:
workflow install "Install the bell" in Home {
lanes button, hub
button: pair "Pair with the hub"
button -> hub : join "Join request"
}in Home lets the lanes be written by their names in that system. A workflow
is a scenario with one sequence: archec diagram main.arche seq:install draws
it as a sequence diagram. alt, loop, opt and par branch it as in a
sequence.
Deliverables and verification means#
A deliverable is a document the project delivers: a specification, an ICD,
a plan. It says its kind, status, owner, version, due date and what
it covers. A requirement says which deliverable it belongs to with
document SRS, and archec doc groups the requirements by deliverable when
there are several:
deliverable SRS "Doorbell specification" {
kind specification
status draft
covers UC-RING
}
A means names a means of verification once (a bench, a simulator, a
review), so that a requirement's verify { means bench } can say it by name:
means bench "Door bench: a button, a hub and a test phone"
What the build writes#
archec build writes each of these to the Arche project: actors.yaml,
missions.yaml, usecases.yaml, functional.yaml (the functions, flows and
chains), modes.yaml and deliverables.yaml. The Arche app shows them and
its Documentation page assembles each deliverable. archec capella and
archec sysml export them too: see importing for what each
tool holds.
Limits#
- Operating modes are not simulated. A run does not switch mode, and a mode's
componentsdo not turn parts on or off inarchec sim. A mode's trigger (on RING) and guard are not checked against the model's messages. - A function chain is measured only to a part that is linked: the end is a message the last function's part sends on a link. A send on a port that no link leaves is not seen, and the case then says nothing about the chain.
archec analyzegives a lower bound of a chain, not its time: the time a state machine waits is left out. The simulator's run is the measure.- A use case has no diagram of its own, and
archec docdoes not list use cases, functions or chains: the Arche app andarchec diagramshow them. - A system function's
states(the modes it is active in) is written to the Arche project, and archec does not check it. - What a use case
involvessits at several levels at once: an exporter to a tool with fixed levels, such as Capella, leaves out what it cannot place and says so.