Page 2 of 2 FirstFirst 1 2
Showing results 11 to 13 of 13

Thread: Read with main project (scada) variable form CE project

  1. #11
    Join Date
    30.09.2010
    Posts
    14

    Default Re: Read with main project (scada) variable form CE project

    Hello,

    I have the following project setup:

    Project1(Scada) with Zenon
    Project2(CEpannel) with ZenonCE

    I have in VSTA from Project1 make a Container Event.
    This Container Event push up when a variable "test9" changed in project2.

    It's work great, only the Container Event push up two times by one change!

    When I have a numerical value box in project1 the Container Event push up three times!

    What must I changed that the Container Event push up one time?

    Thanks,

    DvG



    I have make the following code:

    //Make the Online Vars Container    
    public  void Macro_CreateOnlineVarsLine()
            {
                try
                {
                    String[] OnlineVarString = new String[0];
    
                    Line1OnlineVar = this.Parent.Parent.Projects().Item("LINE1").OnlineVariables().CreateOnlineVariables("Line1OnlineVars");
    
                    Line1OnlineVar.Add("test9");
    
                    Line1OnlineVar.Define();
    
                    Line1OnlineVar.VariableChange += new zenOn.VariableChangeEventHandler(Line1OnlineVars);
                    }
                catch { MessageBox.Show("onlinebox error line"); }
            }
    
    //Event handler   Online Vars Container    
    public void Line1OnlineVars(zenOn.IVariable obVar)
            {
                MessageBox.Show(obVar.Name);
            }
            
    
    //Delete Online Vars Container   
            public void Macro_DeleteOnlineVarsLine()
            {
                Line1OnlineVar.Undefine();
                this.Parent.Parent.Projects().Item("LINE1").OnlineVariables().DeleteOnlineVariables("Line1OnlineVars");
    
                MessageBox.Show("delete online container");
            }

  2. #12

    Default Re: Read with main project (scada) variable form CE project

    Where and when do you call " Macro_CreateOnlineVarsLine() " ?

    When you create an online container, and add a variable, nothing happens yet, until you call "define".

    On define, the variable will be advised, and from now on continually requested from the PLC. After the define, the driver will read the variable from the PLC. After the value is received from the PLC, the value is sent to the runtime.

    Also if no value is received, e.g. due to a communication issue between the driver and the PLC, a "value" with status "INVALID" is sent by the driver to the runtime.

    Every change in the variable value, status or timestamp, will be sent by the driver into the runtime. Every one of these changes will trigger the change event of the online container where this variable is used.

    In the change event, try getting the status and timestamp as well, to see which values / stati you are receiving.

    System.Diagnostics.Debug.WriteLine("Status: " + obVar.StatusString + " Value: " + (Convert.ToString(obVar.get_Value(0))) + " Timestamp: " + obVar.LastUpdateTime);

  3. #13
    Join Date
    24.04.2009
    Posts
    15

    Default Re: Read with main project (scada) variable form CE project

    I know this is a pretty "old" thread, but I still would like to add some additional information to the topic.

    Accessing data from another project by use of the zenon-API:
    Although it might be very easy to retrieve and store an object from a different project, I strongly advice not use any cross-project references. And ever since the variable assignments support the use of variables from different projects, there’s really no reason to use cross-project references. There’s always a more viable, less complex and safe solution.The reason why cross-project references should not be used is quite simple:
    Cross-References might (and in most cases will) become invalid when the project to which the object belongs is reloaded or unloaded. Since there's no easy way to detect/react to reload/unload actions from other projects, you are more likely to end up with invalid references, likely to result in a crash of the RT.

    Example:
    Our Workspace consists of 2 projects; Project1 which "contains" a subproject "Project2".
    A variable "int" from Project2 is stored in the "VSTA-Context" of Project1. This Cross-Project reference is used a macro in Project1. And the macro is executed every 10 minutes.
    Crash-Case:
    By use of the zenon-editor a part of project2 is modified (let's say a new variable was added to the project). The RT-Files for Project2 are created and transfered, now the RT is reloaded.
    Result: Due to the reload the variable "int" is on a total different location in the memory and the reference in Project1 is invalid. The next time the Macro in project1 is executed, the RT will crash with a high certainty!

    Mixed workspaces (CE and “normal”-Projects), how to handle this scenario:
    Although CE-Machines do not support VSTA/VBA, any “normal” machine (=client) loading Projects which are running on a CE-Machine (=Server) will in fact load and execute any VBA/VSTA-code present for the CE-projects. But wait: The VSTA/VBA editor cannot even be opened for projects which are configured to be a “CE”-Project? This is a bit confusing; but the “CE-Project” property is more or less only a “filter” for the editor, causing any features not available on CE-Machines to be “hidden”. How else would you know which features are actually “working” on the CE-Machine? You can however clear the “CE” checkbox from the project-settings; write and compile code for the subproject(s) and recheck the CE-Flag to re-enable the filter for further (non-coding) projecting purposes. In the end any CE-machine loading the projects (either as client or server) will “ignore” the VSTA/VBA-Code. And normal machines (running XP, 7, etc) loading the projects will be load and execute the VSTA-Assembly/VBA-Code.

Similar Threads

  1. VSTA read variable value's another project!
    By dvangenderen in forum VSTA
    Replies: 5
    Last Post: 1st December 2011, 10:04
  2. Replies: 4
    Last Post: 21st June 2010, 07:12
  3. how can be save the project that consist of the sub project?
    By michael_k in forum zenon Supervisor
    Replies: 1
    Last Post: 6th March 2010, 12:31
  4. s7 project import
    By gh_ounie in forum Drivers
    Replies: 1
    Last Post: 27th October 2008, 12:59

Posting Rules

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