Skip to content

Commit 8598906

Browse files
committed
Merge with ES6 release
2 parents 38d4380 + 035ba4b commit 8598906

File tree

6 files changed

+172
-195
lines changed

6 files changed

+172
-195
lines changed

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"extends": "eslint:recommended",
7+
"rules": {
8+
"indent": [
9+
"error",
10+
2
11+
],
12+
"linebreak-style": [
13+
"error",
14+
"unix"
15+
],
16+
"quotes": [
17+
"error",
18+
"single"
19+
],
20+
"semi": [
21+
"error",
22+
"never"
23+
]
24+
}
25+
}

CHANGELOG

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v0.6:
2-
- Migration to jsmf-core 0.4
1+
v0.7:
2+
- ES6 migration
33
v0.6:
44
- Migration to jsmf-core 0.4

examples/ArduinoML/ArduinoToCode.js

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,118 +7,116 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
77
Authors : Nicolas Biri
88
*/
99

10-
'use strict';
10+
'use strict'
1111

1212
// model imports
13-
var JSTL = require('../../index');
14-
var Transformation = JSTL.Transformation;
15-
var NAV = require('jsmf-magellan');
16-
var Model = require('jsmf-core').Model;
13+
const JSTL = require('../../index')
14+
const Transformation = JSTL.Transformation
15+
const NAV = require('jsmf-magellan')
16+
const Model = require('jsmf-core').Model
1717

1818
// other imports
19-
var _ = require('lodash');
20-
var inspect = require('eyes').inspector({
21-
maxLength: 50000
22-
});
19+
const _ = require('lodash')
20+
const inspect = require('eyes').inspector({maxLength: 50000})
2321

2422
// Metamodels
25-
var MMI = require('./MMArduinoML');
26-
var MMO = require('./MMAbstractCode');
23+
const MMI = require('./MMArduinoML')
24+
const MMO = require('./MMAbstractCode')
2725

2826
// input file
29-
var input = require('./MArduinoML').switchExample;
30-
var output = new Model('Out');
27+
const input = require('./MArduinoML').switchExample
28+
const output = new Model('Out')
3129

32-
var module = new Transformation();
30+
const transfo = new Transformation()
3331

34-
module.addRule({
35-
in: function(x) { return NAV.allInstancesFromModel(MMI.App, x)},
32+
transfo.addRule({
33+
in: x => NAV.allInstancesFromModel(MMI.App, x),
3634
out: function(i) {
37-
var app = MMO.App.newInstance();
38-
this.assign(app, 'structural', [i]);
39-
this.assign(app, 'behavioural', [i]);
40-
return [app];
35+
var app = MMO.App.newInstance()
36+
this.assign(app, 'structural', [i])
37+
this.assign(app, 'behavioural', [i])
38+
return [app]
4139
}
42-
});
40+
})
4341

44-
module.addRule({
45-
in: function(x) { return NAV.allInstancesFromModel(MMI.App, x)},
42+
transfo.addRule({
43+
in: x => NAV.allInstancesFromModel(MMI.App, x),
4644
out: function(i) {
47-
var s = MMO.StructuralConcerns.newInstance();
48-
this.assign(s, 'alias', i.brick);
49-
this.assign(s, 'pinMode', i.brick);
50-
return [s];
45+
var s = MMO.StructuralConcerns.newInstance()
46+
this.assign(s, 'alias', i.brick)
47+
this.assign(s, 'pinMode', i.brick)
48+
return [s]
5149
}
52-
});
50+
})
5351

54-
module.addRule({
55-
in: function(x) { return NAV.allInstancesFromModel(MMI.Brick, x)},
52+
transfo.addRule({
53+
in: x => NAV.allInstancesFromModel(MMI.Brick, x),
5654
out: function(i) {
57-
return [MMO.BrickAlias.newInstance({name: i.name, pin: i.pin})];
55+
return [MMO.BrickAlias.newInstance({name: i.name, pin: i.pin})]
5856
}
59-
});
57+
})
6058

61-
module.addRule({
62-
in: function(x) { return NAV.allInstancesFromModel(MMI.Sensor, x)},
59+
transfo.addRule({
60+
in: x => NAV.allInstancesFromModel(MMI.Sensor, x),
6361
out: function(i) {
64-
return [MMO.PinMode.newInstance({name: i.name, mode: MMO.IO.INPUT})];
62+
return [MMO.PinMode.newInstance({name: i.name, mode: MMO.IO.INPUT})]
6563
}
66-
});
64+
})
6765

