Skip to content

Commit

Permalink
renamed period to interval
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonV-Skyline committed May 7, 2024
1 parent 4046b94 commit fbabf85
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 103 deletions.
6 changes: 3 additions & 3 deletions QAction_1/PollingManager/GenericAPI/Enums/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public enum Column
{
Id = 0,
Name = 1,
Period = 2,
DefaultPeriod = 3,
PeriodType = 4,
Interval = 2,
DefaultInterval = 3,
IntervalType = 4,
LastPoll = 5,
Status = 6,
Reason = 7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// <summary>
/// Represents period types of the <see cref="PollingmanagerQActionTable"/>.
/// </summary>
public enum PeriodType
public enum IntervalType
{
Default = 1,
Custom = 2,
Expand Down
14 changes: 7 additions & 7 deletions QAction_1/PollingManager/GenericAPI/Enums/Trigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/// </summary>
public enum Trigger
{
Period = 1053,
PeriodType = 1055,
Interval = 1053,
IntervalType = 1055,
Poll = 1059,
}

Expand All @@ -29,17 +29,17 @@ public static Column ToColumn(this Trigger trigger)
{
switch (trigger)
{
case Trigger.Period:
return Column.Period;
case Trigger.Interval:
return Column.Interval;

case Trigger.PeriodType:
return Column.PeriodType;
case Trigger.IntervalType:
return Column.IntervalType;

case Trigger.Poll:
return Column.Poll;

default:
throw new ArgumentException($"Unsupported PeriodType '{trigger}'.");
throw new ArgumentException($"Unsupported IntervalType '{trigger}'.");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions QAction_1/PollingManager/GenericAPI/Pollable/IPollable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public interface IPollable

string Name { get; set; }

double Period { get; set; }
double Interval { get; set; }

double DefaultPeriod { get; set; }
double DefaultInterval { get; set; }

PeriodType PeriodType { get; set; }
IntervalType IntervalType { get; set; }

DateTime LastPoll { get; set; }

Expand Down
18 changes: 9 additions & 9 deletions QAction_1/PollingManager/GenericAPI/Pollable/PollableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public PollableBase(SLProtocol protocol, string name)
{
Protocol = protocol;
Name = name;
Period = 5;
DefaultPeriod = 10;
PeriodType = PeriodType.Default;
Interval = 5;
DefaultInterval = 10;
IntervalType = IntervalType.Default;
LastPoll = default;
Status = Status.NotPolled;
Reason = string.Empty;
Expand All @@ -32,11 +32,11 @@ public PollableBase(SLProtocol protocol, string name)

public string Name { get; set; }

public double Period { get; set; }
public double Interval { get; set; }

public double DefaultPeriod { get; set; }
public double DefaultInterval { get; set; }

public PeriodType PeriodType { get; set; }
public IntervalType IntervalType { get; set; }

public DateTime LastPoll { get; set; }

Expand Down Expand Up @@ -72,9 +72,9 @@ public void Update(object[] row)
}

Name = Convert.ToString(row[(int)Column.Name]) ?? string.Empty;
Period = Convert.ToDouble(row[(int)Column.Period]);
DefaultPeriod = Convert.ToDouble(row[(int)Column.DefaultPeriod]);
PeriodType = (PeriodType)Convert.ToDouble(row[(int)Column.PeriodType]);
Interval = Convert.ToDouble(row[(int)Column.Interval]);
DefaultInterval = Convert.ToDouble(row[(int)Column.DefaultInterval]);
IntervalType = (IntervalType)Convert.ToDouble(row[(int)Column.IntervalType]);
LastPoll = DateTime.FromOADate(Convert.ToDouble(row[(int)Column.LastPoll]));
Status = (Status)Convert.ToDouble(row[(int)Column.Status]);
Reason = Convert.ToString(row[(int)Column.Reason]) ?? string.Empty;
Expand Down
40 changes: 20 additions & 20 deletions QAction_1/PollingManager/GenericAPI/PollingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public PollingManager(SLProtocol protocol, int tablePid, List<PollableBase> rows
/// Checks <see cref="PollingmanagerQActionTable"/> for rows that are ready to be polled and polls them.
/// </summary>
/// <exception cref="ArgumentException">
/// Throws if <see cref="PollableBase.PeriodType"/> is not <see cref="PeriodType.Default"/> or <see cref="PeriodType.Custom"/>.
/// Throws if <see cref="PollableBase.IntervalType"/> is not <see cref="IntervalType.Default"/> or <see cref="IntervalType.Custom"/>.
/// </exception>
public void CheckForUpdate()
{
Expand All @@ -165,18 +165,18 @@ public void CheckForUpdate()

bool readyToPoll;

switch (currentRow.PeriodType)
switch (currentRow.IntervalType)
{
case PeriodType.Default:
readyToPoll = CheckLastPollTime(currentRow.DefaultPeriod, currentRow.LastPoll);
case IntervalType.Default:
readyToPoll = CheckLastPollTime(currentRow.DefaultInterval, currentRow.LastPoll);
break;

case PeriodType.Custom:
readyToPoll = CheckLastPollTime(currentRow.Period, currentRow.LastPoll);
case IntervalType.Custom:
readyToPoll = CheckLastPollTime(currentRow.Interval, currentRow.LastPoll);
break;

default:
throw new ArgumentException($"Unsupported PeriodType '{currentRow.PeriodType}'.");
throw new ArgumentException($"Unsupported PeriodType '{currentRow.IntervalType}'.");
}

if (readyToPoll)
Expand All @@ -198,7 +198,7 @@ public void CheckForUpdate()
/// <param name="column">Column on which set was performed.</param>
/// <exception cref="ArgumentException">Throws if <paramref name="rowKey"/> doesn't exist in the table.</exception>
/// <exception cref="ArgumentException">
/// Throws if <paramref name="column"/> is not <see cref="Column.Period"/>, <see cref="Column.PeriodType"/> or <see cref="Column.Poll"/>.
/// Throws if <paramref name="column"/> is not <see cref="Column.Interval"/>, <see cref="Column.IntervalType"/> or <see cref="Column.Poll"/>.
/// </exception>
public void HandleRowUpdate(string rowKey, Column column)
{
Expand All @@ -211,17 +211,17 @@ public void HandleRowUpdate(string rowKey, Column column)

switch (column)
{
case Column.Period:
case Column.Interval:
tableRow = LoadRow(rowKey);
tableRow.PeriodType = PeriodType.Custom;
tableRow.IntervalType = IntervalType.Custom;
break;

case Column.PeriodType:
double period = rows[rowKey].Period;
case Column.IntervalType:
double interval = rows[rowKey].Interval;
tableRow = LoadRow(rowKey);
if (tableRow.PeriodType == PeriodType.Custom)
if (tableRow.IntervalType == IntervalType.Custom)
{
tableRow.Period = period;
tableRow.Interval = interval;
}

break;
Expand Down Expand Up @@ -457,12 +457,12 @@ private void ShowChildren(IPollable row)
/// <summary>
/// Checks whether poll period has elapsed.
/// </summary>
/// <param name="period">Poll period.</param>
/// <param name="interval">Poll period.</param>
/// <param name="lastPoll">Last poll timestamp.</param>
/// <returns>True if poll period has elapsed, false otherwise.</returns>
private bool CheckLastPollTime(double period, DateTime lastPoll)
private bool CheckLastPollTime(double interval, DateTime lastPoll)
{
return (DateTime.Now - lastPoll).TotalSeconds > period;
return (DateTime.Now - lastPoll).TotalSeconds > interval;
}

/// <summary>
Expand Down Expand Up @@ -552,9 +552,9 @@ private PollingmanagerQActionRow CreateTableRow(string rowKey, PollableBase valu
{
Pollingmanager_id = rowKey,
Pollingmanager_name = value.Name,
Pollingmanager_period = value.PeriodType == PeriodType.Custom ? value.Period : value.DefaultPeriod,
Pollingmanager_defaultperiod = value.DefaultPeriod,
Pollingmanager_periodtype = value.PeriodType,
Pollingmanager_interval = value.IntervalType == IntervalType.Custom ? value.Interval : value.DefaultInterval,
Pollingmanager_defaultinterval = value.DefaultInterval,
Pollingmanager_intervaltype = value.IntervalType,
Pollingmanager_lastpoll = value.LastPoll == default ? Convert.ToDouble(Status.NotPolled) : value.LastPoll.ToOADate(),
Pollingmanager_status = value.State == State.Disabled ? Status.Disabled : value.Status,
Pollingmanager_reason = value.Reason,
Expand Down
Loading

0 comments on commit fbabf85

Please sign in to comment.