Skip to content

Commit e532161

Browse files
committed
Make source and destination VSG configurable
1 parent 947ac0c commit e532161

File tree

3 files changed

+184
-19
lines changed

3 files changed

+184
-19
lines changed

QAction_100/QAction_100.cs

+33-15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Skyline.DataMiner.Net.Messages.SLDataGateway;
1212
using Skyline.DataMiner.Scripting;
1313

14+
using Parameter = Skyline.DataMiner.Scripting.Parameter;
15+
1416
/// <summary>
1517
/// DataMiner QAction Class.
1618
/// </summary>
@@ -26,22 +28,21 @@ public void Run(SLProtocolExt protocol)
2628
{
2729
try
2830
{
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");
31+
GetVirtualSignalGroups(protocol, out var srcVsg, out var dstVsg);
3432

3533
switch (_nextAction)
3634
{
3735
case ControlSurfaceAction.Connect:
38-
PerformConnect(protocol, dms, source, destination);
39-
_nextAction= ControlSurfaceAction.Disconnect;
36+
PerformConnect(protocol, srcVsg, dstVsg);
37+
_nextAction = ControlSurfaceAction.Disconnect;
38+
4039
break;
40+
4141
case ControlSurfaceAction.Disconnect:
4242
default:
43-
PerformDisconnect(protocol, dms, destination);
44-
_nextAction= ControlSurfaceAction.Connect;
43+
PerformDisconnect(protocol, dstVsg);
44+
_nextAction = ControlSurfaceAction.Connect;
45+
4546
break;
4647
}
4748
}
@@ -51,20 +52,21 @@ public void Run(SLProtocolExt protocol)
5152
}
5253
}
5354

54-
private void PerformConnect(SLProtocolExt protocol, IDms dms, DomInstance source, DomInstance destination)
55+
private void PerformConnect(SLProtocolExt protocol, DomInstance source, DomInstance destination)
5556
{
5657
protocol.Lastconnecttime = DateTime.Now.ToOADate();
57-
ExecuteTakeScript(dms, "Connect", source.ID.Id, destination.ID.Id);
58+
ExecuteTakeScript(protocol, "Connect", source.ID.Id, destination.ID.Id);
5859
}
5960

60-
private void PerformDisconnect(SLProtocolExt protocol, IDms dms, DomInstance destination)
61+
private void PerformDisconnect(SLProtocolExt protocol, DomInstance destination)
6162
{
6263
protocol.Lastdisconnecttime = DateTime.Now.ToOADate();
63-
ExecuteTakeScript(dms, "Disconnect", default, destination.ID.Id);
64+
ExecuteTakeScript(protocol, "Disconnect", default, destination.ID.Id);
6465
}
6566

66-
private void ExecuteTakeScript(IDms dms, string action, Guid source, Guid destination)
67+
private void ExecuteTakeScript(SLProtocolExt protocol, string action, Guid source, Guid destination)
6768
{
69+
var dms = protocol.GetDms();
6870
var script = dms.GetScript("ControlSurface_Take");
6971

7072
var parameters = new[]
@@ -79,9 +81,25 @@ private void ExecuteTakeScript(IDms dms, string action, Guid source, Guid destin
7981
script.ExecuteAsync(parameters, dummies);
8082
}
8183

84+
private void GetVirtualSignalGroups(SLProtocolExt protocol, out DomInstance srcVsg, out DomInstance dstVsg)
85+
{
86+
var parameters = (object[])protocol.GetParameters(new uint[] { Parameter.sourcevsgname, Parameter.destinationvsgname });
87+
var sourceVsgName = Convert.ToString(parameters[0]);
88+
var destinationVsgName = Convert.ToString(parameters[1]);
89+
90+
var domHelper = new DomHelper(protocol.SLNet.SendMessages, "(slc)virtualsignalgroup");
91+
92+
srcVsg = GetVirtualSignalGroup(domHelper, sourceVsgName);
93+
dstVsg = GetVirtualSignalGroup(domHelper, destinationVsgName);
94+
}
95+
8296
private DomInstance GetVirtualSignalGroup(DomHelper domHelper, string name)
8397
{
8498
var filter = DomInstanceExposers.Name.Equal(name);
85-
return domHelper.DomInstances.Read(filter).FirstOrDefault();
99+
100+
var instance = domHelper.DomInstances.Read(filter).SingleOrDefault()
101+
?? throw new Exception($"Couldn't find VSG with name '{name}'");
102+
103+
return instance;
86104
}
87105
}

QAction_Helper/QAction_Helper.cs

