added driver mode tab to settings in the ui

This commit is contained in:
ori agranat
2019-11-01 17:10:48 +02:00
parent 7ef05e6077
commit 51a3f677bd
18 changed files with 211 additions and 136 deletions

View File

@@ -10,7 +10,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-nop:1.7.26" level="project" />
<orderEntry type="library" name="Maven: io.javalin:javalin:3.4.1" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.31" level="project" />
@@ -39,9 +38,6 @@
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
<orderEntry type="library" name="Maven: org.msgpack:msgpack-core:0.8.18" level="project" />
<orderEntry type="library" name="Maven: org.msgpack:jackson-dataformat-msgpack:0.8.18" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.0.pr1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.0.pr1" level="project" />

View File

@@ -229,26 +229,26 @@ public class Camera {
public void setDriverMode(boolean state)
{
Map<String,Integer> data = new HashMap<>();
isDriver=state;
if(isDriver){
UsbCam.setBrightness(driverBrightness);
UsbCam.setBrightness(driverBrightness);
try{UsbCam.setExposureManual(driverExposure);}
catch (VideoException e)
{
System.out.println("Exposure change isnt supported");
}
data.put("brightness",getBrightness());
data.put("exposure",driverExposure);
}
else{
UsbCam.setBrightness(getCurrentPipeline().brightness);
UsbCam.setBrightness(getCurrentPipeline().brightness);
try{UsbCam.setExposureManual(getCurrentPipeline().exposure);}
catch (VideoException e)
{
System.out.println("Exposure change isnt supported");
isDriver=state;
if(isDriver){
UsbCam.setBrightness(driverBrightness);
UsbCam.setBrightness(driverBrightness);
try{UsbCam.setExposureManual(driverExposure);}
catch (VideoException e)
{
System.out.println("Exposure change isnt supported");
}
data.put("brightness",getBrightness());
data.put("exposure",driverExposure);
}
else{
UsbCam.setBrightness(getCurrentPipeline().brightness);
UsbCam.setBrightness(getCurrentPipeline().brightness);
try{UsbCam.setExposureManual(getCurrentPipeline().exposure);}
catch (VideoException e)
{
System.out.println("Exposure change isnt supported");
}
data.put("brightness",getBrightness());
data.put("exposure",getCurrentPipeline().exposure);
}

View File

@@ -114,6 +114,7 @@ public class ServerHandler {
break;
case "save":
SettingsManager.saveSettings();
System.out.println("saved Settings");
break;
}
// used to define all incoming commands

View File

@@ -14,4 +14,4 @@ module.exports = {
parserOptions: {
parser: 'babel-eslint'
}
}
};

View File

@@ -2,4 +2,4 @@ module.exports = {
presets: [
'@vue/app'
]
}
};

View File

@@ -2,4 +2,4 @@ module.exports = {
plugins: {
autoprefixer: {}
}
}
};

View File

@@ -15,7 +15,12 @@
<v-container fluid fill-height>
<v-layout>
<v-flex>
<router-view/>
<router-view @save="startTimer"/>
<v-snackbar :timeout="1000" v-model="saveSnackbar" top color="#4baf62">
<div style="text-align: center;width: 100%;">
<h4>Saved All changes</h4>
</div>
</v-snackbar>
</v-flex>
</v-layout>
</v-container>
@@ -42,9 +47,23 @@
}
}
}
},
saveSettings() {
clearInterval(this.timer);
this.saveSnackbar = true;
this.handleInput("command", "save");
},
startTimer() {
if (this.timer !== undefined) {
clearInterval(this.timer);
}
this.timer = setInterval(this.saveSettings, 4000);
}
},
data: () => ({}),
data: () => ({
saveSnackbar: false,
timer: undefined
}),
created() {
this.$options.sockets.onmessage = async (data) => {
try {

View File

@@ -29,7 +29,7 @@
}
},
indexList() {
let list = []
let list = [];
for (let i = 0; i < this.list.length; i++) {
list.push({
name: this.list[i],

View File

@@ -9,18 +9,18 @@ import msgPack from 'msgpack5';
Vue.config.productionTip = false;
// Vue.use(VueNativeSock,'ws://' + location.host + '/websocket',{format: 'json'});
Vue.use(VueNativeSock, 'ws://' + location.hostname + ':8888/websocket');
Vue.prototype.$msgPack = msgPack(true)
Vue.prototype.$msgPack = msgPack(true);
Vue.mixin({
methods: {
handleInput(key, value) {
let msg = this.$msgPack.encode({[key]: value})
let msg = this.$msgPack.encode({[key]: value});
this.$socket.send(msg);
}
}
})
});
new Vue({
router,
store,
vuetify,
render: h => h(App)
}).$mount('#app')
}).$mount('#app');

View File

@@ -1,6 +1,6 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
Vue.use(Router);
function lazyLoad(view){
return() => import(`@/views/${view}.vue`)

View File

@@ -1,77 +1,84 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
Vue.use(Vuex);
const set = key => (state,val) =>{
Vue.set(state,key,val);
const set = key => (state, val) => {
Vue.set(state, key, val);
};
export default new Vuex.Store({
state: {
settings:{
teamNumber:1577,
connectionType:0,
ip:"",
gateway:"",
netmask:"",
hostname: "Chameleon-vision"
state: {
settings: {
teamNumber: 1577,
connectionType: 0,
ip: "",
gateway: "",
netmask: "",
hostname: "Chameleon-vision"
},
pipeline: {
exposure: 0,
brightness: 0,
orientation: 0,
hue: [0, 15],
saturation: [0, 15],
value: [0, 25],
erode: false,
dilate: false,
area: [0, 12],
ratio: [0, 12],
extent: [0, 12],
speckle: 5,
targetGrouping: 0,
targetIntersection: 0,
sortMode: 0,
isBinary: 0,
calibrationMode: 0
},
driverState: {
startDriver: false,
exposure: 0,
brightness: 0
},
cameraSettings: {},
resolutionList: [],
port: 1181,
currentCameraIndex: 0,
currentPipelineIndex: 0,
cameraList: [],
pipelineList: [],
point: {}
},
pipeline:{
exposure:0,
brightness:0,
orientation:0,
hue:[0,15],
saturation:[0,15],
value:[0,25],
erode:false,
dilate:false,
area:[0,12],
ratio:[0,12],
extent:[0,12],
speckle:5,
targetGrouping:0,
targetIntersection:0,
sortMode:0,
isBinary:0,
calibrationMode:0
mutations: {
settings: set('settings'),
pipeline: set('pipeline'),
cameraSettings: set('cameraSettings'),
resolutionList: set('resolutionList'),
port: set('port'),
currentCameraIndex: set('currentCameraIndex'),
currentPipelineIndex: set('currentPipelineIndex'),
cameraList: set('cameraList'),
pipelineList: set('pipelineList'),
point: set('point'),
setPipeValues(state, obj) {
for (let i in obj) {
Vue.set(state.pipeline, i, obj[i]);
}
},
driverState: set('driverState')
},
cameraSettings:{},
resolutionList:[],
port:1181,
currentCameraIndex:0,
currentPipelineIndex:0,
cameraList:[],
pipelineList:[],
point:{}
},
mutations: {
settings: set('settings'),
pipeline: set('pipeline'),
cameraSettings: set('cameraSettings'),
resolutionList: set('resolutionList'),
port: set('port'),
currentCameraIndex: set('currentCameraIndex'),
currentPipelineIndex: set('currentPipelineIndex'),
cameraList: set('cameraList'),
pipelineList: set('pipelineList'),
point:set('point'),
setPipeValues(state,obj){
for(let i in obj){
Vue.set(state.pipeline,i,obj[i]);
}
actions: {
settings: state => state.settings,
pipeline: state => state.pipeline,
cameraSettings: state => state.cameraSettings,
resolutionList: state => state.resolutionList,
port: state => state.port,
currentCameraIndex: state => state.currentCameraIndex,
currentPipelineIndex: state => state.currentPipelineIndex,
cameraList: state => state.cameraList,
pipelineList: state => state.pipelineList,
point: state => state.point,
driverState: state => state.driverState
}
},
actions: {
settings: state => state.settings,
pipeline: state => state.pipeline,
cameraSettings: state =>state.cameraSettings,
resolutionList: state =>state.resolutionList,
port: state =>state.port,
currentCameraIndex: state =>state.currentCameraIndex,
currentPipelineIndex: state =>state.currentPipelineIndex,
cameraList: state =>state.cameraList,
pipelineList: state =>state.pipelineList,
point: state =>state.point,
}
})

View File

@@ -85,7 +85,7 @@
<div style="padding-left:30px">
<keep-alive>
<!-- vision component -->
<component v-model="pipeline" :is="selectedComponent" @update="startTimer"/>
<component v-model="pipeline" :is="selectedComponent" @update="$emit('save')"/>
</keep-alive>
</div>
</v-col>
@@ -131,12 +131,6 @@
<span style="color:#000">Can not remove the only pipeline!</span>
<v-btn color="black" text @click="snackbar = false">Close</v-btn>
</v-snackbar>
<v-snackbar :timeout="1000" v-model="saveSnackbar" top color="#4baf62">
<div style="text-align: center;width: 100%;">
<h4>Saved All changes</h4>
</div>
</v-snackbar>
</div>
</template>
@@ -198,7 +192,7 @@
this.pipelineDuplicate = {
pipeline: this.currentPipelineIndex,
camera: -1
}
};
this.duplicateDialog = true;
},
closeDuplicateDialog() {
@@ -214,16 +208,6 @@
} else {
this.snackbar = true;
}
},
saveSettings() {
clearInterval(this.timer);
this.saveSnackbar = true;
},
startTimer() {
if (this.timer !== undefined) {
clearInterval(this.timer);
}
this.timer = setInterval(this.saveSettings, 4000);
}
},
data() {
@@ -243,8 +227,6 @@
camera: -1
},
snackbar: false,
saveSnackbar: false,
timer: undefined
}
},

