Skip to content

Commit

Permalink
Merge branch 'main' into sns-i2c_temp
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeechey committed Oct 3, 2024
2 parents 5877132 + 56f3286 commit faf8802
Show file tree
Hide file tree
Showing 265 changed files with 33,365 additions and 0 deletions.
40 changes: 40 additions & 0 deletions telemetry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# compiled output
dist
node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
.turbo

# .env files
.env

# influx
influxdb/config
influxdb/data

# mosquitto persistence & logs
mosquitto/data
mosquitto/log
5 changes: 5 additions & 0 deletions telemetry/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf"
}
37 changes: 37 additions & 0 deletions telemetry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:18.17.0

# Create app directory
WORKDIR /usr/src/app

# Install pnpm
RUN npm install -g pnpm

# Install dependencies
COPY package.json ./
COPY packages/constants/package.json ./packages/constants/
COPY packages/server/package.json ./packages/server/
COPY packages/types/package.json ./packages/types/
COPY packages/ui/package.json ./packages/ui/
COPY packages/public-app/package.json ./packages/public-app/
COPY packages/fake/package.json ./packages/fake/
COPY packages/eslint-config/package.json ./packages/eslint-config/
COPY packages/tsconfig/package.json ./packages/tsconfig/
COPY packages/e2e-tests/package.json ./packages/e2e-tests/
COPY pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
COPY patches ./patches
COPY turbo.json ./
RUN pnpm install --frozen-lockfile
RUN pnpm --filter=e2e-tests exec playwright install --with-deps

# Expose ports
EXPOSE 5173
EXPOSE 3000
EXPOSE 3001
EXPOSE 8086
EXPOSE 9323

# Entrypoint
COPY entry.sh ./

ENTRYPOINT [ "/usr/src/app/entry.sh" ]
19 changes: 19 additions & 0 deletions telemetry/docker-compose.mqtt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3'

services:
mosquitto:

Check warning on line 4 in telemetry/docker-compose.mqtt.yml

View workflow job for this annotation

GitHub Actions / Spell check with typos

"mosquitto" should be "mosquito".
container_name: mosquitto

Check warning on line 5 in telemetry/docker-compose.mqtt.yml

View workflow job for this annotation

GitHub Actions / Spell check with typos

"mosquitto" should be "mosquito".
image: eclipse-mosquitto:2.0.18

Check warning on line 6 in telemetry/docker-compose.mqtt.yml

View workflow job for this annotation

GitHub Actions / Spell check with typos

"mosquitto" should be "mosquito".
ports:
- 1883:1883
- 8080:8080
volumes:
- ./mosquitto/config:/mosquitto/config
- ./mosquitto/data:/mosquitto/data
- ./mosquitto/log:/mosquitto/log
restart: always
networks:
- telemetry

volumes:
mosquitto:

Check warning on line 19 in telemetry/docker-compose.mqtt.yml

View workflow job for this annotation

GitHub Actions / Spell check with typos

"mosquitto" should be "mosquito".
58 changes: 58 additions & 0 deletions telemetry/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: '3'

services:
telemetry:
container_name: telemetry
build:
context: .
dockerfile: Dockerfile
ports:
- 5173:5173
- 3000:3000
- 3001:3001
- 9323:9323
environment:
- PNPM_SCRIPT
- IS_DOCKER=true
- E2E_TEST_MQTT_BROKER=mqtt://mosquitto:1883

Check warning on line 17 in telemetry/docker-compose.yml

View workflow job for this annotation

GitHub Actions / Spell check with typos

"mosquitto" should be "mosquito".
- PWTEST_SKIP_TEST_OUTPUT=1
volumes:
- ./:/usr/src/app
# Exclude node_modules from being mounted
- /usr/src/app/node_modules
- /usr/src/app/packages/constants/node_modules
- /usr/src/app/packages/server/node_modules
- /usr/src/app/packages/types/node_modules
- /usr/src/app/packages/ui/node_modules
- /usr/src/app/packages/public-app/node_modules
- /usr/src/app/packages/public-app/.next
- /usr/src/app/packages/fake/node_modules
- /usr/src/app/packages/eslint-config/node_modules
- /usr/src/app/packages/e2e-tests/node_modules
networks:
- telemetry
influxdb:
container_name: influxdb
image: influxdb:2.7
ports:
- 8086:8086
volumes:
- ./influxdb/data:/var/lib/influxdb2
- ./influxdb/config:/etc/influxdb2
- ./influxdb/scripts:/docker-entrypoint-initdb.d
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=hyped
- DOCKER_INFLUXDB_INIT_PASSWORD=edinburgh
- DOCKER_INFLUXDB_INIT_ORG=hyped
- DOCKER_INFLUXDB_INIT_BUCKET=telemetry
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=edinburgh
networks:
- telemetry

