Skip to content

Commit b3356a5

Browse files
committed
Minor corrections as per code review comments
1 parent 6421502 commit b3356a5

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

Launcher.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENUM_CONVERSION_BEGIN(Plugin::Launcher::mode)
77

88
{ Plugin::Launcher::mode::RELATIVE, _TXT("relative") },
99
{ Plugin::Launcher::mode::ABSOLUTE, _TXT("absolute") },
10-
{ Plugin::Launcher::mode::ABSOLUTE_WITH_INTERVAL, _TXT("absolute_with_interval") },
10+
{ Plugin::Launcher::mode::ABSOLUTE_WITH_INTERVAL, _TXT("interval") },
1111

1212
ENUM_CONVERSION_END(Plugin::Launcher::mode)
1313
;
@@ -219,21 +219,23 @@ Core::Time Launcher::FindAbsoluteTimeForSchedule(const Time& absoluteTime, const
219219
}
220220
}
221221
else {
222-
if (slotTime >= startTime) {
223-
uint32_t jump (absoluteTime.HasHours() ? HoursPerDay * MinutesPerHour * SecondsPerMinute : (absoluteTime.HasMinutes() ? MinutesPerHour * SecondsPerMinute : SecondsPerMinute));
224-
225-
// Go back the biggest chunk of the absoluteTime
226-
slotTime.Sub(jump * 100);
227-
}
228222
uint32_t intervalJump = ( (interval.HasHours() ? interval.Hours() * MinutesPerHour * SecondsPerMinute : 0) +
229223
(interval.HasMinutes() ? interval.Minutes() * SecondsPerMinute : 0) +
230224
interval.Seconds() ) * 100;
231225

232226
ASSERT (intervalJump != 0);
227+
if (slotTime >= startTime) {
228+
Core::Time workTime (slotTime);
233229

234-
// Now increment with the intervall till we reach a valid point
235-
while (slotTime < startTime) {
236-
slotTime.Add(intervalJump);
230+
while (workTime.Sub(intervalJump) > startTime) {
231+
slotTime.Sub(intervalJump);
232+
}
233+
}
234+
else {
235+
// Now increment with the intervall till we reach a valid point
236+
while (slotTime < startTime) {
237+
slotTime.Add(intervalJump);
238+
}
237239
}
238240
}
239241

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ Plugin to "Launch" linux applications and scripts
6969
{ "option": "-h"}
7070
],
7171
"schedule": {
72-
"mode": 0,
72+
"mode": "relative",
7373
"time": "06:04.10"
7474
}
7575
}
7676
```
7777

7878
Note:
79-
1. If field "mode" is zero or not set, it will treat the time as relative
79+
1. If field "mode" is empty or not set, it will treat the time as relative
8080
2. If relative time value is "00:00.00"/invalid format/not set, the launcher will ignore the given time and launch the application at the launcher activation time itself.
8181
3. If time format given is
8282
a. "XX", treat it as SS
@@ -93,7 +93,7 @@ Note:
9393
{ "option": "-h"}
9494
],
9595
"schedule": {
96-
"mode": 1,
96+
"mode": "absolute",
9797
"time": "06:04.10"
9898
}
9999
}
@@ -121,7 +121,7 @@ Note:
121121
{ "option": "-h"}
122122
],
123123
"schedule": {
124-
"mode": 2,
124+
"mode": "interval",
125125
"time": "06:04.10",
126126
"interval": "00:40.10"
127127
}
@@ -130,9 +130,9 @@ Note:
130130

131131
Note:
132132
1. If interval value is "00:00.00"/invalid format/not set, the launcher will treat it as invalid value and ignore the interval time settings.
133-
2. If mode is 2 (absolute with interval) and interval is set, it will identify next matching time and schedule application launch to that time.
133+
2. If mode is interval (absolute with interval) and interval is set, it will identify next matching time and schedule application launch to that time.
134134
i.e, if the absolute time given is 04:00:00, current time is 05:10:00 and interval is 00:30:00, then next scheduling time will be 05:30:00 (will be identified from the next intervals - 04:30:00, 05:00:00, 05:30:00)
135-
3. If mode is 0(relative) or 1(absolute), the interval time will be taken only for the subsequent scheduling
135+
3. If mode is relative or absolute, the interval time will be taken only for the subsequent scheduling
136136

137137
# How to launch multiple scripts/applcations
138138

0 commit comments

Comments
 (0)