Hi,
I have issues running QAction with timer I follow this flow
Timer->group->Action->Param->QAction
I run manually this QAction and Work fine:
SLManagedScripting.exe|ManagedInterop|DBG|1|9|QA3 started
SLManagedScripting.exe|ManagedInterop|DBG|1|9|QA3 - Raw JSON: '{"ping": "ok"}'
SLManagedScripting.exe|ManagedInterop|DBG|1|9|QA3 - Extracted 'ping' value: 'ok'
SLProtocol - 22168 - Titan-Live - copy|8916|CParameter::SetValue|DBG|2|-> APIHealth set value to VT_R8 : 1.000000 (calculated = 1.000000)
SLProtocol - 22168 - Titan-Live - copy|8916|CParameter::SetValue|DBG|2| 000000 31 1
SLElement.exe|21240|CElement::SetParameterValueFuncAsync|DBG|5|Set for PID 100 Value = VT_R8 : 1.000000
SLManagedScripting.exe|ManagedInterop|DBG|1|9|QA3 - Ping is OK. apihealth = 1
SLProtocol - 22168 - Titan-Live - copy|17072|CParameter::RunQActions|DBG|5|QAction 3 finished
With timer:
SLProtocol - 22168 - Titan-Live - copy|17072|CParameter::RunQActions|DBG|5|Find QAction 3
SLProtocol - 22168 - Titan-Live - copy|17072|CParameter::RunQActions|DBG|5|Run QAction 3
SLProtocol - 22168 - Titan-Live - copy|17072|CQAction::Run|INF|2|QAction [3] triggered by [pid=4/idx=-1/pk=/user=]
Input: new = <NULL>
Input: old = <NULL>
Input: extra = <NULL>
SLManagedScripting.exe|ManagedInterop|ERR|-1|9|No CodeBuilder found (element 12512/19 trigger 4 cookie 0)
SLProtocol - 22168 - Titan-Live - copy|17072|CQAction::Run|ERR|-1|QAction [3] triggered by [pid=4/idx=-1/pk=/user=] failed. (0x80040221)
Input: new = <NULL>
Input: old = <NULL>
Input: extra = <NULL>
SLProtocol - 22168 - Titan-Live - copy|17072|CParameter::RunQActions|DBG|1|QAction 3 execution failed with Invalid data. (hr = 0x80040221)
SLProtocol - 22168 - Titan-Live - copy|17072|CParameter::RunQActions|DBG|5|QAction 3 finished
This is my XML:
<?xml version="1.0" encoding="utf-8" ?>
<Protocol xmlns="http://www.skyline.be/protocol">
<Name>ATEME Titan-Live</Name>
<Description>XXXXXXXXXX</Description>
<Version>1.0.0.1</Version>
<IntegrationID>DMS-DRV-0001</IntegrationID>
<Provider>XXXXXX</Provider>
<Vendor>XXXXX</Vendor>
<VendorOID>1.3.6.1.4.1.8813.2.99</VendorOID>
<DeviceOID>100</DeviceOID>
<ElementType>Monitoring Platform</ElementType>
<Type relativeTimers="true">http</Type>
<Display defaultPage="General" pageOrder="General;----------;Security;----------;Resources;Management;Services;Networking;Sensor;Licence;----------;Webpage#http://[Polling Ip]/" wideColumnPages="Security"/>
<SNMP includepages="true">auto</SNMP>
<Compliancies>
<CassandraReady>true</CassandraReady>
<MinimumRequiredVersion>10.2.0.0 - 12603</MinimumRequiredVersion>
</Compliancies>
<Params>
<Param id="1">
<Name>AfterStartup</Name>
<Description>After Startup</Description>
<Type>dummy</Type>
</Param>
<Param id="2">
<Name>StatusCodePingCheck</Name>
<Description>Statuscodepingcheck</Description>
<Type>read</Type>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Licence</Page>
<Column>0</Column>
<Row>1</Row>
</Position>
</Positions>
</Display>
</Param>
<Param id="3">
<Name>PingCheckResponse</Name>
<Description>Pingcheckresponse</Description>
<Type>read</Type>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Licence</Page>
<Column>0</Column>
<Row>2</Row>
</Position>
</Positions>
</Display>
</Param>
<Param id="4">
<Name>DummyRunQA3</Name>
<Description>DummyRunQA3</Description>
<Type>dummy</Type>
</Param>
<Param id="5">
<Name>StatusCodeLogin</Name>
<Description>status Code Login</Description>
<Type>dummy</Type>
</Param>
<Param id="6">
<Name>LoginResponse</Name>
<Description>Login Response</Description>
<Type>dummy</Type>
</Param>
<Param id="100" trending="true">
<Name>APIHealth</Name>
<Description>API Health</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[API Health Status]]>
</Subtext>
</Information>
<Interprete>
<RawType>numeric text</RawType>
<Type>double</Type>
<LengthType>next param</LengthType>
</Interprete>
<Alarm>
<Monitored>true</Monitored>
<CH>Fail</CH>
<Normal>Ok</Normal>
</Alarm>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Resources</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Management</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Services</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Networking</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Sensor</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
<Position>
<Page>Licence</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>discreet</Type>
<Discreets>
<Discreet>
<Display>Fail</Display>
<Value>0</Value>
</Discreet>
<Discreet>
<Display>Ok</Display>
<Value>1</Value>
</Discreet>
</Discreets>
</Measurement>
</Param>
<Param id="101" trending="false">
<Name>ProtocolSupport</Name>
<Description>Protocol Support</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[API support with this protocol]]>
</Subtext>
</Information>
<Alarm>
<Monitored>true</Monitored>
<Normal>Support</Normal>
<CH>Not Support</CH>
</Alarm>
<Interprete>
<RawType>numeric text</RawType>
<Type>double</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>1</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>discreet</Type>
<Discreets>
<Discreet>
<Display>Not Support</Display>
<Value>0</Value>
</Discreet>
<Discreet>
<Display>Support</Display>
<Value>1</Value>
</Discreet>
</Discreets>
</Measurement>
</Param>
<Param id="102" trending="false">
<Name>APIVersion</Name>
<Description>API Version</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[API Version]]>
</Subtext>
</Information>
<Alarm>
<Monitored>true</Monitored>
<Normal>2.4.0.3</Normal>
<CH>=!2.4.0.3</CH>
</Alarm>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>2</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="103" trending="false">
<Name>FirmwareVersion</Name>
<Description>Firmware Version</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[Firmware Version]]>
</Subtext>
</Information>
<Alarm>
<Monitored>true</Monitored>
<Normal>4.1.30.0-0</Normal>
<CH>=!4.1.30.0-0</CH>
</Alarm>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>3</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="104" trending="false">
<Name>ServerUUID</Name>
<Description>Server UUID</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[Unique UUID of Encoder]]>
</Subtext>
</Information>
<Alarm>
<Monitored>false</Monitored>
</Alarm>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>4</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="105" trending="false">
<Name>EncoderStatus</Name>
<Description>Encoder Status</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[Login Status of Encoder]]>
</Subtext>
</Information>
<Alarm>
<Monitored>true</Monitored>
<Normal>Authorized</Normal>
<CH>Not Authorized</CH>
</Alarm>
<Interprete>
<RawType>numeric text</RawType>
<Type>double</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>5</Row>
</Position>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>0</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>discreet</Type>
<Discreets>
<Discreet>
<Display>Not Authorized</Display>
<Value>0</Value>
</Discreet>
<Discreet>
<Display>Authorized</Display>
<Value>1</Value>
</Discreet>
</Discreets>
</Measurement>
</Param>
<Param id="106" trending="false">
<Name>FirmwareRelease</Name>
<Description>Firmware Release</Description>
<Type>read</Type>
<Information>
<Subtext>
<![CDATA[Firmware release version]]>
</Subtext>
</Information>
<Alarm>
<Monitored>false</Monitored>
</Alarm>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>General</Page>
<Column>0</Column>
<Row>6</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="135" trending="false">
<Name>username</Name>
<Description>Username</Description>
<Type>read</Type>
<Information>
<Subtext>
0
</Subtext>
</Information>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>2</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="235" setter="true">
<Name>username</Name>
<Description>Username</Description>
<Type>write</Type>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>2</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="136" trending="false">
<Name>Password</Name>
<Description>Password</Description>
<Type>read</Type>
<Information>
<Subtext>
0
</Subtext>
</Information>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>3</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type options="Password">string</Type>
</Measurement>
</Param>
<Param id="236" setter="true">
<Name>Password</Name>
<Description>Password</Description>
<Type>write</Type>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>3</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type options="Password">string</Type>
</Measurement>
</Param>
<Param id="137" trending="false">
<Name>TokenValue</Name>
<Description>Token</Description>
<Type>read</Type>
<Information>
<Subtext>
0
</Subtext>
</Information>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>1</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
<Param id="237" setter="true">
<Name>TokenValue</Name>
<Description>Token</Description>
<Type>write</Type>
<Interprete>
<RawType>other</RawType>
<Type>string</Type>
<LengthType>next param</LengthType>
</Interprete>
<Display>
<RTDisplay>true</RTDisplay>
<Positions>
<Position>
<Page>Security</Page>
<Column>0</Column>
<Row>1</Row>
</Position>
</Positions>
</Display>
<Measurement>
<Type>string</Type>
</Measurement>
</Param>
</Params>
<QActions>
<QAction id="1" name="Precompiled Code" encoding="csharp" options="precompile" />
<QAction id="2" name="After Startup" encoding="csharp" triggers="1" />
<QAction id="3" name="Ping Status" encoding="csharp" triggers="4" />
</QActions>
<HTTP>
<Session id="1" name="API Status">
<Connection id="1" name="Check Ping">
<Request verb="GET" url="/api/v1/system/network/ping">
</Request>
<Response statusCode="2">
<Content pid="3"></Content>
</Response>
</Connection>
</Session>
<Session id="2" name="API Login">
<Connection id="1" name="Credentials">
<Request verb="POST" url="/api/management/login">
<Parameters>
<Parameter key="user" pid="135"></Parameter>
<Parameter key="password" pid="136"></Parameter>
</Parameters>
<Headers>
<Header key="Content-Type">application/json</Header>
</Headers>
</Request>
<Response statusCode="5">
<Content pid="6"></Content>
</Response>
</Connection>
</Session>
</HTTP>
<Groups>
<Group id="1">
<Name>After Startup</Name>
<Description>After Startup</Description>
<Type>poll action</Type>
<Content>
<Action>2</Action>
</Content>
</Group>
<Group id="2">
<Name>Fast Polling Session</Name>
<Description>Fast Polling 10s</Description>
<Type>poll</Type>
<Content>
<Session>1</Session>
</Content>
</Group>
<Group id="3">
<Name>Fast Polling QAction</Name>
<Description>Fast Polling 10s</Description>
<Type>poll action</Type>
<Content>
<Action>3</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>
<Action id="3">
<Name>Run Ping Check</Name>
<On id="4">parameter</On>
<Type>run actions</Type>
</Action>
</Actions>
<Timers>
<Timer id="1">
<Name>Fast Timer (10s)</Name>
<Time initial="true">10000</Time>
<Interval>75</Interval>
<Content>
<Group>2</Group>
</Content>
</Timer>
<Timer id="2">
<Name>Medium Timer (1m)</Name>
<Time initial="true" dataDisplay="30000">60000</Time>
<Interval>75</Interval>
<Content>
<Group>3</Group>
</Content>
</Timer>
<Timer id="3">
<Name>Slow Timer (5m)</Name>
<Time initial="true">300000</Time>
<Interval>75</Interval>
<Content>
</Content>
</Timer>
</Timers>
<PortSettings name="HTTP Connection">
<BusAddress>
<DefaultValue>ByPassProxy</DefaultValue>
<Disabled>false</Disabled>
</BusAddress>
<IPport>
<DefaultValue>80</DefaultValue>
<Disabled>false</Disabled>
</IPport>
</PortSettings>
<VersionHistory>
</Protocol>
this is my QAction:
using System;
using Newtonsoft.Json.Linq;
using Skyline.DataMiner.Scripting;
public static class QAction
{
publicstaticvoid Run(SLProtocol protocol)
{
try
{
protocol.Log("QA3 started", LogType.DebugInfo, LogLevel.Level1);
// Obtener JSON del parámetro 3
var raw = protocol.GetParameter(Parameter.pingcheckresponse);
if (raw == null)
{
protocol.Log("QA3 - Parameter 3 (pingcheckresponse) is null.", LogType.DebugInfo, LogLevel.Level1);
protocol.SetParameter(Parameter.apihealth, 0);
return;
}
string json = raw.ToString();
protocol.Log($"QA3 - Raw JSON: '{json}'", LogType.DebugInfo, LogLevel.Level1);
if (string.IsNullOrWhiteSpace(json))
{
protocol.Log("QA3 - JSON is empty or whitespace.", LogType.DebugInfo, LogLevel.Level1);
protocol.SetParameter(Parameter.apihealth, 0);
return;
}
JObject jsonObject;
try
{
jsonObject = JObject.Parse(json);
}
catch (Exception exJson)
{
protocol.Log($"QA3 - JSON parsing failed: {exJson}", LogType.Error, LogLevel.NoLogging);
protocol.SetParameter(Parameter.apihealth, 0);
return;
}
// Extraer valor "ping"
if (jsonObject.TryGetValue("ping", out JToken pingToken))
{
string pingValue = pingToken.ToString();
protocol.Log($"QA3 - Extracted 'ping' value: '{pingValue}'", LogType.DebugInfo, LogLevel.Level1);
if (string.Equals(pingValue, "ok", StringComparison.OrdinalIgnoreCase))
{
protocol.SetParameter(Parameter.apihealth, 1);
protocol.Log("QA3 - Ping is OK. apihealth = 1", LogType.DebugInfo, LogLevel.Level1);
}
else
{
protocol.SetParameter(Parameter.apihealth, 0);
protocol.Log($"QA3 - Ping is NOT OK ('{pingValue}'). apihealth = 0", LogType.DebugInfo, LogLevel.Level1);
}
}
else
{
protocol.Log("QA3 - Property 'ping' not found in JSON.", LogType.DebugInfo, LogLevel.Level1);
protocol.SetParameter(Parameter.apihealth, 0);
}
}
catch (Exception ex)
{
protocol.Log($"QA3 - UNEXPECTED EXCEPTION: {ex}", LogType.Error, LogLevel.NoLogging);
protocol.SetParameter(Parameter.apihealth, 0);
}
}
}
I don't know what's wrong with my code
Thanks
Hi,
I solve import this Newtonsoft.Json.Linq in my solution.
is working !
thanks