jw-automator 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +375 -192
- package/docs/ARCHITECTURE.md +342 -0
- package/docs/MIGRATION.md +411 -0
- package/docs/QUICKSTART.md +356 -0
- package/examples/basic-example.js +135 -0
- package/examples/hello-world.js +40 -0
- package/examples/iot-sensor-example.js +149 -0
- package/index.js +7 -0
- package/package.json +53 -19
- package/src/Automator.js +476 -0
- package/src/core/CoreEngine.js +210 -0
- package/src/core/RecurrenceEngine.js +237 -0
- package/src/host/SchedulerHost.js +174 -0
- package/src/storage/FileStorage.js +59 -0
- package/src/storage/MemoryStorage.js +27 -0
- package/.actions.json +0 -1
- package/.jshintrc +0 -16
- package/.vscode/settings.json +0 -6
- package/LICENSE +0 -674
- package/automator.js +0 -696
- package/demo.js +0 -76
package/demo.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
//add the library
|
|
2
|
-
var Auto = require('./automator');
|
|
3
|
-
|
|
4
|
-
//create the automator, set the save mode to false
|
|
5
|
-
//this is mostly useful for testing, under normal operation you will want it
|
|
6
|
-
//to save it's sate
|
|
7
|
-
var automator = new Auto.automator({save:false});
|
|
8
|
-
|
|
9
|
-
//attach some events
|
|
10
|
-
automator.on('debug', function(msg) {
|
|
11
|
-
//console.log('-DEBUG: ' + msg);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
automator.on('ready', function() {
|
|
15
|
-
console.log('---automator started---');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
automator.on('error', function(err) {
|
|
19
|
-
console.log('-Error: ' + err);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
automator.on('update', function(msg) {
|
|
23
|
-
//console.log('-update');
|
|
24
|
-
//console.log(automator.getActions());
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
automator.on('action', function(actions) {
|
|
28
|
-
//console.log('Actions run: ' + JSON.stringify(actions));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//add a single function that takes a simple payload
|
|
35
|
-
automator.addFunction('test', function(msg) {
|
|
36
|
-
console.log('My cmd: ' + msg);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
//create an action that fires every second
|
|
40
|
-
|
|
41
|
-
automator.addAction({
|
|
42
|
-
name: 'sec', //user definable
|
|
43
|
-
date: null, //next time the action should run (UTC), set default immediately
|
|
44
|
-
cmd: 'test', //cmd to call
|
|
45
|
-
payload: 'tick', //payload to send to cmd
|
|
46
|
-
unBuffered: null, //when true actions missed due to sync delay will be skipped
|
|
47
|
-
repeat: { //set this to null to only run the action once, alternatively set limit to 1
|
|
48
|
-
type:'second', // second/minute/hour/day/week/month/year/weekday/weekend
|
|
49
|
-
interval: 1, //how many of the type to skip, 2=every other time
|
|
50
|
-
count: 0, //number of times the action has run, 0=hasn't run yet
|
|
51
|
-
limit: null, //number of times the action should run, false means don't limit
|
|
52
|
-
endDate: null //null = no end date
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//create an action that fires every 4 seconds, and stops after it's run 4 times
|
|
58
|
-
automator.addAction({
|
|
59
|
-
name: '4sec', //user definable
|
|
60
|
-
date: null, //next time the action should run (UTC), set default immediately
|
|
61
|
-
cmd: 'test', //cmd to call
|
|
62
|
-
payload: '********4 seconds********', //payload to send to cmd
|
|
63
|
-
unBuffered: null, //when true actions missed due to sync delay will be skipped
|
|
64
|
-
repeat: { //set this to null to only run the action once, alternatively set limit to 1
|
|
65
|
-
type:'second', // second/minute/hour/day/week/month/year/weekday/weekend
|
|
66
|
-
interval: 4, //how many of the type to skip, 3=every 3rd type
|
|
67
|
-
count: 0, //number of times the action has run, 0=hasn't run yet
|
|
68
|
-
limit: 4, //number of times the action should run, false means don't limit
|
|
69
|
-
endDate: null //null = no end date
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
automator.start();
|
|
75
|
-
|
|
76
|
-
|