Bytes array to double words array

I have an array of bytes. I need to take 4 bytes at a time to create a doubleword (32bits).
I am currently using Decimate Array and Join Numbers twice to do this.
Is there a more efficient way of doing this that I am overlooking?
Solved!
Go to Solution.

nyc wrote: I do have to perform endian manipulation. The information is little endian. My original information is a string from a TCPIP read. My current attempt is to convert it to a bytes array. 
Can you explain in more detail what I would do in this case?
As I noted, you can use the Unflatten From String. Since the data is coming from a TCP Read you can wire that directly to it:
Message Edited by smercurio_fc on 06-15-2010 09:19 AM
Attachments:
byte array to integer array_BD.png ‏8 KB
byte array to integer array.vi ‏18 KB

Similar Messages

  • Transfering elements to new array and doubling values.

    Hi my problem is that I need to ask a user to enter 5 integers that stores them in an array. Transfer them to a new array by doubling the values when trasferred.
    Please help I have 3 errors.
    class arrays
         public static void main (String[] args)
              int numbers[] = new int [5];
              byte array1Size = 0;
              int input = 0;
              char goon = 'y';
                   //create and initialise an array of 5 integers
                   int array1[] = new int [5];
                   // loop and fill each element
                   for (int x = 0; x < array1.length; x++)
                        System.out.println("Enter a number: ");
                        array1[x] = EasyIn.getInt();
                        // Filling array
                        if (array1Size >= array1.length)
                             //Make a new array doubling the values od the integers
                             int array2 [] = new int [2 * array1.length]; // 10 integers
                             //Copying integers
                             System.arrayCopy (array1, 0, array2, 0, array1.length);
                             //Make old reference point to new array
                             array1 = array2;
                        else
                             //normal
                             do
                                  System.out.print("Enter an integer: ");
                                  input = EasyIn.getInt();
                                  anotherArray[anotherArraySize] = input;
                                  anotherArraySize++;
                                  System.out.print ("Another number? Enter Y or N: ");
                                  goon = EasyIn.getChar();
                             }     while(goon = = 'y' | goon = = 'Y');
    the errros >>>
    G:\Java\Practical 7\Practical74.java:33: '.class' expected
                             int array2 [] = new int [2 * array1.length]; // 10 integers
    ^
    G:\Java\Practical 7\Practical74.java:33: not a statement
                             int array2 [] = new int [2 * array1.length]; // 10 integers
    ^
    G:\Java\Practical 7\Practical74.java:41: 'else' without 'if'
                        else
    ^
    3 errors
    Tool completed with exit code 1
    Thanks

    Hi,
    it seems you forgot the curly braces in the if-else statement:
    if (array1Size >= array1.length){
    //Make a new array doubling the values od the integers
    int array2 [] = new int [2 * array1.length]; // 10 integers
    //Copying integers
    System.arrayCopy (array1, 0, array2, 0, array1.length);
    //Make old reference point to new array
    array1 = array2;
    else{
    //normal
    do
    System.out.print("Enter an integer: ");
    input = EasyIn.getInt();
    anotherArray[anotherArraySize] = input;
    anotherArraySize++;
    System.out.print ("Another number? Enter Y or N: ");
    goon = EasyIn.getChar();
    } while(goon = = 'y' | goon = = 'Y');
    }

  • Array of doubles filled by DLL contains weird values

    Hello everyone
    I am working on a DLL invocation which needs to resize and fill an array of doubles named 'values' (2nd to last parameter). I have defined the signature as follows:
    _declspec (dllexport) uint8_t readDoubleArray(uint8_t handle, LStrHandle lPath, int64_t startTime,
    int64_t endTime, DblArrHdl *values, LongArrHdl *timebase);
    Where DblArrHdl is
    typedef struct {
    int32_t dimSize;
    double doubles[1];
    } DblArr;
    typedef DblArr **DblArrHdl;
    In the invocation I read doubles from a database, and resize the double array as follows:
    int size = doubleArray.size();
    if (NumericArrayResize(0x0A, 1, (UHandle*)values, size) != noErr) {
    setLastError(MG_ERR_LABVIEW_ERROR, "Failed to allocate memory");
    return FALSE;
     I set the size, and copy the values:
    (**values)->dimSize = size;
    for (int i = 0; i < size; i++) {
    (**values)->doubles[i] = doubleArray[i];
    When I use the DbgPrintF to validate the values it gives me a value around 120000 which is correct. However, when returned by labview the array contains strange data, like 5.38564E-315. Here is print out of the 'values' array after it has been through the DLL:
    Here is how I wired it, ignore the clustering, it occurs in the array of values which exits the DLL call.
    I have no idea how this can be. I followed the examples on the site. I also tried the normal DSSetHandleSize, but it didn't change anything. Any idea what I did wrong?
    Thanks in advance,
    Vincent
    Message Edited by DaVince on 10-22-2008 10:10 AM
    Solved!
    Go to Solution.
    Attachments:
    doubleArrayWeird.png ‏7 KB
    wireUpDoubles.png ‏18 KB

    You're right, this not directly described...  
    First you should read how LabVIEW stores data in memory,
    then read about structure packing pragma,
    and finally take a look to C/C++ preprocessor reference,
    then you will get feeling how to solve this problem...
    Otherwise own DLLs used in LabVIEW code pretty rarely, and Double precision also not very often...
    The same trouble you may get with clusters, but here behaviour described:
    "...The memory layout of a cluster depends on the platform you are running. LabVIEW may add padding between cluster elements so that those elements are aligned to certain address boundaries. Address boundaries relate to the concept of natural alignment. A piece of data is aligned on its natural boundary if the address at which it begins is a multiple of the size of the data. For example, a 4-byte integer is aligned naturally if it begins at an address which is a multiple of four. Most compilers have an upper limit on this boundary at which the restriction is relaxed. For instance, an 8-byte integer may be aligned on a 4-byte boundary. For the platforms on which LabVIEW runs, the alignment constraints are as follows:
    (Windows) Data is aligned only to 1-byte boundaries.
    (Mac OS and Linux) Data is aligned naturally up to 4-byte boundaries.
    (VxWorks PowerPC) Data is aligned naturally up to 8-byte boundaries.
    On all platforms, clusters adopt the alignment of their most restrictively aligned element..."
    best regards and happy wiring...
    Andrey.
    Message Edited by Andrey Dmitriev on 10-23-2008 03:38 PM

  • Reading arrays of double from S7 with OPC & Datasocket

    Hi friends:
    We are developing an application with a S7-315-2DP PLC and a PC with a PCI1500PFB. We use the OPC server from Applicom. We read the data very quickly with the datasocket (arrays of boolean, arrays of doubles ...and so on, and a very big amount of data over 100 ms) but when we try to write arrays datasocket faield and we have to write item on item and the speed decrease. For intance, if we try to write doubles ( 50 items) the refresh period is over 5 seconds ( some times more since we launch the data and we read the same data on the PC). Perhaps we failed configuring the OPC but there isn´t many things to configure, perhaps the problem is the board configuration .. I don´t know.
    We
    try to find some examples that write an array of doubles on one time but..
    Thank you for yours answers.
    Javi

    Hi Javi,
    I'm not aware of any known issues writing to the Applicom OPC server. In LabVIEW there isn't anything special you need to configure to be able to write arrays of doubles through DataSocket. You can test this by using the DataSocket Server Manager, make a new member that is an array of doubles, and try reading and writing to that member. You may also want to check to make sure the data member the OPC server is expecting is an arry of doubles and not an array of singles or integers.

  • ODI-40406: Bytes are too big for array error

    Hello ,
    I am trying to load a flat file from a table. I am working on ODI 11G.
    Following are performed.
    Staging area different from SOurce is checked.
    IKM used is : IKM SQL to File Append
    Truncate is True
    No LKM is used.
    I am getting following error:
    java.lang.IllegalArgumentException: ODI-40406: Bytes are too big for array
    create header (RECORDTYPE,
    ASSIGN_NUM,
    USR_ID,
    START_TIME,
    JOBCODEID,
    AISLE_AREA_ID,
    PLANE_DATE,
    CLIENT_ID,
    CSTNUM,
    WH_ID)
    /*$$SNPS_START_KEYSNP$CRDWG_TABLESNP$CRTABLE_NAME=UNITIME TO RPSNP$CRLOAD_FILE=C:\Program Files\ODI_BI_APPS/UNITIME TO RP.txtSNP$CRFILE_FORMAT=FSNP$CRFILE_SEP_FIELD=0x0009SNP$CRFILE_SEP_LINE=0x000D0x000ASNP$CRFILE_FIRST_ROW=0SNP$CRFILE_ENC_FIELD=SNP$CRFILE_DEC_SEP=SNP$CRSNP$CRDWG_COLSNP

    There is a possibility of mismatch of datatype, that can cause the problem.
    Say in ODI model, you have defined a 'Date type' field to be stored as 'String' however at the time of mapping in 'Interface', no conversion happens (from date to string)  for this particular object. This causes the problem.
    The original query remains valid at DB side (fires for datetype) however fails while integrating (anticipating String which may be longer than defined in modelbecause of your NLS setting in DB). Therefore the best way would be to apply conversion for that particular field (in this case, use TO_CHAR(Date type,'Desired Date Format').

  • ODI-40406: Bytes are too big for array

    I am getting the following error: java.lang.IllegalArgumentException: ODI-40406: Bytes are too big for array
    I am trying to a file to file mapping and all of my columns match in size. Does anyone have any ideas what this problem could be? I am getting an error when it tries to perform an integration step while trying to create the target table. I am assuming it is something wrong with one of my datastores
    Edited by: 897642 on Nov 16, 2011 5:19 PM

    There is a possibility of mismatch of datatype, that can cause the problem.
    Say in ODI model, you have defined a 'Date type' field to be stored as 'String' however at the time of mapping in 'Interface', no conversion happens (from date to string)  for this particular object. This causes the problem.
    The original query remains valid at DB side (fires for datetype) however fails while integrating. Therefore the best way would be to apply conversion for that particular field (in this case, use TO_CHAR(Date type,'Desired Date Format').

  • I need to display an array of doubles on a table and I am loosing my percision

    Hello,
    I need to display an array of doubles on a table but I am losing my decimal precision. I am converting the array to a string in order to display it on the table with a number to decimal function. This is where I lose my precision since that control converts the double into an integer and then into the string. What control do I need to use instead of that in order to preserve my decimal precision all the way to the table? I have attached my VI. Thanks in advance!
    Gregory Osenbach, CLA
    Fluke
    Attachments:
    canalyzer_prototype_1.vi ‏52 KB

    Thank you both for the quick response. Its just the info I needed!
    Gregory Osenbach, CLA
    Fluke

  • Converting 1d array of double

    I have a 1-D array of double inside of a while loop.  I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0).  How should I go about doing this? 
    I cant link the array directly to the "less than or equal to 0" icon because it requires a single double.  Any help would be much appreciated.  Thanks. 
    Jerry

    qiora wrote:
    I cant link the array directly to the "less than or equal to 0" icon because it requires a single double. 
    Of course you can connect an array to "less than or equal to 0". The output will be a boolean array that you can feed into a "OR array elements" or "AND array elements" to get a true if either (1) at least one array element matches or (2) all elements match, respectively.
    qiora wrote:
    I would like to control the execution of the while loop based on one of the numeric values in that array (like I would stop the while loop if the numeric value in the array is less than or equal to 0). 
    If it should be based on one specific element (e.g. element(0) or element(5)), you need to get that element using "index array" and do the comparison.
    The implementation will depend on your exact requirement. Your question is quite ambiguous.
    LabVIEW Champion . Do more with less code and in less time .

  • How to write a 2-D Array of Doubles to a binary file in LabView 8.5?

    Okay, this is driving me nuts. I got a program that worked fine in LabView 8.0 but refused to write any data after my institute upgraded to LabView 8.5. The data is stored in a 2-D array of doubles and is supposed to be written to a binary file, that has been correctly opened and got a header written to it containing some meta-data of the measurement. But when the doubles from the array should be written to the file, nothing happens. All I get is an (except for the header) empty file of 786 kB. I found out that writing works if I convert the data from the array to singles right before wiring them to the "write to binary file" VI, but for several reasons I need the data as doubles. Can anyone help me? I've tried everything anyone has written here about writing to binary files and more.
    Remember, it worked perfectly fine with an older version of LabView. Any ideas?

    It is possible that you run into a known memory optimization bug.
    Try to place an "always copy" primitive as discussed here.
    Message Edited by altenbach on 11-18-2008 09:11 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Problem with reading numbers from file into double int array...

    Okay, this is a snippet of my code:
    public void readMap(String file){
            try {
                URL url = getClass().getResource(file);
                System.out.println(url.getPath());
                BufferedReader in = new BufferedReader(new FileReader(url.getPath()));
                String str;
                String[] temp;
                int j=0;
                while ((str = in.readLine()) != null) {
                    temp = str.split(",");
                    for(int i=0;i<temp.length;i++){
                        map[j] = java.lang.Integer.parseInt(temp[i]);
    j++
    in.close();
    } catch (IOException e) {
    System.out.println("Error: "+ e.toString());
    map[][] is a double int array. Now, the code is running through each line of the text file (with each line looking like this: 0,3,6,2,2,3,1,5,2,3,5,2), and I want to put the numbers into a corresponding double int array (which is where map[][] comes in). Now, this code WOULD work, except I need to set the sizes of each array before I start adding, but I don't know how to get the exact sizes.. how can I get around this issue?
    Message was edited by:
    maxfarrar

    You can do a two-dimensional ArrayList? That syntax
    you wrote didn't work.
    I tried doing:
    private ArrayList<ArrayList><Integer>> map;
    Your syntax is just wrong -- or, this forum software has bug in handling angle brackets.
    ArrayList<ArrayList<Integer>>...The closing angle bracket after the second 'ArrayList' is the one generated by the bug. Basically, it should be T<T<T2>> without spaces. Oh, for that matter:
    Arraylist<ArrayList<Integer>>

  • Working with word arrays in a game

    In my spelling game, I have arrays of words that is added to a text field one at a time (through a loop). They are also split into letters so that the player can click on a corresponding letter tile to copy the word. The active letter would be 100% visible (alpha setting )and the other letters would be set to 80%.
    Splitting each word works well it you just want the entire word broken into individual letters, BUT I want my game to be phonics based - so sometimes the sound in a word will have more than one letter e.g. for the word "elephant" the array would be: activeWord:Array = ["e","l","e","ph","a","nt"] and there would of cause be letter tiles with the sound -ph- and -nt- on them to click on too.
    I guess this is where arrays within arrays gets the job done? I have 10 words per level and 30 levels. I will break each word into it's sounds and hardcode each word like I did elephant above.
    How do I rewrite the loop below to accomodate the 10 word loop within a level. After each level I want a score to appear with the option to click next for the next level.
    public var  wordsL1:Array = ["elephant","has","of","off","on","not","got","in","is","it"];
                    private var tf:TextField;
                    public var letterArray:LetterArray;
                    public var tileTimer = new Timer(500,384);
                    // ***constructor code
                    public function WordArray(_tf:TextField)
                        tf = _tf;
                        nextWordF();
                        //**Run letter Tiles Start**//
                        letterArray = new LetterArray();
                        addChild(letterArray);
                        tileTimer.addEventListener(TimerEvent.TIMER, gameLoop);
                        tileTimer.start();
                        public function gameLoop(timerEvent:TimerEvent):void
                            trace("Tile Timer Started");
                            letterArray.gameLoop();
                        //**end**//   
                    function nextWordF():void
                        if(wordsL1.length>0)
                            activeWordF();
                            populateMyWordBox();
                        else
                                //quiz is complete
                        private function activeWordF():void
                            activeWordArray = wordsL1.shift().split("");
                             // this array needs to be passed to the class that checks which letters are clicked (or used in this class if that's where the clicked letters are handled) so the clicked letters                               can be compared to activeWordArray's elements.   
                            // when the clicked letters are completed for this word, call nextWordF().

    There's always a better way to do things but ultimately it comes down to if what you're doing works for your audience. If it does, the majority would say you did it correct. After you did it correctly you can spend time optimizing it however you like. If you get down to those specific questions be sure to provide a sample and some code that you think needs optimization and I'm sure we'll be able to help. You're welcome and good luck!

  • I want to cast Array to double[]

    I make an windowsForm class for draw graph.
    It has an input param
    public FormGraph(string title, string name1, Array data1)
    I need data of double[] type for draw graph. But I think users are want to input double[] or int[] ect...
    So I try to get data as Array type and cast it to double[].
    double[] series1 = (double[])data1;
    But it throw exception about fail to cast.
    How can I cast variable type of array to double[]?

    Another option is to combine Generics with this.
    You can use generics to allow the users to pass different types of data to a method, but type specific in a different way.
    public FormGraph<T>(string title, string name1, IEnumerable<T> data1)
    var series1 = data1.Select(x => Convert.ToDouble(x)).ToArray();
    Muthukrishnan Ramasamy
    net4.rmkrishnan.net
    Use only what you need, Reduce global warming

  • Converting array of Double Precision values to U16 for MODBUS

    Hello,
    I am trying to send over pressure and temperature information via the Input Register array in MODBUS TCP.  My question is, how to I properly send over an array of double precision values without loosing my data?
    For example, my array of data looks like:
    12.0001
    32.001
    0.00051234
    0.0014838
    1.02
    12.0232
    31.920
    Thanks so much.

    Thank you Ravens Fan for replying.
    I missed one extra point of data.  Below is what I'd like to send:
    12.0001
    32.001
    0.00051234
    0.0014838
    1.02
    12.0232
    31.920
    2046
    The array above is an array of double precision values.  I will convert that array to an array of single precision floating data to reduce data size.
    Since I have eight pieces of single precision floating point data now, I will need to write to 16 registers correct?  What is the best method to split up each piece of data into two consecutive registers?
    Attached is a Slave Send Data.VI that I want to send this data through.  The end goal is to have a Master PC (not using labview, but a MODBUS utility) to read my MODBUS TCP message from the "Slave Send Data.vi" 
    Thanks
    Attachments:
    Slave Send Data.vi ‏15 KB

  • 2 D array of doubles

    I was wondering how to pass a 2D array of doubles through JNI?
    I am doing this so that I can change the 2D array to a Variant that contains a 2D array of SAFEARRAYS of doubles. Then I am going to invoke a method of a 3rd party software through COM.

    It's possible, but I believe that you'll be crazy using such an array in JNI (dereferencing lots of things etc.) and the performance will be very poor.
    You can do the following thing:
    - Convert the 2D array into a 1D array in Java code. It's faster in the Java side than doing it using JNI (basically you'll need to use a lot of System.arraycopy() calls and some multiplications and additions).
    - Transfer the 1D array to the JNI code
    - Convert it back to the Variant or SAFEARRAY(double) 2D array - I believe that if you've done the things right you'll need only to do a straight memcpy in the JNI code.

  • Creating polygons with an array of doubles instead of ints

    Hi,
    I want to create a polygon using:
    Polygon u = new Polygon(xPoints, yPoints, numTs);
    my problem is that my x & y points are stored in double arrays not ints. Is there a way to create a polygon using double arrays instead of ints?
    cheers,
    elmicko

    or cast them as int. imaginr posX, posY, width and height are doubles.
    Rectangle rect = new Rectangle( (int)posX, (int)posY, (int)width,(int)height );or, with an array of doubles:
    Rectangle rect = new Rectangle( (int)array[0], (int)array[1], (int)array[2],(int)array[3] );

Maybe you are looking for