Showing results 1 to 7 of 7

Thread: C# program executed cyclically - Zenon 8.00

  1. #1
    Join Date
    11.02.2019
    Posts
    9

    Default C# program executed cyclically - Zenon 8.00

    Hello,

    I'm developing a C# program to read data from .txt files and write this data in zenon variables. This application intends to be executed cyclically by zenon (i.e. each 2 hours).

    I would like to know what is the best way to implement it, if using the VSTA or the SharpDevelop. Also, what is the zenon mechanism to execute the C# programs in background?


    Regards,

    Carlos

  2. #2
    Join Date
    28.02.2013
    Posts
    118

    Default Re: C# program executed cyclically - Zenon 8.00

    Dear Carlos,

    did you have a look on or file driver? Maybe he can do what you need without programming.
    File operations could also be done using zenon Logic, our integrated soft PLC.

    If you prefer programming I'd suggest to take a look on our AddIn framework.
    For your task I would go for a runtime wizard that performs the requested task when called.

    The recurring calling of your wizard could then be done by zenon time control standard functions.

    Regards,
    Felix

  3. #3
    Join Date
    11.02.2019
    Posts
    9

    Default Re: C# program executed cyclically - Zenon 8.00

    Quote Originally Posted by felixst View Post
    Dear Carlos,

    did you have a look on or file driver? Maybe he can do what you need without programming.
    File operations could also be done using zenon Logic, our integrated soft PLC.

    If you prefer programming I'd suggest to take a look on our AddIn framework.
    For your task I would go for a runtime wizard that performs the requested task when called.

    The recurring calling of your wizard could then be done by zenon time control standard functions.

    Regards,
    Felix

    Dear Felix,

    Thanks for your reply and suggestions. In the meantime I've already created the C# program that I need, I cannot use the file driver because the files I will read have a specific format not compatible with the Zenon file driver.
    Right now I have another issues which I will describe below. I have cyclically all the values read from the files and at the same time I've created Zenon internal variables to store the data read from the file. The issues are:
    1. I need to store the value in each internal variable, the values read from the files have time stamp which I need also to store:
      • If I use the set_Value(0,"value") function it will set the actual value of the variable but how can I make correspond the time stamp value that I have also read from the file for this specific value? Is there any function on the internal variables that I can use to set the time stamp?
      • After setting the values on the internal variables what function or mechanism should I use to store that value of the variables on the Zenon database? I ask it because my application will do this cyclically, I'll read data from the files and right after I should store this data on the Zenon database for historical and report functions.
    2. Create function to execute the VSTA macro
      • I'm trying to create a new function to execute the VSTA macro but when I try to create the function the macro selection window is empty and I do not found the macros created in the C# program.
      • In other hand the macros that I've created  in the C# program are visible and I can execute it in the VSTA submenu of the project manager.
      • Do you have any suggestion to make my VSTA macros listed in the macro selection window? 

     
    Best regards,
    Carlos


  4. #4
    Join Date
    28.02.2013
    Posts
    118

    Default Re: C# program executed cyclically - Zenon 8.00

    Dear Carlos,

    1. Please take a look at the function SetValueWith Status. Additionally you need to enable status processing for internal variables in the general project settings (from version 8.0) on. With that also the internal variables will be considered for the tag count of the runtime.
    For recording our standard mechanisms can be used. Please take a look on the event triggered archiving and also set the trigger variable from within your macro?

    2. Have you created a macro for the runtime or the editor? Does your name start with "Macro_"?

    Best Regards,
    Felix

  5. #5
    Join Date
    11.02.2019
    Posts
    9

    Default Re: C# program executed cyclically - Zenon 8.00

    Dear Felix,

    About your comment on point 2., I have created a macro (starting with "Macro_") using Tools-> Open VSTA Editor with WorkspaceAddin, I don't know exactly if this is the way to make it for the runtime or for the editor but the fact is that up to now I just can run the macro in the editor because I still not be able to run it with a function. 
    What shoudl I chose, runtime or editor mode? What is the difference between these two modes?

    Can you also explain me how to proceed with the suggestion you sent yesterday "For recording our standard mechanisms can be used. Please take a look on
    the event triggered archiving and also set the trigger variable from
    within your macro?
    " ?

    Regards,
    Carlos


  6. #6
    Join Date
    28.02.2013
    Posts
    118

    Default Re: C# program executed cyclically - Zenon 8.00

    Dear Carlos,

    it seems that you have created a macro for the editor.
    To create a macro that is included in the runtime files and executable there, you need to create it in the project itself. Editor and Runtime macros are two different things.
    Editor macros are intended to run in the context of the zenon editor, do i.e. automated engineering, etc.
    Runtime macros are intended to run in the context of the zenon runtime doing things where no zenon standard function exists for.

    Please expand the node "programming interface" in the project tree an via right click on "VSTA" you can open the VSTA editor with the ProjectAddIn.

    One hint: There is an online training available for VBA/VSTA which is free for members of our partner community. If you are interested here, please contact your sales representative.

    About the archiving: Please take a look on the historian module (and it's documntation): Here you can create different types of archives (cyclic, on-change, event triggered) that record the values of variables that are linked to that archive.
    If you chose the event-triggered mode, every time a trigger variable goes true, a set of all linked variables will be recorded. So the only thing you need to do in your code is to set and reset this trigger variable on your needs and configure the archive the way you need it.

    Regards,
    Felix

  7. #7
    Join Date
    11.02.2019
    Posts
    9

    Default Re: C# program executed cyclically - Zenon 8.00

    Hello Felix,

    Thanks for your guidance, I've already created a new macro for runtime and it is working fine now with the functions module. 

    In case of need I'll make other posts.

    Before finalize I would like to ask you another thing, the machine where I'll install Zenon have Windows 10 Pro but I'm concerned about the eventual negative impact of the Windows update on the Zenon application. What is your advise in terms of operating system to be used if we do not want updates to be runing?

    Regards,

    Carlos

Similar Threads

  1. download or upload a program on Zenon HMI
    By ykrdd in forum zenon Supervisor
    Replies: 1
    Last Post: 3rd July 2017, 13:36
  2. Replies: 1
    Last Post: 3rd March 2015, 15:30
  3. Zenon Logic sample program for EV3 needed
    By dimi in forum straton / zenon Logic
    Replies: 1
    Last Post: 10th July 2014, 10:23
  4. straton does not run cyclically
    By wolfgangm in forum straton / zenon Logic
    Replies: 0
    Last Post: 7th May 2008, 12:15
  5. The event OnElementCreated is not executed
    By markclemens in forum VBA
    Replies: 0
    Last Post: 21st February 2008, 14:31

Posting Rules

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