Help!!!
this is an example of a tag list that I have created seen in the Design view:
Tag Controllers
Name DataType AccessRight DataType EMCP1
SPNFMI_0 UNIT32 Read UNIT32 41511
....
....
SPNFMI_39 UNIT32 Read UNIT32 41890
1. I have to go through every tag (EMCP1 value) to get some info
2. Insted of manually changing the tag name, can it be done using an array,
e.g
for(int x=0; x < 40; x++)
{
value [x] = (Globals.Tags.SPNFMI_[x].Value>>5) & (0x7FFFF);
}
So when x=0, it will get the info from SPNFMI_0
when x=1, it will get the info from SPNFMI_1 and so on.
Any hints? is it possible?
Arrays 2
Re: Arrays 2
I got this tip for concatinating strings to read tag values from the support guys in Sweden.
Just include the method GetGlobalDataItem in your code and these using statements.
using Neo.ApplicationFramework.Tools.OpcClient;
using System.Reflection
int number = 1;
decimal val = GetGlobalDataItem("Tag" + number.ToString()).Value.Decimal;
private GlobalDataItem GetGlobalDataItem(string propertyName)
{
PropertyInfo tagProperty = typeof(Neo.ApplicationFramework.Generated.Tags).GetProperty(propertyName);
if(tagProperty == null)
return null;
else
return tagProperty.GetValue(Globals.Tags, null) as GlobalDataItem;
}
Just include the method GetGlobalDataItem in your code and these using statements.
using Neo.ApplicationFramework.Tools.OpcClient;
using System.Reflection
int number = 1;
decimal val = GetGlobalDataItem("Tag" + number.ToString()).Value.Decimal;
private GlobalDataItem GetGlobalDataItem(string propertyName)
{
PropertyInfo tagProperty = typeof(Neo.ApplicationFramework.Generated.Tags).GetProperty(propertyName);
if(tagProperty == null)
return null;
else
return tagProperty.GetValue(Globals.Tags, null) as GlobalDataItem;
}
Re: Arrays 2
Does it work for you?
I've been trying with no success; found another link with different approach:
http://ixtalk.beijerelectronics.com/vie ... tring#p126
I've been trying with no success; found another link with different approach:
http://ixtalk.beijerelectronics.com/vie ... tring#p126
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Arrays 2
See below for a working example on Screen1 with a button.
Code: Select all
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
using Neo.ApplicationFramework.Tools.OpcClient;
using System.Reflection;
public partial class Screen1
{
void Button1_Click(System.Object sender, System.EventArgs e)
{
//Number at end of tag.
//Tag name should look like Tag1, Tag2, TagX
int number = 2;
decimal val = GetGlobalDataItem("Tag" + number.ToString()).Value.Decimal;
this.Text1.Text = val.ToString();
}
private GlobalDataItem GetGlobalDataItem(string propertyName)
{
PropertyInfo tagProperty = typeof(Neo.ApplicationFramework.Generated.Tags).GetProperty(propertyName);
if(tagProperty == null)
return null;
else
return tagProperty.GetValue(Globals.Tags, null) as GlobalDataItem;
}
}
}
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer