Skip to content

Commit

Permalink
v1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lich426 committed Dec 3, 2022
1 parent 8653c8b commit 4044769
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 28 deletions.
3 changes: 2 additions & 1 deletion FanCtrl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PublisherName>Lich</PublisherName>
<SuiteName>FanCtrl</SuiteName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.5.4.0</ApplicationVersion>
<ApplicationVersion>1.5.5.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -423,6 +423,7 @@ mkdir "$(TargetDir)locale\ko"
copy /Y "$(TargetDir)fr\*.*" "$(TargetDir)locale\fr"
copy /Y "$(TargetDir)ja\*.*" "$(TargetDir)locale\ja"
copy /Y "$(TargetDir)ko\*.*" "$(TargetDir)locale\ko"
timeout 1 &gt; NUL
rmdir /S /Q "$(TargetDir)fr"
rmdir /S /Q "$(TargetDir)ja"
rmdir /S /Q "$(TargetDir)ko"
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
[assembly: AssemblyVersion("1.5.4")]
[assembly: AssemblyFileVersion("1.5.4")]
[assembly: AssemblyInformationalVersion("1.5.4")]
[assembly: AssemblyVersion("1.5.5")]
[assembly: AssemblyFileVersion("1.5.5")]
[assembly: AssemblyInformationalVersion("1.5.5")]
12 changes: 8 additions & 4 deletions src/UI/ControlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,11 +873,12 @@ private void onPresetLoadButtonClick(object sender, EventArgs e)

// check data
var rootObject = JObject.Parse(jsonString);
bool isStep = rootObject.Value<bool>("step");
int hysteresis = rootObject.Value<int>("hysteresis");
int auto = rootObject.Value<int>("auto");
bool isStep = (rootObject.ContainsKey("step") == true) ? rootObject.Value<bool>("step") : true;
int hysteresis = (rootObject.ContainsKey("hysteresis") == true) ? rootObject.Value<int>("hysteresis") : 0;
int auto = (rootObject.ContainsKey("auto") == true) ? rootObject.Value<int>("auto") : 0;
int delay = (rootObject.ContainsKey("delay") == true) ? rootObject.Value<int>("delay") : 0;

