From 45d2cf345edf45a0a007be993e911bb40c1127f7 Mon Sep 17 00:00:00 2001 From: Lars Dietrich Date: Fri, 20 Dec 2019 20:28:36 +0100 Subject: [PATCH] Make it possible to set external fan table file --- README.md | 10 ++++++++++ src/common/fanTable.ts | 14 ++++++++++++-- src/electron/electronmain.ts | 20 ++++++++++---------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 49048e9..d1e96e4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,16 @@ Currently we support the follow platforms: All other platforms are not tested and we not give warranty to run. +# Config + +## TUXEDO_FAN_TABLE_FILE +It is possible to set a external fantables.json via the environment variable +**TUXEDO_FAN_TABLE_FILE** (use absolute file paths). + +**IMPORTANT: Wrong or to low values can overheat the hardware and damage the system!** + +Example see: [fantables.json](./src/data/fantables.json) + ## Development ### Dependencies diff --git a/src/common/fanTable.ts b/src/common/fanTable.ts index 8f9224d..984d4fd 100644 --- a/src/common/fanTable.ts +++ b/src/common/fanTable.ts @@ -28,13 +28,23 @@ export class TemperaturEntry */ export function readFanTables(): FanTable[] { - let fanTablesFilePath: string = "../data/fantables.json"; let fs: any = Environment.getObject("fs"); let path: any = Environment.getObject("path"); + let fanTablesFilePath: string = "../data/fantables.json"; + fanTablesFilePath = path.join(__dirname, fanTablesFilePath); + if (process.env.TUXEDO_FAN_TABLE_FILE) { + fs.writeFileSync( + System.LOGFILE_PATH, + new Date().toISOString() + ' use TUXEDO_FAN_TABLE_FILE: ' + process.env.TUXEDO_FAN_TABLE_FILE + '\n', + {flag: "a"} + ); + fanTablesFilePath = process.env.TUXEDO_FAN_TABLE_FILE; + } + let tables = new Array(); fs.writeFileSync(System.LOGFILE_PATH, new Date().toISOString() + " Read fan table\n", { flag: "a" }); - let content = fs.readFileSync(path.join(__dirname, fanTablesFilePath)).toString() + let content: string = fs.readFileSync(fanTablesFilePath).toString(); tables = JSON.parse(content); return tables; diff --git a/src/electron/electronmain.ts b/src/electron/electronmain.ts index d78f7a3..cf2cc16 100644 --- a/src/electron/electronmain.ts +++ b/src/electron/electronmain.ts @@ -159,7 +159,7 @@ let publicOptions: Array = [ tuxedoCheckerAndExecuter(() => { try - { + { require("./common/system").System.createUnitFile(); } catch(error) @@ -227,11 +227,11 @@ let privateOptions: Array = [ environment.setDaemonMode(true); environment.setEnvironmentVariable("fs", require("fs"), "daemon"); - tuxedoCheckerAndExecuter(() => { + tuxedoCheckerAndExecuter(() => { try { - fs.writeFileSync(logFilePath, "Configure daemon", { flag: "a" }); - + fs.writeFileSync(logFilePath, new Date().toISOString() + " Configure daemon\n", { flag: "a" }); + environment.setEnvironmentVariable("os", require("os"), "daemon"); environment.setEnvironmentVariable("path", require("path"), "daemon"); environment.setEnvironmentVariable("child_process", require("child_process"), "daemon"); @@ -245,7 +245,7 @@ let privateOptions: Array = [ } catch (error) { - fs.writeFileSync(logFilePath, "Error at start daemon, error: " + error + "\n", { flag: "a" }); + fs.writeFileSync(logFilePath, new Date().toISOString() + "Error at start daemon, error: " + error + "\n", { flag: "a" }); } }); } @@ -254,17 +254,17 @@ let privateOptions: Array = [ option: null, optionLong: "--expert", description: "", - action: (arg, index, array) => { + action: (arg, index, array) => { (global).expertMode = true; - } + } }, { option: null, optionLong: "--novendorcheck", description: "", - action: (arg, index, array) => { + action: (arg, index, array) => { (global).vendorcheck = false; - } + } } ]; @@ -372,7 +372,7 @@ function printCurrentFanInformations(): void { console.log("Nvidia Card exist"); gpuOneInfon = ec_access.getFanInformation(ec_access.FAN.GPUONEDATA); - + for(let i = 0; i < 100000; i++) {} gpuTwoInfon = ec_access.getFanInformation(ec_access.FAN.GPUTWODATA);