Files
PhotonVision/photon-client/src/mixins/global/dataHandleMixin.js
2021-01-09 14:50:46 -08:00

54 lines
1.8 KiB
JavaScript

export const dataHandleMixin = {
methods: {
handleInput(key, value) {
let msg = this.$msgPack.encode({[key]: value});
this.$socket.send(msg);
},
handleInputWithIndex(key, value, cameraIndex = this.$store.getters.currentCameraIndex) {
let msg = this.$msgPack.encode({
[key]: value,
["cameraIndex"]: cameraIndex,
});
this.$socket.send(msg);
},
handleData(val) {
this.handleInput(val, this[val]);
this.$emit('update')
},
handlePipelineData(val) {
let msg = this.$msgPack.encode({
["changePipelineSetting"]: {
[val]: this[val],
["cameraIndex"]: this.$store.getters.currentCameraIndex
}
});
this.$socket.send(msg);
this.$emit('update')
},
handlePipelineUpdate(key, val) {
let msg = this.$msgPack.encode({
["changePipelineSetting"]: {
[key]: val,
["cameraIndex"]: this.$store.getters.currentCameraIndex
}
});
this.$socket.send(msg);
this.$emit('update')
},
handleTruthyPipelineData(val) {
let msg = this.$msgPack.encode({
["changePipelineSetting"]: {
[val]: !!(this[val]),
["cameraIndex"]: this.$store.getters.currentCameraIndex
}
});
this.$socket.send(msg);
this.$emit('update')
},
rollback(val, e) {
//TODO UPDATE VALUES INTO WEBSOCKET
this.$store.commit('updatePipeline', {[val]: e})
}
}
};