From 5e19a4e6039708dcb262c5214c52c93acbbbbd29 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Tue, 30 Apr 2024 01:45:08 +0200 Subject: [PATCH] Init --- .gitignore | 1 + PklProject | 8 ++++++++ PklProject.deps.json | 4 ++++ controller.pkl | 18 ++++++++++++++++++ core.pkl | 18 ++++++++++++++++++ lib/common.pkl | 15 +++++++++++++++ lib/controller.pkl | 17 +++++++++++++++++ lib/core.pkl | 12 ++++++++++++ 8 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 PklProject create mode 100644 PklProject.deps.json create mode 100644 controller.pkl create mode 100644 core.pkl create mode 100644 lib/common.pkl create mode 100644 lib/controller.pkl create mode 100644 lib/core.pkl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab87873 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.out diff --git a/PklProject b/PklProject new file mode 100644 index 0000000..bc7911f --- /dev/null +++ b/PklProject @@ -0,0 +1,8 @@ +amends "pkl:Project" + +package { + name = "emgauwa" + baseUri = "package://emgauwa.app/pkl/\(name)" + version = "0.1.0" + packageZipUrl = "https://emgauwa.app/pkl/\(name)@\(version).zip" +} \ No newline at end of file diff --git a/PklProject.deps.json b/PklProject.deps.json new file mode 100644 index 0000000..836079a --- /dev/null +++ b/PklProject.deps.json @@ -0,0 +1,4 @@ +{ + "schemaVersion": 1, + "resolvedDependencies": {} +} \ No newline at end of file diff --git a/controller.pkl b/controller.pkl new file mode 100644 index 0000000..6ada2ba --- /dev/null +++ b/controller.pkl @@ -0,0 +1,18 @@ +amends "./lib/controller.pkl" + +server { + host = "127.0.0.1" + port = 4419 +} + +database = "sqlite://emgauwa-controller.sqlite" + +permissions { + user = "" // read("env:USER") + group = "" // read("env:USER") +} + +logging { + level = "INFO" + file = "stdout" +} diff --git a/core.pkl b/core.pkl new file mode 100644 index 0000000..dd63722 --- /dev/null +++ b/core.pkl @@ -0,0 +1,18 @@ +amends "./lib/core.pkl" + +server { + host = "127.0.0.1" + port = 4419 +} + +database = "sqlite://emgauwa-core.sqlite" + +permissions { + user = "" // read("env:USER") + group = "" // read("env:USER") +} + +logging { + level = "INFO" + file = "stdout" +} diff --git a/lib/common.pkl b/lib/common.pkl new file mode 100644 index 0000000..5d223d0 --- /dev/null +++ b/lib/common.pkl @@ -0,0 +1,15 @@ +class ServerConfig { + host: String + port: UInt16 +} + +/// Set to a user and a group to drop privileges to after binding to the port +class PermissionsConfig { + user: String + group: String +} + +class LoggingConfig { + level: "TRACE"|"DEBUG"|"INFO"|"WARN"|"ERROR"|"FATAL" + file: String +} diff --git a/lib/controller.pkl b/lib/controller.pkl new file mode 100644 index 0000000..51417d6 --- /dev/null +++ b/lib/controller.pkl @@ -0,0 +1,17 @@ +import "./common.pkl" + +server: common.ServerConfig + +database: String + +permissions: common.PermissionsConfig + +logging: common.LoggingConfig + +class RelayConfig { + driver: "null"|"gpio"|"piface" + pin: Number + inverted: Boolean + pulse: Number(this >= 0)|Null = null +} +relays: Listing diff --git a/lib/core.pkl b/lib/core.pkl new file mode 100644 index 0000000..d522e17 --- /dev/null +++ b/lib/core.pkl @@ -0,0 +1,12 @@ +import "./common.pkl" + +server: common.ServerConfig + +database: String + +permissions: common.PermissionsConfig + +logging: common.LoggingConfig + +/// Leave empty to allow all origins (will always respond with Origin and not "*") +origins: Listing