- OCaml 100%
mal #
The Mission Operations Message Abstraction Layer (MAL) of CCSDS 521.0-B-2 in OCaml.
Overview #
A mission control system talks to many services, on the ground and on board the spacecraft. Without a shared layer, each service defines its own messages and its own transport. The CCSDS Mission Operations framework instead specifies every service in terms of MAL, a standard set of interaction patterns and data types that sits between the consumer of a service and its provider. The same service can then run over different transports.
MAL has six interaction patterns: Send, Submit, Request, Invoke, Progress and Pub-Sub. Each one fixes the sequence of typed messages that the consumer and the provider exchange, and this package supports all six.
The package implements the abstract layer only: the message header, the interaction patterns and their stages, the error codes, a service registry and dispatcher, and the signature of a transport. It has neither the standard's binary encoding nor any transport binding such as MAL/TCP/IP. Message bodies are opaque strings, and the only transport is an in-memory one meant for tests.
Installation #
Install with opam:
$ opam install mal
If opam cannot find the package, it may not yet be released in the public
opam-repository. Add the overlay repository, then install it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install mal
Usage #
let run () =
(* Create an in-memory transport for testing *)
let provider = Mal.Mem_transport.v "mal:provider" in
let consumer = Mal.Mem_transport.v "mal:consumer" in
(* Build a Request message *)
let tid = Mal.next_transaction_id () in
let msg =
Mal.header
~uri_from:"mal:consumer" ~uri_to:"mal:provider"
~interaction_type:Mal.Request ~stage:Mal.Request_stage
~transaction_id:tid ~area:1 ~service:1 ~operation:1
~body:"ping" ()
in
(* Send and dispatch *)
let _ = Mal.Mem_transport.send consumer msg in
(match Mal.Mem_transport.recv provider with
| Ok received -> Printf.printf "Got: %s\n" received.Mal.body
| Error code -> Fmt.pr "Error: %a\n" Mal.pp_error_code code);
Mal.Mem_transport.close provider;
Mal.Mem_transport.close consumer
API Overview #
- The interaction patterns are
Send,Submit,Request,Invoke,ProgressandPub_sub. - The data types are
blob,identifier,uri,time,fine_timeandduration. headerbuilds a message header with its routing metadata: URIs, QoS, session and transaction identifier.register_area,register_handleranddispatchform the service registry.Transportis the signature of a transport binding (send,recv,close), andMem_transportthe in-memory one.next_transaction_idandvalidate_stageare helpers.
References #
- CCSDS 521.0-B-2, Mission Operations Message Abstraction Layer.
- CCSDS 520.0-G, Mission Operations Services Concept (Green Book).
Licence #
ISC License. See LICENSE.md for details.