diff --git a/openc3/lib/openc3/models/cvt_model.rb b/openc3/lib/openc3/models/cvt_model.rb index b861583efd..df7a20179a 100644 --- a/openc3/lib/openc3/models/cvt_model.rb +++ b/openc3/lib/openc3/models/cvt_model.rb @@ -100,15 +100,21 @@ def self.get_item(target_name, packet_name, item_name, type:, cache_timeout: nil result, types = self._handle_item_override(target_name, packet_name, item_name, type: type, cache_timeout: cache_timeout, scope: scope) return result if result hash = get(target_name: target_name, packet_name: packet_name, cache_timeout: cache_timeout, scope: scope) - hash.values_at(*types).each do |result| - if result + hash.values_at(*types).each do |cvt_value| + if cvt_value if type == :FORMATTED or type == :WITH_UNITS - return result.to_s + return cvt_value.to_s end - return result + return cvt_value end end - return nil + # RECEIVED_COUNT is a special case where it is 0 if it doesn't exist + # This allows scripts to check against the value to see if the packet was ever received + if item_name == "RECEIVED_COUNT" + return 0 + else + return nil + end end # Return all item values and limit state from the CVT diff --git a/openc3/python/openc3/models/cvt_model.py b/openc3/python/openc3/models/cvt_model.py index 02f46e3200..4df3de1388 100644 --- a/openc3/python/openc3/models/cvt_model.py +++ b/openc3/python/openc3/models/cvt_model.py @@ -127,12 +127,17 @@ def get_item( if result is not None: return result hash = cls.get(target_name, packet_name, scope=scope) - for result in [hash[x] for x in types if x in hash]: - if result is not None: + for cvt_value in [hash[x] for x in types if x in hash]: + if cvt_value is not None: if type == "FORMATTED" or type == "WITH_UNITS": - return str(result) - return result - return None + return str(cvt_value) + return cvt_value + # RECEIVED_COUNT is a special case where it is 0 if it doesn't exist + # This allows scripts to check against the value to see if the packet was ever received + if item_name == "RECEIVED_COUNT": + return 0 + else: + return None # Return all item values and limit state from the CVT # diff --git a/playwright/tests/bucket-explorer.spec.ts b/playwright/tests/bucket-explorer.spec.ts index 31fa4de4f2..07d1005fc7 100644 --- a/playwright/tests/bucket-explorer.spec.ts +++ b/playwright/tests/bucket-explorer.spec.ts @@ -244,12 +244,11 @@ test('navigate logs and tools bucket', async ({ page, utils }) => { await expect( page.getByText('DEFAULT__INST__ALL__rt__raw').first(), ).toBeVisible() - await expect(page.getByText('1970')).not.toBeVisible() await page.getByText('tools').click() await expect(page).toHaveURL(/.*\/tools\/bucketexplorer\/tools%2F/) if (process.env.ENTERPRISE === '1') { - await expect(page.locator('tbody > tr')).toHaveCount(19) + await expect(page.locator('tbody > tr')).toHaveCount(20) } else { await expect(page.locator('tbody > tr')).toHaveCount(17) } diff --git a/playwright/tests/data-extractor.spec.ts b/playwright/tests/data-extractor.spec.ts index b681fe2c6c..fe08b9a816 100644 --- a/playwright/tests/data-extractor.spec.ts +++ b/playwright/tests/data-extractor.spec.ts @@ -334,7 +334,6 @@ test('fills values', async ({ page, utils }) => { break } else if (lines[i].includes('HEALTH_STATUS')) { // Look for the second line containing HEALTH_STATUS - // console.log("Found first HEALTH_STATUS on line " + i); if (firstHS === -2) { firstHS = -1 } else { @@ -381,8 +380,8 @@ test('works with UTC date / times', async ({ page, utils }) => { expect( isWithinInterval(startTime, { // Start time is automatically 1hr in the past - start: subMinutes(now, 61), - end: subMinutes(now, 59), + start: subMinutes(now, 62), + end: subMinutes(now, 58), }), ).toBeTruthy() let endTimeString = @@ -391,8 +390,8 @@ test('works with UTC date / times', async ({ page, utils }) => { expect( isWithinInterval(endTime, { // end time is now - start: subMinutes(now, 1), - end: addMinutes(now, 1), + start: subMinutes(now, 2), + end: addMinutes(now, 2), }), ).toBeTruthy() @@ -411,29 +410,25 @@ test('works with UTC date / times', async ({ page, utils }) => { await expect(page.locator('#openc3-nav-drawer')).toBeHidden() now = new Date() - // The date is now in UTC but we parse it like it is local time + // add the timezone offset to get it to UTC + now = addMinutes(now, now.getTimezoneOffset()) startTimeString = (await page.inputValue('[data-test=start-time]'))?.trim() || '' startTime = parse(startTimeString, 'HH:mm:ss.SSS', now) - // so subtrack off the timezone offset to get it back to local time - let localStartTime = subMinutes(startTime, now.getTimezoneOffset()) expect( - isWithinInterval(localStartTime, { + isWithinInterval(startTime, { // Start time is automatically 1hr in the past - start: subMinutes(now, 61), - end: subMinutes(now, 59), + start: subMinutes(now, 62), + end: subMinutes(now, 58), }), ).toBeTruthy() - // The date is now in UTC but we parse it like it is local time endTimeString = (await page.inputValue('[data-test=end-time]'))?.trim() || '' endTime = parse(endTimeString, 'HH:mm:ss.SSS', now) - // so subtrack off the timezone offset to get it back to local time - endTime = subMinutes(endTime, now.getTimezoneOffset()) expect( isWithinInterval(endTime, { // end time is now - start: subMinutes(now, 1), - end: addMinutes(now, 1), + start: subMinutes(now, 2), + end: addMinutes(now, 2), }), ).toBeTruthy()