Chrisn Posted June 12, 2013 Share Posted June 12, 2013 Hello. I am seeing really odd behavoir of class functions in DAQFacory. I have a class MFC_Control defined in a startup routine with the following function in the definition (id and dig_Pot are local variables in the class): //////////////////////////////////////Function to set pot-level for MFC////////////////////////////// function set_Pot(potLevel) private level if(debug == 1) ? "Setting MFC"+id ? "potLevel to "+potLevel endif Pot_Pulse(id,127,0) // Pulse down 127 times to put pot in known state Pot_Pulse(id,potLevel,1) // Pulse up potLevel times dig_Pot = potLevel //update dig_Pot for later queary if(dig_Pot < 0) dig_Pot = 0 endif if(dig_Pot > 127) dig_Pot = 127 endif endfunction Then I initialize 4 of these as follows: //////////////////////////////////////////////////////////////////////////////////////////////////////// /* CREATE MFC structrues with global access and initialize */ //////////////////////////////////////////////////////////////////////////////////////////////////////// global MFCS //Array of 4 objects MFC_Control MFC_Init() for(private.i = 0, i < 4, i++) MFCS = new(MFC_Control) MFCS.id = i+1 MFCS.set_Pot(0) MFCS.turnOff() MFCS.maxFlow = 2 endfor MFCS[0].maxFlow = 5 //MFC1 will actually have a max flow of 5 L/min MFCS[0].set_Pot(0) MFCS[1].set_Pot(1) MFCS[2].set_Pot(2) MFCS[3].set_Pot(3) This is all done in a startup script. The probelm is with the function set_Pot. When called in this sequence, its' input paramater is not passed (near as I can tell from debug lines). So when Pot_Pulse is called within this function to pulse the potentionmeter up, for MFCS[0] it works fine, but for MFCS[1] it gets pulsed up 2 times, MFCS[2] gets pulsed up 3 times ande MFCS[4] gets pulsed up 4 times. Howerver, when I use this class function outside of this sequence (such as the command window or other sequences), they work just fine. Is there something I'm not understanding here? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 13, 2013 Share Posted June 13, 2013 This is the one major bug in DAQFactory OOP and why OOP has remained undocumented. Truthfully, its not really a bug as much as a limitation in the original expression parser. Anyhow, the issue it that you can't have more than one () or [] when referencing a symbol or function. So: MFCS.set_Pot(0) is invalid because you have both and (0). The workaround is pretty simple, though understandably annoying: assign the arrayed object to a private variable, then reference that: private newMFCS = new(MFC_Control) MFCS = newMFCS newMFCS.id = i+1 newMFCS.set_Pot(0) etc... and: for (private i = 0, i < numrows(MFCS), i++) private tMFCS = MFCS tMFCS.set_Pot(i) endfor Link to comment Share on other sites More sharing options...
Chrisn Posted June 14, 2013 Author Share Posted June 14, 2013 Ah, I see. I already made a seperate work around, but this is good to keep in mind. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.