43327members
217741posts

.NET API for variable float array

Highlighted
Ensign
Ensign

.NET API for variable float array

What .NET API functions can I call to set values and length for the variable float array?

 

The ClearSCADA code looks like this. TimeSlices is a Variable Float Array.

 

IF samplecount > 0 THEN

    TimeSlices.Value[TimeSlice] := Total/samplecount;

    TimeSlices.Length := INT_TO_DINT(TimeSlices + 1);

END_IF

 

I need to achieve the same results in an .NET application but am not sure what API functions to use.

 

Thanks a lot.

Tags (1)
2 REPLIES 2
Highlighted
Ensign
Ensign

Re: .NET API for variable float array

OK. I figured it out myself. To set value, I need to call SetElement()

 

private const string FUNC_SET_ELEMENT = "SetElement";

 

DBObject timeSliceObj = connection.GetObject(timeSliceFullPath);

 

//Initialise time slices.
object[] args = new object[2];

for(int i = 0; i < timeSliceSize; i++)
{
    args[0] = i;
    args[1] = 0.0;

    timeSliceObj.InvokeMethod(FUNC_SET_ELEMENT, args);
}

Tags (1)
Highlighted
Commander

Re: .NET API for variable float array

Yeah,

In regards to these items for the future, the schema is your friend 🙂

 

If you're looking to call a method on a particular Type of object in the database, you're best to find the methods that it has, starting in the schema at the leaf, and working your way back up the object hierarchy until you find the method that you were looking for.

 

Then InvokeMethod is the answer, passing in the arguments required, and handling the returned data.


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Tags (1)