limit resources that can be specified in build config
This commit is contained in:
parent
0574e8b47b
commit
4a388561ab
|
@ -9,14 +9,17 @@ types:
|
|||
value: M5_CAN_KIT
|
||||
description: "M5 Stack CAN Kit"
|
||||
url: "http://docs.m5stack.com/en/atom/atom_can"
|
||||
resource: can
|
||||
- value: M5_SERIAL_KIT_232
|
||||
description: "M5 Stack RS232 Base"
|
||||
label: "Atomic RS232 Base"
|
||||
url: "http://docs.m5stack.com/en/atom/Atomic%20RS232%20Base"
|
||||
resource: serial
|
||||
- value: M5_SERIAL_KIT_485
|
||||
description: "M5 Stack RS485 Base"
|
||||
label: "Atomic RS485 Base"
|
||||
url: "http://docs.m5stack.com/en/atom/Atomic%20RS485%20Base"
|
||||
resource: serial
|
||||
- &m5groovei2c
|
||||
type: multi
|
||||
key: m5groovei2c
|
||||
|
@ -32,6 +35,7 @@ types:
|
|||
url: "http://docs.m5stack.com/en/unit/can"
|
||||
description: "M5 Can unit"
|
||||
value: M5_CANUNIT
|
||||
resource: can
|
||||
- &m5grooveserial
|
||||
type: select
|
||||
label: "M5 Groove Serial Unit"
|
||||
|
@ -43,11 +47,13 @@ types:
|
|||
value: SERIAL_GROOVE_485
|
||||
description: "M5 RS485 unit"
|
||||
url: "http://docs.m5stack.com/en/unit/rs485"
|
||||
resource: serial
|
||||
- label: "Tail485"
|
||||
value: SERIAL_GROOVE_485
|
||||
key: tail485
|
||||
description: "M5 Tail 485"
|
||||
url: "http://docs.m5stack.com/en/atom/tail485"
|
||||
resource: serial
|
||||
|
||||
- &m5groove
|
||||
type: select
|
||||
|
@ -63,7 +69,11 @@ types:
|
|||
- label: 'Serial'
|
||||
children:
|
||||
- *m5grooveserial
|
||||
|
||||
resources:
|
||||
default: &esp32default
|
||||
serial: 2
|
||||
can: 1
|
||||
i2c: 1
|
||||
|
||||
config:
|
||||
children:
|
||||
|
@ -76,6 +86,7 @@ config:
|
|||
label: m5stack-atom
|
||||
description: "M5 Stack Atom light"
|
||||
url: "http://docs.m5stack.com/en/core/atom_lite"
|
||||
resource: *esp32default
|
||||
children:
|
||||
- *m5base
|
||||
- *m5groove
|
||||
|
@ -83,6 +94,7 @@ config:
|
|||
label: m5stack-atoms3
|
||||
description: "M5 Stack AtomS3 light"
|
||||
url: "http://docs.m5stack.com/en/core/AtomS3%20Lite"
|
||||
resource: *esp32default
|
||||
children:
|
||||
- *m5base
|
||||
- *m5groove
|
|
@ -91,6 +91,9 @@
|
|||
display: none;
|
||||
color: red;
|
||||
}
|
||||
.configui .error .value{
|
||||
color: red;
|
||||
}
|
||||
.configui #warn.warn{
|
||||
display: block;
|
||||
}
|
||||
|
@ -131,3 +134,7 @@
|
|||
.configui .label {
|
||||
width: 10em;
|
||||
}
|
||||
.configui .row input{
|
||||
flex-grow: 1;
|
||||
width: initial;
|
||||
}
|
|
@ -33,6 +33,10 @@
|
|||
<span class="label">Build Flags</span>
|
||||
<input type="text" id="buildflags" disabled>
|
||||
</div>
|
||||
<div class="row hidden error">
|
||||
<span class="label">Error</span>
|
||||
<span class="value" id="configError"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button id="start">Start</button>
|
||||
</div>
|
||||
|
|
|
@ -56,6 +56,11 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
|||
enableEl('start',false);
|
||||
return;
|
||||
}
|
||||
let e=document.getElementById('configError');
|
||||
if (e.textContent) {
|
||||
enableEl('start',false);
|
||||
return;
|
||||
}
|
||||
if (displayMode != 'existing'){
|
||||
if (currentPipeline !== undefined){
|
||||
//check pipeline state
|
||||
|
@ -261,7 +266,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
|||
if (val === undefined) val=key;
|
||||
re.setAttribute('type', 'radio');
|
||||
re.setAttribute('name', name);
|
||||
re.addEventListener('change', (ev) => callback(v.children,key,val,false));
|
||||
re.addEventListener('change', (ev) => callback(v.children,key,val,v.resource,false));
|
||||
if (v.description && v.url) {
|
||||
let lnk = addEl('a', 'radioDescription', ef, v.description);
|
||||
lnk.setAttribute('href', v.url);
|
||||
|
@ -269,7 +274,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
|||
}
|
||||
if (key == current) {
|
||||
re.setAttribute('checked','checked');
|
||||
callback(v.children,key,val,true);
|
||||
callback(v.children,key,val,v.resource,true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -307,9 +312,9 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
|||
configList.forEach((cfg)=>{
|
||||
let name=prefix?(prefix+SEPARATOR+cfg.key):cfg.key;
|
||||
let current=config[name];
|
||||
buildSelector(frame,cfg,name,current,(children,key,value,initial)=>{
|
||||
buildSelector(frame,cfg,name,current,(children,key,value,resource,initial)=>{
|
||||
buildSelectors(name,children,initial);
|
||||
configStruct[name]={cfg:cfg, key: key, value:value};
|
||||
configStruct[name]={cfg:cfg, key: key, value:value,resource:resource};
|
||||
buildValues(initial);
|
||||
})
|
||||
})
|
||||
|
@ -321,27 +326,65 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
|||
if (! initial){
|
||||
config={};
|
||||
}
|
||||
for (let k in configStruct){
|
||||
let struct=configStruct[k];
|
||||
if (! struct || ! struct.cfg || struct.value === undefined) continue;
|
||||
config[k]=struct.key;
|
||||
if (struct.cfg.target !== undefined) {
|
||||
if (struct.cfg.target === 'environment') {
|
||||
environment = struct.value;
|
||||
}
|
||||
if (struct.cfg.target === 'define') {
|
||||
flags += " -D" + struct.value;
|
||||
}
|
||||
const DEFPRFX = "define:";
|
||||
if (struct.cfg.target.indexOf(DEFPRFX) == 0) {
|
||||
let def = struct.cfg.target.substring(DEFPRFX.length);
|
||||
flags += " -D" + def + "=" + struct.value;
|
||||
let allowedResources={};
|
||||
let currentResources={};
|
||||
let errors="";
|
||||
for (let round = 0; round <= 1; round++) {
|
||||
//round1: find allowed resources
|
||||
//round2: really collect values
|
||||
for (let k in configStruct) {
|
||||
let struct = configStruct[k];
|
||||
if (!struct || !struct.cfg || struct.value === undefined) continue;
|
||||
if (round > 0) config[k] = struct.key;
|
||||
if (struct.cfg.target !== undefined) {
|
||||
if (struct.cfg.target === 'environment') {
|
||||
if (round > 0) environment = struct.value;
|
||||
else allowedResources=struct.resource;
|
||||
continue;
|
||||
}
|
||||
if (round < 1) continue;
|
||||
if (struct.resource){
|
||||
let resList=currentResources[struct.resource];
|
||||
if (! resList){
|
||||
resList=[];
|
||||
currentResources[struct.resource]=resList;
|
||||
}
|
||||
resList.push(struct);
|
||||
}
|
||||
if (struct.cfg.target === 'define') {
|
||||
flags += " -D" + struct.value;
|
||||
continue;
|
||||
}
|
||||
const DEFPRFX = "define:";
|
||||
if (struct.cfg.target.indexOf(DEFPRFX) == 0) {
|
||||
let def = struct.cfg.target.substring(DEFPRFX.length);
|
||||
flags += " -D" + def + "=" + struct.value;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById('environment').value=environment;
|
||||
document.getElementById('buildflags').value=flags;
|
||||
//check resources
|
||||
for (let k in currentResources){
|
||||
let resList=currentResources[k];
|
||||
if (allowedResources[k] !== undefined){
|
||||
if (resList.length > allowedResources[k]){
|
||||
errors+=" more than "+allowedResources[k]+" "+k+" device(s) used";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errors){
|
||||
setValue('configError',errors);
|
||||
setVisible('configError',true,true);
|
||||
}
|
||||
else{
|
||||
setValue('configError','');
|
||||
setVisible('configError',false,true);
|
||||
}
|
||||
if (! initial) findPipeline();
|
||||
updateStart();
|
||||
}
|
||||
let findIdx=0;
|
||||
const findPipeline=()=>{
|
||||
|
|
Loading…
Reference in New Issue