Skip to content

Commit c996193

Browse files
committed
Try to fix v-img event spam, condional showing the video stream. Minimum control command threshold 500->250ms
1 parent 132947c commit c996193

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

src/components/Blockly.vue

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
<v-card-title class="headline grey lighten-2" primary-title>
7777
Esecuzione
7878
</v-card-title>
79-
<v-card-text>
80-
<v-img :src="webcamStream" />
79+
<v-card-text v-if="runtimeDialog">
80+
<v-img v-if="runtimeDialog" :src="webcamStream" />
8181
</v-card-text>
8282
<v-divider></v-divider>
8383
{{ log }}
@@ -433,10 +433,10 @@ export default {
433433
},
434434
saveProgramAs: function(e) {
435435
if (this.newProgramName != '') {
436-
if(this.isDefault == "True" && this.programName == this.newProgramName){
436+
if (this.isDefault == "True" && this.programName == this.newProgramName) {
437437
this.CannotOverwrite = true
438438
console.log("error")
439-
} else{
439+
} else {
440440
this.defaultProgramName = this.programName
441441
this.programName = this.newProgramName
442442
this.newProgramName = ''
@@ -461,24 +461,21 @@ export default {
461461
default: ''
462462
})
463463
.then(function(data) {
464-
if(data.data == "defaultOverwrite" || data.data == "askOverwrite"){
465-
if(data.data == "askOverwrite"){
464+
if (data.data == "defaultOverwrite" || data.data == "askOverwrite") {
465+
if (data.data == "askOverwrite") {
466466
this.$data.overwriteDialog = true
467-
}
468-
else{
467+
} else {
469468
this.$data.programName = this.$data.defaultProgramName
470469
this.$data.defaultProgramName = ''
471470
this.$data.CannotOverwrite = true
472471
}
473-
}
474-
else{
472+
} else {
475473
this.$data.isDefault = ''
476474
this.$data.overwrite = 0
477475
console.log("salvato")
478476
}
479477
}.bind(this))
480-
}
481-
else {
478+
} else {
482479
this.unvalidName = true
483480
}
484481
},
@@ -637,6 +634,7 @@ export default {
637634
},
638635
runProgramLegacy() {
639636
if (this.status) {
637+
this.runtimeDialog = true;
640638
let axios = this.$axios
641639
let CB = this.CB
642640
let qs = this.$qs
@@ -654,19 +652,22 @@ export default {
654652
'dom_code': dom_code,
655653
'code': code,
656654
})
657-
658-
axios.post(this.CBv1 + '/program/exec', valuesAsString)
659-
.then(function(response) {
660-
console.log(response)
661-
this.runtimeDialog = true;
662-
setTimeout(function() {
663-
this.updateExecStatus();
664-
}.bind(this), 1000)
665-
}.bind(this))
666-
655+
setTimeout(function() {
656+
axios.post(this.CBv1 + '/program/exec', valuesAsString)
657+
.then(function(response) {
658+
console.log(response)
659+
660+
setTimeout(function() {
661+
this.updateExecStatus();
662+
}.bind(this), 1000)
663+
}.bind(this))
664+
665+
// Postpone the actual execution by 1 second (allow the popup to open, ..)
666+
}.bind(this), 1000)
667667
}
668+
668669
},
669-
stopProgram(){
670+
stopProgram() {
670671
console.log("Stopping")
671672
let axios = this.$axios
672673
axios.post(this.CBv1 + '/program/end')

src/components/Control.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export default {
273273
let CB = this.CB
274274
let pressDuration = this.pressDuration
275275
pressDuration = performance.now() - this.pressDuration
276-
let minTreshold = 500
276+
let minTreshold = 250
277277
let delay = minTreshold - pressDuration
278278
console.log("Pressed for", pressDuration, "ms")
279279
if (pressDuration < 500) {

0 commit comments

Comments
 (0)