Skip to content

Commit 947ac0c

Browse files
committed
Measure time between starting connect/disconnect and receiving the FlowInfoMessage interapp
1 parent fa43cda commit 947ac0c

8 files changed

+348
-24
lines changed

QAction_100/ControlSurfaceAction.cs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace QAction_100
2+
{
3+
public enum ControlSurfaceAction
4+
{
5+
Connect,
6+
Disconnect,
7+
}
8+
}

QAction_100/QAction_100.cs

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using System;
2+
using System.Linq;
3+
4+
using Newtonsoft.Json;
5+
6+
using QAction_100;
7+
8+
using Skyline.DataMiner.Core.DataMinerSystem.Common;
9+
using Skyline.DataMiner.Core.DataMinerSystem.Protocol;
10+
using Skyline.DataMiner.Net.Apps.DataMinerObjectModel;
11+
using Skyline.DataMiner.Net.Messages.SLDataGateway;
12+
using Skyline.DataMiner.Scripting;
13+
14+
/// <summary>
15+
/// DataMiner QAction Class.
16+
/// </summary>
17+
public class QAction
18+
{
19+
private ControlSurfaceAction _nextAction = ControlSurfaceAction.Connect;
20+
21+
/// <summary>
22+
/// The QAction entry point.
23+
/// </summary>
24+
/// <param name="protocol">Link with SLProtocol process.</param>
25+
public void Run(SLProtocolExt protocol)
26+
{
27+
try
28+
{
29+
var dms = protocol.GetDms();
30+
31+
var domHelper = new DomHelper(protocol.SLNet.SendMessages, "(slc)virtualsignalgroup");
32+
var source = GetVirtualSignalGroup(domHelper, "LA CAM-01");
33+
var destination = GetVirtualSignalGroup(domHelper, "FLE Test 1");
34+
35+
switch (_nextAction)
36+
{
37+
case ControlSurfaceAction.Connect:
38+
PerformConnect(protocol, dms, source, destination);
39+
_nextAction= ControlSurfaceAction.Disconnect;
40+
break;
41+
case ControlSurfaceAction.Disconnect:
42+
default:
43+
PerformDisconnect(protocol, dms, destination);
44+
_nextAction= ControlSurfaceAction.Connect;
45+
break;
46+
}
47+
}
48+
catch (Exception ex)
49+
{
50+
protocol.Log($"QA{protocol.QActionID}|{protocol.GetTriggerParameter()}|Run|Exception thrown:{Environment.NewLine}{ex}", LogType.Error, LogLevel.NoLogging);
51+
}
52+
}
53+
54+
private void PerformConnect(SLProtocolExt protocol, IDms dms, DomInstance source, DomInstance destination)
55+
{
56+
protocol.Lastconnecttime = DateTime.Now.ToOADate();
57+
ExecuteTakeScript(dms, "Connect", source.ID.Id, destination.ID.Id);
58+
}
59+
60+
private void PerformDisconnect(SLProtocolExt protocol, IDms dms, DomInstance destination)
61+
{
62+
protocol.Lastdisconnecttime = DateTime.Now.ToOADate();
63+
ExecuteTakeScript(dms, "Disconnect", default, destination.ID.Id);
64+
}
65+
66+
private void ExecuteTakeScript(IDms dms, string action, Guid source, Guid destination)
67+
{
68+
var script = dms.GetScript("ControlSurface_Take");
69+
70+
var parameters = new[]
71+
{
72+
new DmsAutomationScriptParamValue("Action", JsonConvert.SerializeObject(new[] { action })),
73+
new DmsAutomationScriptParamValue("Source", JsonConvert.SerializeObject(source != default ? new[] { source } : Array.Empty<Guid>())),
74+
new DmsAutomationScriptParamValue("Destinations", JsonConvert.SerializeObject(destination != default ? new[] { destination } : Array.Empty<Guid>())),
75+
new DmsAutomationScriptParamValue("Levels", JsonConvert.SerializeObject(Array.Empty<Guid>())),
76+
};
77+
var dummies = Enumerable.Empty<DmsAutomationScriptDummyValue>();
78+
79+
script.ExecuteAsync(parameters, dummies);
80+
}
81+
82+
private DomInstance GetVirtualSignalGroup(DomHelper domHelper, string name)
83+
{
84+
var filter = DomInstanceExposers.Name.Equal(name);
85+
return domHelper.DomInstances.Read(filter).FirstOrDefault();
86+
}
87+
}

