Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
where the GetGlobalDataItem was a function posted to this forum a long time ago to get a tag from a string.
Except I can't get that to work. I tried eventTag[k].value, eventTag.values[k], evenTag.value[k].Ushort, and I also tried to modify the GetGlobalDataItem function to return the Kth item of a tag.
I need to parse individual registers within that tag array. Any ideas on how to do this? Thank you!
arrEvent[k]=eventTag[k].value;
//'Neo.ApplicationFramework.Interfaces.IGlobalDataSubItem' does not contain a definition for 'value' and no extension method 'value' accepting a first argument of type....
GlobalDataItem eventTag = GetGlobalDataItem("arrTags_" + (j).ToString());
for (int k=0;k<14;k++) {
arrEvent[k]=eventTag.Values[k];
}
if (j==0) {
Globals.Tags.Event2.SetAnalog(arrEvent[0]);
Globals.Tags.Event3.SetAnalog(arrEvent[1]);
}
//event 2 and 3 always show a value of 0. (tested with a label on a screen), but if I map an additional tag to the first register that the arrTags_0 array also maps to, that additional tag does not show 0 (so I know the arrTags_0[0] is not zero).
for (int j=0;j<40;j++) {
ushort[] arrEvent=new ushort[14];
GlobalDataItem eventTag = GetGlobalDataItem("arr_EventRegisterGroup_" + (j).ToString());
for (int k=0;k<14;k++) {
arrEvent[k]=eventTag[k].Values;
}
//'Neo.ApplicationFramework.Interfaces.IGlobalDataSubItem' does not contain a definition for 'Values' and no extension method 'Values accepting a first argument of type 'Neo.ApplicationFramework.Interfaces.IGlobalDataSubItem' could be found (are you missing a using directive or an assembly reference?)
arrEvent[k]=eventTag[k].Value
compiles. I will see how it behaves
for (int j=0;j<40;j++) {
ushort[] arrEvent=new ushort[14];
GlobalDataItem eventTag = GetGlobalDataItem("arr_EventRegisterGroup_" + j.ToString());
for (int k=0;k<14;k++) {
arrEvent[k]=eventTag[k].Value;
}
if (j==0) { // test the array values by displaying them
Globals.Tags.Event2.SetAnalog(arrEvent[0]);
Globals.Tags.Event3.SetAnalog(arrEvent[1]);
Globals.Tags.Event4.SetAnalog(arrEvent[2]);
Globals.Tags.Event5.SetAnalog(arrEvent[3]);
Globals.Tags.Event6.SetAnalog(arrEvent[4]);
Globals.Tags.Event7.SetAnalog(arrEvent[5]);
Globals.Tags.Event8.SetAnalog(arrEvent[6]);
Globals.Tags.Event9.SetAnalog(arrEvent[7]);
Globals.Tags.Event10.SetAnalog(arrEvent[8]);
Globals.Tags.Event11.SetAnalog(arrEvent[9]);
Globals.Tags.Event12.SetAnalog(arrEvent[10]);
Globals.Tags.Event13.SetAnalog(arrEvent[11]);
Globals.Tags.Event14.SetAnalog(arrEvent[12]);
Globals.Tags.Event15.SetAnalog(arrEvent[13]);
Globals.Tags.testTag.IncrementAnalog(1);
}
}
The label showing Event1 (@ 40412) is a nonzero value (always).
However, all labels showing Event2...Event15 are always zero even when the refresh is clicked. The testTag label is incremented, so I know the event occurs. I would expect that at least Event14 should be non zero as it should reflect the same value as Event1.
Attachments
tagName_arrEventRegGrp.png (3.13 KiB) Viewed 16504 times
I tried what you suggested, Mark, except that I used Event14. The new analog numeric on the screen also displays Event14 as zero at all times. My Event0 and Event1 tags now point to the first and second addresses of the arr_EventRegisterGroup_0 array also, and they are both non-zero.
//remove the local array variable AND change to uint instead of ushort
uint arrEvent;
GlobalDataItem eventTag = GetGlobalDataItem("arr_EventRegisterGroup_0");
arrEvent=eventTag[0].Value;
Globals.Tags.Event14.SetAnalog(arrEvent);
//remove the local array variable AND change to uint instead of ushort
//ALSO, try .Values[0] instead of [0].Value
uint arrEvent;
GlobalDataItem eventTag = GetGlobalDataItem("arr_EventRegisterGroup_0");
arrEvent=eventTag.Values[0];
Globals.Tags.Event14.SetAnalog(arrEvent);
//use ONLY the GlobalDataItem and its 0th indexed value. no local variable at all
GlobalDataItem eventTag = GetGlobalDataItem("arr_EventRegisterGroup_0");
Globals.Tags.Event14.SetAnalog(eventTag[0].Value);