Math operations on array in TestStand

Hi.
I have 2 questions
1. Is it possible to multiply an array by a number in TestStand?
I know there are some numeric functions available in TestStand but I don't know if like LabVIEW I can multiple ( subtract/add/divide...) all the elements of an array by a number
2. Let's say I want to pass a 1D array of numbers ( size 10) to a code module but I would like to just pass the first 5 elements . How can I do it in TestStand ? I have checked the array function but I couldn't find something like Array Subset?
Could you please help me with these question

In TS 2012 and later they added some new array functions such as Min, Max, Split, Sort, etc...  They also added the ability to do Locals.MyArray[4..8].  Which will give you elements 4 through 8 of the 0 indexed array.
As for the adding to each number I don't think that capability exists.  If it did it would be something like Locals.MyArray + 100.  It defnitely doesn't work in TS 2010.
Hope this helps,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~

Similar Messages

  • How to call a CString array from TestStand

    I have a C++ DLL that uses a CString array, CString myString[ ],  that I need to pass back to TestStand 4.0 for inclusion in my results database.
    In the TestStand module definition the parameter argument Description comes up as a CStriing pointer (CString*) instead of a CStringArray.
    When I put my array of strings into the Value Expression I get an error: Expected String, found Array of Strings.
    I have no trouble passing just a string pointer but that's not working either.
    Can someone help?
    Thanks,
    Steve S

    Hi Steve,
    I don't think that you can pass a CString Array from C++ DLL to TestStand 4.0 directly.
    But you can do it another way: concatenate all Strings by a delimit in your CString Array to build a new String,  then pass it to TestStand. In TestStand you can separate those Strings by the delimit, and rebuild a String Array.
    For example:
    // If this is your CString Array.
    CString myString[] = {"AAA", "BBB", "CCC"};
    // Build a  new String in your C++, and pass it to TestStand.
    char  *myNewString = "AAA~BBB~CCC";
    // Separate myNewString and build an Array in TestStand...
    Hope that can help you!
    Message Edited by My NI on 11-29-2007 11:34 AM
    Regards
    MY

  • Math Operations on LV for Palm

    I am trying to write a program for a Treo 680 running PalmOS 5.4 (Garnet) using LV for PDA 8.0, and I observe some strange behavior in math operations. The test that I did was to calculate B = log10(A). Both A and B are defined as DBL. The B field is programmed to show 16 decimal places. When I run this program on the PC, I get the following results:
    log10(10) = 1.0000000000000000
    log10(50) = 1.6989700043360187
    log10(100)= 2.0000000000000000
    When I run the same program on the Treo (or on Palm OS Garnet Simulator - same results), I get
    log10(10) = 1.0000000000
    log10(50) = 1.2694732747
    log10(100)= 2.0000000000
    A couple more interesting results:
    log10(72) = 1.4278357668
    log10(73) = 1.0043294009
    Two questions:
    1) Why do the results on Palm have only 10 decimal places?
    2) Why are non-integer results so far from the correct values?
    A few notes:
    1) This is not a question of DBL vs. SGL: log10(50) in SGL arithmetic is 1.6989699602127075
    on the PC - the difference starts only in the 7th decimal place.
    2) I have MathLib.prc installed on the Treo (and on the simulator).
    3) The Palm calculator works correctly: e.g. log10(50) = 1.698970004336
    TIA,
    Sergey

    Cepera wrote:
    I mean, how can you have a bug in such a fundamental operation as log(a)?
    As mentioned, the PDA module converts your code to C, which is an error prone process.
    Couple that with the fact that the PDA module has a relatively small market (and the Palm version an even smaller one, as evidenced by its scrubbing), and you can see how bugs like this can slip through the cracks. As you mentioned, the error does not occur for all values of a.
    Try to take over the world!

  • Math operations on history chart

    Hi everyone, I'd like to be able to do some math processing to chart history in that way:
    1) visualizing continuous data from serial port on a multi plot chart  ---> done
    2) at a certain point be able to do some basic math operation on all the chart plots, say for example plot1 multiply by 2, plot 2 multiply by 1.5 ecc.. and visualize those operations on all the history collected till that moment on the same chart replacing raw data, and maybe return to visualize all the raw data collected, programmatically.
    Thanx

    Hi ghrsdr,
    The best way to do it is to maintain a data structure in memory containing a portion of the acquired data (even all). When you need to do some operations on the data you could use this data structure to retrieve and modify your data, even creating a new data structure to maintain the original data. If the data set is large you may consider to stream data to and from your hard disk. The chart should be used only for data visualization purposes, not as a data structure to store the acquired data.
    I suggest you to read the following white papers on the management of large data sets in LabVIEW.
    Managing Large Data Sets in LabVIEW
    http://www.ni.com/white-paper/3625/en
    Memory Management for Large Data Sets
    http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/memory_management_for_large_data_sets/
    I hope I have given you some useful suggestion for your project.
    Best regards,
    Enrico

  • Deprecated math operator  ^ ?

    I was using Cold Fusion MX7, and now I'm on CF8.
    This week someone told me that I had a problem with one of my
    calculation, it use to be giving the good result but now it is not
    giving good result. The only thing I can see is that the math
    operator ^ is deprecated in CF8, is there something that replace
    it???

    > the math operator ^ is deprecated in CF8,
    Cite?
    It certainly doesn't say anything like that in the docs:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/Expressions_03.html
    {quote}
    ^
    Exponentiation: Return the result of a number raised to a
    power (exponent).
    Use the caret character (^) to separate the number from the
    power; for
    example, 2^3 is 8. Real and negative numbers are allowed for
    both the base
    and the exponent. However, any expression that equates to an
    imaginary
    number, such -1^.5 results in the string "-1.#IND. ColdFusion
    does not
    support imaginary or complex numbers.
    {quote}
    But anyway, if something is deprecated, it still works same
    as it ever did,
    it's simply flagged for obsolescence. So even if the ^
    operator was
    deprecated, there'd be no difference in how it worked before
    and after
    deprecation.
    CF seldom deprecates things, and even when deprecated, things
    are seldom
    actually obsoleted. A good example is the parameterExists()
    function: it's
    be deprecated since (at least) CF5. It's still there and
    functional in CF8
    though.
    > <cfset mtp = #rem# * 100 * ( (1 - ((1+
    (#tme#/100))^-#duree#) ) ) / #tme#>
    Well you don't need those pound signs in there, but having
    them just makes
    your code look untidy, it doesn't actually impact anything.
    What kind of differences in results are you seeing?
    Adam

  • Sort array in TestStand

    Hi,
    I have an array of custom type container, something like:
    - TestName
    - Type
    - Operation
    I'd like to sort this array by Type and Operation.
    Is that possible in TS 2010? If not - what is the best way to do that? I'm using also LabVIEW and C/C++.
    Thanks in advance
    Solved!
    Go to Solution.

    In this case I would recommend passing it to LabVIEW and let LV handle the heavy lifting: http://forums.ni.com/t5/LabVIEW/Sort-1D-array-of-c​lusters-by-the-second-element-in-the-cluster/td-p/​...
    Check out Darren's post.  It's a clean sort of clusters.
    TestStand isn't designed for complex algorithms.  Although you could probably do it in TS you would have to come up with the algorithm.
    Cheers,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • (Error in documentation?) Math operator precedence problem

    Hello,
    I apologize in advance, while I do know programming (I'm a PHP and Perl programmer) I'm fairly new to Java so this may well be a silly question, but that's why I am here. I hope you'll show me where my error is so I can finally set this to rest before it drives me mad :)
    (Also, I hope I'm posting this in the right forum?)
    So, I am taking a Java class, and the question in the homework related to operand precendence. When dealing with multiplication, division and addition, things were fine, the documentation is clear and it also makes sense math-wise (multiplication comes before addition, etc etc).
    However, we got this exercise to solve:
    If u=2, v=3, w=5, x=7 and y=11, find the value assuming int variables:
    u++ / v+u++ *w
    Now, according to the operator precedence table (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html) the unary operator u++ comes first, before multiplication, division and addition.
    This would mean I could rewrite the exercise as:
    ((u+1)/v) + ((u+1)*w) = (3/3) + (4*5) = 1+20 = 21
    However, if I run this in Java, the result I get is 15.
    I tried breaking up the result for the two values in the Java code, so I could see where the problem is with my calculation.
    For
    System.out.println(u++ /v);
    I get 0
    For
    System.out.println("u++ *w");
    I get 15
    My professor suggested I attempt to change the values from int to float, so I can see if the division came out to be something illogical. I did so, and now I get:
    For
    System.out.println(u++ /v);
    I get 0.66667
    For
    System.out.println("u++ *w");
    I get 15.0000
    Which means that for the first operation (the division) the division happens on 2/3 (which is 0.6667) and only afterwards the u value is increased. That is, the u++ operation is done after the division, not before. The same happens with the multiplication; when that is carried out, the value of u is now 3 (after it was raised by one in the previous operation) and the first to be carried out is the multiplication (3*5=15) and only then the u++.
    That is entirely against the documentation.
    This is the script I wrote to test the issue:
    public class MathTest {
         public static void main (String [] args) {
              float u=2, v=3, w=5, x=7, y=11;
              System.out.println("Initial value for 'u': " + u);
              float tmp1 = u++ /v;
              System.out.println("u++ /v = " + tmp1);
              System.out.println("First ++ value for 'u': " + u);
              float tmp2 = u++ *w;
              System.out.println("u++ *w= " + tmp2);
              System.out.println("Second ++ value for 'u': " + u);
              System.out.println(tmp1+tmp2);
    The output:
    Initial value for 'u': 2.0
    u++ /v = 1.0
    First ++ value for 'u': 3.0
    u++ *w= 20.0
    Second ++ value for 'u': 4.0
    21.0
    Clearly, the ++ operation is done after the division and after the multiplication.
    Am I missing something here? Is the documentation wrong, or have I missed something obvious? This is driving me crazy!
    Thanks in advance,
    Mori

    >
    The fact that u++ is evaluated but in the calculation itself the "previously stored" value of u is used is completely confusing.
    >
    Yes it can be confusing - and no one is claiming otherwise. Here are some more thread links from other users about the same issue.
    Re: Code Behavior is different in C and Java.
    Re: diffcult to understand expression computaion having operator such as i++
    Operator Precedence for Increment Operator
    >
    So, when they explain that ++ has a higher precedence, the natural thing to consider is that you "do that first" and then do the rest.
    >
    And, as you have discovered, that would be wrong and, to a large degree, is the nut of the issue.
    What you just said illustrates the difference between 'precedence' and 'evaluation order'. Precedence determines which operators are evaluated first. Evaluation order determines the order that the 'operands' of those operators are evaluated. Those are two different, but related, things.
    See Chapter 15 Expressions
    >
    This chapter specifies the meanings of expressions and the rules for their evaluation.
    >
    Sections in the chapter specify the requirements - note the word 'guarantees' in the quoted text - see 15.7.1
    Also read carefully section 15.7.2
    >
    15.7. Evaluation Order
    The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right.
    15.7.1. Evaluate Left-Hand Operand First
    The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated.
    If the operator is a compound-assignment operator (§15.26.2), then evaluation of
    the left-hand operand includes both remembering the variable that the left-hand
    operand denotes and fetching and saving that variable's value for use in the implied
    binary operation.
    15.7.2. Evaluate Operands before Operation
    The Java programming language guarantees that every operand of an operator (except the conditional operators &&, ||, and ? appears to be fully evaluated before any part of the operation itself is performed.
    15.7.3. Evaluation Respects Parentheses and Precedence
    The Java programming language respects the order of evaluation indicated explicitly by parentheses and implicitly by operator precedence.
    >
    So when there are multiple operators in an expression 'precedence' determines which is evaluated first. And, the chart in your link shows 'postfix' is at the top of the list.
    But, as the quote from the java language spec shows, the result of 'postfix' is the ORIGINAL value before incrementation. If it makes it easier for then consider that this 'original' value is saved on the stack or a temp variable for use in the calculation for that operand.
    Then the evalution order determines how the calculation proceeds.
    It may help to look at a different, simpler, but still confusing example. What should the value of 'test' be in this example?
    i = 0;
    test = i++; The value of 'test' will be zero. The value of i++ is the 'original' value before incrementing and that 'original' value is assigned to 'test'.
    At the risk of further confusion here are the actual JVM instructions executed for your example. I just used
    javap -c -l Test1to disassemble this. I manually added the actual source code so you can try to follow this
            int u = 2;
       4:iconst_2       
       5:istore  5
            int v = 3;
       7:iconst_3       
       8:istore          6
            int w = 5;
      10:iconst_5       
      11:istore          7
            int z;
            z = z = u++ / v + u++ * w;
       13:  iload   5
       15:  iinc    5, 1
       18:  iload   6
       20:  idiv
       21:  iload   5
       23:  iinc    5, 1
       26:  iload   7
       28:  imul
       29:  iadd
       30:  dup
       31:  istore  8
       33:  istore  8The Java Virtual Machine Specification has all of the JVM instructions and what they do.
    http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf
    Your assignment to z and formula starts with line 13: above
    13: iload 5 - 'Load int from local variable' page 466
    15: iinc 5, 1 - 'Increment local variable by constant' page 465
    18: iload 6 - another load
    20: idiv - do the division page
    21: iload 5 - load variable 5 again
    23: iinc 5, 1 - inc variable 5 again
    26: iload 7 - load variable 7
    28: imul - do the multiply
    29: iadd - do the addition
    30: dup - duplicate the top stack value and put it on the stack
    31: istore 8 - store the duplicated top stack value
    33: istore 8 - store the original top stack value
    Note the description of 'iload'
    >
    The value of the local variable at index
    is pushed onto the operand stack.
    >
    IMPORTANT - now note the description of 'iinc'
    >
    The value const is first sign-extended to an int, and then
    the local variable at index is incremented by that amount.
    >
    The 'iload' loads the ORIGINAL value of the variable and saves it on the stack.
    Then the 'iinc' increments the VARIABLE value - it DOES NOT increment the ORIGINAL value which is now on the stack.
    Now note the description of 'idiv'
    >
    The values are popped
    from the operand stack. The int result is the value of the Java
    programming language expression value1 / value2. The result is
    pushed onto the operand stack.
    >
    The two values on the stack include the ORIGINAL value of the variable - not the incremented value.
    The above three instructions explain the result you are seeing. For postfix the value is loaded onto the stack and then the variable itself (not the loaded original value) is incremented.
    Then you can see what this line does
      21:  iload   5 - load variable 5 againIt loads the variable again. This IS the incremented value. It was incremented by the 'iinc' on line 15 that I discussed above.
    Sorry to get so detailed but this question seems to come up a lot and maybe now you have enough information and doc links to explore this to any level of detail that you want.

  • Two dimension string array in teststand

    Hello,
    I want to pass a two dimension string array from a labWindows dll into Teststand. My labwindows dll:
    #define NR_columns 12
    #define NR_rows  1200
    #define NR_hight   1024
    int__declspec(dllexport) __stdcall  sort( char pspec[NR_columns][NR_rows][NR_hight])
    The call of the dll in teststand looks like the attached picture in the doc file.
    and I got the error message which shows the attached second picture in the doc file
    what is the problem?
    regards
    samuel
    Attachments:
    Error1.doc ‏94 KB

    Hello Samuel,
    I'm not experienced in LabWindows but I think the reason for this Error is the dimension of FileGlobals.loadspec in TestStand. The Error Dialog displays for this String Array [0..11][0..1200]. That's an array of 12 and 1201 elements but function is expecting 12 and 1200 elements.
    I hope this helps.
    Kind regards
    C. Dietz
    Test Engineering
    digades GmbH
    www.digades.com

  • Can I create a VI to change the 'operator' name on the teststand report?

    I want the user to be able to type in a name, as well as other information, in a VI when a test begins. I do not want to create 'users' as I don't know who the testers will be.
    I want the user to log in as an administrator (or tester -- any generic login), then type in their name into a VI that pops up when the test is started. I would then like to take their name as a string variable and pass it through to teststand and have it appear in the 'operator' area on the report.
    How do i do this?
    Thanks in advance!
    Dave Neumann

    In your process model, you can modify the Locals.StationInfo.LoginName variable. The default process model does this in the "Get Station Info" subsequence with the expression "Parameters.StationInfo.LoginName = StationGlobals.TS.CurrentUser.LoginName". You could either replace that statement, or add another one after it.
    An easy way to create a prompt is with the Message Popup step type. To get input back from the user, edit the step properties and configure the message box. Under the Options tab you can select "Enable Response Text Box". Then you can enter a post-expression like "Parameters.StationInfo.LoginName = Step.Result.Response" to assign the name to the TestStand variable.

  • Atomic operation on array elements

    For array elements of primitive types (32 bits and less): byte, short, int. Are array operations atomic?
    For example, define byte b[] = new byte[1];
    thread A executes b[0]++; thread B reads b[0]. or both threads writing..
    Question:
    1 Is it possible to get an incostintent value reading b[0].
    2. Do you think JVM or OS know that two threads work on the same element and synchronizes them to ensure value consistency?
    As a consequence of synchronizatrion, is there speed difference if I have two threads writing to b[0] and b[1] OR two threads writing to same element b[0]. I checked, there seems to be none.

    Suppose I do not want to synchronize access to array
    elements. Then you can't guarantee correct behavior of things like ++.
    It's going degrade performanceHave you measured this, so that you know it will be a problem, or are you just assuming?
    but would
    like to understand whether JVM enforces the same
    atomic rule on array elements as does with variables.++ is NOT atomic on anything--variables or array elements. All threading issues are the same for array elements as for variables.
    Can anynody comment on performance? Is it faster to
    modify different elements of array versus the same
    index? shouldn't the same be slower?Try it yourself and see if you can even see a meaningful difference.

  • Array in TestStand

    Hi  gurus,
           I have a doubt that how can we create Array of string in TestStand 4.0 using C#.NET environment.
    I used following method, but failed to create array:
    objPropertyObj.SetValStringByOffset(10,PropertyOptions.PropOption_InsertIfMissing,"SRU"); // exception here....
    The other following method creates array with empty size:
    objPropertyObj.NewSubProperty("SUBSTITUTE.SRU", PropertyValueTypes.PropValType_String, true, "Arrayw",10 );
    Please let me know how to set the size of the array at second method.
    Thank you,
    regards
    RKK

    Hi rkk,
    I have added a small function from a former thread to you
    Just take a look at it
    Greetings
    Juergen
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=
    Attachments:
    CTestStandDialog.zip ‏35 KB

  • Program and send several coordinates for steeper motor operation. Arrays?

    Hello,
    I am a beginner in LabVIEW and currently I am developing a project to design and build a Cartesian robot.
    I have a generic VI to control my stepper motors in which I only can introduce one target position and then execute it. I would like to introduce several positions and execute them in one click, I mean, for example enter several coordinates instead only one at time, then execute the profile and get the motor perform them one after another.
    To do it I am thinking in doing it by an array in which I introduce the values of my target positions and then the array would send them one by one once the previous one has finished.
    First of all would you do it like that using arrays?
    If so please if someone has an idea of how to achieve it I would be grateful to hear it.
    I enclose the Vi I'm using. As you can see I can introduce only one value in the "target position" field whereas I need to have for example a column of values and perform the one after another until the last one just clicking "start profile"
    Thank you very much in advance, all ideas/examples are welcome.
    Attachments:
    Nanotec-Example for LabView 2011.zip ‏68 KB

    Hello!
     Thanks very much for replying!
    The answers to your questions are:
    1. Have you every time to push "Change Position" when you want to set a new position and then to push "Start Profile" to perform the move to this position?
    Yes, actually that is one of my problems, I have implemented an array which is able to send positions stored in it, but I have to click an ok button to send the next position, then change the position and finally start profile. The current sequence is:
    - When executing the VI the array send the value stored in 0 position --> Click in "Change Position" --> Click in "Start Profile" --> Performing the profile --> Click in "Next position" --> Click in "Change Position" --> Click in "Start Profile" --> Execution of second position and so on.
    What I would need to do is automatically to perform all the positions with a single "Start profile" button click.
    2. How do I know if the current position is reached and the move is ready?
    There is a led labeled "ready" which is an indicator that the motor has finished to execute the profile.
    So currently I need to press manually 3 Booleans and the goal is do it automatically as sequence or so.
    All ideas/solutions are welcome.
    Thanks again for replying again.
    I enclose the latest VI and a picture as an explanation.
    Kind regards.
    Attachments:
    Example3.zip ‏72 KB
    Example_3.jpg ‏452 KB

  • Perform math functions on arrays

    Hello,
    How do I go about dividing each element of my 1D array by 1000???
    Thanks for your help and time.
    hiNi

    Hi hiNI,
    do show a picture for Altenbach's comment:
    Have you ever gone through the free online courses offered by NI here? They also explain, how to work with arrays...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Implementing IN operator with array binding

    Is there a way to have an SQL statement with a simple WHERE clause like "WHERE my_col = :p1" or "WHERE my_col IN (:p1)" and bind an array to p1?
    My goal is to avoid blowing up of the command text like "WHERE my_col IN (:p1, :p2, :p3 ...)". In my case the array containing the params could contain several hundreds of items, so the where clause may become quite long...
    Thanks,
    Daniel

    Is there a way to have an SQL statement with a simple
    WHERE clause like "WHERE my_col = :p1" or "WHERE
    my_col IN (:p1)" and bind an array to p1?
    I would also like a solution for this problem.
    It is possible to generate very long IN conditions.
    There is a limit of 1000 values in the IN list, but that can be handled by OR-ing several IN conditions.
    Executing this kind of expression is however terribly slow, so some other solution would be nice.
    Thanks

  • Row operation on array with a For Loop

    Hi,
    I'm working with a large one dimensional column array. I'm trying to do the following
    for i=1:size(A)/2
    B(i,: ) =A(1+(i-1)*2:i*2)
    So, for example if
    A=          
    0
    1
    2
    3
    4
    5
    6
    7
    then
    B=             
    0 1
    2 3
    4 5
    6 7
    My approach was to use an array subset block inside the for loop to select a number of elements but I'm not sure how to transpose the selected elements into a new row to create the new array B. Is there a more straightforward approach?
    Thanks,
    Mike
    Solved!
    Go to Solution.

    try experimenting with the reshape array feeding it your input array and re-sizing it to output a 2d aray. It is much faster than using a For loop becuase the data never gets moved and LV just changes the array dimensions and updates the stride.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for