+46
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ namespace Skyline.DataMiner.Scripting
88
{
99
public static class Parameter
1010
{
11+
/// <summary>PID: 100 | Type: read</summary>
12+
[EditorBrowsable(EditorBrowsableState.Never)]
13+
public const int sourcevsgname_100 = 100;
14+
/// <summary>PID: 100 | Type: read</summary>
15+
public const int sourcevsgname = 100;
16+
/// <summary>PID: 102 | Type: read</summary>
17+
[EditorBrowsable(EditorBrowsableState.Never)]
18+
public const int destinationvsgname_102 = 102;
19+
/// <summary>PID: 102 | Type: read</summary>
20+
public const int destinationvsgname = 102;
1121
/// <summary>PID: 200 | Type: read</summary>
1222
[EditorBrowsable(EditorBrowsableState.Never)]
1323
public const int lastconnecttime_200 = 200;
@@ -40,6 +50,16 @@ public static class Parameter
4050
public const int fleinterappreturn = 9990991;
4151
public class Write
4252
{
53+
/// <summary>PID: 101 | Type: write</summary>
54+
[EditorBrowsable(EditorBrowsableState.Never)]
55+
public const int sourcevsgname_101 = 101;
56+
/// <summary>PID: 101 | Type: write</summary>
57+
public const int sourcevsgname = 101;
58+
/// <summary>PID: 103 | Type: write</summary>
59+
[EditorBrowsable(EditorBrowsableState.Never)]
60+
public const int destinationvsgname_103 = 103;
61+
/// <summary>PID: 103 | Type: write</summary>
62+
public const int destinationvsgname = 103;
4363
/// <summary>PID: 9991158 | Type: write</summary>
4464
[EditorBrowsable(EditorBrowsableState.Never)]
4565
public const int fleincomingflowstableexpectedrxbitrate_9991158 = 9991158;
@@ -799,6 +819,10 @@ public class Idx
799819
}
800820
public class WriteParameters
801821
{
822+
/// <summary>PID: 101 | Type: write</summary>
823+
public System.Object Sourcevsgname {get { return Protocol.GetParameter(101); }set { Protocol.SetParameter(101, value); }}
824+
/// <summary>PID: 103 | Type: write</summary>
825+
public System.Object Destinationvsgname {get { return Protocol.GetParameter(103); }set { Protocol.SetParameter(103, value); }}
802826
/// <summary>PID: 9991158 | Type: write</summary>
803827
public System.Object Fleincomingflowstableexpectedrxbitrate {get { return Protocol.GetParameter(9991158); }set { Protocol.SetParameter(9991158, value); }}
804828
/// <summary>PID: 9991165 | Type: write | DISCREETS: Delete = 1</summary>
@@ -829,6 +853,12 @@ public interface SLProtocolExt : SLProtocol
829853
FleprovisionedflowstableQActionTable fleprovisionedflowstable { get; set; }
830854
object Afterstartup_dummy { get; set; }
831855
object Trigger1min_dummy { get; set; }
856+
object Sourcevsgname_100 { get; set; }
857+
object Sourcevsgname { get; set; }
858+
object Sourcevsgname_101 { get; set; }
859+
object Destinationvsgname_102 { get; set; }
860+
object Destinationvsgname { get; set; }
861+
object Destinationvsgname_103 { get; set; }
832862
object Lastconnecttime_200 { get; set; }
833863
object Lastconnecttime { get; set; }
834864
object Connectduration_201 { get; set; }
@@ -995,6 +1025,22 @@ public class ConcreteSLProtocolExt : ConcreteSLProtocol, SLProtocolExt
9951025
public System.Object Afterstartup_dummy {get { return GetParameter(2); }set { SetParameter(2, value); }}
9961026
/// <summary>PID: 10 | Type: dummy</summary>
9971027
public System.Object Trigger1min_dummy {get { return GetParameter(10); }set { SetParameter(10, value); }}
1028+
/// <summary>PID: 100 | Type: read</summary>
1029+
[EditorBrowsable(EditorBrowsableState.Never)]
1030+
public System.Object Sourcevsgname_100 {get { return GetParameter(100); }set { SetParameter(100, value); }}
1031+
/// <summary>PID: 100 | Type: read</summary>
1032+
public System.Object Sourcevsgname {get { return GetParameter(100); }set { SetParameter(100, value); }}
1033+
/// <summary>PID: 101 | Type: write</summary>
1034+
[EditorBrowsable(EditorBrowsableState.Never)]
1035+
public System.Object Sourcevsgname_101 {get { return GetParameter(101); }set { SetParameter(101, value); }}
1036+
/// <summary>PID: 102 | Type: read</summary>
1037+
[EditorBrowsable(EditorBrowsableState.Never)]
1038+
public System.Object Destinationvsgname_102 {get { return GetParameter(102); }set { SetParameter(102, value); }}
1039+
/// <summary>PID: 102 | Type: read</summary>
1040+
public System.Object Destinationvsgname {get { return GetParameter(102); }set { SetParameter(102, value); }}
1041+
/// <summary>PID: 103 | Type: write</summary>
1042+
[EditorBrowsable(EditorBrowsableState.Never)]
1043+
public System.Object Destinationvsgname_103 {get { return GetParameter(103); }set { SetParameter(103, value); }}
9981044
/// <summary>PID: 200 | Type: read</summary>
9991045
[EditorBrowsable(EditorBrowsableState.Never)]
10001046
public System.Object Lastconnecttime_200 {get { return GetParameter(200); }set { SetParameter(200, value); }}

protocol.xml

+105-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,107 @@ Any inquiries can be addressed to:
8989
<Type>dummy</Type>
9090
</Param>
9191

92+
<Param id="100" trending="false" save="true">
93+
<Name>sourceVsgName</Name>
94+
<Description>Source VSG Name</Description>
95+
<Type>read</Type>
96+
<Information>
97+
<Subtext>Name of the source virtual signal group to connect.</Subtext>
98+
</Information>
99+
<Interprete>
100+
<RawType>other</RawType>
101+
<Type>string</Type>
102+
<LengthType>next param</LengthType>
103+
<DefaultValue>LA CAM-01</DefaultValue>
104+
</Interprete>
105+
<Display>
106+
<RTDisplay>true</RTDisplay>
107+
<Positions>
108+
<Position>
109+
<Page>General</Page>
110+
<Column>0</Column>
111+
<Row>0</Row>
112+
</Position>
113+
</Positions>
114+
</Display>
115+
<Measurement>
116+
<Type>string</Type>
117+
</Measurement>
118+
</Param>
119+
<Param id="101" setter="true">
120+
<Name>sourceVsgName</Name>
121+
<Description>Source VSG Name</Description>
122+
<Type>write</Type>
123+
<Interprete>
124+
<RawType>other</RawType>
125+
<Type>string</Type>
126+
<LengthType>next param</LengthType>
127+
</Interprete>
128+
<Display>
129+
<RTDisplay>true</RTDisplay>
130+
<Positions>
131+
<Position>
132+
<Page>General</Page>
133+
<Column>0</Column>
134+
<Row>0</Row>
135+
</Position>
136+
</Positions>
137+
</Display>
138+
<Measurement>
139+
<Type>string</Type>
140+
</Measurement>
141+
</Param>
142+
<Param id="102" trending="false" save="true">
143+
<Name>destinationVsgName</Name>
144+
<Description>Destination VSG Name</Description>
145+
<Type>read</Type>
146+
<Information>
147+
<Subtext>Name of the destination virtual signal group to connect.</Subtext>
148+
</Information>
149+
<Interprete>
150+
<RawType>other</RawType>
151+
<Type>string</Type>
152+
<LengthType>next param</LengthType>
153+
<DefaultValue>NY MON-01</DefaultValue>
154+
</Interprete>
155+
<Display>
156+
<RTDisplay>true</RTDisplay>
157+
<Positions>
158+
<Position>
159+
<Page>General</Page>
160+
<Column>0</Column>
161+
<Row>1</Row>
162+
</Position>
163+
</Positions>
164+
</Display>
165+
<Measurement>
166+
<Type>string</Type>
167+
</Measurement>
168+
</Param>
169+
<Param id="103" setter="true">
170+
<Name>destinationVsgName</Name>
171+
<Description>Destination VSG Name</Description>
172+
<Type>write</Type>
173+
<Interprete>
174+
<RawType>other</RawType>
175+
<Type>string</Type>
176+
<LengthType>next param</LengthType>
177+
</Interprete>
178+
<Display>
179+
<RTDisplay>true</RTDisplay>
180+
<Positions>
181+
<Position>
182+
<Page>General</Page>
183+
<Column>0</Column>
184+
<Row>1</Row>
185+
</Position>
186+
</Positions>
187+
</Display>
188+
<Measurement>
189+
<Type>string</Type>
190+
</Measurement>
191+
</Param>
192+
92193
<Param id="200" trending="false">
93194
<Name>lastConnectTime</Name>
94195
<Description>Last Connect Time</Description>
@@ -108,7 +209,7 @@ Any inquiries can be addressed to:
108209
<Positions>
109210
<Position>
110211
<Page>General</Page>
111-
<Column>0</Column>
212+
<Column>1</Column>
112213
<Row>0</Row>
113214
</Position>
114215
</Positions>
@@ -143,7 +244,7 @@ Any inquiries can be addressed to:
143244
<Positions>
144245
<Position>
145246
<Page>General</Page>
146-
<Column>0</Column>
247+
<Column>1</Column>
147248
<Row>1</Row>
148249
</Position>
149250
</Positions>
@@ -173,7 +274,7 @@ Any inquiries can be addressed to:
173274
<Position>
174275
<Page>General</Page>
175276
<Column>1</Column>
176-
<Row>0</Row>
277+
<Row>3</Row>
177278
</Position>
178279
</Positions>
179280
</Display>
@@ -208,7 +309,7 @@ Any inquiries can be addressed to:
208309
<Position>
209310
<Page>General</Page>
210311
<Column>1</Column>
211-
<Row>1</Row>
312+
<Row>4</Row>
212313
</Position>
213314
</Positions>
214315
</Display>

0 commit comments

Comments
 (0)