Skip to content

Commit 4d74fba

Browse files
committed
Initial import
0 parents  commit 4d74fba

File tree

210 files changed

+31430
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+31430
-0
lines changed

.env.local

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SO_API=/api
2+
SO_MQTT=localhost
3+
SO_MQTT_PORT=8080
4+
SO_MQTT_PATH=/mqtt
5+
SO_MCS_USERNAME=sim
6+
SO_MCS_PASSWORD=ops
7+
SO_MCS_ADMIN_PASSWORD=admin
8+
SO_MCS_SIMPLE=0

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.env
2+
.venv
3+
.vscode
4+
__pycache__
5+
*-notes.txt
6+
*.bsp
7+
*.old
8+
sim-ops-lib/data/hist/*json
9+
.DS_Store
10+
.pytest_cache

LICENSE.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
# Sim-Ops
3+
4+
Sim-Ops is software suite for running spacecraft operations simulations exercises and demonstrations. It includes
5+
a minimalist spacecraft simulator, a ground station simulator and a Monitoring and Control System (MCS).
6+
Note, that the software suite is under constant development so things change fast. The following video
7+
illustrates the MCS UI.
8+
9+
https://github.com/nunorc/sim-ops/assets/118554/82d92168-ed7e-46f9-ac71-f78d44988842
10+
11+
Repository content:
12+
13+
* `sim-ops-lib/`: Python packages to run in the background, including API and simulators.
14+
* `sim-ops-mcs/`: MCS frontend interface.
15+
* `containers/`: containers files and configurations.
16+
17+
The following scripts are required to be running:
18+
19+
* `so-master.py`: the master script managing the simulations in the background.
20+
* `so/api.py`: the API required for the web interface.
21+
22+
### Run using Docker
23+
24+
Run using [Docker](https://www.docker.com/) containers, recommended, make sure to set the required
25+
content in the `.env` file, or by using the option `--env-file`, for example to use the `.env.local` run:
26+
27+
sim-ops$ docker compose --env-file .env.local build
28+
sim-ops$ docker compose --env-file .env.local up
29+
# mcs is available from http://localhost:8080
30+
31+
In case you are running behind a reverse proxy, firewall, or any similar setting you may need to update the values
32+
described in `.env.local` to your needs.
33+
34+
### Run from the command line
35+
36+
A Python (version 3.11 recommended) needs to be available, the list of required packages is available from `sim-ops-lib/requirements.txt` file.
37+
38+
**Note** A MQTT service, e.g. [Eclipse Mosquitto](https://mosquitto.org/) to run the scripts from a command line, check `containers/mqtt/config/mosquitto.conf` for an example configuration
39+
40+
Once an MQTT is running and reachable and all the requirements installed, run:
41+
42+
sim-ops$ cd sim-ops-lib
43+
44+
# run master script
45+
sim-ops-lib$ python so-master.py
46+
47+
# run api
48+
sim-ops-lib$ uvicorn so.api:app
49+
50+
sim-ops$ cd sim-ops-mcs
51+
52+
# run mcs
53+
sim-ops-mcs$ npm run dev
54+
55+
Running Python lib tests:
56+
57+
$ cd sim-ops-lib
58+
sim-ops-lib$ pytest
59+
60+
### The Sim-Ops Team
61+
62+
Nuno Carvalho, Peter Stöferle, Adrian Calleja, Vladimir Zelenevskiy, Rodrigo Laurinovics, Marcin Kovalevskij, Tim Oerther, Frederik Dall'Omo and David Evans.
63+
64+
### Acknowledgements
65+
66+
MCS UI theme based on HUD Vue by Sean Ngu.

compose.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
services:
2+
so-mqtt:
3+
image: eclipse-mosquitto:latest
4+
container_name: so-mqtt
5+
volumes:
6+
- ./containers/mqtt/config:/mosquitto/config
7+
ports:
8+
- "8083:8083"
9+
so-api:
10+
container_name: so-api
11+
build:
12+
context: .
13+
dockerfile: ./containers/Dockerfile_so-api
14+
links:
15+
- so-mqtt
16+
depends_on:
17+
- so-mqtt
18+
ports:
19+
- "8000:8000"
20+
environment:
21+
- SO_MCS_ADMIN_PASSWORD=${SO_MCS_ADMIN_PASSWORD}
22+
so-master:
23+
container_name: so-master
24+
build:
25+
context: .
26+
dockerfile: ./containers/Dockerfile_so-master
27+
links:
28+
- so-mqtt
29+
ports:
30+
- "5555:5555"
31+
depends_on:
32+
- so-mqtt
33+
so-mcs:
34+
container_name: so-mcs
35+
build:
36+
context: .
37+
dockerfile: ./containers/Dockerfile_so-mcs
38+
ports:
39+
- "8080:8080"
40+
depends_on:
41+
- so-api
42+
environment:
43+
- SO_API=${SO_API}
44+
- SO_MQTT=${SO_MQTT}
45+
- SO_MQTT_PORT=${SO_MQTT_PORT}
46+
- SO_MQTT_PATH=${SO_MQTT_PATH}
47+
- SO_MCS_USERNAME=${SO_MCS_USERNAME}
48+
- SO_MCS_PASSWORD=${SO_MCS_PASSWORD}
49+
- SO_MCS_ADMIN_PASSWORD=${SO_MCS_ADMIN_PASSWORD}
50+
- SO_MCS_SIMPLE=${SO_MCS_SIMPLE}

containers/Dockerfile_so-api

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
FROM python:3.11-slim
3+
4+
RUN apt-get update
5+
RUN apt-get install -y libpq-dev gcc
6+
7+
ADD sim-ops-lib/requirements.txt .
8+
RUN pip install -r requirements.txt
9+
10+
RUN mkdir /app
11+
COPY sim-ops-lib/ /app
12+
WORKDIR /app
13+
14+
ENV SO_MCS_ADMIN_PASSWORD ${SO_MCS_ADMIN_PASSWORD}
15+
16+
EXPOSE 8000
17+
ENTRYPOINT [ "/usr/local/bin/uvicorn", "--host", "0.0.0.0", "--port", "8000", "so.api:app" ]

containers/Dockerfile_so-master

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
FROM python:3.11-slim
3+
4+
RUN apt-get update
5+
RUN apt-get install -y libpq-dev gcc
6+
7+
ADD sim-ops-lib/requirements.txt .
8+
RUN pip install -r requirements.txt
9+
10+
RUN mkdir /app
11+
COPY sim-ops-lib/ /app
12+
WORKDIR /app
13+
14+
ENTRYPOINT [ "python", "so-master.py" ]

containers/Dockerfile_so-mcs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# build stage
3+
FROM node:20.2.0-bullseye-slim as build-stage
4+
5+
WORKDIR /app
6+
COPY sim-ops-mcs/package*.json ./
7+
RUN npm install
8+
COPY sim-ops-mcs/ .
9+
RUN npm run build
10+
11+
# production stage
12+
FROM nginx:stable-alpine as production-stage
13+
COPY --from=build-stage /app/dist /usr/share/nginx/html
14+
COPY containers/nginx/default.conf /etc/nginx/conf.d/
15+
COPY containers/entrypoint.sh /usr/share/nginx/entrypoint.sh
16+
RUN chmod +x /usr/share/nginx/entrypoint.sh
17+
RUN apk update && apk add apache2-utils
18+
19+
ENTRYPOINT ["/usr/share/nginx/entrypoint.sh"]
20+
21+
# start nginx
22+
CMD ["nginx", "-g", "daemon off;"]

containers/entrypoint.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
# handle htpasswd tasks
4+
5+
/usr/bin/htpasswd -c -b /etc/nginx/htpasswd ${SO_MCS_USERNAME:=sim} ${SO_MCS_PASSWORD:=ops}
6+
/usr/bin/htpasswd -b /etc/nginx/htpasswd admin ${SO_MCS_ADMIN_PASSWORD:=admin}
7+
8+
# handle MCS config
9+
10+
JSON_STRING='window.configs = { '
11+
if [[ ! -z "${SO_API}" ]]; then
12+
JSON_STRING="${JSON_STRING} 'SO_API': '${SO_API}',"
13+
fi
14+
if [[ ! -z "${SO_MQTT}" ]]; then
15+
JSON_STRING="${JSON_STRING} 'SO_MQTT': '${SO_MQTT}',"
16+
fi
17+
if [[ ! -z "${SO_MQTT_PORT}" ]]; then
18+
JSON_STRING="${JSON_STRING} 'SO_MQTT_PORT': parseInt('${SO_MQTT_PORT}'),"
19+
fi
20+
if [[ ! -z "${SO_MQTT_PATH}" ]]; then
21+
JSON_STRING="${JSON_STRING} 'SO_MQTT_PATH': '${SO_MQTT_PATH}',"
22+
fi
23+
if [[ ! -z "${SO_MCS_SIMPLE}" ]]; then
24+
JSON_STRING="${JSON_STRING} 'SO_MCS_SIMPLE': parseInt('${SO_MCS_SIMPLE}'),"
25+
else
26+
JSON_STRING="${JSON_STRING} 'SO_MCS_SIMPLE': 0,"
27+
fi
28+
JSON_STRING=$( echo "${JSON_STRING}" | sed 's#,$##' )
29+
JSON_STRING="${JSON_STRING} };"
30+
31+
sed -i "s@// CONFIGURATIONS_PLACEHOLDER@${JSON_STRING}@" /usr/share/nginx/html/index.html
32+
exec "$@"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
listener 1883
2+
listener 8083
3+
protocol websockets
4+
allow_anonymous true
5+
6+
connection_messages false
7+
log_timestamp true

0 commit comments

Comments
 (0)