C# Windows form app live updates

Igb_kingsley 0 Reputation points
2023-02-24T14:44:17.9433333+00:00

Hi,

I am currently trying to create a GUI for a PLC project using C#, I have been able to set up the link via ADS and more.

The only problem i am having is displaying live changes on the winform.

Ideally i would like to display some variable changes without having to click a button, like the code below.

I have been looking online for sometime but couldn't find a solution that actually worked.

Any insight or recommendations would be really helpful.

Thanks

using TwinCAT.Ads;

namespace HMI_PLC1
{
    public partial class Form1 : Form
    {
        TcAdsClient CX_611115 = new TcAdsClient();

        public ITcAdsSymbol SET_F_Evac = null;
        public bool SET_F_Evac_state { get; private set; }
        
        public Form1()
        {
            InitializeComponent();
        }
        public void Form1_Load(object sender, EventArgs e)
        {
            CX_611115.Connect("ams netid", 851);
        }
        
        private void Conn_Btn_Click(object sender, EventArgs e)
        {
            SET_F_Evac = CX_611115.ReadSymbolInfo("VAR_Serial_Comms.Set_Fire_Evacuation");
            SET_F_Evac_state = Convert.ToBoolean(CX_611115.ReadSymbol(SET_F_Evac));
            if (SET_F_Evac_state == true)
            {
                // do something
            }
            else
            {
                // do something else
            }
        }
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,827 questions
{count} votes