68-
module.addRule({
69-
in: function(x) { return NAV.allInstancesFromModel(MMI.Actuator, x)},
66+
transfo.addRule({
67+
in: x => NAV.allInstancesFromModel(MMI.Actuator, x),
7068
out: function(i) {
71-
return [MMO.PinMode.newInstance({name: i.name, mode: MMO.IO.OUTPUT})];
69+
return [MMO.PinMode.newInstance({name: i.name, mode: MMO.IO.OUTPUT})]
7270
}
73-
});
71+
})
7472

75-
module.addRule({
76-
in: function(x) { return NAV.allInstancesFromModel(MMI.App, x)},
73+
transfo.addRule({
74+
in: x => NAV.allInstancesFromModel(MMI.App, x),
7775
out: function(i) {
78-
var b = MMO.BehaviouralConcerns.newInstance();
79-
b.timeConfig = MMO.TimeConfig.newInstance({initialTime: 0, debounce: 200});
80-
this.assign(b, 'stateFunction', i.state);
81-
this.assign(b, 'mainLoop', i.initial);
82-
return [b];
76+
var b = MMO.BehaviouralConcerns.newInstance()
77+
b.timeConfig = MMO.TimeConfig.newInstance({initialTime: 0, debounce: 200})
78+
this.assign(b, 'stateFunction', i.state)
79+
this.assign(b, 'mainLoop', i.initial)
80+
return [b]
8381
}
84-
});
82+
})
8583

86-
module.addRule({
87-
in: function(x) { return NAV.allInstancesFromModel(MMI.State, x)},
84+
transfo.addRule({
85+
in: x => NAV.allInstancesFromModel(MMI.State, x),
8886
out: function(i) {
89-
var t = i.transition[0];
87+
var t = i.transition[0]
9088
var s = MMO.StateFunction.newInstance({
9189
name: i.name,
9290
next: t.next[0].name,
9391
readOn: t.sensor[0].name,
9492
read: t.value
95-
});
96-
this.assign(s, 'write', i.action);
97-
return [s];
93+
})
94+
this.assign(s, 'write', i.action)
95+
return [s]
9896
}
99-
});
97+
})
10098

101-
module.addRule({
102-
in: function(x) { return NAV.allInstancesFromModel(MMI.State, x)},
99+
transfo.addRule({
100+
in: x => NAV.allInstancesFromModel(MMI.State, x),
103101
out: function(i) {
104-
return [MMO.MainLoop.newInstance({ init: i.name })];
102+
return [MMO.MainLoop.newInstance({ init: i.name })]
105103
}
106-
});
104+
})
107105

108106

109-
module.addRule({
110-
in: function(x) { return NAV.allInstancesFromModel(MMI.Action, x)},
107+
transfo.addRule({
108+
in: x => NAV.allInstancesFromModel(MMI.Action, x),
111109
out: function(i) {
112-
return [MMO.Write.newInstance({
110+
return [MMO.Write.newInstance({
113111
on: i.actuator[0].name,
114112
value: i.value
115-
})];
113+
})]
116114
}
117-
});
115+
})
118116

119117

120118
// launch transformation
121119

122-
var log = module.apply(input, output, false);
120+
const log = transfo.apply(input, output, false)
123121

124-
_.forEach(NAV.allInstancesFromModel(MMO.App, output), function(x) {console.log(x.toCode())});
122+
_.forEach(NAV.allInstancesFromModel(MMO.App, output), x => console.log(x.toCode()))

examples/Family2Person/FamiliesToPerson.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ transformation.addRule(Member2Male);
113113
transformation.addRule(Member2FeMale);
114114

115115

116-
//Apply all rules in the models and resolve references, actual transformation execution
116+
// Apply all rules in the models and resolve references, actual transformation execution
117117
transformation.apply(Mi.ma, Mo);
118+
// Useless, used in test to see if debug mode is ok
119+
transformation.apply(Mi.ma, undefined, true)
118120

119121
module.exports.result = Mo;

0 commit comments

Comments
 (0)