Showing results 1 to 2 of 2

Thread: Not DDE active by starting up

  1. #1
    Join Date
    07.07.2010
    Posts
    9

    Default Not DDE active by starting up

    When I startup my zenon application and I read an variable, I get my own made error message "_GetZenOnVar - ValveOpen is not DDE Active" because I check if the variable is active. When I do an reload I didn't get this message.

    Also I check the variable in the editor on DDE active and the setting was enabled.

    I use the following code by the startup:

           private void ThisProject_Startup(object sender, EventArgs e)
            {
                this.Active += new zenOn.ActiveEventHandler(ThisProject_Active);
                this.Inactive += new zenOn.InactiveEventHandler(ThisProject_Inactive);
            }
    
            void ThisProject_Active()
            {
                ThisProject_CreatEventHandlers();
            }
    
            void ThisProject_CreatEventHandlers()
            {
                try
                {
                        object oValveOpen = ZenOnClass.GetZenOnVar("Valve_Open");
                        bool bValveOpen = Convert.ToBoolean(oValveOpen);  
    
                        if (  bValveOpen )
                        {
                              MessageBox.Show("Test");
                        } 
                }
                catch
                {
                    this.Cel().WriteCelString("ThisProject_CreatEventHandlers FAILED!!!");
                }
            }
    
    private static Object _GetZenOnVar(string VarNaam)
            {
                object ReturnVal = new object();
                object oActive;
                bool bActive;
    
                    if (ZenOnVariabelen.Item(VarNaam) != null)
                    {
                        try
                        {
                            oActive = ZenOnVariabelen.Item(VarNaam).get_DynProperties("DDEActive");
                            if (oActive != null)
                            {
                                bActive = Convert.ToBoolean(oActive);
                                if (bActive)
                                {
                                    if (ZenOnVariabelen.Item(VarNaam).IsOnline())
                                    {
                                        ReturnVal = (ZenOnVariabelen.Item(VarNaam).get_Value(VarNaam));
                                        return ReturnVal;
                                    }
                                    else
                                    {
                                        // Indien de variabele niet online is false returnen.
                                        ZenOnClass.WriteZenOnCel("_GetZenOnVar - " + VarNaam + " is niet online", 1);
                                        return null;
                                    }
                                }
                                else
                                {
                                    // Indien de variabele niet bestaat false returnen.
                                    ZenOnClass.WriteZenOnCel("_GetZenOnVar - " + VarNaam + " is not DDE Active", 1);
                                    return null;
                                }
                            }
                        }
                        catch
                        {
                            // Indien de variabele niet bestaat false returnen.
                            return null;
                        }
                    }
                    else
                    {
                        // Indien de variabele niet bestaat false returnen.
                        return null;
    
                    }
                
    
                return null;
            }

    Can you help me to solve this problem. So that I can use this variable when I startup my application and also by an reload.

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    881

    Default Re: Not DDE active by starting up

    check out the help documenation (Progamming Interfaces -> Object model) about the method .IsOnline():

    This method checks, if the current variable is advised and has a valid value.
    So when starting the runtime and thus also the drivers where the variables are based on they need some time to get all the requested data. Thsu the Project_Active() event is not the right place.
    Instead use a Online Container and in the Change-Event of the Online Container check when the variable has the desired value.

    Regards,
    Herbert

Similar Threads

  1. Zenon ED and RT starting in wrong resolution [Windows 7]
    By kicker in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 2
    Last Post: 18th October 2010, 07:13
  2. VBA Engineering and Active X
    By shikra in forum VBA
    Replies: 1
    Last Post: 9th March 2010, 10:38
  3. ZenOn RT starting before TwinCAT on CE
    By davidgrice in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 1
    Last Post: 29th September 2009, 23:29
  4. Display active clients
    By ionvalesareanu in forum zenon Network
    Replies: 7
    Last Post: 6th May 2009, 08:39
  5. error message when starting the Runtime
    By martinw in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 0
    Last Post: 20th August 2007, 07:06

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •