FTOptix 1.7.0.804, VariableChange handler causing exception
02:53 04 Mar 2026

I am working with FTOptix 1.7.0.804, I am trying to create an VariableChange handler that, the C# source code:

//------------------------------------------------------------------------------
//File:    clsLiveIO.cs
//Author:  Simon Platten
//Purpose: Updates controls with live I/O data
//History:
// 2026/03/02 Created
//------------------------------------------------------------------------------
#region Using directives
using System.Threading;
using UAManagedCore;
using FTOptix.NetLogic;
using System;
using FTOptix.RAEtherNetIP;
#endregion

public class clsLiveIO : BaseNetLogic {
    //Alias 
    const string mcstrAliasModule = "aModule";
    //Point / Label prefix
    const string mcstrPrefixPt = "Pt";
    //Path to I/O point description
    const string mcstrPtMarker = "##";
    IUAVariable[] maryiuavIO = null;
    /// 
    /// Event handler for when variable value changes.
    /// 
    /// 
    /// 
    /// 
    private void OnChange(object sender, VariableChangeEventArgs e) {
        Log.Info("clsLiveIO.cs OnChange()...");
        try {
            Tag tTag = sender as Tag;
            if (tTag == null || tTag.Owner == null) {
                throw new Exception($"tTag is null or has no owner");
            }
            TagStructure tsTag = tTag.Owner as TagStructure;
            if (tsTag == null) {
                throw new Exception($"tsTag is null");
            }
            string strPt = tsTag.BrowseName.Substring(mcstrPrefixPt.Length);
            UAValue uaValue = tsTag.Value as UAValue;
            if (uaValue == null) {
                throw new Exception($"Cannot convert tsTag.Value to UAValue");
            }
            bool blnValue = Convert.ToBoolean(uaValue.Value);
            Log.Info($"clsLiveIO OnChange {tsTag.BrowseName} value {blnValue}");
        } catch (Exception ex) {
            Log.Error($"clsLiveIO.cs OnChange() exception: {ex.Message}!");                
        }
    }
    /// 
    /// Called when runtime logic is started.
    /// 
    public override void Start() {
        //Thread.Sleep(5000);
        Log.Info("clsLiveIO.cs Start()...");
        try {
            IUANode iuanModule = Owner.GetAlias(mcstrAliasModule);
            if (iuanModule == null) {
                throw new Exception($"Cannot find alias \"{mcstrAliasModule}\"");
            }
            maryiuavIO = new IUAVariable[iuanModule.Children.Count];
            uint uintRow = 0;
            do {
                string strPtData = $"Pt{uintRow:D2}/Data";
                maryiuavIO[uintRow] = iuanModule.Get(strPtData) as IUAVariable;
                if (maryiuavIO[uintRow] != null) {
                    Tag tIO = maryiuavIO[uintRow] as Tag;
                    Log.Info($"clsLiveIO.cs tIO.BrowseName: {tIO?.BrowseName}...");
                    bool blnValue = Convert.ToBoolean(maryiuavIO[uintRow].Value.Value);
                    Log.Info($"clsLiveIO.cs adding VariableChange handler for I/O Pt: {uintRow:D2}...");
                    tIO.VariableChange += OnChange;
                    OnChange(tIO, null);
                }
            } while (++uintRow < maryiuavIO.Length);
        } catch (Exception ex) {
            Log.Error($"clsLiveIO.cs Start() exception: {ex.Message}!");
        }
        Log.Info("clsLiveIO.cs Start() completed...");
    }
    public override void Stop() {
        // Insert code to be executed when the user-defined logic is stopped
    }
}

The above is a runtime class, the line

bool blnValue = Convert.ToBoolean(uaValue.Value);

Causes an exception:

2026-03-04 08:53:56.143;;0;Error;0;clsLiveIO.cs OnChange() exception: Unable to cast object of type 'UAManagedCore.Struct' to type 'System.IConvertible'.!

How can I convert data from a Digital Input module so I can process it?

c# rockwell ftoptix