Showing results 1 to 2 of 2

Thread: Getting and Setting Values in Standard Recipes

  1. #1
    Join Date
    04.09.2019
    Posts
    2

    Beitrag Getting and Setting Values in Standard Recipes

    What would be the best way to get/set values in the Standard Recipes?

    I have a Standard Recipe Collection which includes pipe "Size" and "Schedule" entries and if these match my target values, I want to set a "Selected" value as true. Please see the draft below.
    I am using the GetDynamicProperties method, but I am not sure that is the right way to do it.

    IStandardRecipeCollection standardRecipes;

    // The Standard Recipe Collection is extracted from the context.

    foreach (IStandardRecipe recipe in standardRecipes)
    {
    bool match = false;

    try
    {
    Int32 sched = Int32.Parse(recipe.GetDynamicProperty("Pipe_Schedule").ToString());
    Double diameter = Double.Parse(recipe.GetDynamicProperty("Size_Of_Pipe").ToString());

    if (Int32.Parse(recipeFilter.mSchedule) == sched &&
    Double.Parse(recipeFilter.mDiameter) == diameter)
    {
    match = true;
    }

    recipe.SetDynamicProperty("Selected", match);
    }
    catch ()
    }

    Thanks
    Last edited by EhsanMehr : 11th September 2019 at 04:18

  2. #2
    Join Date
    04.09.2019
    Posts
    2

    Default Re: Getting and Setting Values in Standard Recipes

    using Scada.AddIn.Contracts.Recipe;
    using System;
    using System.Collections.Generic;
    using System.Text;
    namespace NovarcStratusInterface
    {
        public class ZenonRecipes : INvRecipes
        {
            IStandardRecipeCollection standardRecipes;
            public ZenonRecipes(IStandardRecipeCollection standardRecipeCollection)
            {
                standardRecipes = standardRecipeCollection;
            }
            // match function should match any and all recipes in the system and 
            // modify zenon vaiables as needed
            public void Match(RecipeFilter recipeFilter)
            {
                // go through all recipes and check if match
                foreach (IStandardRecipe recipe in standardRecipes)
                {
                    bool match = false;
                    try
                    {
                        Int32 sched = Int32.Parse(recipe.GetDynamicProperty("Pipe_Schedule").ToString());
                        Double diameter = Double.Parse(recipe.GetDynamicProperty("Size_Of_Pipe").ToString());
                        if (Int32.Parse(recipeFilter.mSchedule) == sched &&
                            Double.Parse(recipeFilter.mDiameter) == diameter)
                        {
                            match = true;
                        }
                        recipe.SetDynamicProperty("Selected", match);
                    }
                    catch (ArgumentNullException)
                    {
                        // put out a log
                        // set match  to false
                    }
                    catch (FormatException)
                    {
                        // put out a log
                        // set match to false
                    }
                    catch (OverflowException)
                    {
                        // put out a log
                        // set match to false
                    }
                }
            }
        }
    }

Similar Threads

  1. Replies: 2
    Last Post: 1st May 2019, 11:49
  2. recipes password
    By aleb2 in forum zenon Supervisor
    Replies: 1
    Last Post: 19th December 2016, 15:16
  3. Replies: 0
    Last Post: 26th January 2015, 12:36
  4. Setting transient values to 0
    By knubla in forum zenon Energy Edition
    Replies: 8
    Last Post: 26th May 2014, 10:04
  5. copy recipes
    By hicom in forum zenon Supervisor
    Replies: 9
    Last Post: 11th May 2009, 05:28

Posting Rules

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