capstone

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

0 Neutral

About capstone

  • Rank
    Member
  1. Well, I'm trying to import some data from a text file when we first open DAQFactory's application. I want this to be automatic, but it would be nice to let the user browse to that text file. I know that File.FileOpenDialog only works from inside a quick sequence. So can I have that quicksequence (which is tied to a button) automatically start at the initialization of the application?? Any other work arounds? Thanks!
  2. capstone

    Tables

    Actually my bad, the array doesn't get set to zero, the strings are still in the array, but table shows the string values as NAN all of a sudden until I close DAQFactory and open it up, and then the strings are back again! any ideas?
  3. capstone

    Tables

    Hello! So I'm using tables to display string data. It shows the data the first time the table is populated, but all of a sudden at some point, the string data gets replaced with zeroes. And interestingly enough the whole array of strings gets replaced by zeroes! Any ideas why this happens?
  4. capstone

    Array of Objects Inside Another Object!

    Here is what I have, I made the corrections you said: class Location local current_Alg local Alg function OnCreate() ? "Creating New alg block." //current_Alg = new(AlgBlock) ? "MAX_ALGBLOCKS: " + doubletostr(MAX_ALGBLOCKS) for (private i = 0, i < MAX_ALGBLOCKS, i++) ? doubletostr(i) Alg[i]= new(AlgBlock) endfor current_Alg = Alg[0] endfunction endclass And when I execute these lines, this is what I get! global tempAllLoc = all_loc[0] global tempAlg = tempAllLoc.alg[2] global temp = tempAlg.CSource[1] C1000 Channel or function not found: Line 1 It doesn't like the third line! It can't find Alg[2]! why?
  5. capstone

    Array of Objects Inside Another Object!

    Thanks for the explanation. And now I'm confused a little, but I tried the two different ways that I'll explain below and I didn't get the Alg, i>0 to work. Only my Alg[0] works. Confusion: When you say "You should instead instantiate objects to be stored in local variables in OnCreate()." what do you mean? Do you mean I should first declare "local current_Alg " and then in OnCreate() instantiate the new() object to it like this? class Location .... local current_Alg = 0 local Alg function OnCreate() current_Alg = new(AlgBlock) for (private i = 0, i < MAX_ALGBLOCKS, i++) Alg[i]= new(AlgBlock) endfor Alg[0] = current_Alg endfunction endclass Or should I declare the local inside the function like this?: class Location .... function OnCreate() local current_Alg = new(AlgBlock) for (private i = 0, i < MAX_ALGBLOCKS, i++) local Alg[i]= new(AlgBlock) endfor Alg[0] = current_Alg endfunction endclass I need to access Alg from outside, so I need to be able to assign something like this: All_loc[0].Alg[2].CSource[1] = 2 At this point, I can do this: All_loc[0].Alg[0].CSource[1] = 2 and it works, but when Alg, i>0, it doesn't work! I'm using the same method though to declare Alg[0] and Alg, so I don't see why this happens. And to answer your "bet" question, this is what I get when I type ? all_loc[1]: "Object(s)" I am indeed instantiating All_loc[1] in another sequence. But All_loc[1].Alg[1] returns nothing! (All_loc[1].Alg[0] returns "Object(s)"!) Even though it's instantiated, since I have some printing code that shows it instantiates the object (in my for loop, I have it print the i each time and in my AlgBlock's OnCreate function I have it print out the Alg_empty each time, so I can see the number of times it gets created), but later I can't seem to access other elements than 0 or they go away somehow! Thanks! Just for reference: class AlgBlock local Alg_Empty = 0 //Empty local num_conditions = 0 local string strCType = {"None", "None", "None"} //Condition Type (Threshold, On/off) local CSource = {0,0,0} //Source ADC/Relay number local string strCGreater = {"=", "=", "="} //Condition Greater local CValue = {0,0,0} //Condition Value local num_results = 0 local string strRAction = {"None", "None", "None"} //Resulted Action (Set, Clear) local RDestination = {0,0,0} //Destination Relay number function OnCreate() ? "Alg_Empty" endfunction endclass
  6. capstone

    Array of Objects Inside Another Object!

    Well, first off, when I used local instead of Global, it wouldn't compile. It gave me this error message: C1000 Channel or function not found - Error compiling sequence Auto_Startup, Line Number 43 But when I changed that to Global it would compile fine. Just now I tried fixing this issue this way: local current_Alg = new(AlgBlock) local Alg Alg = current_Alg Instead of doing both steps at once and it worked. Secondly, I did try doing this function as you said: function OnCreate() ? "Creating New alg block. Alg[1] = new(AlgBlock) private ob = Alg[1] ob.Alg_Empty = 1 endfunction But it didn't fix the problem. The problem is, when I executed: Global ob = All_loc[1] ? doubletostr(ob.Alg[1].Alg_Empty) And I get the same error: Invalid object reference Please help!!!
  7. So I have this other question about objects. I have an object called Location and I'm trying to create another object called AlgBlock inside it. 1. I have the definition of class AlgBlock outside of Class Location, is that okay? 2. I'm trying to have an array of AlgBlocks inside Location and it's not working. I can only get the first element to display it's value. Here are my class difinitions: ***************************************** //Initialize Variables class AlgBlock //A class to hold the Algorithm settings. Global Alg_Empty = 0 //Empty local num_conditions = 0 local string strCType = {"None", "None", "None"} //Condition Type (Threshold, On/off) local CSource = {0,0,0} //Source ADC/Relay number local string strCGreater = {"=", "=", "="} //Condition Greater local CValue = {0,0,0} //Condition Value local num_results = 0 local string strRAction = {"None", "None", "None"} //Resulted Action (Set, Clear) local RDestination = {0,0,0} //Destination Relay number function OnCreate() ? "Alg_Empty = 0" Alg_Empty = 0 endfunction endclass class Location local ID = 0 local string phone_number = "None" local string name = "None" local Refresh_Time = 0 local Active = 0 local ADC [8] = 0 //Array of ADC values - (0-7:Pressure sensors) local Relay [8] = 0//Array of relay values - Total of 10 Relays.(0-3:12V, 4-7:AC, 8:12V,9:AC) local UVT[8] = 0 //***** Algorithm Block Variables: Global current_Alg = new(AlgBlock) Global Alg = current_Alg function OnCreate() ? "Creating New alg block. Alg[1] = new(AlgBlock) Alg[1].Alg_Empty = 1 endfunction endclass Global current_location = new(Location) Global All_loc[0] = current_location ************************************** So when I "watch" All_loc[0].Alg[1].Alg_Empty, I get "Invalid object reference," while All_loc[0].Alg[0].Alg_Empty gives me "0". 2. Why is that? Thanks a bunch!
  8. capstone

    Array in a Class

    I still have a question on this though, could you answer my first question? (#1) Thanks!
  9. capstone

    Array in a Class

    Yes, this works! I can't believe this was the fix... took so much of my time. Well, I'm glad it's fixed. Thanks!
  10. Hey again, So in the quick sequence in a symbol component's properties, is there a way to retrieve the "Component Name" and use it in the sequence?? (like is there an existing variable that holds it?) Since I need to copy 500 of the same component on a page, I'm trying to write a quick sequence (Action) which is the same for all of them, and that I won't have to go to every single one of them to change the code. I could only assign component's names and have it working based on their names. Thanks!
  11. capstone

    Array in a Class

    Hi, I have a class and some of the variables in there are arrays of numbers. I can't get the array to populate! I should be able to, right? Here is my class def: ******************* class Location local ID local string phone_number local string name local Refresh_Time local Active = 0 local ADC //Array of ADC values - (0-7:Pressure sensors) local Relay //Array of relay values - Total of 10 Relays.(0-3:12V, 4-7:AC, 8:12V,9:AC) local UVT[8] = 0 endclass global All_loc = new(Location) All_loc.ID = 0 All_loc.name = "Boulder" All_loc.phone_number = "1234556677" private LocID = 1 //new object All_loc[LocID] = new(Location) All_loc[LocID].ID = LocID All_loc[LocID].phone_number = "3034443333" All_loc[LocID].name = "Rhungari" ********************* 1. Does "local UVT[8] = 0", initialize UVT array to 9 zeros? 2. This is how I'm trying to pupulate ADC array for instance: *********** global string strParse1 = Parse(strParse0,-1,",") //Creates an array global Parse1 = strtodouble(strParse1) //For instance: {0,4,0,0,10,1,20,2,30,3,40,4,50,5,60,6,70,7,80} ? "NumRows: " + doubletostr(NumRows(Parse1)) for (private i = 3, i < NumRows(strParse1) , i= i +2) private IdNum = Parse1[i] private Measurement = Parse1[i+1] ? "Sensor:" + doubletostr(IdNum) + " = " + doubletostr(Measurement) All_loc[0].ADC[IdNum] = Measurement endfor *********** What I get is: All_loc[0].ADC[0] gets updated to all of those values from 10 to 80, so it's final value is 80! (Here is my output on the command lines: NumRows: 19 Sensor:0 = 10 Sensor:1 = 20 Sensor:2 = 30 Sensor:3 = 40 Sensor:4 = 50 Sensor:5 = 60 Sensor:6 = 70 Sensor:7 = 80) What am I doing wrong here?
  12. It's just that, since there seems to be no way to create a new component programmatically, I'm trying to create the components beforehand and then when needed, bring them in that page. Is there a way to do that in a sequence? let's say my component's name is 1. component.1. Thanks!
  13. I just found a bug when I tried to create new protocol configs, and I thought I let you know: The "On Send" event/page which exists on Protocol Configuration (a white page), doesn't update as we click on it, and it shows the code from any previous screen like "Poll" or On Recieve" etc. Even when we add some code and Ok it, and then come back to it, the "On Send" doesn't show the code we wrote, depending on what event/page we have clicked on, it shows that code in there.... Any fix for it yet??
  14. capstone

    C1136 Timeout: Line 3

    I'll let you know about the timeout later... But when I tested it last time, I was getting that Timeout everytime, and there was no other info on what sequence was generating that. Now, I have a similar problem. What is generating the errors when there is no sequence name is mentioned?? Is it something internal to DAQFactory? This is what I'm getting everytime I try to connect to the serial-USB bus, and have no idea what "Line 6" this is?? 11/18/09 17:30:22.683 C1000 Channel or function not found: Line 6
  15. capstone

    C1136 Timeout: Line 3

    So I've written some code to retrieve measurements form a particular microcontroller through the serial bus. I'm using the Poll function and we have a "~" at the end of each line to tell DAQFactory to ReadUntil(126) basically. After I execute this line of code: private string strDataInMCU = device.MCU.Poll("01" , 126) //0: Command number, 1: ID number I get the data back (which is in the form of: 0,1,2196~), and can parse it (2196 for instance) but I also get this error message: C1136 Timeout: Line 3 And I have no idea where it's coming from and what it means! Any ideas?