LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.dll and status bar

Don't you want to check the status more than once? It looks like you'll only check the status once at the moment. If you put the getStatus call in a while loop, looping while counter < 100, does it change anything?
0 Kudos
Message 11 of 22
(1,704 Views)
C Code:
//////////////////////////////////////////////////////////////////////////////
int OnDeviceProgram(void){
DWORD iBytesWritten;
DWORD iBytesRead;

count = 0;
while (curr->next) {                         // Move thru whole prepared package link list
          curr=curr->next;

          something = WriteFile(hCom,pData,134,&iBytesWritten,NULL);
          do {
    (ReadFile(hCom,&ch,sizeof(ch),&iBytesRead,NULL));// Wait for receiving
    ch[1]= '\0';
 
          }while (ch[0]!=ACKNOWLEDGE);              // Wait for acknowledge character
        count = count + 1;                                        //global increments
     }

  return 1;
}
 
////////////////////////////////////////////////////////////////////////////////////
_declspec(dllexport) int Status(void){
 return count;
}
0 Kudos
Message 12 of 22
(1,701 Views)
Nice, getting closer...
The way its written now the while loop will take almost no time to complete because it can make 100 calls very very fast.  You need a wait in the loop.  Also 100 might not be enough.  You cant use a constant here as different runs will take different amounts to complete.  Instead of a constant 100 iterations replace it with another function call.
 
In your main loop of OnDeviceProgram() first iterate completely through the list once to see how long it is IE:
 
max=0;
while (curr->next) {                         // Move thru whole prepared package link list
          curr=curr->next;
          max=max+1;
}
 
Use this as the stopping point for the while loop and reconfigure it as picture:
(of course you will also then need a "getmaxvalue" function or something).  And I did not change the picture to reflect the new external call...

Message Edited by Chaos on 08-23-2005 02:21 PM

0 Kudos
Message 13 of 22
(1,694 Views)
The code that labview runs to see the status is only run once. Labview needs to start the download and asynchronously execute a function that returns the status of the download multiple times until count == 100. If the dll does this, labview still only sees it once, which will not give you the effect of a status bar.
0 Kudos
Message 14 of 22
(1,691 Views)
Genius, pure genuis. Thanks a lot chaos and whatsthis, your ideas and assistance pushed me in the right direction. Now my status bar works.

Message Edited by Newguy100 on 08-23-2005 03:02 PM

0 Kudos
Message 15 of 22
(1,686 Views)
I am using a status bar again to dump a large file up to almost 300000 bytes. (Required). I used the same status bar method as before but this time it only does it once. Here is an attachment. They are nearly identical. I used the same C function. Can anybody explain the difference.
0 Kudos
Message 16 of 22
(1,670 Views)
DLL:
Global: FileSize, Current;
 
Download (filename)
{
           FileSize=GetFileSize(filename);
           do {
                     
           } while (! all downloaded)
}

Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 17 of 22
(1,663 Views)
prev. message is not complete. My baby plays with my notebook 🙂
 
I developed the status bar like here (pseudocode). VI code looks like yours.

DLL:
 

// Global
 
static long filesize, current;
static unsigned char data[MAXBYTES];
static int break_flag
 
Download (filename)
{
         filesize <- GetFileSize (filename);
         GetDataFromFile (filename, data);
 
         current=0; break_flag=0;
         do {
              errorcode=download_to_device (data[], numbytes))
              current+=numbytes;
/* Get a chance to other processes  (if it is possible) */
              ProcessSystemEvents();
         } while (download not complete && ! break_flag && !errorcode);
 
         return errorcode;
}
 
int GetStatus()
{
    return current / filesize * 100%;
}
 
void ControlDownload (int flag)
{
    break_flag=flag;
}

Message Edited by EVS on 08-27-2005 03:03 AM


Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
0 Kudos
Message 18 of 22
(1,663 Views)
I was able to get my status bar working along with my download function, but the thing is that in Labview ver. 6.1, it doesn't react the same way as it is in version 7.1. In 7.1, the status bar actually moves to help me see that the dowload is in progress, but in version 6.1 it remains stationary until the end of the download. How do I make it work like version 7.1.

Message Edited by Newguy100 on 09-02-2005 03:05 PM

0 Kudos
Message 19 of 22
(1,653 Views)
Are there any other alternatives?
0 Kudos
Message 20 of 22
(1,645 Views)