View File

@@ -31,7 +31,7 @@
},
methods: {
handleData(val) {
this.handleInput(val, this.value[val])
this.handleInput(val, this.value[val]);
this.$emit('update')
}
},

View File

@@ -20,7 +20,7 @@
},
methods: {
handleData(val) {
this.handleInput(val, this.value[val])
this.handleInput(val, this.value[val]);
this.$emit('update')
}
},

View File

@@ -31,7 +31,7 @@
},
methods: {
handleData(val) {
this.handleInput(val, this.value[val])
this.handleInput(val, this.value[val]);
this.$emit('update')
},
doUpdate() {

View File

@@ -27,7 +27,7 @@ import CVswitch from '../../components/cv-switch'
},
methods:{
handleData(val){
this.handleInput(val,this.value[val])
this.handleInput(val,this.value[val]);
this.$emit('update')
}
}

View File

@@ -1,19 +1,20 @@
<template>
<div>
<v-row>
<v-col cols="6" class="colsClass">
<v-tabs fixed-tabs background-color="#212121" dark height="50" slider-color="#4baf62"
<v-col class="colsClass" cols="6">
<v-tabs background-color="#212121" dark fixed-tabs height="50" slider-color="#4baf62"
v-model="selectedTab">
<v-tab to="">General</v-tab>
<v-tab to="">Cameras</v-tab>
<v-tab to="">Driver Mode</v-tab>
</v-tabs>
<div style="padding-left:30px">
<component :is="selectedComponent"/>
<component :is="selectedComponent" @update="$emit('save')"/>
</div>
</v-col>
<v-col v-show="selectedTab === 1" class="colsClass">
<v-col class="colsClass" v-show="selectedTab === 1 || selectedTab === 2">
<div class="videoClass">
<img :src="steamAdress">
<img :src="steamAddress">
</div>
</v-col>
</v-row>
@@ -23,12 +24,14 @@
<script>
import General from './SettingsViewes/General'
import Cameras from './SettingsViewes/Cameras'
import DriverMode from './SettingsViewes/DriverMode'
export default {
name: 'SettingsTab',
components: {
General,
Cameras,
DriverMode
},
data() {
return {
@@ -36,15 +39,20 @@
}
},
computed: {
selectedComponent() {
switch (this.selectedTab) {
case 0:
return "General";
case 1:
return "Cameras";
selectedComponent: {
get() {
switch (this.selectedTab) {
case 0:
return "General";
case 1:
return "Cameras";
case 2:
return "DriverMode";
}
return "";
}
},
steamAdress: {
steamAddress: {
get: function () {
return "http://" + location.hostname + ":" + this.$store.state.port + "/stream.mjpg";
}

View File

@@ -0,0 +1,62 @@
<template>
<div>
<CVselect name="Camera" :list="cameraList" v-model="currentCameraIndex"/>
<CVswitch v-model="driverState.startDriver" name="Driver Mode" @input="sendDriverMode"/>
<CVslider name="Exposure" v-model="driverState.exposure" :min="0" :max="100" @input="sendDriverMode"/>
<CVslider name="Brightness" v-model="driverState.brightness" :min="0" :max="100"
@input="sendDriverMode"/>
</div>
</template>
<script>
import CVselect from '../../components/cv-select'
import CVswitch from '../../components/cv-switch'
import CVslider from '../../components/cv-slider'
export default {
name: "DriverMode",
components: {
CVselect,
CVswitch,
CVslider
},
methods: {
sendDriverMode() {
this.handleInput('driverState', this.driverState);
this.$emit("update");
}
},
computed: {
currentCameraIndex: {
get() {
return this.$store.state.currentCameraIndex;
},
set(value) {
this.$store.commit('currentCameraIndex', value);
}
},
cameraList: {
get() {
return this.$store.state.cameraList;
},
set(value) {
this.$store.commit('cameraList', value);
}
},
driverState: {
get() {
return this.$store.state.driverState;
},
set(value) {
this.$store.commit("driverState", value);
}
}
}
}
</script>
<style scoped>
</style>