update
Took 1 hour 16 minutes
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import GPIO from "rpi-gpio";
|
||||
import Container from "./database/Container";
|
||||
import debug from "debug";
|
||||
|
||||
const log = debug("itender:gpio");
|
||||
|
||||
// Package is raspi-gpio in raspberrypi
|
||||
|
@ -78,7 +78,7 @@ export class WebSocketHandler {
|
||||
|
||||
let stats = {
|
||||
"drinks_finished": (await Job.countDocuments({successful: true})),
|
||||
"drink_most": ( counts.length == 0 ) ? "Keiner" : counts[0].name,
|
||||
"drink_most": (counts.length == 0) ? "Keiner" : counts[0].name,
|
||||
"count_ingredients": (await Ingredient.countDocuments()),
|
||||
"count_cocktails": (await Drink.countDocuments())
|
||||
};
|
||||
|
@ -41,7 +41,6 @@ router.ws('/', async (ws, req, next) => {
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (msg.event) {
|
||||
case WebSocketEvent.TARE: {
|
||||
if (msg.data["state"] == true) {
|
||||
@ -52,14 +51,14 @@ router.ws('/', async (ws, req, next) => {
|
||||
break;
|
||||
}
|
||||
case WebSocketEvent.CONTAINERS: {
|
||||
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; volume: number; }[];
|
||||
await Container.deleteMany({});
|
||||
let data = msg.data as { pumpPin: number; sensorType: SensorType; sensor1: number; sensor2: number; }[];
|
||||
await Container.deleteMany({}); // V2: Remove this and check every container based on id if changes occurs
|
||||
|
||||
let i = 0;
|
||||
for (let c of data) {
|
||||
let container = new Container();
|
||||
container.slot = i;
|
||||
container.volume = c.volume;
|
||||
//container.volume = c.volume; // V2: Removed
|
||||
container.pumpPin = c.pumpPin;
|
||||
container.sensorType = c.sensorType;
|
||||
container.sensorPin1 = c.sensor1;
|
||||
@ -83,6 +82,7 @@ router.ws('/', async (ws, req, next) => {
|
||||
}
|
||||
|
||||
container.filled = parseInt(msg.data["filled"]);
|
||||
container.volume = parseInt(msg.data["filled"]); // V2: Volume is now being updated after change of ingredient
|
||||
container.content = ingredient;
|
||||
|
||||
await container.save();
|
||||
@ -94,7 +94,7 @@ router.ws('/', async (ws, req, next) => {
|
||||
case WebSocketEvent.CONFIG: {
|
||||
// ToDo
|
||||
console.log("New Settings:", msg.data);
|
||||
// Danach setup modus us
|
||||
// Danach setup modus aus
|
||||
for (const [key, value] of Object.entries(msg.data)) {
|
||||
Settings.set(key, value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user