Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Reload only modified devices
Browse files Browse the repository at this point in the history
Refactoring

Signed-off-by: Hayden Briese <[email protected]>
  • Loading branch information
hbriese committed Sep 2, 2020
1 parent ec1d960 commit ecb899f
Show file tree
Hide file tree
Showing 27 changed files with 331 additions and 200 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ set(SOURCE_FILES ${SRC}/main.cpp ${SRC}/main.hpp
${SRC}/Args.hpp ${SRC}/Args.cpp
${SRC}/Client.cpp ${SRC}/Client.hpp
${SRC}/Controller.cpp ${SRC}/Controller.hpp
${SRC}/FanThread.cpp ${SRC}/FanThread.hpp
${SRC}/FanTask.cpp ${SRC}/FanTask.hpp
${SRC}/Devices.cpp ${SRC}/Devices.hpp
${SRC}/FanInterface.cpp ${SRC}/FanInterface.hpp
${SRC}/SensorInterface.cpp ${SRC}/SensorInterface.hpp
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fancon (0.23.2) UNRELEASED; urgency=low
fancon (0.23.3) UNRELEASED; urgency=low

* Initial release. Closes: #00000

Expand Down
2 changes: 1 addition & 1 deletion debian/fancon-resume.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate
[Service]
Type=oneshot
User=root
ExecStart=/usr/bin/fancon reload
ExecStart=/usr/bin/fancon recover

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
1 change: 1 addition & 0 deletions proto/DevicesSpec.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ service DService {
rpc DisableAll(Empty) returns (Empty) {}
rpc Test(TestRequest) returns (stream TestResponse) {}
rpc Reload(Empty) returns (Empty) {}
rpc Recover(Empty) returns (Empty) {}
rpc NvInit(Empty) returns (Empty) {}
}
2 changes: 2 additions & 0 deletions src/Args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ fc::Arg::Arg(string name, string short_name, bool has_value, bool needs_value,
bool fc::Arg::has_value() const { return !value.empty(); }

fc::Arg::operator bool() const { return triggered; }

pair<string, fc::Arg &> fc::Args::a(Arg &arg) { return {arg.key, arg}; }
28 changes: 11 additions & 17 deletions src/Args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,17 @@ class Args {
service = {"service"}, daemon = {"daemon"},
stop_service = {"stop-service"},
sysinfo = {"sysinfo", "i", true, true, DEFAULT_SYSINFO_PATH},
nv_init = {"nv-init"}, verbose = {"verbose", "v"}, trace = {"trace", "a"};

map<string, Arg &> from_key = {{help.key, help},
{status.key, status},
{enable.key, enable},
{disable.key, disable},
{test.key, test},
{force.key, force},
{reload.key, reload},
{config.key, config},
{service.key, service},
{daemon.key, daemon},
{stop_service.key, stop_service},
{sysinfo.key, sysinfo},
{nv_init.key, nv_init},
{verbose.key, verbose},
{trace.key, trace}};
recover = {"recover"}, nv_init = {"nv-init"}, verbose = {"verbose", "v"},
trace = {"trace", "a"};

map<string, Arg &> from_key = {
a(help), a(status), a(enable), a(disable),
a(test), a(force), a(reload), a(config),
a(service), a(daemon), a(stop_service), a(sysinfo),
a(recover), a(nv_init), a(verbose), a(trace)};

private:
static pair<string, Arg &> a(Arg &arg);
};
} // namespace fc

Expand Down
10 changes: 10 additions & 0 deletions src/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void fc::Client::run(Args &args) {
reload();
} else if (args.stop_service) {
stop_service();
} else if (args.recover) {
recover();
} else if (args.nv_init) {
nv_init();
} else if (args.sysinfo) {
Expand Down Expand Up @@ -199,6 +201,12 @@ void fc::Client::reload() {
LOG(llvl::error) << "Failed to reload";
}

void fc::Client::recover() {
ClientContext context;
if (!check(client->Recover(&context, empty, &empty)))
LOG(llvl::error) << "Failed to init nvidia";
}

void fc::Client::nv_init() {
ClientContext context;
if (!check(client->NvInit(&context, empty, &empty)))
Expand Down Expand Up @@ -268,6 +276,8 @@ void fc::Client::print_help(const string &conf) {
<< " stop-service Stop the service" << endl
<< "i sysinfo [file] Save system info to file (default: "
<< fc::DEFAULT_SYSINFO_PATH << ")" << endl
<< " recover Recover control of enabled devices"
<< endl
<< " nv-init Init nvidia devices" << endl
<< "v verbose Debug logging level" << endl
<< "a trace Trace logging level" << endl;
Expand Down
1 change: 1 addition & 0 deletions src/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Client {
void test(bool forced);
void test(const string &flabel, bool forced);
void reload();
void recover();
void nv_init();
void sysinfo(const string &p);

Expand Down
Loading

0 comments on commit ecb899f

Please sign in to comment.