Skip to content

Commit

Permalink
Working limits
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Mar 16, 2023
1 parent c2bd675 commit 51c0671
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@
:colors="colors"
:item="selectedItem"
@changeColor="changeColor"
@changeLimits="changeLimits"
@close="closeEditItem"
@enableLimits="enableLimits"
/>

<!-- Edit Item right click context menu -->
Expand Down Expand Up @@ -518,7 +518,7 @@ export default {
graphEndDateTime: null,
indexes: {},
items: this.initialItems || [],
limits: [],
limitsValues: [],
drawInterval: null,
zoomChart: false,
zoomOverview: false,
Expand Down Expand Up @@ -1223,19 +1223,24 @@ export default {
let key = this.subscriptionKey(this.selectedItem)
let index = this.indexes[key]
this.items[index - 1].color = event
this.selectedItem.color = event
this.graph.root.querySelectorAll('.u-marker')[index].style.borderColor =
event
},
enableLimits: function (event) {
this.limits = event
changeLimits: function (limits, limitsValues) {
let key = this.subscriptionKey(this.selectedItem)
let index = this.indexes[key]
this.items[index - 1].limits = limits
this.selectedItem.limits = limits
this.limitsValues = limitsValues
},
linesPlugin: function () {
return {
hooks: {
draw: (u) => {
const { ctx, bbox } = u
for (var i = 0; i < this.limits.length; i++) {
let yPos = u.valToPos(this.limits[i], 'y', true)
for (var i = 0; i < this.limitsValues.length; i++) {
let yPos = u.valToPos(this.limitsValues[i], 'y', true)
ctx.save()
ctx.beginPath()
if (i === 0 || i === 3) {
Expand Down Expand Up @@ -1275,6 +1280,9 @@ export default {
if (item.color === undefined) {
item.color = this.colors[this.colorIndex]
}
if (item.limits === undefined) {
item.limits = 'NONE'
}
this.colorIndex++
if (this.colorIndex === this.colors.length) {
this.colorIndex = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
hide-details
label="Display Limits"
:items="limitsNames"
v-model="selectedLimits"
@change="$emit('enableLimits', limits[selectedLimits])"
v-model="editItem.limits"
@change="
$emit('changeLimits', editItem.limits, limits[editItem.limits])
"
/>
<div class="pa-3">
{{ selectedLimits }}: {{ limits[selectedLimits] }}
{{ editItem.limits }}: {{ limits[editItem.limits] }}
</div>
</div>
<v-card-actions>
Expand Down Expand Up @@ -93,7 +95,6 @@ export default {
return {
editItem: null,
limits: { NONE: [] },
selectedLimits: null,
valueTypes: ['CONVERTED', 'RAW'],
reduction: [
// Map NONE to DECOM for clarity
Expand All @@ -120,13 +121,15 @@ export default {
},
async created() {
this.editItem = { ...this.item }
console.log('editItem:')
console.log(this.editItem)
await this.api
this.api = new OpenC3Api()
.get_item(this.item.targetName, this.item.packetName, this.item.itemName)
.then((details) => {
console.log(details.limits)
// console.log(details.limits)
for (const [key, value] of Object.entries(details.limits)) {
console.log(`${key}: ${value} keys:${Object.keys(value)}`)
// console.log(`${key}: ${value} keys:${Object.keys(value)}`)
if (Object.keys(value).includes('red_low')) {
// Must call this.$set to allow Vue to make the limits object reactive
this.$set(this.limits, key, Object.values(value))
Expand Down

0 comments on commit 51c0671

Please sign in to comment.