Revize 6dab0250
Přidáno uživatelem Jakub Šilhavý před asi 2 roky(ů)
ld_client/LDClient/detection/InfoFetcher.cs | ||
---|---|---|
4 | 4 |
namespace LDClient.detection { |
5 | 5 |
|
6 | 6 |
public class InfoFetcher { |
7 |
|
|
8 |
private const string F32RemExecutable = "/home/silhavyj/School/KIV-ASWI/aswi2022bug-thugs/ld_client/Mock/t32rem/build/t32rem_mock"; |
|
9 |
private const string F32RemArguments = "localhost port=20000 VERSION.HARDWARE"; |
|
7 |
|
|
10 | 8 |
private const string UndefinedSerialNumber = "number"; |
11 | 9 |
|
12 |
private readonly int _maxAttempts; |
|
13 |
private readonly int _waitPeriodMs; |
|
10 |
private readonly string _f32RemExecutable; |
|
11 |
private readonly string _f32RemArguments; |
|
12 |
|
|
13 |
private readonly uint _maxAttempts; |
|
14 |
private readonly uint _waitPeriodMs; |
|
14 | 15 |
private readonly string _infoFilePath; |
15 | 16 |
|
16 | 17 |
public string HeadSerialNumber { get; private set; } = UndefinedSerialNumber; |
17 | 18 |
public string BodySerialNumber { get; private set; } = UndefinedSerialNumber; |
18 | 19 |
|
19 |
public InfoFetcher(int maxAttempts, int waitPeriodMs, string infoFilePath) {
|
|
20 |
public InfoFetcher(uint maxAttempts, uint waitPeriodMs, string infoFilePath, string f32RemExecutable, string f32RemArguments) {
|
|
20 | 21 |
_maxAttempts = maxAttempts; |
21 | 22 |
_waitPeriodMs = waitPeriodMs; |
22 | 23 |
_infoFilePath = infoFilePath; |
24 |
_f32RemExecutable = f32RemExecutable; |
|
25 |
_f32RemArguments = f32RemArguments; |
|
23 | 26 |
} |
24 | 27 |
|
25 | 28 |
public async Task<bool> FetchDataAsync() { |
26 | 29 |
Program.DefaultLogger.Info("Fetching data from the debugger."); |
27 |
var success = await SendRetrieveInfoCommandAsync(F32RemExecutable, F32RemArguments);
|
|
30 |
var success = await SendRetrieveInfoCommandAsync(_f32RemExecutable, _f32RemArguments);
|
|
28 | 31 |
if (!success) { |
29 | 32 |
Program.DefaultLogger.Error("Failed to fetch data from the debugger."); |
30 | 33 |
return false; |
... | ... | |
35 | 38 |
Program.DefaultLogger.Info($"Info file has been parsed successfully."); |
36 | 39 |
return true; |
37 | 40 |
} |
38 |
await Task.Delay(_waitPeriodMs); |
|
41 |
await Task.Delay((int)_waitPeriodMs);
|
|
39 | 42 |
} |
40 | 43 |
Program.DefaultLogger.Error("Failed to parse the into file. It may have not been created."); |
41 | 44 |
return false; |
Také k dispozici: Unified diff
re #9566 Moved magic values into the configuration file.