AzeoTech Posted June 15, 2008 Share Posted June 15, 2008 One of the big advantages of DAQFactory over other SCADA solutions is the ability to make changes without stopping. However, there are still plenty of cases where you will be doing development offsite. In these situations you probably don't have hardware available and probably want any script that accesses the hardware not to execute, or to at least generate simulation data. The problem is that you don't want to forget to reenable the hardware code before you ship. Fortunately there is an easy way to avoid this problem: Because numeric registry variables default to 0, you can use one as a flag to determine if your code is running on your office machine, or its running on the customer / plant floor computer. In the beginning of your auto-start sequence put this: global debug = registry.debug and then, anywhere you have script that accesses hardware, or really anything else you don't want to have happen at your office, like accessing a database, firing off alarm emails, etc, just wrap the script in an if() statement. For example: if (debug) ? "Email alert sent" else SendEmail() endif In this case, if debug is set, then a message is displayed in the command alert window, but the email routine is not called. If debug is not set, then the normal processing occurs. Next, on your office machine you simply have to set registry.debug to 1. This can be done at the command/alert window prompt simply as: registry.debug = 1 It only has to be done once, because the registry will hold that value. Then, next time you load the document, debug will become 1 and your test code will execute. When you send the file to your customer or load it on the plant floor machine, registry.debug won't be set, so it will default to 0 and all your normal code will execute. A few misc points: 1) I did global debug = registry.debug, but really you can access registry.debug anywhere in your code. I copy it to a global because reading a global is much faster than going to the registry everytime. 2) You may want to use registry.debug_projectX or something similar, especially if you work on multiple documents. That way each project gets its own registry variable. You can still copy it to a global called debug since the global is only visible to the one document. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.