QAction_100/QAction_100.csproj

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net48</TargetFramework>
4+
<Company>Skyline Communications</Company>
5+
<Copyright>© Skyline Communications</Copyright>
6+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
7+
<LangVersion>7.3</LangVersion>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="..\QAction_Helper\QAction_Helper.csproj" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="Skyline.DataMiner.Core.DataMinerSystem.Protocol" Version="1.1.1.12" />
14+
<PackageReference Include="Skyline.DataMiner.Dev.Protocol" Version="10.4.5.1" />
15+
</ItemGroup>
16+
<ProjectExtensions>
17+
<VisualStudio>
18+
<UserProperties DisLinkedXmlFile="..\protocol.xml" DisProjectType="qactionProject" DisLinkId="100" />
19+
</VisualStudio>
20+
</ProjectExtensions>
21+
</Project>

QAction_2/QAction_2.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private static void FillInterfacesTable(SLProtocolExt protocol)
4141
new InterfacestableQActionRow
4242
{
4343
Interfacestableid = "1",
44-
Interfacestablename = "Ethernet 2",
44+
Interfacestablename = "Ethernet 1",
4545
},
4646
new InterfacestableQActionRow
4747
{

QAction_9990990/FlowProvisioningExecutor.cs

+17
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ public override bool TryExecute(object dataSource, object dataDestination, out M
2828
switch (Message.ActionType)
2929
{
3030
case ActionType.Create:
31+
UpdateLastDuration(protocol, Parameter.lastconnecttime, Parameter.connectduration);
3132
var addedFlows = flowEngineering.RegisterProvisionedFlowFromInterAppMessage(protocol, Message);
3233

3334
break;
3435

3536
case ActionType.Delete:
37+
UpdateLastDuration(protocol, Parameter.lastdisconnecttime, Parameter.disconnectduration);
3638
var (provisionedFlow, removedFlows) = flowEngineering.UnregisterProvisionedFlowFromInterAppMessage(protocol, Message);
3739

3840
break;
@@ -53,5 +55,20 @@ public override bool TryExecute(object dataSource, object dataDestination, out M
5355
optionalReturnMessage = null;
5456
return true;
5557
}
58+
59+
private void UpdateLastDuration(SLProtocolExt protocol, int pidTime, int pidDuration)
60+
{
61+
var lastTimeDouble = Convert.ToDouble(protocol.GetParameter(pidTime));
62+
if (lastTimeDouble <= 0)
63+
{
64+
return;
65+
}
66+
67+
var lastTime = DateTime.FromOADate(lastTimeDouble);
68+
var duration = DateTime.Now - lastTime;
69+
70+
protocol.SetParameter(pidDuration, duration.TotalMilliseconds);
71+
}
72+
5673
}
5774
}

QAction_Helper/QAction_Helper.cs

+51
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,26 @@ namespace Skyline.DataMiner.Scripting
88
{
99
public static class Parameter
1010
{
11+
/// <summary>PID: 200 | Type: read</summary>
12+
[EditorBrowsable(EditorBrowsableState.Never)]
13+
public const int lastconnecttime_200 = 200;
14+
/// <summary>PID: 200 | Type: read</summary>
15+
public const int lastconnecttime = 200;
16+
/// <summary>PID: 201 | Type: read</summary>
17+
[EditorBrowsable(EditorBrowsableState.Never)]
18+
public const int connectduration_201 = 201;
19+
/// <summary>PID: 201 | Type: read</summary>
20+
public const int connectduration = 201;
21+
/// <summary>PID: 210 | Type: read</summary>
22+
[EditorBrowsable(EditorBrowsableState.Never)]
23+
public const int lastdisconnecttime_210 = 210;
24+
/// <summary>PID: 210 | Type: read</summary>
25+
public const int lastdisconnecttime = 210;
26+
/// <summary>PID: 211 | Type: read</summary>
27+
[EditorBrowsable(EditorBrowsableState.Never)]
28+
public const int disconnectduration_211 = 211;
29+
/// <summary>PID: 211 | Type: read</summary>
30+
public const int disconnectduration = 211;
1131
/// <summary>PID: 9990990 | Type: read</summary>
1232
[EditorBrowsable(EditorBrowsableState.Never)]
1333
public const int fleinterappreceive_9990990 = 9990990;
@@ -808,6 +828,15 @@ public interface SLProtocolExt : SLProtocol
808828
/// <summary>PID: 9991300</summary>
809829
FleprovisionedflowstableQActionTable fleprovisionedflowstable { get; set; }
810830
object Afterstartup_dummy { get; set; }
831+
object Trigger1min_dummy { get; set; }
832+
object Lastconnecttime_200 { get; set; }
833+
object Lastconnecttime { get; set; }
834+
object Connectduration_201 { get; set; }
835+
object Connectduration { get; set; }
836+
object Lastdisconnecttime_210 { get; set; }
837+
object Lastdisconnecttime { get; set; }
838+
object Disconnectduration_211 { get; set; }
839+
object Disconnectduration { get; set; }
811840
object Interfacestableid_1001 { get; set; }
812841
object Interfacestableid { get; set; }
813842
object Interfacestablename_1002 { get; set; }
@@ -964,6 +993,28 @@ public class ConcreteSLProtocolExt : ConcreteSLProtocol, SLProtocolExt
964993
public FleprovisionedflowstableQActionTable fleprovisionedflowstable { get; set; }
965994
/// <summary>PID: 2 | Type: dummy</summary>
966995
public System.Object Afterstartup_dummy {get { return GetParameter(2); }set { SetParameter(2, value); }}
996+
/// <summary>PID: 10 | Type: dummy</summary>
997+
public System.Object Trigger1min_dummy {get { return GetParameter(10); }set { SetParameter(10, value); }}
998+
/// <summary>PID: 200 | Type: read</summary>
999+
[EditorBrowsable(EditorBrowsableState.Never)]
1000+
public System.Object Lastconnecttime_200 {get { return GetParameter(200); }set { SetParameter(200, value); }}
1001+
/// <summary>PID: 200 | Type: read</summary>
1002+
public System.Object Lastconnecttime {get { return GetParameter(200); }set { SetParameter(200, value); }}
1003+
/// <summary>PID: 201 | Type: read</summary>
1004+
[EditorBrowsable(EditorBrowsableState.Never)]
1005+
public System.Object Connectduration_201 {get { return GetParameter(201); }set { SetParameter(201, value); }}
1006+
/// <summary>PID: 201 | Type: read</summary>
1007+
public System.Object Connectduration {get { return GetParameter(201); }set { SetParameter(201, value); }}
1008+
/// <summary>PID: 210 | Type: read</summary>
1009+
[EditorBrowsable(EditorBrowsableState.Never)]
1010+
public System.Object Lastdisconnecttime_210 {get { return GetParameter(210); }set { SetParameter(210, value); }}
1011+
/// <summary>PID: 210 | Type: read</summary>
1012+
public System.Object Lastdisconnecttime {get { return GetParameter(210); }set { SetParameter(210, value); }}
1013+
/// <summary>PID: 211 | Type: read</summary>
1014+
[EditorBrowsable(EditorBrowsableState.Never)]
1015+
public System.Object Disconnectduration_211 {get { return GetParameter(211); }set { SetParameter(211, value); }}
1016+
/// <summary>PID: 211 | Type: read</summary>
1017+
public System.Object Disconnectduration {get { return GetParameter(211); }set { SetParameter(211, value); }}
9671018
/// <summary>PID: 1001 | Type: read</summary>
9681019
[EditorBrowsable(EditorBrowsableState.Never)]
9691020
public System.Object Interfacestableid_1001 {get { return GetParameter(1001); }set { SetParameter(1001, value); }}

Skyline Example Flow Engineering.sln

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QAction_9990990", "QAction_
4848
EndProject
4949
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QAction_9991000", "QAction_9991000\QAction_9991000.csproj", "{63E474B9-5AAF-4D55-B2B1-1040F8A863A6}"
5050
EndProject
51+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QAction_100", "QAction_100\QAction_100.csproj", "{4E63E13F-8458-44AA-AAB5-8EA00C796BE1}"
52+
EndProject
5153
Global
5254
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5355
Debug|Any CPU = Debug|Any CPU
@@ -70,6 +72,10 @@ Global
7072
{63E474B9-5AAF-4D55-B2B1-1040F8A863A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
7173
{63E474B9-5AAF-4D55-B2B1-1040F8A863A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
7274
{63E474B9-5AAF-4D55-B2B1-1040F8A863A6}.Release|Any CPU.Build.0 = Release|Any CPU
75+
{4E63E13F-8458-44AA-AAB5-8EA00C796BE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
76+
{4E63E13F-8458-44AA-AAB5-8EA00C796BE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
77+
{4E63E13F-8458-44AA-AAB5-8EA00C796BE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
78+
{4E63E13F-8458-44AA-AAB5-8EA00C796BE1}.Release|Any CPU.Build.0 = Release|Any CPU
7379
EndGlobalSection
7480
GlobalSection(SolutionProperties) = preSolution
7581
HideSolutionNode = FALSE
@@ -80,6 +86,7 @@ Global
8086
{23DD4085-E9B7-41F5-8885-9B4CB48DC5DE} = {658269EB-119E-402B-9202-973ABEF9C012}
8187
{67506985-4F86-4E8C-AC73-57B7A872EC95} = {658269EB-119E-402B-9202-973ABEF9C012}
8288
{63E474B9-5AAF-4D55-B2B1-1040F8A863A6} = {658269EB-119E-402B-9202-973ABEF9C012}
89+
{4E63E13F-8458-44AA-AAB5-8EA00C796BE1} = {658269EB-119E-402B-9202-973ABEF9C012}
8390
EndGlobalSection
8491
GlobalSection(ExtensibilityGlobals) = postSolution
8592
SolutionGuid = {B591CBD0-A8D2-451C-A2BF-AE5C109F71AA}

0 commit comments

Comments
 (0)