Hi all!
I have a question on script variables. In the documentation it is explained that:
"Prior to running a script, operators will first have to link the dummies and parameters to actual elements and values in the DMS. Therefore, it is best to give the variables a meaningful name the operators will be able to work with."
Is there any way that this operator interaction is not necessary? The background is that we would like to execute a script via a task in the scheduler, which has a changing value from a memory file for the parameter.
Best regards and thank you in advance for your inspiring answers!
Daniel
Hi José,
Hi Miguel,
thanks for your help, I think to be on the rigth path for a solution.
But now I have the problem to update the variable in my view with the memory file value.
And the second point: I still have to add a memory file dummy(?) on the automation script, to use the "GetMemory" method. Is there any way to call the memory file directly from the C# script? If I don't create a dummy, the memory file is not found.
using System;
using System.IO;
using Skyline.DataMiner.Net;
using Skyline.DataMiner.Net.Exceptions;
using Skyline.DataMiner.Net.AutomationUI;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Net.Messages;
public class Script
{
public void Run(Engine engine)
{
engine.Log("Before Memory Load");
ScriptMemory memory = engine.GetMemory("Annotations");
if (memory == null)
{
engine.Log("Memory file 'Annotations' not found.");
return;
}
else
{
engine.Log("Memory file 'Annotations' was loaded successfully.");
}
engine.Log("After Memory Load");
/*
// Speichern von Werten mit aufsteigenden Adressen als Schlüssel
for (int address = 0; address < 1; address++)
{
memory.Set(address, $"Wert an Adresse {address}");
}*/
// Auslesen und Anzeigen der Werte
for (int address = 0; address < 1; address++)
{
try
{
engine.Log("Text vor Get Value on address: ");
object rawValue = memory.Get(address);
if (rawValue == null)
{
engine.Log($"Address {address}: No value found");
}
else
{
string value = rawValue as string;
if (value != null)
{
engine.Log($"Address {address}: {value}");
engine.Log("Text nach Get Value on address: ");
}
else
{
engine.Log($"Adress {address}: Value is not a string (Typ: {rawValue.GetType().Name})");
}
}
}
catch (Exception ex)
{
engine.Log($"Error accessing address {address}: {ex.Message}");
}
}
// Aktualisieren der Visual Overview
UpdateVisualOverview(engine, memory);
}
private void UpdateVisualOverview(Engine engine, ScriptMemory memory)
{
// Annahme: Es gibt einen Parameter in der Visual Overview für jede Adresse
for (int address = 0; address < 1; address++)
{
engine.Log("Befor Visual Overview");
string value = memory.Get(address) as string;
engine.AddScriptOutput(UIVariables.VisualOverview.CreateKey("MyOutput1"), value);
engine.Log("After Visual Overview");
}
}
}
Thank you for the help for a technician who programs 😉
Best regards, Daniel