Hi:
I am writing a dataminer xml protocol. Could i have some guidance on how to setup a QAction that only being run ONCE after element start.
Thanks
Hi,
The following sequence can be used to trigger a QAction after element startup.
Note: this will be executed every time the element is (re)started.
After startup trigger -> Action -> group -> Action -> dummy param -> QAction
The following example should help:
"""
<Params>
<Param id="1">
<Name>AfterStartupDummy</Name>
<Description>After Startup Dummy</Description>
<Type>dummy</Type>
</Param>
</Params>
<QActions>
<QAction id="1" name="After Startup QAction" encoding="csharp" triggers="1">
<![CDATA[using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Skyline.DataMiner.Scripting;
/// <summary>
/// DataMiner QAction Class: After Startup QAction
/// </summary>
public static class QAction
{
/// <summary>
/// The QAction entry point.
/// </summary>
/// <param name="protocol">Link with SLProtocol process.</param>
public static void Run(SLProtocol protocol)
{
try
{
// DO LOGIC HERE
}
catch (Exception ex)
{
protocol.Log($"QA{protocol.QActionID}|{protocol.GetTriggerParameter()}|Run|Exception thrown:{Environment.NewLine}{ex}", LogType.Error, LogLevel.NoLogging);
}
}
}]]>
</QAction>
</QActions>
<Groups>
<Group id="1">
<Name>After Startup</Name>
<Description>After Startup</Description>
<Type>poll action</Type>
<Content>
<Action>2</Action>
</Content>
</Group>
</Groups>
<Triggers>
<Trigger id="1">
<Name>After Startup</Name>
<On>protocol</On>
<Time>after startup</Time>
<Type>action</Type>
<Content>
<Id>1</Id>
</Content>
</Trigger>
</Triggers>
<Actions>
<Action id="1">
<Name>After Startup Group</Name>
<On id="1">group</On>
<Type>execute next</Type>
</Action>
<Action id="2">
<Name>After Startup QAction</Name>
<On id="1">parameter</On>
<Type>run actions</Type>
</Action>
</Actions>
"""
More information about the After startup trigger and how this works in DataMiner can be found here.
Hope this helps!
Kind regards,