osbox68 Posted December 11, 2010 Share Posted December 11, 2010 Estimates. I'm making an application with DF and I need to enable or disable a channel group, as I can do this, I was checking the post and saw something MyChannel.timing = 0 but did not understand much. Atte. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 11, 2010 Share Posted December 11, 2010 what do you mean by enable/disable? Just stop polling? Link to comment Share on other sites More sharing options...
osbox68 Posted December 14, 2010 Author Share Posted December 14, 2010 Thanks for your reply, I have an application with 5 groups and each group with 50 channels or so, I need to stop the polling in a group, I can do this. Atte. Link to comment Share on other sites More sharing options...
AzeoTech Posted December 14, 2010 Share Posted December 14, 2010 OK, then to stop one channel you'd do: mychannel.timing = 0 channel.restart() To stop several, you'd do: chan1.timing = 0 chan2.timing = 0 ... channel.restart() To restart, just repeat with a non-zero value. I recommend doing this in a loop. Probably the best way is to list the channels in each group in an array of strings, then loop through it. Something like this: function startStop(string group, timing) private string group1 = {"chan1","chan2"} private string group2 = {"chan10","chan11"} private rows = evaluate("numrows(" + group + ")") for (private i = 0, i < rows, i++) execute(evaluate(group + "[i]") + ".timing = " + timing) endfor channel.restart() Then pass in the name of the group and 0 or the desired timing. For example: startStop("group2", 0) would stop the channels in group2, and: startStop("group1", 1) would set the timing of the channels in group1 to 1 second Note: the script was off the cuff, so there might be a typo or two. It uses execute / evaluate heavily to make it more flexible. Link to comment Share on other sites More sharing options...
osbox68 Posted December 15, 2010 Author Share Posted December 15, 2010 Thanks for your answer. this is very clear Link to comment Share on other sites More sharing options...
Luzifull Posted December 25, 2010 Share Posted December 25, 2010 yess OK :P It was really good.! Link to comment Share on other sites More sharing options...
Olavur Posted March 2, 2011 Share Posted March 2, 2011 This code to set timing of a group is just what i need in my project. - But i cant get i to work. I have put your code in a sequence, and get an "One of the parameters was empy: ..Line5 this line private rows = evaluate("numrows(" + group + ")") Hope you can tell me what i am doing wrong. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 2, 2011 Share Posted March 2, 2011 You probably didn't pass anything in to the function so group does not exist. There is a difference between an empty array (like a channel without any values) which will return 0 from numrows(), and trying to do numrows() with a variable that just plain doesn't exist. Link to comment Share on other sites More sharing options...
Olavur Posted March 4, 2011 Share Posted March 4, 2011 I am just not very good at this. I have tried again, and now i get Uncaught error in seqence at the same line. I realy dont know what i am doing wrong, Hope you can explane how to get this to work. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 4, 2011 Share Posted March 4, 2011 Please post your sequence as it exists now (cut and paste) Link to comment Share on other sites More sharing options...
Olavur Posted March 5, 2011 Share Posted March 5, 2011 Here is the sequence function startStop(string group, timing) private string group1 = Channel.ListAll("registerCANadr2") private string group2 = Channel.ListAll("bitCANadr2") private string group3 = Channel.ListAll("registerCANadr3") private string group4 = Channel.ListAll("bitCANadr3") while(1) private rows = evaluate("numrows(" + group + ")") for (private i = 0, i < rows, i++) execute(evaluate(group + "[i]") + ".timing = " + timing) endfor channel.restart() catch() ? strLastError endcatch delay(0.2) endwhile In the decription you say Then pass in the name of the group - in the sequence? Link to comment Share on other sites More sharing options...
AzeoTech Posted March 7, 2011 Share Posted March 7, 2011 Yes, you need to call startStop like this: startStop("group1", 1.5) Link to comment Share on other sites More sharing options...
Olavur Posted March 8, 2011 Share Posted March 8, 2011 I am still not getting it right I have tried this simple code and it only sets the timing of the first channel to 1.1 private string group1 = {"O2_1_set_L_CANadr3","O2_2_set_L_CANadr2"} execute(evaluate("group1") + ".timing = " + 1.1) channel.restart() Hope you can help me out. Link to comment Share on other sites More sharing options...
AzeoTech Posted March 8, 2011 Share Posted March 8, 2011 you have to still loop over the channels: private string group1 = {"O2_1_set_L_CANadr3","O2_2_set_L_CANadr2"} for (private i = 0, i < numrows(group1), i++) execute(group1[i] + ".timing = 1.1") endfor channel.restart() Link to comment Share on other sites More sharing options...
Olavur Posted March 9, 2011 Share Posted March 9, 2011 Thanks for good support There was at typo in the seqence name, but now it works just fine with your original code Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.