ParthDesai

Convert String to Tag in iX Developer

4 posts in this topic

Hello,

I am trying to pass tag name as string and trying to write the tag value, but facing an error "Object reference not set to an instance of an object".Is there any dll which I have to add to my project files.Please Tell me what I am doing Wrong.Below is my code

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 System.IO;                    // for ApplicationPath
    using System.Reflection;            // for ApplicationPath
    using Neo.ApplicationFramework.Tools.OpcClient;


    public partial class Screen1
    {
      
        void Button1_Click(System.Object sender, System.EventArgs e)
        {
            var myTag = GetGlobalDataItem("value1");
            myTag.Value = 123; 
        }
        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;
        }

        private string ApplicationPath
        {            
            get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); }                
        }
    }
}

Share this post


Link to post
Share on other sites

With this I am able to get tag names but only of tags having read access rights. I want to get Tag names with readwrite access rights.

void Button1_Click(System.Object sender, System.EventArgs e)
        {

            foreach(GlobalDataItem gdi in Globals.Tags.DataItem){
                MessageBox.Show(gdi.Name.ToString());
            }
            }

Share this post


Link to post
Share on other sites

Which version of iX are you using (version number and SP)?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now