|
@@ -9,26 +9,22 @@
|
|
|
<script src="js/vue.js"></script>
|
|
|
</head>
|
|
|
<body>
|
|
|
-
|
|
|
<div id="app">
|
|
|
<textarea v-model="input" cols="80" rows="20"></textarea>
|
|
|
- <div id='example-3'>
|
|
|
- <input type="checkbox" id="do1" value="1" v-model="doBits">
|
|
|
- <input type="checkbox" id="do2" value="2" v-model="doBits">
|
|
|
- <input type="checkbox" id="do3" value="3" v-model="doBits">
|
|
|
- <input type="checkbox" id="do4" value="4" v-model="doBits">
|
|
|
- <input type="checkbox" id="do5" value="5" v-model="doBits">
|
|
|
- <input type="checkbox" id="do6" value="6" v-model="doBits">
|
|
|
- <input type="checkbox" id="do7" value="7" v-model="doBits">
|
|
|
- <input type="checkbox" id="do8" value="8" v-model="doBits">
|
|
|
- <br>
|
|
|
- </div>
|
|
|
-
|
|
|
<button v-on:click="send">send</button>
|
|
|
-
|
|
|
+ <table border="1">
|
|
|
+ <tr v-for="x in cData">
|
|
|
+ <td>{{x.type}}</td>
|
|
|
+ <td>{{x.ts}}</td>
|
|
|
+ <td>
|
|
|
+ <pre>{{JSON.stringify(x.entry, null, 2)}}</pre>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
<ul id="loglist">
|
|
|
<li v-for="(item, index) in log.slice().reverse()">
|
|
|
- {{ ts2txt(item.ts) }} - {{ item.entry.message }} - <pre>{{ JSON.stringify(item.entry) }}</pre>
|
|
|
+ {{ ts2txt(item.ts) }} - {{ item.entry.message }} -
|
|
|
+ <pre>{{ JSON.stringify(item.entry) }}</pre>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|
|
@@ -39,29 +35,30 @@
|
|
|
data: {
|
|
|
input: '// rde.writeCmd("set_digital_out(2,True)");\n' +
|
|
|
'// rde.writeCmd("movej([-1.95,-1.58,-1.16,-1.15,-1.55,1.25], a=1.0, v=0.1)");\n' +
|
|
|
- '//rde.writeCmd("freedrive_mode()");\n'+
|
|
|
+ '//rde.writeCmd("freedrive_mode()");\n' +
|
|
|
'def asdf():\n' +
|
|
|
' set_digital_out(3, True) \n' +
|
|
|
' set_digital_out(4, True) \n' +
|
|
|
'end',
|
|
|
log: [],
|
|
|
lastID: -1,
|
|
|
- doBits: []
|
|
|
+ doBits: [],
|
|
|
+ cData: {}
|
|
|
},
|
|
|
- created: function() {
|
|
|
+ created: function () {
|
|
|
setInterval(this.update, 200);
|
|
|
},
|
|
|
watch: {
|
|
|
doBits: (newValue, oldValue) => {
|
|
|
let diff1 = newValue.filter(x => !oldValue.includes(x));
|
|
|
let diff2 = oldValue.filter(x => !newValue.includes(x));
|
|
|
- for(const x of diff1) {
|
|
|
+ for (const x of diff1) {
|
|
|
fetch('/digital/' + x, {method: "POST", body: 'True'})
|
|
|
.then(function (response) {
|
|
|
return response;
|
|
|
});
|
|
|
}
|
|
|
- for(const x of diff2) {
|
|
|
+ for (const x of diff2) {
|
|
|
fetch('/digital/' + x, {method: "POST", body: 'False'})
|
|
|
.then(function (response) {
|
|
|
return response;
|
|
@@ -72,22 +69,23 @@
|
|
|
methods: {
|
|
|
send: function (event) {
|
|
|
fetch('/cmd', {method: "POST", body: this.input})
|
|
|
- .then(function(response) {
|
|
|
+ .then(function (response) {
|
|
|
return response;
|
|
|
});
|
|
|
},
|
|
|
ts2txt: function (ts) {
|
|
|
return moment(ts).format('YYYY-MM-DD hh:mm ss.SSS ')
|
|
|
},
|
|
|
- handlePackage: function(package) {
|
|
|
+ handlePackage: function (package) {
|
|
|
+ Vue.set(this.$data.cData, package.type, package)
|
|
|
switch (package.type) {
|
|
|
case 'Message':
|
|
|
break;
|
|
|
case 'MasterBoardData':
|
|
|
- let bits=package.entry.digitalOutputBits;
|
|
|
- for(let i=0;i<8;i++) {
|
|
|
- if(bits& (1<<i)) {
|
|
|
- this.doBits.push(''+(i+1));
|
|
|
+ let bits = package.entry.digitalOutputBits;
|
|
|
+ for (let i = 0; i < 8; i++) {
|
|
|
+ if (bits & (1 << i)) {
|
|
|
+ this.$data.doBits.push('' + (i + 1));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -105,32 +103,34 @@
|
|
|
break;
|
|
|
case 'AdditionalInfo':
|
|
|
break;
|
|
|
+ case 'KinematicsInfo':
|
|
|
+ break;
|
|
|
+ case 'ConfigurationData':
|
|
|
+ break;
|
|
|
default:
|
|
|
console.log('unknown package:' + package.type);
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
update: function (event) {
|
|
|
- fetch('/log/'+this.lastID, {method: "GET"})
|
|
|
+ fetch('/log/' + this.lastID, {method: "GET"})
|
|
|
.then(handleErrors)
|
|
|
.then((response) => {
|
|
|
return response.json();
|
|
|
})
|
|
|
.then((myJson) => {
|
|
|
- for(const entry of myJson.entries) {
|
|
|
+ for (const entry of myJson.entries) {
|
|
|
this.handlePackage(entry);
|
|
|
}
|
|
|
- this.$data.log=this.$data.log.concat(myJson.entries);
|
|
|
- this.$data.lastID=myJson.lastID;
|
|
|
- let len=this.$data.log.length;
|
|
|
- this.$data.log.splice(0, len-200);
|
|
|
+ this.$data.log = this.$data.log.concat(myJson.entries);
|
|
|
+ this.$data.lastID = myJson.lastID;
|
|
|
+ let len = this.$data.log.length;
|
|
|
+ this.$data.log.splice(0, len - 200);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
- this.$data.lastID=0;
|
|
|
- this.$data.log=[];
|
|
|
+ this.$data.lastID = 0;
|
|
|
+ this.$data.log = [];
|
|
|
console.log(error)
|
|
|
- } );
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
})
|