This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add set defaults function and update release to version v0.3.0-alpha
- Loading branch information
Dominik Serve
committed
Feb 24, 2018
1 parent
a49daec
commit b24351a
Showing
14 changed files
with
423 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
exports.baseNode = "RootFolder"; | ||
|
||
exports.moduleStructure = { | ||
"mi5":{ | ||
type: 'Folder', | ||
content: { | ||
"$(moduleName)": { | ||
type: 'Folder', | ||
content: { | ||
identification:{ | ||
type: 'Folder', | ||
content: {} | ||
}, | ||
skill: { | ||
type: 'Folder', | ||
content: {} | ||
}, | ||
state: { | ||
type: 'Folder' | ||
}, | ||
variables: { | ||
type: 'Folder' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
exports.skillStructure = { | ||
"$(skillName)": { | ||
type: 'Folder', | ||
content: { | ||
state: { | ||
type: 'Folder' | ||
}, | ||
inputParameters: { | ||
type: 'Folder' | ||
}, | ||
outputParameters: { | ||
type: 'Folder' | ||
} | ||
} | ||
} | ||
}; | ||
|
||
exports.stateStructure = { | ||
stateMachine: { | ||
type: 'Folder', | ||
content: { | ||
operationalState: { | ||
type: 'Variable', | ||
dataType: 'String', | ||
initValue: '17' | ||
}, | ||
errorAcknowledge: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
errorMessage: { | ||
type: 'Folder', | ||
content: { | ||
messageID: { | ||
type: 'Variable', | ||
dataType: 'Integer', | ||
initValue: 0 | ||
}, | ||
messageType: { | ||
type: 'Variable', | ||
dataType: 'String', | ||
initValue: '' | ||
}, | ||
messageText: { | ||
type: 'Variable', | ||
dataType: 'String', | ||
initValue: '' | ||
}, | ||
messageTime: { | ||
type: 'Variable', | ||
dataType: 'String', | ||
initValue: '' | ||
}, | ||
} | ||
}, | ||
stateTransition: { | ||
type: 'Folder', | ||
content: { | ||
start: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
pause: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
resume: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
suspend: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
unsuspend: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
hold: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
unhold: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
stop: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
abort: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
clear: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
reset: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
}, | ||
done: { | ||
type: 'Variable', | ||
dataType: 'Boolean', | ||
initValue: false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
|
||
exports.stateVariablesStructure = {}; | ||
|
||
exports.skillParametersStructure = {}; | ||
|
||
exports.skillParametersStructure = {}; | ||
|
||
exports.pathToModule = ["mi5", "$(moduleName)"]; | ||
exports.pathToModuleIdentification = ["mi5", "$(moduleName)", "identification"]; | ||
exports.pathToModuleStates = ["mi5", "$(moduleName)", "state"]; | ||
exports.pathToModuleStateVariables = ["mi5", "$(moduleName)", "variables"]; | ||
exports.pathToSkillsBaseFolder = ["mi5", "$(moduleName)", "skill"]; | ||
exports.pathToSkillStates = ["$(skillName)","state"]; | ||
exports.pathToSkillInputParameters = ["$(skillName)","inputParameters"]; | ||
exports.pathToSkillOutputParameters = ["$(skillName)","outputParameters"]; | ||
exports.pathToStateTransitions = ["stateMachine", "stateTransition"]; | ||
exports.pathToOperationalState = ["stateMachine", "operationalState"]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const addClusterStateTransitions = require('../../helpers/resolveClusters'); | ||
|
||
const clusters = { | ||
/*whiteCluster: ["Running", "Paused", "Pausing"], | ||
transparentCluster: ["whiteCluster", "Suspending", "Suspended", "Unsuspending"], | ||
yellowCluster: ["transparentCluster", "Idle", "Starting", "Completing", "Complete", "Resetting", "Holding", "Held", "Unholding"], | ||
redCluster: ["yellowCluster", "Clearing", "Stopped", "Stopping"]*/ | ||
}; | ||
|
||
let StateTransitions = { | ||
// Idle | ||
0: { | ||
start: "Starting" // Running | ||
}, | ||
Starting: { | ||
done: 2 // Running | ||
}, | ||
// Running | ||
2: { | ||
done: 12 // Complete | ||
},/* | ||
Pausing: { | ||
suspend: "Suspending" | ||
}, | ||
Paused: { | ||
resume: "Running" | ||
}, | ||
Suspending: { | ||
done: "Suspended" | ||
}, | ||
Suspended: { | ||
unsuspend: "Unsuspended" | ||
}, | ||
Unsuspended: { | ||
done: "Running" | ||
}, | ||
Unsuspending: { | ||
suspend: "Suspended" | ||
}, | ||
Completing: { | ||
done: "Complete" | ||
},*/ | ||
// Complete | ||
12: { | ||
reset: "Resetting" | ||
}, | ||
/* | ||
Aborting: { | ||
done: "Aborted" | ||
},*/ | ||
// Aborted | ||
17: { | ||
clear: "Clearing", | ||
reset: "Resetting" | ||
},/* | ||
Stopping: { | ||
done: "Stopped" | ||
},*/ | ||
// Stopped | ||
15: { | ||
reset: "Resetting" | ||
}, | ||
/* | ||
Holding: { | ||
done: "Held" | ||
}, | ||
Held: { | ||
unhold: "Unholding" | ||
}, | ||
Unholding: { | ||
done: "Running" | ||
},*/ | ||
Clearing: { | ||
done: 15 // Stopped | ||
}, | ||
Resetting: { | ||
done: "0" // Idle | ||
},/* | ||
whiteCluster: { | ||
suspend: "Suspending" | ||
}, | ||
transparentCluster: { | ||
hold: "Holding" | ||
}, | ||
yellowCluster: { | ||
stop: "Stopping" | ||
}, | ||
redCluster: { | ||
abort: "Aborting" | ||
}*/ | ||
}; | ||
|
||
addClusterStateTransitions(StateTransitions, clusters); | ||
exports.stateTransitions = StateTransitions; | ||
exports.initialState = 17; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Adds the state transitions noted by clusters to the state transitions object. | ||
* @param StateTransitions | ||
* @param clusters | ||
*/ | ||
function addClusterStateTransitions(StateTransitions, clusters) { | ||
for (let key in StateTransitions) { | ||
//console.log(key); | ||
// if it is a cluster | ||
if (clusters[key]) | ||
resolveCluster(key, StateTransitions[key], StateTransitions, clusters); | ||
} | ||
} | ||
|
||
function resolveCluster(clusterName, followUpStates, StateTransitions, clusters) { | ||
clusters[clusterName].forEach(function (item) { | ||
// recursive if the item itself is a clusters | ||
if (clusters[item]) | ||
return resolveCluster(item, followUpStates, StateTransitions, clusters); | ||
// if it is a single state | ||
addFollowUpStatesToSingleState(item, followUpStates, StateTransitions); | ||
}); | ||
} | ||
|
||
function addFollowUpStatesToSingleState(state, followUpStates, StateTransitions) { | ||
// add multiple followUpStates to state | ||
for (let key in followUpStates) { | ||
if (followUpStates.hasOwnProperty(key)) | ||
if (!StateTransitions[state]) | ||
return new Error("Probable typo: " + state + " is not defined in StateTransitions."); | ||
StateTransitions[state][key] = followUpStates[key]; | ||
} | ||
} | ||
|
||
module.exports = addClusterStateTransitions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module.exports.Mi5Module = require('./models/mi5-module'); | ||
module.exports.Mi5Skill = require('./models/mi5-skill'); | ||
module.exports.Mi5mqttPublisher = require('./lib/mqttPublisher'); | ||
module.exports.Mi5mqttPublisher = require('./lib/mqttPublisher'); | ||
module.exports.setDefaults = require('./models/setDefaults').setDefaults; | ||
module.exports.resolveClusters = require('./helpers/resolveClusters'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.