USE OF Type cast function ?

can any one explain the use of type cast function with help of example please i am not able to understand the explaination given in ni.com site

LabVIEW provides a function called Type Cast, which allows data to pass through it unchanged while the type of the wire changes. Please refer to the given link which elaborates on the type cast function with required instances.
http://zone.ni.com/reference/en-XX/help/371361H-01​/glang/type_cast/
In case of any clarifications needed, do revert.
Regards,
Sahil Singla
Applications Engineer | National Instruments
(Give Kudos to good Answers and Mark it as a Solution if your problem is Solved)

Similar Messages

  • Reading a binary file using the type cast function is not working

    Hello
    I am trying to read a binary file.  Using the Read from binary file and type cast functions I can actually get the information from the file.
    I set an indicator in the “Normal” option in Properties. I can read the header and footer but not the body of the file; For the body of the file all I can see is characters of the type
    “C¾ Ü Qþ  X@ “. One of the other options, Password, seems to provide an output of just the characters that were originally written, but then again, I can not read the characters because it is only asterisks and I can not copy them onto a word processor either.
    I tried setting the indicator in Hexadecimal mode, then creating a local variable that acts as a control and use the type cast function again to see if  could convert the Hexadecimal string to readable ASCII characters; unfortunately, this did not work either.
    I don’t know what else I should try or if there is something that I may not be doing right and for that reason I am not getting the desired results. I hope someone has an idea about this issue.
    Regards,
    Roberto

    Thank you for your reply,
    Well, actually I don’t have any information about this file. I will try to obtain information about it though.
    This is a file that contains velocity information; there are 65 channels that form a velocity profile in a pipe. Also, there are 4096 velocity profiles. I don’t know what is the format of these values.
    The software that creates the file provides a text file. Using this text file the velocity information can be processed and then plotted.
    I want to avoid all these intermediate steps and read, process and plot everything using only LabView. BTW, I am using LabView 8.2
    Roberto

  • Type cast function use

    Good
    morning,
    I am using
    the “type cast” function and the “visa write” subvi to control a DO channel of
    Arduino (RS232 communication), please see image attached. Can somebody advise how
    should I program in LabVIEW in order to control more DO channels? Furthermore,
    when I tried to read the output of “type cast function” during the run of vi I
    saw a square symbol. Is there any way to decode this symbol ? I tried to use a
    “decimal string to number” suvi but it didn’t work.
    Thank you
    in advance
    Attachments:
    samplevi.jpg ‏27 KB

    dan_u,
    Thank you for your reply. It's the first time I am using RS232 communication and also other harware than that of NI and I am little bit confused. With the configuration shown on my vi everything seems to work fine. This means that I can enable and disable a DO channel of arduino, thus the format comes from the "type cast" function seems ok. A previous effort, when I tried to send a string (also by using the "write to visa") of "0" or "1" to disable and enable the same DO channel wasn't successful. This is the reason why I thought that using the "type cast" function is the correct way to write to visa. Now, what I want to do is using e.g three boolean to control three different DO channels. Could you please advise?
    Thank you in advance
    Attachments:
    myvi.jpg ‏99 KB

  • I need To Understand the "Type Cast Function"

    Dears,
    I need To Understand How the "Type Cast Function" Work, and if you can Give me an Example it will be Apperciated
    BR
    Ahmed

    In its simplest explanation Type Cast allows you to reinterpret a series of bytes. The numeric conversion functions convert from one data type to another and essentially do the same thing that Type Cast does, albeit with just numbers. Type Cast allows you to extend this to convert one data type to another, beyond just numbers. Thus, you could convert an array of 2 U8 values into a single U16 number by using Type Cast like this:
    or you could reinterpret an array of lots of U8 values into an array of U16 values like this:
    How you use it is entirely up to you, but it is an extremely powerful function. What are you trying to do?
    Attachments:
    Example_VI.png ‏6 KB
    Example2_VI.png ‏11 KB

  • How use clear type font function in application 10g

    i now use application form 10g and in this version, if i set "Clear Type" Fonts in windows xp effect it do not work in application server.
    In the old version (application 1.1.2) it work very well and the fonts on internet are more comprensive than the new version ?
    and then application 10G is the only software that do not support clear type fonts ???
    SomoOne Know Some Thing ????

    Hi,
       Did you instll the font as follows.
       In SE73.. select the Radio button "Font Families" And click on the "True type Font Installation" button.
    Regards
    GK.

  • Is there a byte swapping side effect to the type cast function?

    I am developing a PC based program that reads from a TCP connection (network byte order), yet doesn't require byte swaps? There is a non-labVIEW program on the PC which receives the same byte stream and does need to swap!
    Attachments:
    type_cast_functionality.doc ‏112 KB
    Read_GRETS_Packet.vi ‏59 KB

    I guess you have to repack your string before sending it to the non Labview program(se posted picture). I think visual C uses litlle endian. As an example. In Labview the sgl number 123.123 is equal to to the hex byte array 42 F6 3E FA. Doing the same in  visual C for a float, will give  FA 3E F6 42. The same bytes but in a different order. The flatten to string function will hanlde this job for you. Use the ditailed help for pointer to examples. On this page http://www.61131.com/download.htm You will find a tool if you want to toy with number (Floating point to/from hex/binary conversion).
    @grahamwebb
    I think you should look at your code. Perhaps you lose or get some ekstra unwanted bytes in your programming/transmission.
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)
    Attachments:
    sample.PNG ‏6 KB

  • Type casting an array as element

    Hello all,
    I'm relatively new to labVIEW and I would like your help with something.
    Let us say I have an array of two I16 elements. I would like to type cast it into one single U32 element. In C, I could simple read it as a U32 or use pointers to get away with it, but I don't seem to be able to find a way to do it here.
    Cheers,
    S

    You can, in fact, use the Type Cast function to do this. Alternately, index out the two array elements, then use Join Numbers to merge them.

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • How to use type cast change string to number(dbl)?can it work?

    how to use type cast change string to number(dbl)?can it work?

    Do you want to Type Cast (function in the Advanced >> Data Manipulation palette) or Convert (functions in the String >> String/Number Conversion palette)?
    2 simple examples:
    "1" cast as I8 = 49 or 31 hex.
    "1" converted to decimal = 1.
    "20" cast as I16 = 12848 or 3230 hex.
    "20" converted to decimal = 20.
    Note that type casting a string to an integer results in a byte by byte conversion to the ASCII values.
    32 hex is an ASCII "2" and 30 hex is an ASCII "0" so "20" cast as I16 becomes 3230 hex.
    When type casting a string to a double, the string must conform the the IEEE 32 bit floating point representation, which is typically not easy to enter from the keyboard.
    See tha attached LabView 6.1 example.
    Attachments:
    TypeCastAndConvert.vi ‏34 KB

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • Datasources with function module which uses table type

    hi..
    I am creating a datasource which extracts data using a function module from xRPM to BW. When creating the function module it gives an error " TABLES parameters are obsolete!" while trying to specify the extract structure. I searched in SDN and learnt that we need to use table types and use that in the changing tab.Not sure how that works and where we need to use the extract structure for this.
    Could someone please explain this to me and let me know how i can create my datasource using this type of function module.

    Hi,
    in your case you need the tables parameter, as the service api expects the result of the fm in a table called e_t_data. Of course table parameters are obsolet but you can just ignore the warning and it will work.
    regards
    Siggi
    PS: Extraction fm must follow a strict interface definition.
    Message was edited by:
            Siegfried Szameitat

  • J2SE 6 warning message when using type casting

    With Java SE 5 and 6 version, there's always an annoying warning message when I write the following code:
    LinkedList<MyBean> cart0 = (LinkedList<MyBean>) session.getAttribute("cart");The warning message is because I use the type casting with the getAttribute method and thus this is not type-safe. So how do I get around the warning message and write standard code that sticks to the J2SE 6 standards? Thank you.

    Add a @SuppressWarnings annotation to the method. A bit intelligent IDE will provide you a quickfix option for it.
    Keep in mind: it's a warning, not an error. The sessionMap is cannot be specifically parameterized and will never be, it should be able to store any object to your taste. Further on this has not much to do with JSF at itself.

  • Splitting and type casting huge string into arrays

    Hello,
    I'm developing an application which is supposed to read measurement files. Files contain I16 and SGL data which is type casted into string. I16 data is data from analog input and SGL is from CAN-bus data in channel form. CAN and analog data is recorded using same scan rate.
    For example, if we have 6 analog channels and 2 CAN channels string will be (A represents analog and C represents CAN):
    A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 A3 A4 A5 A6 C1 C2 A1 A2 .... and so on
    Anyway, I have problems reading this data fast enough into arrays. Most obvious solution to me was to use shift registers and split string in for loop. I created a for loop with two inner for loops. Number of scans to read from string is wired to N terminal of the outermost loop. Shift register is initialized with string read from file.
    First of the inner loops reads analog input data. Number of analog channels is wired to its N terminal. It's using split string to read 2 bytes at a time and then type casts data to I16. Rest of the string is wired to shift register. When every I16 channel from scan is read, rest of the string is passed to shift register of the second for loop.
    Second loop is for reading CAN channels. It's similar to first loop except data is read 4 bytes at a time and type casted to SGL. When every CAN channel from scan is read, rest of the string is passed to shift register of the outermost loop. Outputs of type cast functions are tunneled out of loops to produce 2D arrays.
    This way reading about 500 KB of data can take for example tens of seconds depending on PC and number of channels. That's way too long as we want to read several megabytes at a time.
    I created also an example with one inner loop and all data is type casted to I16. That is extremely fast when compared to two inner loops!
    Then I also made a test with two inner loops where I replaced shift register and split string with string subset. That's also faster than two inner loops + shift register, but still not fast enough. Any improvement ideas are highly appreciated. Shift register example attached (LV 7.1)
    Thanks in advance,
    Jakke Palonen
    Attachments:
    String to I16 and SGL arrays.vi ‏39 KB

    OK, there is clearly room for improvement. I did some timing and my two above suggestions are already about 100x faster than yours. A few teeaks led to a version that is now over 500x faster than the original code.
    A few timings on my rather slow computer (1GHz PIII Laptop) are shown on the front panel. For example with 10000 scans (~160kB data as 6+2) my new fastest version (Reshape II) takes 14 ms versus the original 7200ms! It can do 100000 scans (1.6MB data) in under 200 ms and 1000000 scans (15MB data) in under 2 seconds.
    I am sure the code could be further improved. I recommend the Reshape II algoritm. It is fastest and can deal with variable channel counts. Modify as needed.
    Attached is a LabVIEW 7.1 version of the benchmarking code, containing all algorithms. I have verified that all algorithms produce the same result (with the limitation that the cluster version only works for 6*I16+2*SGL data, of course). Remember that the reshape function is extremely efficient, because it does not move the data in memory. I have some ideas for further improvements, but this should get you going.
    Message Edited by altenbach on 08-05-2005 03:06 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StringI16SGLCastingTimer.png ‏48 KB
    StringtoI16andSGLArraysMODTimer.vi ‏120 KB

  • Type cast array to cluster

    Is there any real difference between the 'array to cluster' function and simply type casting to a cluster?  The image below shows a simple example.  Aside from providing the names of each cluster element, the type cast function automatically sets the cluster size, which is a nice feature when working with a typedef.  I am really wondering whether there is any downside to type casting when the array and cluster elements are the same data type.
    Thanks in advance.
    Solved!
    Go to Solution.

    Type Cast man knows where I live, so my opinion is biased.  When I have to make such a conversion, which is practically never, but not equal to never, then I go with the Type Cast.  You hit the biggest points, meaningful labels and the ease of going from six to seven to eleven elements with the Type Def.  When I do this conversion it is typically because I need to do some property magic which arrays do not allow (all elements must share properties except value).  Creating a control from the Array to Cluster function is let's say a Clusterflop, from the Type Cast, exactly what I am looking for.  Besides, that Array to Cluster function obfuscates code, is always left at 9 elements, and otherwise needs to go away, or at least do this:
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Remove-Default-Behavior-from-Array-To-Cluster/idi-p/17...
    First of all, ask yourself if you really should be doing this, if the answer is yes then I say Type Cast.

  • Help on CAST function, defining TYPE TABLE and using a REF cursor

    Hi,
    I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
    Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
    I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
    CREATE OR REPLACE PACKAGE lookup_pkg AS
    TYPE t_lookup_refcur IS REF CURSOR;
    CURSOR c_lookup IS
         Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1;
    TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
    Procedure lookup(id Number, o_lookup OUT t_lookup);
    End lookup_pkg;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this procedure, I am getting invalid datatype Oracle error and
    cursor points the datatype t_lookup in the CAST function.
    1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
    Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
    create or replace type t_lookuprec as object
                   (Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1);
    create or replace type t_lookup_tab AS table of t_lookuprec;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup_tab));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
    points the datatype t_lookup_tab in the CAST function.
    2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
    I have checked the all_types view and found that
    value for Incomplete column for these two types are YES.
    3. What does that mean?
    Any suggestions and help is appreciated.
    Thanks
    Srinivas

    create or replace type t_lookuprec as object
    (Select columns1,2,3,....100
    FROM A, B, C, D, E
    WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
    However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

Maybe you are looking for