Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ def build_autocomplete_data(type, scope)
OpenC3::TargetModel.packets(target_name, type: type.upcase.intern, scope: scope).each do |packet|
packet_to_autocomplete_hashes(autocomplete_data, packet, target_info, type)
end
if type.upcase.intern == :TLM
items = OpenC3::TargetModel.all_item_names(target_name, type: :TLM, scope: scope)
items.each do |item|
autocomplete_data <<
{
:caption => "#{target_name} LATEST #{item}",
:snippet => "#{target_name} LATEST #{item}",
:meta => 'telemetry',
}
end
end
end
autocomplete_data.sort_by { |packet| packet[:caption] }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
</v-list>
</v-menu>
</template>
<template #item.limits="{ item }">

Check warning on line 134 in openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-limitsmonitor/src/tools/LimitsMonitor/LimitsControl.vue

View workflow job for this annotation

GitHub Actions / limitsmonitor

'item' is defined but never used
<v-spacer></v-spacer>
</template>
</v-data-table>
Expand Down Expand Up @@ -212,6 +212,7 @@
items: [],
itemList: [],
screenItems: [],
availableItems: [],
screenValues: {},
updateCounter: 0,
itemsPerPage: 25,
Expand Down Expand Up @@ -441,7 +442,7 @@
this.updateOutOfLimits()
},
updateIgnored() {
this.$emit('update:modelValue', this.ignored)

Check warning on line 445 in openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-limitsmonitor/src/tools/LimitsMonitor/LimitsControl.vue

View workflow job for this annotation

GitHub Actions / limitsmonitor

The "update:modelValue" event has been triggered but not declared on `emits` option
},
handleConfigEvents(config) {
for (let event of config) {
Expand Down Expand Up @@ -508,8 +509,8 @@
}
},
update() {
if (this.screenItems.length !== 0) {
this.api.get_tlm_values(this.screenItems).then((data) => {
if (this.availableItems.length !== 0) {
this.api.get_tlm_values(this.availableItems).then((data) => {
this.updateValues(data)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the calculation of available just to optimize this update() method so it doesn't call updateValues() if there are no available items?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

available is required once we implement the time series database. Just getting ahead on that.

})
}
Expand All @@ -522,11 +523,15 @@
}
},
addItem: function (valueId) {
this.screenItems.push(valueId)
this.screenValues[valueId] = [null, null, 0]
this.api.get_tlm_available([valueId]).then((available) => {
this.screenItems.push(valueId)
this.availableItems.push(available[0])
this.screenValues[available[0]] = [null, null, 0]
})
},
deleteItem: function (valueId) {
let index = this.screenItems.indexOf(valueId)
this.availableItems.splice(index, 1)
this.screenItems.splice(index, 1)
},

Expand Down Expand Up @@ -596,5 +601,4 @@
font-weight: bold;
background-color: var(--color-background-base-default);
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<target-packet-item-chooser
:initial-target-name="$route.params.target"
:initial-packet-name="$route.params.packet"
show-latest
@on-set="packetChanged($event)"
/>
</div>
Expand Down Expand Up @@ -252,6 +253,8 @@ export default {
itemName: '',
x: 0,
y: 0,
latestAvailable: null,
latestItems: null,
}
},
computed: {
Expand Down Expand Up @@ -503,19 +506,34 @@ export default {
}
},
packetChanged(event) {
this.api
.get_target(event.targetName)
.then((target) => {
// Handle LATEST packet specially
if (event.packetName === 'LATEST') {
this.api.get_target(event.targetName).then((target) => {
if (target) {
this.ignoredItems = target.ignored_items
// For LATEST, we can't get specific packet derived items
this.derivedItems = []

return this.api.get_packet_derived_items(
event.targetName,
event.packetName,
)
this.targetName = event.targetName
this.packetName = event.packetName
const currentTarget = this.$route.params.target?.toUpperCase()
const currentPacket = this.$route.params.packet?.toUpperCase()
if (
currentTarget !== event.targetName ||
currentPacket !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
})
}
this.changeUpdater(true)
} else {
// Probably got here from an old config or URL params that point to something that no longer exists
// (e.g. the plugin that defined this target was deleted). Unset these to avoid API errors.
this.targetName = null
this.packetName = null
this.$router.push({
Expand All @@ -524,28 +542,93 @@ export default {
})
}
})
.then((derived) => {
if (derived) {
this.derivedItems = derived
} else {
// Regular packet handling
this.api
.get_target(event.targetName)
.then((target) => {
if (target) {
this.ignoredItems = target.ignored_items

this.targetName = event.targetName
this.packetName = event.packetName
if (
this.$route.params.target !== event.targetName ||
this.$route.params.packet !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
return this.api.get_packet_derived_items(
event.targetName,
event.packetName,
)
} else {
// Probably got here from an old config or URL params that point to something that no longer exists
// (e.g. the plugin that defined this target was deleted). Unset these to avoid API errors.
this.targetName = null
this.packetName = null
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
params: {},
})
}
})
.then((derived) => {
if (derived) {
this.derivedItems = derived

this.targetName = event.targetName
this.packetName = event.packetName
const currentTarget = this.$route.params.target?.toUpperCase()
const currentPacket = this.$route.params.packet?.toUpperCase()
if (
currentTarget !== event.targetName ||
currentPacket !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
})
}
this.changeUpdater(true)
}
})
}
},
latestGetTlmValues(values) {
if (values != null && values.length > 0) {
this.counter += 1
let derived = []
let other = []
this.latestItemNames.forEach((itemName, index) => {
if (!this.showIgnored && this.ignoredItems.includes(itemName)) {
return
}
const itemValue = values[index]
if (itemValue) {
if (this.derivedItems.includes(itemName)) {
derived.push({
name: itemName,
value: itemValue[0],
limitsState: itemValue[1],
derived: true,
counter: this.counter,
pinned: this.isPinned(itemName),
})
} else {
other.push({
name: itemName,
value: itemValue[0],
limitsState: itemValue[1],
derived: false,
counter: this.counter,
pinned: this.isPinned(itemName),
})
}
this.changeUpdater(true)
}
})
if (this.derivedLast) {
this.rows = other.concat(derived)
} else {
this.rows = derived.concat(other)
}
}
},
changeUpdater(clearExisting) {
if (this.updater != null) {
Expand All @@ -554,62 +637,107 @@ export default {
}
if (clearExisting) {
this.rows = []
this.latestAvailable = null
this.latestItems = null
}
this.updater = setInterval(() => {
if (!this.targetName || !this.packetName) {
return // noop if target/packet aren't set
}
this.api
.get_tlm_packet(
this.targetName,
this.packetName,
this.valueType,
this.staleLimit,
)
.then((data) => {
// Make sure data isn't null or undefined. Note this is the only valid use of == or !=
if (data != null) {
this.counter += 1
let derived = []
let other = []
data.forEach((value) => {
if (!this.showIgnored && this.ignoredItems.includes(value[0])) {
return
}
if (this.derivedItems.includes(value[0])) {
derived.push({
name: value[0],
value: value[1],
limitsState: value[2],
derived: true,
counter: this.counter,
pinned: this.isPinned(value[0]),
})

// Handle LATEST packet using get_tlm_values
if (this.packetName === 'LATEST') {
if (this.latestAvailable) {
this.api
.get_tlm_values(this.latestAvailable, this.staleLimit)
.then((values) => {
this.latestGetTlmValues(values)
})
.catch((error) => {
// eslint-disable-next-line
console.log(error)
})
} else {
this.api
.get_all_tlm_item_names(this.targetName)
.then((itemNames) => {
this.latestItemNames = itemNames
// Build items array in format TGT__LATEST__ITEM__TYPE
const items = itemNames.map(
(item) =>
`${this.targetName}__LATEST__${item}__${this.valueType}`,
)
return this.api.get_tlm_available(items)
})
.then((available) => {
this.latestAvailable = available
return this.api.get_tlm_values(available, this.staleLimit)
})
.then((values) => {
this.latestGetTlmValues(values)
})
.catch((error) => {
// eslint-disable-next-line
console.log(error)
})
}
} else {
// Regular packet handling using get_tlm_packet
this.api
.get_tlm_packet(
this.targetName,
this.packetName,
this.valueType,
this.staleLimit,
)
.then((data) => {
// Make sure data isn't null or undefined. Note this is the only valid use of == or !=
if (data != null) {
this.counter += 1
let derived = []
let other = []
data.forEach((value) => {
if (
!this.showIgnored &&
this.ignoredItems.includes(value[0])
) {
return
}
if (this.derivedItems.includes(value[0])) {
derived.push({
name: value[0],
value: value[1],
limitsState: value[2],
derived: true,
counter: this.counter,
pinned: this.isPinned(value[0]),
})
} else {
other.push({
name: value[0],
value: value[1],
limitsState: value[2],
derived: false,
counter: this.counter,
pinned: this.isPinned(value[0]),
})
}
})
if (this.derivedLast) {
this.rows = other.concat(derived)
} else {
other.push({
name: value[0],
value: value[1],
limitsState: value[2],
derived: false,
counter: this.counter,
pinned: this.isPinned(value[0]),
})
this.rows = derived.concat(other)
}
})
if (this.derivedLast) {
this.rows = other.concat(derived)
} else {
this.rows = derived.concat(other)
}
}
})
// Catch errors but just log to the console
// We don't clear the updater because errors can happen on upgrade
// and we want to continue updating once the new plugin comes online
.catch((error) => {
// eslint-disable-next-line
console.log(error)
})
})
// Catch errors but just log to the console
// We don't clear the updater because errors can happen on upgrade
// and we want to continue updating once the new plugin comes online
.catch((error) => {
// eslint-disable-next-line
console.log(error)
})
}
}, this.refreshInterval)
},
resetConfig: function () {
Expand Down
Loading
Loading