Skip to content

Commit

Permalink
Update classes, fix configuration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WannesW committed Dec 13, 2024
1 parent 9fb6095 commit bc8749b
Show file tree
Hide file tree
Showing 31 changed files with 1,308 additions and 836 deletions.
6 changes: 6 additions & 0 deletions .cr/personal/FavoritesList/List.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Root Type="DevExpress.CodeRush.Foundation.CodePlaces.Options.FavoritesListContainer">
<Options Language="Neutral">
<Groups />
</Options>
</Root>
18 changes: 18 additions & 0 deletions QAction_1/PollingManager/CustomCode/Configuration/BasicPoll.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Skyline.Protocol.PollingManager.CustomCode.Configuration
{
using Skyline.DataMiner.PollingManager;
using Skyline.DataMiner.Scripting;

internal class BasicPoll : PollableBase
{
public BasicPoll(SLProtocol protocol, string description, int actionID) : base(protocol, description)
{
ActionId = actionID;
}

protected override void PollConfiguration()
{
Protocol.Log($"Polling '{Name}'.");
}
}
}
17 changes: 17 additions & 0 deletions QAction_1/PollingManager/CustomCode/Configuration/Pollable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Skyline.Protocol.PollingManager.CustomCode.Configuration
{
using Skyline.DataMiner.PollingManager;
using Skyline.DataMiner.Scripting;

public class Pollable : PollableBase
{
public Pollable(SLProtocol protocol, string description) : base(protocol, description)
{
}

protected override void PollConfiguration()
{
Protocol.Log($"Polling '{Name}'.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
namespace Skyline.Protocol.PollingManager.CustomCode.Configuration
{
using System.Collections.Generic;
using Skyline.DataMiner.PollingManager;
using Skyline.DataMiner.Scripting;
using Skyline.Protocol.PollingManager.CustomCode.ResponseHandlers;
using Skyline.Protocol.PollingManager.GenericAPI.Handlers;

public class PollingManagerConfiguration : PollingManagerConfigurationBase
{
public PollingManagerConfiguration(SLProtocol protocol) : base(protocol)
{
Rows = new Dictionary<string, PollableBase>()
{
{ "Basic", new BasicPoll(Protocol, "Basic Dataset", 60_001) },
{ "Fail", new BasicPoll(Protocol, "Failing Dataset", 60_002) },
{ "Parent1", new Pollable(Protocol, "Parent1 Dataset") },
{ "Parent2", new Pollable(Protocol, "Parent2 Dataset") },
{ "Child1", new Pollable(Protocol, "Parent1 - Child 1 Dataset") },
{ "Child2", new Pollable(Protocol, "Multiple Parent - Child 2 Dataset") },
{ "Dependency", new Pollable(Protocol, "API 2.0 Dataset") },
{ "Mandatory", new Pollable(Protocol, "Mandatory Dataset") },
};

Rows["Mandatory"].Mandatory = true;

Dependencies = new List<Dependency>()
{
};

ResponseHandlers = new Dictionary<int, ResponseHandler>()
{ };
}

public override Dictionary<int, ResponseHandler> ResponseHandlers { get; set; }

protected override List<Dependency> Dependencies { get; set; }

protected override Dictionary<string, PollableBase> Rows { get; set; }

protected override void CreateDependencies()
{
var apiDependency = new Dependency("Version2", true, "Only supported in Api version 2.0");
Rows["Dependency"].AddDependency(Parameter.apiversion_5, apiDependency);
}

protected override void CreateParameterRelations()
{
var basicSingleParameter = new Dictionary<int, object>
{
{ Parameter.systemname_20, string.Empty},
{ Parameter.serialNumber_21,"-1"},
};

var basicTableParameters = new List<int> { 100 };
Rows["Basic"].AddParameters(basicSingleParameter, basicTableParameters);
}

protected override void CreateRelations()
{
Rows["Parent1"].AddChildren(Rows["Child1"], Rows["Child2"]);
Rows["Parent2"].AddChildren(Rows["Child2"]);
}

protected override void CreateResponseHandlers()
{
ResponseHandlers.Add(61001, new ResponseBasicDataSet("Basic"));
ResponseHandlers.Add(61002, new ResponseBasicFailDataSet("Fail"));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
namespace Skyline.Protocol.PollingManager.CustomCode.ResponseHandlers
{
using System;
using System.Collections.Generic;
using System.Linq;
using Skyline.DataMiner.Scripting;
using Skyline.Protocol.PollingManager.GenericAPI.Exceptions;
using Skyline.Protocol.PollingManager.GenericAPI.Handlers;

public class ResponseBasicDataSet : ResponseHandler
{
public ResponseBasicDataSet(string rowName) : base(rowName)
{
}

public override void ProcessResponse(SLProtocol protocol)
protected override void ProcessResponse(SLProtocol protocol)
{
return;
Dictionary<int, object> setParameters = new Dictionary<int, object>
{
{ Parameter.systemname_20, "Dummy Name" },
{ Parameter.serialNumber_21, "DUMMY23430E7W" },
};
protocol.SetParameters(setParameters.Keys.ToArray(), setParameters.Values.ToArray());

int dummyRows = 10;
List<DummydataQActionRow> tableRows = new List<DummydataQActionRow>();
Random random = new Random();

for (int i = 0; i < dummyRows; i++)
{
var row = new DummydataQActionRow
{
Dummydatainstance_101 = $"{i}",
Dummydatadescription_102 = $"Dummy Entry {i}",
Dummydatastatus_103 = random.Next(0, 2),
};

tableRows.Add(row);
}

protocol.FillArray(100, tableRows.ToArray().Select(r => r.ToObjectArray()).ToList(), NotifyProtocol.SaveOption.Full);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
namespace Skyline.Protocol.PollingManager.CustomCode.ResponseHandlers
{
using Skyline.DataMiner.Scripting;
using Skyline.Protocol.PollingManager.GenericAPI.Exceptions;
using Skyline.Protocol.PollingManager.GenericAPI.Handlers;

public class ResponseBasicFailDataSet : ResponseHandler
{
public ResponseBasicFailDataSet(string rowName) : base(rowName)
{
}

public override void ProcessResponse(SLProtocol protocol)
protected override void ProcessResponse(SLProtocol protocol)
{
throw new PollingException("Incorrect requirements.");
}
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion QAction_1/PollingManager/GenericAPI/Enums/AdminState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using Skyline.DataMiner.Scripting;

Expand Down
4 changes: 2 additions & 2 deletions QAction_1/PollingManager/GenericAPI/Enums/Column.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using Skyline.DataMiner.Scripting;

Expand All @@ -11,7 +11,7 @@ public enum Column
ID= 1,
Description = 2,
Interval = 3,
DefaultInterval = 4,
SuggestedInterval = 4,
AdminStatus = 5,
Poll = 6,
LastPoll = 7,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using Skyline.DataMiner.Scripting;

Expand Down
2 changes: 1 addition & 1 deletion QAction_1/PollingManager/GenericAPI/Enums/IntervalType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using Skyline.DataMiner.Scripting;

Expand Down
2 changes: 1 addition & 1 deletion QAction_1/PollingManager/GenericAPI/Enums/PollStatus.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using Skyline.DataMiner.Scripting;

Expand Down
18 changes: 18 additions & 0 deletions QAction_1/PollingManager/GenericAPI/Enums/PollableType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
/// <summary>
/// Represents the type of a pollable.
/// </summary>
public enum PollableType
{
/// <summary>
/// The pollable triggers and action with actionId.
/// </summary>
TriggerAction,

/// <summary>
/// The pollalbe process the poll fully in Code.
/// </summary>
ProcessInCode,
}
}
35 changes: 1 addition & 34 deletions QAction_1/PollingManager/GenericAPI/Enums/Trigger.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
namespace Skyline.DataMiner.PollingManager
namespace Skyline.Protocol.PollingManager.GenericAPI.Enums
{
using System;

using Skyline.DataMiner.Scripting;

/// <summary>
/// Represents triggers of the <see cref="PollingmanagerQActionTable"/>.
/// </summary>
public enum Trigger
{
Description = 999,
Interval = 1054,
IntervalType = 1056,
Poll = 1057,
}

/// <summary>
/// Extension class for <see cref="Trigger"/>.
/// </summary>
public static class TriggerExtensions
{
/// <summary>
/// Converts <see cref="Trigger"/> to its corresponding <see cref="Column"/> value.
/// </summary>
/// <param name="trigger">Trigger to be converted.</param>
/// <returns>Column that corresponds to the trigger.</returns>
/// <exception cref="InvalidOperationException">Throws if trigger has no corresponding column.</exception>
public static Column ToColumn(this Trigger trigger)
{
switch (trigger)
{
case Trigger.Interval:
return Column.Interval;
case Trigger.IntervalType:
return Column.AdminStatus;
case Trigger.Description:
return Column.Description;
case Trigger.Poll:
return Column.Poll;

default:
throw new ArgumentException($"Unsupported IntervalType '{trigger}'.");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
using System.Runtime.Serialization;
using System.Security;

namespace Skyline.Protocol.PollingManager.CustomCode.ResponseHandlers
namespace Skyline.Protocol.PollingManager.GenericAPI.Exceptions
{
using System;

/// <summary>
/// Represents errors that occur during polling execution.
/// </summary>
public class PollingException : Exception
{
/// <summary>Initializes a new instance of the <see cref="PollingException" /> class with a specified error message.</summary>
/// <param name="message">The message that describes the error.</param>
public PollingException(string message) : base(message)
{

}

/// <summary>Initializes a new instance of the <see cref="PollingException" /> class.</summary>
public PollingException()
{

}

/// <summary>Initializes a new instance of the <see cref="PollingException" /> class with a specified error message and a reference to the inner exception that is the cause of this exception.</summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (<see langword="Nothing" /> in Visual Basic) if no inner exception is specified.</param>
public PollingException(string message, Exception innerException) : base(message, innerException)
{

}
}
}
Loading

0 comments on commit bc8749b

Please sign in to comment.