volumes:
influxdb:

networks:
telemetry:
driver: bridge
9 changes: 9 additions & 0 deletions telemetry/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Use docker env files
cp /usr/src/app/packages/server/.env.docker /usr/src/app/packages/server/.env

cp /usr/src/app/packages/ui/.env.docker /usr/src/app/packages/ui/.env

pnpm run $PNPM_SCRIPT
4 changes: 4 additions & 0 deletions telemetry/influxdb/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

set -e
influx bucket create -n faults
14 changes: 14 additions & 0 deletions telemetry/mosquitto/config/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# mqtt protocol
listener 1883
protocol mqtt

# websockets protocol (for GUI)
listener 8080
protocol websockets

allow_anonymous true

# persistence & logs
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
30 changes: 30 additions & 0 deletions telemetry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@hyped/telemetry",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "turbo run start",
"dev": "turbo run dev",
"dev:test": "turbo run dev:test",
"ci": "turbo run build lint e2e:test",
"lint": "turbo run lint --parallel",
"lint:fix": "turbo run lint:fix --parallel",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"e2e:test": "turbo run e2e:test",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\"",
"build": "turbo run build"
},
"devDependencies": {
"@types/node": "^18.11.18",
"prettier": "3.2.4",
"turbo": "^1.11.3",
"typescript": "^5.3.3"
},
"pnpm": {
"patchedDependencies": {
"@nestjs/common@9.4.2": "patches/@nestjs__common@9.4.2.patch",
"nest-mqtt@0.2.0": "patches/nest-mqtt@0.2.0.patch",
"openmct@3.2.0": "patches/openmct@3.2.0.patch"
}
}
}
9 changes: 9 additions & 0 deletions telemetry/packages/constants/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@hyped/eslint-config/basic.js'],
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
};
26 changes: 26 additions & 0 deletions telemetry/packages/constants/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@hyped/telemetry-constants",
"private": true,
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/telemetry-constants.esm.js",
"files": [
"dist",
"src"
],
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"lint": "eslint \"src/**/*.ts\" --max-warnings 0 --report-unused-disable-directives",
"lint:fix": "eslint \"src/**/*.ts\" --fix"
},
"devDependencies": {
"@hyped/telemetry-types": "workspace:*",
"@hyped/eslint-config": "workspace:*",
"@hyped/tsconfig": "workspace:*",
"tsdx": "^0.14.1",
"tslib": "^2.5.3",
"typescript": "^5.3.3"
}
}
7 changes: 7 additions & 0 deletions telemetry/packages/constants/src/faults/levels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const FAULT_LEVEL = {
WATCH: 'WATCH',
WARNING: 'WARNING',
CRITICAL: 'CRITICAL',
} as const;

export type FaultLevel = (typeof FAULT_LEVEL)[keyof typeof FAULT_LEVEL];
19 changes: 19 additions & 0 deletions telemetry/packages/constants/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export { pods, POD_IDS } from './pods/pods';
export type { PodId, Pods } from './pods/pods';
export {
ALL_POD_STATES,
PASSIVE_STATES,
ACTIVE_STATES,
NULL_STATES,
FAILURE_STATES,
getStateType,
} from './pods/states';
export type { PodStateType, PodStateCategoryType } from './pods/states';
export { MODES, MODE_EXCLUDED_STATES } from './pods/modes';
export type { ModeType } from './pods/modes';
export { openMctObjectTypes } from './openmct/object-types/object-types';

export * as socket from './socket';

export { FAULT_LEVEL } from './faults/levels';
export type { FaultLevel } from './faults/levels';
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { OpenMctObjectTypes } from '@hyped/telemetry-types';

export const openMctObjectTypes: OpenMctObjectTypes = [
{
id: 'temperature',
name: 'Temperature',
icon: 'icon-telemetry',
},
{
id: 'thermistor',
name: 'Thermistor',
icon: 'icon-telemetry',
},
{
id: 'acceleration',
name: 'Acceleration',
icon: 'icon-telemetry',
},
{
id: 'pressure',
name: 'Pressure',
icon: 'icon-telemetry',
},
{
id: 'hall_effect',
name: 'Hall Effect',
icon: 'icon-telemetry',
},
{
id: 'displacement',
name: 'Displacement',
icon: 'icon-telemetry',
},
{
id: 'velocity',
name: 'Velocity',
icon: 'icon-telemetry',
},
{
id: 'status',
name: 'status',
icon: 'icon-telemetry',
},
{
id: 'keyence',
name: 'Keyence',
icon: 'icon-telemetry',
},
{
id: 'brake_feedback',
name: 'Brake Feedback',
icon: 'icon-telemetry',
},
];
Loading

0 comments on commit faf8802

Please sign in to comment.