Recipes in DAQFactory


Recommended Posts

A customer recently asked whether DAQFactory supports recipes. The answer is definitely yes. This is actually a somewhat common request, but the term "recipe" can have several meanings. In this case, a recipe is simply a group of setpoints. By calling up a recipe (by name) the device is loaded with all the setpoints required.

The user asked for 12 setpoints, but I'm going to stick with 2 to keep things simple. Attached is a sample that shows a simple recipe system. It allows selection and setting of a group of recipes. Loading and saving of recipe groups to disk (in a comma delimited ASCII file that could be edited in Notepad). It also shows how to Add new recipes from within DAQFactory. Deleting and editing would be done similar. I'll admit that the screens aren't the most fancy, but they demonstrate what they need to. Feel free to post replies to this blog if anyone has any questions, or if you'd like to see how to do the other type of recipe system.

The attached file requires DAQFactory 5.77 or newer.

I've split the functionality into several sequences:

StartUp: initializes the variables and preloads the recipes (not really required, or you could auto load from disk if you wanted). Recipes are stored as a two dimensional array of strings, where each row is a recipe and each column a setpoint with the first column holding the name of the recipe. I used strings to allow for the name, even though the setpoints are numbers. It doesn't really matter since unless you have a billion recipes the space / performance difference between storing numbers and strings is minimal.

ResetDisplay: this function updates the combo box with the selection of recipes. This is called at startup, when a new recipe is added, and when recipes are loaded from disk.

LoadRecipe: this function is called when the user hits the Set button and loads the currently selected recipe into the device by setting the two setpoint channels.

AddRecipe: takes the settings in the edit boxes and adds a recipe with those settings. Called when the user clicks the Add button

Load/SaveRecipes: loads or saves all the recipes to disk. The recipes are stored as a simple comma delimited file. DAQFactory's ReadDelim() and WriteDelim() functions make the real easy.

recipesample.ctl

Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...
  • 2 months later...

I have been using a variation of this code with great success until I upgraded DF recently. Now when I try to add a recipe, I get the following error:

Append() in variables not supported in this version of DAQFactory: when it tries to execute this line - "recipes.Append(newrecipe)"

I can't seem to find where this function has changed or been deprecated in any documentation.

How is appending handled now with regards to this function when a variable is involved.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.