Redesolve

Members
  • Posts

    5
  • Joined

  • Last visited

Redesolve's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ***Further to coments above***** *** This does code faults ***** gloclearglobals() classDef() global SampleArray private i private j private numSensorType = 10 private sData for (i=0, i<numSensorType, i ++) SampleArray[i] = new(typeLiveSensorData) //Create array of Objects (1 for each sensor type) endfor for (i=0, i<numSensorType, i++) for (j=0, j<6, j++) //Loop once for every device in the sensor sData = j+1 //For testing just give some sequential number //SampleArray[i].AddSample(j, sData) SampleArray[0].AddSample(0, 1) endfor endfor /* SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) */ ***** This code Does Not and is fine ******* clearglobals() classDef() global SampleArray private i private j private numSensorType = 10 private sData for (i=0, i<numSensorType, i ++) SampleArray[i] = new(typeLiveSensorData) //Create array of Objects (1 for each sensor type) endfor /* for (i=0, i<numSensorType, i++) for (j=0, j<6, j++) //Loop once for every device in the sensor sData = j+1 //For testing just give some sequential number //SampleArray[i].AddSample(j, sData) SampleArray[0].AddSample(0, 1) endfor endfor */ SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1) SampleArray[0].AddSample(0, 1)
  2. ________________________________Class DEF________________________________ define cSetAverageHistoryLength = 10 class typeSamplePoint local point = 0 function onCreate() point.HistoryLength = cSetAverageHistoryLength endfunction endclass class typeLiveSensorData local Device function onCreate() private i for (i=0, i<6, i++) Device[i] = new(typeSamplePoint) endfor endfunction function AddSample(dnum, newSample) Device[dnum].point[1] = Device[dnum].point //Move array down by 1 Device[dnum].point[0] = newSample //Add new sample to beginning Device[dnum].point = Device[dnum].point[0, cSetAverageHistoryLength-1] //Truncate the Array to the maximun size endfunction endclass _____________________________SEQ ____________________________________________ classDef() global SampleArray private i private j private numSensorType = 10 private sData for (i=0, i<numSensorType, i ++) SampleArray[i] = new(typeLiveSensorData) //Create array of Objects (1 for each sensor type) endfor for (i=0, i<numSensorType, i++) for (j=0, j<6, j++) //Loop once for every device in the sensor sData = j //For testing just give some sequential number SampleArray[i].AddSample(j, sData) endfor endfor endfor ___________________________________________________________________________________ /* When you run thsi sequence it passes ok for the first run subsequent run it faults. However - if i type " SampleArray[0].AddSample(0, 10) " on coammand line it happily populates my structured array (one at a time mind you, but the function does work in that way - jsut wont work in a sequence) Thanks for this, (and it does make sense), but sadly, I still have the same issue. The function works fine if I enter in the command window... It does not work in the sequence. (Exactly as before) ?
  3. ________________________________Class DEF________________________________ define cSetAverageHistoryLength = 10 class typeSamplePoint local point = 0 function onCreate() point.HistoryLength = cSetAverageHistoryLength endfunction endclass class typeLiveSensorData local Device function onCreate() private i for (i=0, i<6, i++) Device[i] = new(typeSamplePoint) endfor endfunction function AddSample(dnum, newSample) Device[dnum].point[1] = Device[dnum].point //Move array down by 1 Device[dnum].point[0] = newSample //Add new sample to beginning Device[dnum].point = Device[dnum].point[0, cSetAverageHistoryLength-1] //Truncate the Array to the maximun size endfunction endclass _____________________________SEQ ____________________________________________ classDef() global SampleArray private i private j private numSensorType = 10 private sData for (i=0, i<numSensorType, i ++) SampleArray[i] = new(typeLiveSensorData) //Create array of Objects (1 for each sensor type) endfor for (i=0, i<numSensorType, i++) for (j=0, j<6, j++) //Loop once for every device in the sensor sData = j //For testing just give some sequential number SampleArray[i].AddSample(j, sData) endfor endfor endfor ___________________________________________________________________________________ /* When you run thsi sequence it passes ok for the first run subsequent run it faults. However - if i type " SampleArray[0].AddSample(0, 10) " on coammand line it happily populates my structured array (one at a time mind you, but the function does work in that way - jsut wont work in a sequence)
  4. Interesting. In fact I do index it (see the sample code I sent) but it sis not copy/paste into the caht wimdow... so my code does read for (i=0, i<6, i++) Device = new(typeSamplePoint) endfor for both sample point and sample array Regardless the code ( as I sent in attachment) does work if I type the function in the command line. it does not work if it is in the sequence.??
  5. Ok, So here is an interesting anomaly I cant figure my way out of. Any help on this is appreciated. I have created 2 classes Class one is subordinate to class Two Class two has a function that when called adds a value to the array declared as a subclass (1) **********************CODE SNIPIT CLASSDEF************************************** define cSetAverageHistoryLength = 10 class typeSamplePoint local point = 0 function onCreate() point.HistoryLength = cSetAverageHistoryLength endfunction endclass class typeLiveSensorData local Device function onCreate() private i for (i=0, i<6, i++) Device = new(typeSamplePoint) endfor endfunction function AddSample(dnum, newSample) Device[dnum].point[1] = Device[dnum].point //Move array down by 1 Device[dnum].point[0] = newSample //Add new sample to beginning Device[dnum].point = Device[dnum].point[0, cSetAverageHistoryLength] //Truncate the Array to the maximun size endfunction endclass My actual function cycles through a loop to add items to the point member of each of the array **************************************CODE of routine that adds the value************************************** classDef() global SampleArray private i private j private numSensorType = 10 private sData for (i=0, i<numSensorType, i ++) SampleArray = new(typeLiveSensorData) //Create array of Objects (1 for each sensor type) endfor for (i=0, i<numSensorType, i++) for (j=0, j<6, j++) //Loop once for every device in the sensor //Commented out for this example - use blank data /* ptr2DataX = ReadAddrArray.PointerArray[j][0] ptr2DataY = ReadAddrArray.PointerArray[j][1] sData = SensorData[ptr2DataX][ptr2DataY] */ sData = j //For testing just give some sequential number ? "sData " + sData ? "Sample Array :" + SampleArray.Device[j].Point //SampleArray.AddSample(j, sData) SampleArray[0].AddSample(0, 0) endfor endfor endfor Note the commented out is the actual -- I'm just sending a value of zero to try and debug this.. Here is the problem..... On first pass (I=0, j=0) -> all good .. array increase in size on second pass (I=0, j- 1) I get an error "Invalid object reference: Line 4....." Here is what is strange.... when I type the my custom command ... " SampleArray[0].AddSample(0, 0)" ...into my command / Alert window everything works fine. I can use my watch and see my arrays grow. I can sub any value for I and j and value and it handles the function correctly…. So Why does it work in the command window but not in the sequence??? Thanks for any help or insight on this. Example for Azeotech.ctl