ChannelName.DeviceNumber Saving the Device Number when in Runtime Mode

Recommended Posts


When changing a Channels Device Number in Run Time mode using : -

e.g. MyChannel.DeviceNumber = 147

How do you get DF to save this Device Number change when in Runtime Mode?

It saves OK if I switch to Run Time Mode whilst in Development Mode (as it prompts to save when exiting). But if I start the app in Run Time mode and change the Device Number it doesn't save this change in the Channel parameters.


Link to comment
Share on other sites

This works, but it is usually better to create a configuration file of your own that holds this information and then updates the channel table with that data on startup.  Doing SaveDocument() in an automated way can be risky.  If you have a power failure during the save your entire ctl file will get corrupted.  More importantly, in general, for security reasons, it is recommended that your deployed .ctl documents be placed in a read-only folder so they could not be replaced with a modified version by someone who has hacked into the system.  DAQFactory scripting has a lot of power and could do a lot of damage in the wrong hands.


Link to comment
Share on other sites

Hi Azeotech,

Thank you for that. I hadn't thought of the ctl file corruption. OK I will look at creating a config. file that loads on startup. I have also tried the registry option which is working ok. 

I will try the read only folder advice for security. Wouldn't this stop writing changes to the ctl from a config file on start up?


Link to comment
Share on other sites

No. Only if you try and save the changes to disk.  If you load the prebuilt ctl doc and then modify it but don't save, then it is no issue.  DAQFactory will run with the changes, but of course when you restart you will have to reapply the changes from your config since the ctl never changed.  

Note of course, that you should also validate your config file to ensure against corruption since it will be read/write.  But this is much easier to do than the ctl doc itself.  Just make sure you don't make any assumptions about the data you are reading in.  And don't use execute() or evaluate() on the data in the file directly.  I've seen folks who will simply read each line of a config file they created and then do execute() on it.  A hacker could just put some bad script in the config file and it would get executed within DAQFactory.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.