Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Make it possible to set external fan table file #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/common/fanTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FanTable>();

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;
Expand Down
20 changes: 10 additions & 10 deletions src/electron/electronmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ let publicOptions: Array<CommandlineOption> = [

tuxedoCheckerAndExecuter(() => {
try
{
{
require("./common/system").System.createUnitFile();
}
catch(error)
Expand Down Expand Up @@ -227,11 +227,11 @@ let privateOptions: Array<CommandlineOption> = [
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");
Expand All @@ -245,7 +245,7 @@ let privateOptions: Array<CommandlineOption> = [
}
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" });
}
});
}
Expand All @@ -254,17 +254,17 @@ let privateOptions: Array<CommandlineOption> = [
option: null,
optionLong: "--expert",
description: "",
action: (arg, index, array) => {
action: (arg, index, array) => {
(<any>global).expertMode = true;
}
}
},
{
option: null,
optionLong: "--novendorcheck",
description: "",
action: (arg, index, array) => {
action: (arg, index, array) => {
(<any>global).vendorcheck = false;
}
}
}
];

Expand Down Expand Up @@ -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);
Expand Down