-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to enable multi-channel redis
Updated CONFIG for use by redis-experiment-publisher shows a simple way to see data move through redis to OnAIR Added custom error to DataSource for key config errors Fixed columnization of redis_adapter Redis adapter now checks multiple channels detects when time is missing from received message helps detect unused keys helps detect missing expected keys warns if listener exits Updated and added necessary unit tests for coverage and code verification
- Loading branch information
Showing
5 changed files
with
384 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,41 @@ | ||
{ | ||
"subsystems": { | ||
"NONE": { | ||
"Time": { | ||
"conversion": "", | ||
"tests": { | ||
"NOOP": "[]" | ||
}, | ||
"description": "No description" | ||
"STATES": { | ||
"time": { | ||
"description": "Time of latest receipt of values" | ||
}, | ||
"THRUST": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[-999999999999999, 999999999999999]" | ||
}, | ||
"description": "No description" | ||
"state_0.x": { | ||
"description": "Vehicle 0's current state of x" | ||
}, | ||
"ALTITUDE": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[-999999999999999, 999999999999999]" | ||
}, | ||
"description": "No description" | ||
"state_0.y": { | ||
"description": "Vehicle 0's current state of y" | ||
}, | ||
"ACCELERATION": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[-20.1111, 20.1111]" | ||
}, | ||
"description": "No description" | ||
"state_1.x": { | ||
"description": "Vehicle 1's current state of x" | ||
}, | ||
"SCIENCE_COLLECTION": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[-0.9999, 1.1111]" | ||
}, | ||
"description": "No description" | ||
"state_1.y": { | ||
"description": "Vehicle 1's current state of y" | ||
}, | ||
"LABEL_ERROR_STATE": { | ||
"conversion": "", | ||
"tests": { | ||
"NOOP": "[]" | ||
}, | ||
"description": "No description" | ||
} | ||
}, | ||
"POWER": { | ||
"VOLTAGE": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[12.9999, 18.1111]" | ||
}, | ||
"description": "No description" | ||
"state_2.x": { | ||
"description": "Vehicle 2's current state of x" | ||
}, | ||
"CURRENT": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[2.9999, 5.1111]" | ||
}, | ||
"description": "No description" | ||
} | ||
}, | ||
"THERMAL": { | ||
"TEMPERATURE": { | ||
"conversion": "", | ||
"tests": { | ||
"FEASIBILITY": "[9.9999, 90.1111]" | ||
}, | ||
"description": "No description" | ||
"state_2.y": { | ||
"description": "Vehicle 2's current state of y" | ||
} | ||
} | ||
}, | ||
"redis_subscriptions": [ | ||
"vehicle_0_state", | ||
"vehicle_1_state", | ||
"vehicle_2_state" | ||
"state_0", | ||
"state_1", | ||
"state_2" | ||
], | ||
"order": [ | ||
"Time", | ||
"VOLTAGE", | ||
"CURRENT", | ||
"THRUST", | ||
"ALTITUDE", | ||
"ACCELERATION", | ||
"TEMPERATURE", | ||
"SCIENCE_COLLECTION", | ||
"LABEL_ERROR_STATE" | ||
"time", | ||
"state_0.x", | ||
"state_0.y", | ||
"state_1.x", | ||
"state_1.y", | ||
"state_2.x", | ||
"state_2.y" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import redis | ||
import time | ||
import random | ||
|
||
# Initialize the Redis connection | ||
redis_host = "localhost" | ||
redis_port = 6379 | ||
# When your Redis server requires a password, fill it in here | ||
redis_password = "" | ||
# Connect to Redis | ||
r = redis.Redis(host=redis_host, | ||
port=redis_port, | ||
password=redis_password, | ||
decode_responses=True) | ||
# List of channel names | ||
channels = ['state_0', 'state_1', 'state_2'] | ||
# Publish messages on each channel in random order | ||
def publish_messages(): | ||
loop_count = 0 | ||
inner_loop_count = 0 | ||
max_loops = 9 | ||
while loop_count < max_loops: | ||
random.shuffle(channels) | ||
for channel in channels: | ||
r.publish(channel, f'{{"time":{inner_loop_count}, ' \ | ||
f'"x":{inner_loop_count+0.1}, ' \ | ||
f'"y":{inner_loop_count+0.2}}}') | ||
print(f"Published data to {channel}, " \ | ||
f"[{inner_loop_count}, " \ | ||
f"{inner_loop_count+0.1}, " \ | ||
f"{inner_loop_count+0.2}]") | ||
inner_loop_count += 1 | ||
time.sleep(2) | ||
loop_count += 1 | ||
print(f"Completed {loop_count} loops") | ||
|
||
if __name__ == "__main__": | ||
publish_messages() |
Oops, something went wrong.