PD Dr. Stefan Bosse
University of Koblenz-Landau, Institute of Software Technology
19.6.2018
sbosse@uni-bremen.de |
Central Question. How to model, design, simulate, and implement (program) complex Cyber-Physical Systems with one unified approach and language?
The design and modelling of complex and heterogeneous distributed sensing and physical control systems is a challenge!
Examples for such systems are
1 SC_MODULE(air_temp_sensor) // Air sensor model using ELN primitive modules
2 {
3 sca_tdf::sca_in< double > in;
4 sca_eln::sca_terminal out;
5 sca_eln::sca_node_ref gnd;
6 sca_eln::sca_tdf_isource *i1; // current source declaration
7 sca_eln::sca_r *r1; // resistor declaration
8 SC_CTOR(air_temp_sensor) // standard constructor
9 {
10 r1 = new sca_eln::sca_r ( "r1" ); // resistor instantiation
11 r1->p ( out );
12 r1->n ( gnd );
13 i1 = new sca_eln::sca_tdf_isource ( "i1", 0.025 ); // current source Instantiation
14 r1->value = 1; // R=1 ohm
15 i1->p ( gnd );
16 i1->n ( out ); // 0.0-3.25 (V)
17 i1->inp ( in );
18 }
19 };
We have to distinguish
Implementation → Programming, and
Modelling → Specification → Declaration
System-of-Systems ⇒ Model of Models!
There are already multiple modelling (M) and programming (implementation, I) languages and tools available:
All modelling and programming languages differ significantly with respect to syntax and semantic
It is difficult and not very intuitive to bind all these different languages in one system-of-system design tool covering all levels and domains!
A unified modelling and implementation language is require to cover all areas and domains!
Basic idea. Create a unified programming and modelling language for complex hardware-software systems (like sensor networks) by
JavaScript is a procedural-functional-object-orientated programming language supporting dynamic / polymorphic typing at run-time
The advantage of using one widely deployed language instead of multiple different expert-level languages is that system modelling and implementation can be performed by a larger community of non-experts and application engineers.
The central concepts of the JavaScript programming model are generic functions and generic objects.
The Semantic Type System (JST) adds “semantic annotations” to functions and objects and introduces type constraints and type signatures
Originally the JST was used to type constraint program code only (software level) and was specified separated from the implementation.
JS : function foo(a,b,c) { return a+b+c }
JST: foo: function (number,number,number) → number
JS : var x,y,z;
JST: type list; x: object, y: function [], z: list [];
JS : function List (params) { this.params=params }
List.prototype.method = function () { .. }
JST: List: constructor function (params:{}) → list
class list = { .. }
JS : var Syms = { S1:'S1', S2:'S2'; ..}
JST: enum Syms = S1 | S2 | .. : syms
Association and definition of semantics by:
var simulationmodel = {
physics : { ..},
agents: { explorer:{..},..},
parameter:{},
..
}
type S = { .. };
class C = { .. }; node class N = {..};
network object = { n1:node class N = { .. }, ..};
process constructor function () {..} → type ..
sensor class straingauge = { .. }
communication protocol class = { .. }
JS
| JST
| JS+
|
var obj-name = {
e1: typ1 = val1,
e2: typ2 = val2,
..
en: typn = valn,
}
class class-name [ (par1,..) ] = {
attr1: typa1 [ = val1 ],
..
attrn: typan [ = valn ],
m1: method (par1,..) [ { statements } ] → typm1,
..
}
class t ⇔ constructor T (par1,..) → t
type struct-name = {
e1: typ1,
e2: typ2,
..
en: typn
}
type sumtype-name =
S1 { tag=S.S1, .. } |
S2 { tag=S.S2, .. } | ..
Sn { tag=S.S3, .. }
Parallel programming and behaviour models can be used to implement parallel software (for multi-processors) and parallel hardware systems (digital logic)
Concurrent Communicating Sequential Processes (CCSP) using process constructors:
process constructor pro-name (par1,..) {
statements
}
cluster object cluster-name = {
node1: node placement object = [pro1,pro2,..],
..
}
agent constructor agent-class-name (par1,..) {
Body Variables and private aux. Functions
this.xi : typ2 = expression;
Agent activities Agent activity transitions
this.act = { this.trans = {
ai : function () { .. }, ai : aj,
aj : function () { .. }, ak : function () { return al .. },
.. ..
} }
Agent signal handler
this.on = {
Signal : function (arg,from) { .. }, ..
}
this.next = ai;
}
type agent constructor = function (parameters) → agent class
type agent class = {
@identifier : body attribute,
act : activity {},
trans : transition {},
on: signal handler function {},
next: string,
}
type activity: function;
type transition: string|function () → string
Communication models define communication ports, links, networks, and communication protocols
Networks are composed of node and link classes
Node classes contain computational classes, sensor classes, port classes
network class N (i:number,j:number,..) {
// User defined components
node: network node {..},
port: network port { .. },
link: network link {..},
links: network link [],
// Combinator creating connectivity
autoconnect?: function (network node,network node) → boolean|port [],
// Service handler
service?: function (event:string,arg:*) { .. }
}
Among data processing on hardware level (digital logic) the hardware level also defines sensors, actuators, and analog electronic circuits
The hardware models define transfer functions (Input-Output relations) and constraints
hardware component class M = {
port: {
p1: input signal logic[n],
p2: output signal logic[n],
clk: input signal std_logic,
..
},
body: {
s1: signal logic[n],
s2: signal number,
t1: type ..,
pr1: process function (){ this.s1=0; if (this.clk.event(1)) {..} },
pr2: process function,
b1: block function () { this.p2=this.s1==0?this.p1:0 },
..
}
}
The physics level defines mechanical models of components, structures composed of components, and materials
Multi-physics body model with mass nodes and springs connecting mass nodes:
physics part class P = {
massi: mass object {m:number,..},
massj: mass object {m:number,..},
// Use specific spring objects
spring: spring class {k:number,l0:number,constraint:function,..},
springj: spring object {k:number,l0:number,constraint:function,..},
connect: link function (obj1:mass object, obj2:mass object) → spring object,
network: [mass object,mass object, spting object] [],
..
}
physics model class M = {
mass: mass constructor function () → mass,
spring: spring constructor function (k:number,l0:number,..) → spring,
constri: constraint function (x,y,..) → z,
..
}
A use-case study combining physical systems and distributed computing used to simulate smart adaptive materials
SEJAM: Simulation Environment for the JavaScript Agent Machine
Fully JavaScript based modelling and programming
SEJAM2 is programmed entirely in JavaScript, too!
Agents are deployed in ICT networks
MAS World
| Physical World |
simulation : model = {
// Physical MBP model
physics : { plate : {..}},
// Computation and Communication: Agent behaviour Classes
classes: {
node : { behaviour: function () {..}, visiual:{..} },
broker : { behaviour: function () {..}, visiual:{..} },
notify : { behaviour: function () {..}, visiual:{..} },
world : { behaviour: function () {..}, visiual:{..} },
},
// Global simulation parameters used by agent and physical simu.
parameter : {
strainDelta: 0.1, optimizaton: 'segment',
stepPhy: 100, stiffness: 500,
holes: [[1,2,0],[1,2,1],[1,2,2], .. ],
..
},
// Simulation set-up and initialization
world: { ..
init : { agents: {..}, physics: {..}},
meshgrid : { node:{..}, port = {..},
link:{..} .. } } // Network model
type model = {
physics : multibody component class {},
classes : agent descriptor {},
paramater: simulation parameter {},
world : {
init : fucntion {},
meshgrid : world class,
..
}
type world class = {
node: node class, port:port class,
link: link class}
}
type agent descriptor = {
behaviour: agent constructor,
visual : visual object
}
One unified modelling and implementation (programming) language using JavaScript and a Semantic Type System extensions simplifies the design and implementation of complex perceptive and Cyber Physical Systems
All modelling and implementation domains can be covered: