Skip to content

Commit

Permalink
pid thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonV-Skyline committed Nov 16, 2023
1 parent 84eed65 commit dd45ec9
Show file tree
Hide file tree
Showing 13 changed files with 852 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ThresholdPidCreateBulk.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<DMSScript options="272" xmlns="http://www.skyline.be/automation">
<Name>ThresholdPidCreateBulk</Name>
<Description></Description>
<Type>Automation</Type>
<Author>SKYLINE2\SVD</Author>
<CheckSets>FALSE</CheckSets>
<Folder>BT VB Probe Series - InterApp Demo</Folder>

<Protocols>
</Protocols>

<Memory>
</Memory>

<Parameters>
<ScriptParameter id="101" type="string" values="">
<Description>Element Name</Description>
</ScriptParameter>
</Parameters>

<Script>
<Exe id="1" type="csharp">
<Value><![CDATA[[Project:ThresholdPidCreateBulk_1]]]></Value>
<!--<Param type="debug">true</Param>-->
<Message></Message>
</Exe>
</Script>
</DMSScript>
143 changes: 143 additions & 0 deletions ThresholdPidCreateBulk_1/ThresholdPidCreateBulk_1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
****************************************************************************
* Copyright (c) 2023, Skyline Communications NV All Rights Reserved. *
****************************************************************************
By using this script, you expressly agree with the usage terms and
conditions set out below.
This script and all related materials are protected by copyrights and
other intellectual property rights that exclusively belong
to Skyline Communications.
A user license granted for this script is strictly for personal use only.
This script may not be used in any way by anyone without the prior
written consent of Skyline Communications. Any sublicensing of this
script is forbidden.
Any modifications to this script by the user are only allowed for
personal use and within the intended purpose of the script,
and will remain the sole responsibility of the user.
Skyline Communications will not be responsible for any damages or
malfunctions whatsoever of the script resulting from a modification
or adaptation by the user.
The content of this script is confidential information.
The user hereby agrees to keep this confidential information strictly
secret and confidential and not to disclose or reveal it, in whole
or in part, directly or indirectly to any person, entity, organization
or administration without the prior written consent of
Skyline Communications.
Any inquiries can be addressed to:
Skyline Communications NV
Ambachtenstraat 33
B-8870 Izegem
Belgium
Tel. : +32 51 31 35 69
Fax. : +32 51 31 01 29
E-mail : [email protected]
Web : www.skyline.be
Contact : Ben Vandenberghe
****************************************************************************
Revision History:
DATE VERSION AUTHOR COMMENTS
01/06/2023 1.0.0.1 SVD, Skyline Initial version
****************************************************************************
*/

namespace ThresholdPidCreateBulk
{
using System;

using Skyline.DataMiner.Automation;
using Skyline.DataMiner.ConnectorAPI.BridgeTechnologies.VBProbeSeries;
using Skyline.DataMiner.ConnectorAPI.BridgeTechnologies.VBProbeSeries.AlarmThresholds.PidThresholds;
using Skyline.DataMiner.Core.InterAppCalls.Common.CallBulk;
using Skyline.DataMiner.Core.InterAppCalls.Common.Shared;

/// <summary>
/// Represents a DataMiner Automation script.
/// </summary>
public class Script
{
/// <summary>
/// The script entry point.
/// </summary>
/// <param name="engine">Link with SLAutomation process.</param>
public void Run(IEngine engine)
{
// Get user input
////string elementName = "BT VB Probe Series";
string elementName = engine.GetScriptParam("Element Name").Value;

// Find Element
var element = engine.FindElement(elementName);
if (element == null)
{
engine.GenerateInformation($"Could not find element with name '{elementName}'.");
return;
}
else
{
engine.GenerateInformation($"Found element with name '{elementName}' - elemendID '{element.DmaId}/{element.ElementId}'");
}

// Build InterApp Message
var command = InterAppCallFactory.CreateNew();
command.Source = new Source("BT VB Series - InterAppDemo - Thresholds - PID - Create Bulk");
command.ReturnAddress = new ReturnAddress(element.DmaId, element.ElementId, 9000001);

for (int i = 1; i <= 10; i++)
{
var message = new CreatePidThreshold
{
ThresholdData = MakeThresholdData(i),
Source = new Source("BT VB Series - InterAppDemo - Thresholds - PID - Create Bulk"),
};

command.Messages.Add(message);
}

// Process InterApp Message
foreach (var responseMessage in command.Send(
Engine.SLNetRaw,
element.DmaId,
element.ElementId,
9000000,
new TimeSpan(0, 0, 10),
InterApp.KnownTypes))
{
if (responseMessage != null)
{
if (responseMessage is CreatePidThresholdResult result)
{
engine.GenerateInformation(result.Description);
}
else
{
engine.GenerateInformation($"{nameof(responseMessage)} is not of expected type '{nameof(CreatePidThresholdResult)}'.{Environment.NewLine}{responseMessage}");
}
}
else
{
engine.GenerateInformation($"{nameof(responseMessage)} is null.");
}
}
}

public PidThresholdData MakeThresholdData(int i)
{
var thresholdData = new PidThresholdData
{
Name = $"Demo_CreateBulk_1{i}",
Description = $"Demo_CreateBulk_1{i}",
};

return thresholdData;
}
}
}
28 changes: 28 additions & 0 deletions ThresholdPidCreateBulk_1/ThresholdPidCreateBulk_1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<Company>Skyline Communications</Company>
<Copyright>© Skyline Communications</Copyright>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-debug.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<CodeAnalysisRuleSet>..\Internal\Code Analysis\qaction-release.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);DCFv1;DBInfo;ALARM_SQUASHING</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Skyline.DataMiner.ConnectorAPI.BridgeTechnologies.VBProbeSeries" Version="1.0.0.1" />
<PackageReference Include="Skyline.DataMiner.Dev.Automation" Version="10.1.0.6" />
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties DisLinkedXmlFile="..\ThresholdPidCreateBulk.xml" DisProjectType="automationScriptProject" DisLinkId="1" />
</VisualStudio>
</ProjectExtensions>
</Project>
29 changes: 29 additions & 0 deletions ThresholdPidCreateSingle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<DMSScript options="272" xmlns="http://www.skyline.be/automation">
<Name>ThresholdPidCreateSingle</Name>
<Description></Description>
<Type>Automation</Type>
<Author>SKYLINE2\SVD</Author>
<CheckSets>FALSE</CheckSets>
<Folder>BT VB Probe Series - InterApp Demo</Folder>

<Protocols>
</Protocols>

<Memory>
</Memory>

<Parameters>
<ScriptParameter id="101" type="string" values="">
<Description>Element Name</Description>
</ScriptParameter>
</Parameters>

<Script>
<Exe id="1" type="csharp">
<Value><![CDATA[[Project:ThresholdPidCreateSingle_1]]]></Value>
<!--<Param type="debug">true</Param>-->
<Message></Message>
</Exe>
</Script>
</DMSScript>
140 changes: 140 additions & 0 deletions ThresholdPidCreateSingle_1/ThresholdPidCreateSingle_1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
****************************************************************************
* Copyright (c) 2023, Skyline Communications NV All Rights Reserved. *
****************************************************************************
By using this script, you expressly agree with the usage terms and
conditions set out below.
This script and all related materials are protected by copyrights and
other intellectual property rights that exclusively belong
to Skyline Communications.
A user license granted for this script is strictly for personal use only.
This script may not be used in any way by anyone without the prior
written consent of Skyline Communications. Any sublicensing of this
script is forbidden.
Any modifications to this script by the user are only allowed for
personal use and within the intended purpose of the script,
and will remain the sole responsibility of the user.
Skyline Communications will not be responsible for any damages or
malfunctions whatsoever of the script resulting from a modification
or adaptation by the user.
The content of this script is confidential information.
The user hereby agrees to keep this confidential information strictly
secret and confidential and not to disclose or reveal it, in whole
or in part, directly or indirectly to any person, entity, organization
or administration without the prior written consent of
Skyline Communications.
Any inquiries can be addressed to:
Skyline Communications NV
Ambachtenstraat 33
B-8870 Izegem
Belgium
Tel. : +32 51 31 35 69
Fax. : +32 51 31 01 29
E-mail : [email protected]
Web : www.skyline.be
Contact : Ben Vandenberghe
****************************************************************************
Revision History:
DATE VERSION AUTHOR COMMENTS
01/06/2023 1.0.0.1 SVD, Skyline Initial version
****************************************************************************
*/

namespace ThresholdPidCreateSingle
{
using System;

using Skyline.DataMiner.Automation;
using Skyline.DataMiner.ConnectorAPI.BridgeTechnologies.VBProbeSeries;
using Skyline.DataMiner.ConnectorAPI.BridgeTechnologies.VBProbeSeries.AlarmThresholds.PidThresholds;
using Skyline.DataMiner.Core.InterAppCalls.Common.CallBulk;
using Skyline.DataMiner.Core.InterAppCalls.Common.Shared;

/// <summary>
/// Represents a DataMiner Automation script.
/// </summary>
public class Script
{
/// <summary>
/// The script entry point.
/// </summary>
/// <param name="engine">Link with SLAutomation process.</param>
public void Run(IEngine engine)
{
// Get user input
////string elementName = "BT VB Probe Series";
string elementName = engine.GetScriptParam("Element Name").Value;

// Find Element
var element = engine.FindElement(elementName);
if (element == null)
{
engine.GenerateInformation($"Could not find element with name '{elementName}'.");
return;
}
else
{
engine.GenerateInformation($"Found element with name '{elementName}' - elemendID '{element.DmaId}/{element.ElementId}'");
}

// Build InterApp Message
var command = InterAppCallFactory.CreateNew();
command.Source = new Source("BT VB Series - InterAppDemo - Thresholds - PID - Create Single");
command.ReturnAddress = new ReturnAddress(element.DmaId, element.ElementId, 9000001);

var message = new CreatePidThreshold
{
ThresholdData = MakeThresholdData(),
Source = new Source("BT VB Series - InterAppDemo - Thresholds - PID - Create Single"),
};

command.Messages.Add(message);

// Process InterApp Message
foreach (var responseMessage in command.Send(
Engine.SLNetRaw,
element.DmaId,
element.ElementId,
9000000,
new TimeSpan(0, 0, 10),
InterApp.KnownTypes))
{
if (responseMessage != null)
{
if (responseMessage is CreatePidThresholdResult result)
{
engine.GenerateInformation(result.Description);
}
else
{
engine.GenerateInformation($"{nameof(responseMessage)} is not of expected type '{nameof(CreatePidThresholdResult)}'.{Environment.NewLine}{responseMessage}");
}
}
else
{
engine.GenerateInformation($"{nameof(responseMessage)} is null.");
}
}
}

public PidThresholdData MakeThresholdData()
{
var thresholdData = new PidThresholdData
{
Name = "Demo_CreateSingle_1",
Description = "Demo_CreateSingle_1",
};

return thresholdData;
}
}
}
Loading

0 comments on commit dd45ec9

Please sign in to comment.