Skip to content

Commit fa43cda

Browse files
committed
Add interfaces implementation
1 parent 8f8cb44 commit fa43cda

File tree

6 files changed

+273
-15
lines changed

6 files changed

+273
-15
lines changed

QAction_2/QAction_2.cs

+82-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,97 @@
11
using System;
2+
using System.Threading.Tasks;
3+
4+
using QAction_2;
25

36
using Skyline.DataMiner.FlowEngineering.Protocol;
7+
using Skyline.DataMiner.FlowEngineering.Protocol.DCF;
8+
using Skyline.DataMiner.FlowEngineering.Protocol.Enums;
9+
using Skyline.DataMiner.FlowEngineering.Protocol.Model;
410
using Skyline.DataMiner.Scripting;
511

612
/// <summary>
713
/// DataMiner QAction Class: After Startup.
814
/// </summary>
915
public static class QAction
1016
{
11-
/// <summary>
12-
/// The QAction entry point.
13-
/// </summary>
14-
/// <param name="protocol">Link with SLProtocol process.</param>
15-
public static void Run(SLProtocol protocol)
16-
{
17-
try
18-
{
17+
/// <summary>
18+
/// The QAction entry point.
19+
/// </summary>
20+
/// <param name="protocol">Link with SLProtocol process.</param>
21+
public static void Run(SLProtocolExt protocol)
22+
{
23+
try
24+
{
1925
// make sure all old cached data is removed
2026
FlowEngineeringManagerInstances.CreateNewInstance(protocol);
2127

28+
FillInterfacesTable(protocol);
29+
UpdateFleInterfaces(protocol);
30+
}
31+
catch (Exception ex)
32+
{
33+
protocol.Log($"QA{protocol.QActionID}|{protocol.GetTriggerParameter()}|Run|Exception thrown:{Environment.NewLine}{ex}", LogType.Error, LogLevel.NoLogging);
34+
}
35+
}
36+
37+
private static void FillInterfacesTable(SLProtocolExt protocol)
38+
{
39+
var table = new InterfacestableQActionRow[]
40+
{
41+
new InterfacestableQActionRow
42+
{
43+
Interfacestableid = "1",
44+
Interfacestablename = "Ethernet 2",
45+
},
46+
new InterfacestableQActionRow
47+
{
48+
Interfacestableid = "2",
49+
Interfacestablename = "Ethernet 2",
50+
},
51+
};
52+
53+
protocol.interfacestable.FillArray(table);
54+
}
55+
56+
private static async void UpdateFleInterfaces(SLProtocolExt protocol)
57+
{
58+
await WaitUntilDcfInterfacesAreCreated(protocol, 2);
59+
60+
var flowEngineering = FlowEngineeringManager.GetInstance(protocol);
61+
var dcfInterfaceHelper = DcfInterfaceHelper.Create(protocol);
62+
63+
flowEngineering.Interfaces.Clear();
64+
flowEngineering.Interfaces.Add(CreateInterface(1, "Ethernet 1", dcfInterfaceHelper));
65+
flowEngineering.Interfaces.Add(CreateInterface(2, "Ethernet 2", dcfInterfaceHelper));
66+
67+
flowEngineering.Interfaces.UpdateTable(protocol);
68+
}
69+
70+
private static Interface CreateInterface(int id, string name, DcfInterfaceHelper dcfInterfaceHelper)
71+
{
72+
var key = Convert.ToString(id);
73+
74+
var intf = new Interface(key)
75+
{
76+
Description = name,
77+
DisplayKey = name,
78+
Type = InterfaceType.Ethernet,
79+
AdminStatus = InterfaceAdminStatus.Up,
80+
OperationalStatus = InterfaceOperationalStatus.Up,
81+
};
82+
83+
if (dcfInterfaceHelper.TryFindInterface(1, key, out var dcfIntf))
84+
{
85+
intf.DcfInterfaceId = dcfIntf.ID;
2286
}
23-
catch (Exception ex)
24-
{
25-
protocol.Log($"QA{protocol.QActionID}|{protocol.GetTriggerParameter()}|Run|Exception thrown:{Environment.NewLine}{ex}", LogType.Error, LogLevel.NoLogging);
26-
}
27-
}
87+
88+
return intf;
89+
}
90+
91+
private static async Task WaitUntilDcfInterfacesAreCreated(SLProtocolExt protocol, int expectedInterfacesCount)
92+
{
93+
await WaitHelper.WaitUntilAsync(
94+
() => protocol.RowCount(65049) >= expectedInterfacesCount,
95+
TimeSpan.FromSeconds(30));
96+
}
2897
}

QAction_2/WaitHelper.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace QAction_2
2+
{
3+
using System;
4+
using System.Diagnostics;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
8+
public static class WaitHelper
9+
{
10+
public static void WaitUntil(Func<bool> condition, TimeSpan timeout, int intervalMs = 100)
11+
{
12+
var stopwatch = Stopwatch.StartNew();
13+
14+
while (!condition())
15+
{
16+
if (stopwatch.Elapsed > timeout)
17+
{
18+
throw new TimeoutException("Timeout occurred while waiting for condition to be true.");
19+
}
20+
21+
Thread.Sleep(intervalMs);
22+
}
23+
}
24+
25+
public static async Task WaitUntilAsync(Func<bool> condition, TimeSpan timeout, int intervalMs = 100)
26+
{
27+
var stopwatch = Stopwatch.StartNew();
28+
29+
while (!condition())
30+
{
31+
if (stopwatch.Elapsed > timeout)
32+
{
33+
throw new TimeoutException("Timeout occurred while waiting for condition to be true.");
34+
}
35+
36+
await Task.Delay(intervalMs);
37+
}
38+
}
39+
}
40+
}

QAction_9990990/QAction_9990990.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static QAction()
2828
/// The QAction entry point.
2929
/// </summary>
3030
/// <param name="protocol">Link with SLProtocol process.</param>
31-
public static void Run(SLProtocol protocol)
31+
public static void Run(SLProtocolExt protocol)
3232
{
3333
try
3434
{

QAction_9990990/QAction_9990990.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<Company>Skyline Communications</Company>
55
<Copyright>© Skyline Communications</Copyright>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
7+
<LangVersion>7.3</LangVersion>
78
</PropertyGroup>
89
<ItemGroup>
910
<ProjectReference Include="..\QAction_Helper\QAction_Helper.csproj" />

QAction_Helper/QAction_Helper.cs

+82
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,44 @@ public class Write
3131
/// <summary>PID: 9991258 | Type: write</summary>
3232
public const int fleoutgoingflowstableexpectedtxbitrate = 9991258;
3333
}
34+
public class Interfacestable
35+
{
36+
/// <summary>PID: 1000</summary>
37+
public const int tablePid = 1000;
38+
/// <summary>IDX: 0</summary>
39+
public const int indexColumn = 0;
40+
/// <summary>PID: 1001</summary>
41+
public const int indexColumnPid = 1001;
42+
public class Pid
43+
{
44+
/// <summary>PID: 1001 | Type: read</summary>
45+
[EditorBrowsable(EditorBrowsableState.Never)]
46+
public const int interfacestableid_1001 = 1001;
47+
/// <summary>PID: 1001 | Type: read</summary>
48+
public const int interfacestableid = 1001;
49+
/// <summary>PID: 1002 | Type: read</summary>
50+
[EditorBrowsable(EditorBrowsableState.Never)]
51+
public const int interfacestablename_1002 = 1002;
52+
/// <summary>PID: 1002 | Type: read</summary>
53+
public const int interfacestablename = 1002;
54+
public class Write
55+
{
56+
}
57+
}
58+
public class Idx
59+
{
60+
/// <summary>IDX: 0 | Type: read</summary>
61+
[EditorBrowsable(EditorBrowsableState.Never)]
62+
public const int interfacestableid_1001 = 0;
63+
/// <summary>IDX: 0 | Type: read</summary>
64+
public const int interfacestableid = 0;
65+
/// <summary>IDX: 1 | Type: read</summary>
66+
[EditorBrowsable(EditorBrowsableState.Never)]
67+
public const int interfacestablename_1002 = 1;
68+
/// <summary>IDX: 1 | Type: read</summary>
69+
public const int interfacestablename = 1;
70+
}
71+
}
3472
public class Fleinterfacesoverviewtable
3573
{
3674
/// <summary>PID: 9991000</summary>
@@ -759,6 +797,8 @@ public WriteParameters(SLProtocolExt protocol)
759797
}
760798
public interface SLProtocolExt : SLProtocol
761799
{
800+
/// <summary>PID: 1000</summary>
801+
InterfacestableQActionTable interfacestable { get; set; }
762802
/// <summary>PID: 9991000</summary>
763803
FleinterfacesoverviewtableQActionTable fleinterfacesoverviewtable { get; set; }
764804
/// <summary>PID: 9991100</summary>
@@ -768,6 +808,10 @@ public interface SLProtocolExt : SLProtocol
768808
/// <summary>PID: 9991300</summary>
769809
FleprovisionedflowstableQActionTable fleprovisionedflowstable { get; set; }
770810
object Afterstartup_dummy { get; set; }
811+
object Interfacestableid_1001 { get; set; }
812+
object Interfacestableid { get; set; }
813+
object Interfacestablename_1002 { get; set; }
814+
object Interfacestablename { get; set; }
771815
object Fleinterappreceive_9990990 { get; set; }
772816
object Fleinterappreceive { get; set; }
773817
object Fleinterappreturn_9990991 { get; set; }
@@ -908,6 +952,8 @@ public interface SLProtocolExt : SLProtocol
908952
}
909953
public class ConcreteSLProtocolExt : ConcreteSLProtocol, SLProtocolExt
910954
{
955+
/// <summary>PID: 1000</summary>
956+
public InterfacestableQActionTable interfacestable { get; set; }
911957
/// <summary>PID: 9991000</summary>
912958
public FleinterfacesoverviewtableQActionTable fleinterfacesoverviewtable { get; set; }
913959
/// <summary>PID: 9991100</summary>
@@ -918,6 +964,16 @@ public class ConcreteSLProtocolExt : ConcreteSLProtocol, SLProtocolExt
918964
public FleprovisionedflowstableQActionTable fleprovisionedflowstable { get; set; }
919965
/// <summary>PID: 2 | Type: dummy</summary>
920966
public System.Object Afterstartup_dummy {get { return GetParameter(2); }set { SetParameter(2, value); }}
967+
/// <summary>PID: 1001 | Type: read</summary>
968+
[EditorBrowsable(EditorBrowsableState.Never)]
969+
public System.Object Interfacestableid_1001 {get { return GetParameter(1001); }set { SetParameter(1001, value); }}
970+
/// <summary>PID: 1001 | Type: read</summary>
971+
public System.Object Interfacestableid {get { return GetParameter(1001); }set { SetParameter(1001, value); }}
972+
/// <summary>PID: 1002 | Type: read</summary>
973+
[EditorBrowsable(EditorBrowsableState.Never)]
974+
public System.Object Interfacestablename_1002 {get { return GetParameter(1002); }set { SetParameter(1002, value); }}
975+
/// <summary>PID: 1002 | Type: read</summary>
976+
public System.Object Interfacestablename {get { return GetParameter(1002); }set { SetParameter(1002, value); }}
921977
/// <summary>PID: 9990990 | Type: read</summary>
922978
[EditorBrowsable(EditorBrowsableState.Never)]
923979
public System.Object Fleinterappreceive_9990990 {get { return GetParameter(9990990); }set { SetParameter(9990990, value); }}
@@ -1259,6 +1315,7 @@ public class ConcreteSLProtocolExt : ConcreteSLProtocol, SLProtocolExt
12591315
public WriteParameters Write { get; set; }
12601316
public ConcreteSLProtocolExt()
12611317
{
1318+
interfacestable = new InterfacestableQActionTable(this, 1000, "interfacestable");
12621319
fleinterfacesoverviewtable = new FleinterfacesoverviewtableQActionTable(this, 9991000, "fleinterfacesoverviewtable");
12631320
fleincomingflowstable = new FleincomingflowstableQActionTable(this, 9991100, "fleincomingflowstable");
12641321
fleoutgoingflowstable = new FleoutgoingflowstableQActionTable(this, 9991200, "fleoutgoingflowstable");
@@ -1267,6 +1324,13 @@ public ConcreteSLProtocolExt()
12671324
}
12681325
}
12691326
/// <summary>IDX: 0</summary>
1327+
public class InterfacestableQActionTable : QActionTable, IEnumerable<InterfacestableQActionRow>
1328+
{
1329+
public InterfacestableQActionTable(SLProtocol protocol, int tableId, string tableName) : base(protocol, tableId, tableName) { }
1330+
IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); }
1331+
public IEnumerator<InterfacestableQActionRow> GetEnumerator() { return new QActionTableEnumerator<InterfacestableQActionRow>(this); }
1332+
}
1333+
/// <summary>IDX: 0</summary>
12701334
public class FleinterfacesoverviewtableQActionTable : QActionTable, IEnumerable<FleinterfacesoverviewtableQActionRow>
12711335
{
12721336
public FleinterfacesoverviewtableQActionTable(SLProtocol protocol, int tableId, string tableName) : base(protocol, tableId, tableName) { }
@@ -1295,6 +1359,24 @@ public FleprovisionedflowstableQActionTable(SLProtocol protocol, int tableId, st
12951359
public IEnumerator<FleprovisionedflowstableQActionRow> GetEnumerator() { return new QActionTableEnumerator<FleprovisionedflowstableQActionRow>(this); }
12961360
}
12971361
/// <summary>IDX: 0</summary>
1362+
public class InterfacestableQActionRow : QActionTableRow
1363+
{
1364+
/// <summary>PID: 1001 | Type: read</summary>
1365+
[EditorBrowsable(EditorBrowsableState.Never)]
1366+
public System.Object Interfacestableid_1001 { get { if (base.Columns.ContainsKey(0)) { return base.Columns[0]; } else { return null; } } set { if (base.Columns.ContainsKey(0)) { base.Columns[0] = value; } else { base.Columns.Add(0, value); } } }
1367+
/// <summary>PID: 1001 | Type: read</summary>
1368+
public System.Object Interfacestableid { get { if (base.Columns.ContainsKey(0)) { return base.Columns[0]; } else { return null; } } set { if (base.Columns.ContainsKey(0)) { base.Columns[0] = value; } else { base.Columns.Add(0, value); } } }
1369+
/// <summary>PID: 1002 | Type: read</summary>
1370+
[EditorBrowsable(EditorBrowsableState.Never)]
1371+
public System.Object Interfacestablename_1002 { get { if (base.Columns.ContainsKey(1)) { return base.Columns[1]; } else { return null; } } set { if (base.Columns.ContainsKey(1)) { base.Columns[1] = value; } else { base.Columns.Add(1, value); } } }
1372+
/// <summary>PID: 1002 | Type: read</summary>
1373+
public System.Object Interfacestablename { get { if (base.Columns.ContainsKey(1)) { return base.Columns[1]; } else { return null; } } set { if (base.Columns.ContainsKey(1)) { base.Columns[1] = value; } else { base.Columns.Add(1, value); } } }
1374+
public InterfacestableQActionRow() : base(0, 2) { }
1375+
public InterfacestableQActionRow(System.Object[] oRow) : base(0, 2, oRow) { }
1376+
public static implicit operator InterfacestableQActionRow(System.Object[] source) { return new InterfacestableQActionRow(source); }
1377+
public static implicit operator System.Object[](InterfacestableQActionRow source) { return source.ToObjectArray(); }
1378+
}
1379+
/// <summary>IDX: 0</summary>
12981380
public class FleinterfacesoverviewtableQActionRow : QActionTableRow
12991381
{
13001382
/// <summary>PID: 9991001 | Type: read</summary>

protocol.xml

+67-1
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,80 @@ Any inquiries can be addressed to:
7272
<Relation path="9991300;9991200" name="FLE Provisioned Flow - Outgoing Flow" />
7373
</Relations>
7474

75+
<ParameterGroups>
76+
<Group id="1" name="Ethernet" type="inout" dynamicId="1000" dynamicIndex="*" dynamicUsePK="true" />
77+
</ParameterGroups>
78+
7579
<Params>
7680
<Param id="2">
7781
<Name>AfterStartup</Name>
7882
<Description>After Startup</Description>
7983
<Type>dummy</Type>
8084
</Param>
8185

82-
86+
<Param id="1000">
87+
<Name>interfacesTable</Name>
88+
<Description>Interfaces Table</Description>
89+
<Type>array</Type>
90+
<ArrayOptions index="0">
91+
<ColumnOption idx="0" pid="1001" type="retrieved" options=""/>
92+
<ColumnOption idx="1" pid="1002" type="retrieved" options=""/>
93+
</ArrayOptions>
94+
<Information>
95+
<Subtext>Interfaces table</Subtext>
96+
</Information>
97+
<Display>
98+
<RTDisplay>true</RTDisplay>
99+
<Positions>
100+
<Position>
101+
<Page>General</Page>
102+
<Column>0</Column>
103+
<Row>0</Row>
104+
</Position>
105+
</Positions>
106+
</Display>
107+
<Measurement>
108+
<Type options="tab=columns:1001|0-1002|1,width:100-300,sort:STRING-STRING,lines:25,filter:true">table</Type>
109+
</Measurement>
110+
</Param>
111+
<Param id="1001" trending="false">
112+
<Name>interfacesTableId</Name>
113+
<Description>ID (Interfaces Table)</Description>
114+
<Type>read</Type>
115+
<Information>
116+
<Subtext>This is the key used internally by DataMiner to identify the table entries.</Subtext>
117+
</Information>
118+
<Interprete>
119+
<RawType>other</RawType>
120+
<Type>string</Type>
121+
<LengthType>next param</LengthType>
122+
</Interprete>
123+
<Display>
124+
<RTDisplay>true</RTDisplay>
125+
</Display>
126+
<Measurement>
127+
<Type>string</Type>
128+
</Measurement>
129+
</Param>
130+
<Param id="1002" trending="false">
131+
<Name>interfacesTableName</Name>
132+
<Description>Name (Interfaces Table)</Description>
133+
<Type>read</Type>
134+
<Information>
135+
<Subtext>Name of the interface.</Subtext>
136+
</Information>
137+
<Interprete>
138+
<RawType>other</RawType>
139+
<Type>string</Type>
140+
<LengthType>next param</LengthType>
141+
</Interprete>
142+
<Display>
143+
<RTDisplay>true</RTDisplay>
144+
</Display>
145+
<Measurement>
146+
<Type>string</Type>
147+
</Measurement>
148+
</Param>
83149

84150
<Param id="9990990" trending="false">
85151
<Name>fleInterAppReceive</Name>

0 commit comments

Comments
 (0)