var unit = (FanValueUnit)rootObject.Value<int>("unit");
var unit = (rootObject.ContainsKey("unit") == true) ? (FanValueUnit)rootObject.Value<int>("unit") : FanValueUnit.Size_5;
var valueList = rootObject.Value<JArray>("value");
if (unit == FanValueUnit.Size_1)
{
Expand All @@ -902,6 +903,7 @@ private void onPresetLoadButtonClick(object sender, EventArgs e)
mSelectedFanData.IsStep = isStep;
mSelectedFanData.Hysteresis = hysteresis;
mSelectedFanData.Auto = auto;
mSelectedFanData.DelayTime = delay;
mSelectedFanData.setChangeUnitAndFanValue(unit);
for (int i = 0; i < valueList.Count; i++)
{
Expand All @@ -917,6 +919,7 @@ private void onPresetLoadButtonClick(object sender, EventArgs e)
mLineItem.Line.StepType = (mStepCheckBox.Checked == true) ? StepType.ForwardStep : StepType.NonStep;
mHysNumericUpDown.Enabled = mStepCheckBox.Checked;
mHysNumericUpDown.Value = mSelectedFanData.Hysteresis;
mDelayNumericUpDown.Value = mSelectedFanData.DelayTime;

this.onUpdateTimer();
}
Expand Down Expand Up @@ -951,6 +954,7 @@ private void onPresetSaveButtonClick(object sender, EventArgs e)
rootObject["hysteresis"] = mSelectedFanData.Hysteresis;
rootObject["unit"] = (int)mSelectedFanData.Unit;
rootObject["auto"] = mSelectedFanData.Auto;
rootObject["delay"] = mSelectedFanData.DelayTime;

var valueList = new JArray();
for (int i = 0; i < mSelectedFanData.getMaxFanValue(); i++)
Expand Down
46 changes: 34 additions & 12 deletions src/libs/Hardware/Control/BaseControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using System.Threading.Tasks;
using LibreHardwareMonitor.Hardware;
using Newtonsoft.Json.Linq;

namespace FanCtrl
{
Expand All @@ -20,8 +21,8 @@ public class BaseControl : BaseDevice
// timer timeout (ms)
public int Timeout { get; set; }

private System.Timers.Timer mTimer;
private object mTimerLock = new object();
private System.Timers.Timer mTimer;
private int mTimerValue;

public BaseControl(LIBRARY_TYPE type)
Expand Down Expand Up @@ -58,45 +59,66 @@ public virtual void setAuto()

}

public void setSpeedWithTimer(int value, int time)
public void setSpeedWithTimer(int value)
{
Monitor.Enter(mTimerLock);
int time = Timeout;
Timeout = 0;

if (time <= 0)
{
mTimerValue = value;
mTimer?.Stop();
this.setSpeed(value);
Monitor.Exit(mTimerLock);
return;
}

if (Value == value)
{
Monitor.Enter(mTimerLock);
mTimerValue = value;
Timeout = 0;
mTimer?.Stop();
Monitor.Exit(mTimerLock);
mTimerValue = value;
Console.WriteLine("BaseControl.setSpeedWithTimer() : equal value({0})", value);
}
else if (mTimerValue != value)
{
Console.WriteLine("BaseControl.setSpeedWithTimer() : value({0}), mTimerValue({1})", value, mTimerValue);

mTimer?.Stop();
mTimerValue = value;
Timeout = 0;

Monitor.Enter(mTimerLock);
mTimer?.Stop();
Monitor.Exit(mTimerLock);

mTimer = new System.Timers.Timer();
mTimer.Interval = time;
var timer = mTimer;
mTimer.Elapsed += (sender, e) =>
{
Monitor.Enter(mTimerLock);
if (timer.Enabled == false)
{
Monitor.Exit(mTimerLock);
return;
}
Console.WriteLine("BaseControl.setSpeedWithTimer() : setSpeed()");
this.setSpeed(value);
mTimer?.Stop();
timer.Stop();
Monitor.Exit(mTimerLock);
};
mTimer.Start();
}
Monitor.Exit(mTimerLock);
}

public void checkTimer()
{
Monitor.Enter(mTimerLock);
if (Value == NextValue && Value != mTimerValue)
{
mTimerValue = Value;
mTimer?.Stop();
Console.WriteLine("BaseControl.checkTimer() : stop timer");
}
Monitor.Exit(mTimerLock);
}

public void stopTimer()
Expand Down
13 changes: 5 additions & 8 deletions src/libs/Hardware/HardwareManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,22 +1227,19 @@ private void onUpdateTimer(object sender, EventArgs e)
Console.WriteLine("manual mode : name({0}), value({1}), nextvalue({2})", control.Name, control.Value, control.NextValue);

if (control.Value == control.NextValue)
continue;

if (control.Timeout > 0)
{
control.setSpeedWithTimer(control.NextValue, control.Timeout);
}
else
{
control.setSpeed(control.NextValue);
control.checkTimer();
continue;
}

control.setSpeedWithTimer(control.NextValue);
}

foreach (var keyPair in mAutoControlDictionary)
{
var control = keyPair.Value;
Console.WriteLine("auto mode : name({0})", control.Name);
control.stopTimer();
control.setAuto();
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/libs/Hardware/liquidctl/LiquidctlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Reflection;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Net;

namespace FanCtrl
{
Expand Down Expand Up @@ -57,6 +58,8 @@ public void start()

try
{
this.initialize();

var jsonString = getStatus();
var rootArray = JArray.Parse(jsonString);
for (int i = 0; i < rootArray.Count; i++)
Expand Down Expand Up @@ -200,6 +203,28 @@ private void onUpdateTimer(object sender, EventArgs e)
Monitor.Exit(mLock);
}

private void initialize()
{
try
{
var p = new Process();
p.StartInfo.FileName = LiquidctlPath;
p.StartInfo.Arguments = "initialize all";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
if (p.Start() == true)
{
var jsonString = p.StandardOutput.ReadToEnd();
p.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}

private string getStatus()
{
try
Expand Down

0 comments on commit 4044769

Please sign in to comment.