Debian Codegraph @

src/core/sysmodelsyncer.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/sysmodelsyncer.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "sysmodelsyncer.h"cxx . . $ `<file>/src/core/sysmodelsyncer.h`/
5
6 #include "iprofileview.h"cxx . . $ `<file>/src/core/iprofileview.h`/
7 #include <QStringList>
8 #include <QVariant>
9 #include <chrono>
10 #include <utility>
11
12 SysModelSyncercxx . . $ SysModelSyncer#::SysModelSyncercxx . . $ SysModelSyncer#SysModelSyncer(522add7052a4c64b).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISysModelcxx . . $ ISysModel#> &&sysModel,
13 stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IHelperSysCtlcxx . . $ IHelperSysCtl#> &&helperSysCtl) noexcept
14 : sysModel_cxx . . $ SysModelSyncer#sysModel_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sysModel))
15 , helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(helperSysCtl))
16 , cmds_cxx . . $ SysModelSyncer#cmds_.({cxx . . $ std/unordered_set#unordered_set(cd91ea9215506ca7)."pp_od_clk_voltage", "fan_curve", "fan_zero_rpm_enable",
17 "fan_zero_rpm_stop_temperature", "fan_target_temperature",
18 "fan_minimum_pwm", "acoustic_target_rpm_threshold",
19 "acoustic_limit_rpm_threshold"})
20 {
21 }
22
23 ISysModelcxx . . $ ISysModel# &SysModelSyncercxx . . $ SysModelSyncer#::sysModelcxx . . $ SysModelSyncer#sysModel(aa35fd785725305d).() const
24 {
25 return *cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).sysModel_cxx . . $ SysModelSyncer#sysModel_.;
26 }
27
28 void SysModelSyncercxx . . $ SysModelSyncer#::settingChangedcxx . . $ SysModelSyncer#settingChanged(1c60a90c724e6bfb).(QStringcxx . . $ QString# const &key, QVariantcxx . . $ QVariant# const &value)
29 {
30 if (key ==cxx . . $ `operator==`(94dc9d443ef00688). "Workarounds/ignoredSensors") {
31 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(sensorsMutex_cxx . . $ SysModelSyncer#sensorsMutex_.);
32 ignoredSensors_cxx . . $ SysModelSyncer#ignoredSensors_..clearcxx . . $ std/unordered_map#clear(ced63f7c635d850d).();
33
34 auto const sensorList = value.toStringListcxx . . $ QVariant#toStringList(2b25566bdf736d18).();
35 for (auto const &sensor : sensorList) {
36 auto componentSensorIdList = sensor.splitcxx . . $ QString#split(4e27fcb098d1f780).('/'cxx . . $ QChar#QChar(93d577a3e9528307).);
37 if (componentSensorIdList.sizecxx . . $ QList#size(6b0412d51016192f).() == 2) {
38 auto component = componentSensorIdList.atcxx . . $ QList#at(c7965f769b39929).(0).toStdStringcxx . . $ QString#toStdString(219584694fe2b248).();
39 auto sensorId = componentSensorIdList.atcxx . . $ QList#at(c7965f769b39929).(1).toStdStringcxx . . $ QString#toStdString(219584694fe2b248).();
40
41 if (ignoredSensors_cxx . . $ SysModelSyncer#ignoredSensors_..countcxx . . $ std/unordered_map#count(b71ff106d381144b).(component) == 0)
42 ignoredSensors_cxx . . $ SysModelSyncer#ignoredSensors_.[cxx . . $ std/unordered_map#`operator[]`(4f10b6009f0ee734).component] =cxx . . $ std/unordered_set#`operator=`(f9fceeb5a0eae059). {cxx . . $ std/initializer_list#initializer_list(ced63f7c635d850d).};
43
44 ignoredSensors_cxx . . $ SysModelSyncer#ignoredSensors_.[cxx . . $ std/unordered_map#`operator[]`(4f10b6009f0ee734).component].emplacecxx . . $ std/unordered_set#emplace(422e73f5886d780d).(sensorId);
45 }
46 }
47 }
48 }
49
50 void SysModelSyncercxx . . $ SysModelSyncer#::logCommandscxx . . $ SysModelSyncer#logCommands(b45ddcbc8423892c).(bool enable)
51 {
52 helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).logCommandscxx . . $ IHelperSysCtl#logCommands(b45ddcbc8423892c).(enable);
53 }
54
55 void SysModelSyncercxx . . $ SysModelSyncer#::initcxx . . $ SysModelSyncer#init(49f6e7a06ebc5aa8).()
56 {
57 helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ IHelperSysCtl#init(49f6e7a06ebc5aa8).();
58
59 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).preInitcxx . . $ ISysModel#preInit(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
60 helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).applycxx . . $ IHelperSysCtl#apply(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
61
62 // NOTE give some time to the helper so it applies the pre-init commands
63 // before the model initialization.
64 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::millisecondscxx . . $ std/chrono/milliseconds#(500));
65
66 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ ISysModel#init(49f6e7a06ebc5aa8).();
67
68 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).postInitcxx . . $ ISysModel#postInit(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
69 helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).applycxx . . $ IHelperSysCtl#apply(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
70
71 // start the sensor updating thread
72 updateThread_cxx . . $ SysModelSyncer#updateThread_. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<stdcxx . . $ std/::threadcxx . . $ std/thread#>([&]() {
73 while (!stopSignal_cxx . . $ SysModelSyncer#stopSignal_..loadcxx . . $ std/atomic#load(84dca352c0e0dfc2).(stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.)) {
74 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::millisecondscxx . . $ std/chrono/milliseconds#(500));
75 updateSensorscxx . . $ SysModelSyncer#updateSensors(49f6e7a06ebc5aa8).();
76 }
77 });
78
79 // start the model syncing thread
80 syncThread_cxx . . $ SysModelSyncer#syncThread_. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<stdcxx . . $ std/::threadcxx . . $ std/thread#>([&]() {
81 while (!stopSignal_cxx . . $ SysModelSyncer#stopSignal_..loadcxx . . $ std/atomic#load(84dca352c0e0dfc2).(stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.)) {
82 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::millisecondscxx . . $ std/chrono/milliseconds#(500));
83 syncModelcxx . . $ SysModelSyncer#syncModel(49f6e7a06ebc5aa8).();
84 }
85 });
86 }
87
88 void SysModelSyncercxx . . $ SysModelSyncer#::stopcxx . . $ SysModelSyncer#stop(49f6e7a06ebc5aa8).()
89 {
90 stopSignal_cxx . . $ SysModelSyncer#stopSignal_..storecxx . . $ std/atomic#store(8f3cbf3da563ad44).(true, stdcxx . . $ std/::memory_order_relaxedcxx . . $ std/memory_order_relaxed.);
91 updateThread_cxx . . $ SysModelSyncer#updateThread_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).joincxx . . $ std/thread#join(49f6e7a06ebc5aa8).();
92 syncThread_cxx . . $ SysModelSyncer#syncThread_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).joincxx . . $ std/thread#join(49f6e7a06ebc5aa8).();
93 }
94
95 void SysModelSyncercxx . . $ SysModelSyncer#::applycxx . . $ SysModelSyncer#apply(1fbcc559ec85543d).(IProfileViewcxx . . $ IProfileView# &profileView)
96 {
97 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(syncMutex_cxx . . $ SysModelSyncer#syncMutex_.);
98 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).importWithcxx . . $ Importable#importWith(94eddebf9440278).(profileView);
99 }
100
101 void SysModelSyncercxx . . $ SysModelSyncer#::updateSensorscxx . . $ SysModelSyncer#updateSensors(49f6e7a06ebc5aa8).()
102 {
103 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(sensorsMutex_cxx . . $ SysModelSyncer#sensorsMutex_.);
104 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).updateSensorscxx . . $ ISysModel#updateSensors(b9a76d75a3ae6a25).(ignoredSensors_cxx . . $ SysModelSyncer#ignoredSensors_.);
105 }
106
107 void SysModelSyncercxx . . $ SysModelSyncer#::syncModelcxx . . $ SysModelSyncer#syncModel(49f6e7a06ebc5aa8).()
108 {
109 stdcxx . . $ std/::lock_guardcxx . . $ std/lock_guard#<stdcxx . . $ std/::mutexcxx . . $ std/mutex#> lockcxx . . $ std/lock_guard#lock_guard(8e935d9c2e576e3a).(syncMutex_cxx . . $ SysModelSyncer#syncMutex_.);
110 sysModel_cxx . . $ SysModelSyncer#sysModel_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).synccxx . . $ ISysModel#sync(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
111 helperSysCtl_cxx . . $ SysModelSyncer#helperSysCtl_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).applycxx . . $ IHelperSysCtl#apply(151e9138769f295e).(cmds_cxx . . $ SysModelSyncer#cmds_.);
112 }