04-18-2019 09:20 AM
Hello everybody
I want to use progress bar for my progrmm. my program consists of 3 parts. I want to divide the progressbar into 3 parts and at the end of each part also the names of part in Progressbar will be shown. how should I write the code.
many thanks
Sub Button1_EventClick (ByRef This)
Call Data.Root.Clear() 'Part 1 open Data
Call DataFileLoad(EditBox1.Text)
Dim oExcel,oWBook,oSheet,K,L,oGroup,lCol,oChn,DisplayType,Sfile,Zbool,Dbool,Ebool,EIbool,Ibool,Vbool,Wbool,N,Vsize,oMyGrp,oMyChn,s,Gz,Cz,Chn,Nbool,myUnit,intLoop
If Editbox3.Text="5" Then 'Part2 Add TimeChannel
For Gz = 1 To Data.Root.ChannelGroups.Count
Set oGroup = Data.Root.ChannelGroups(GZ)
For Cz = 1 To oGroup.Channels.Count
Set Chn = oGroup.Channels(Cz)
If ((Chn.Name= "Veh_Spd") and (Nbool=True)) then
Call ChnResampleFreqBased("[" & Gz & "]/time","[" & Gz & "]/Veh_Spd","[" & Gz & "]/Veh_Spd",5,"Automatic",0,0) ' Kanal "Veh_Spd" wird mit 5Hz hier resmpeliert.
Set oMyGrp = Data.Root.ChannelGroups.Add("ZeitGroup",1)
Set oMyChn = oMyGrp.Channels.Add("Time", DataTypeFloat64)
Set MyUnit = oMyChn.Properties("unit_string")
myUnit.Value = "s"
oMyChn(1)=0
For s = 1 to Chn.Size-1
oMyChn(1)=(0)
oMyChn(s+1) = CDbl(s*2/10)
Next
Nbool=false
End if
Next
Next
Else
For Gz = 1 To Data.Root.ChannelGroups.Count
Set oGroup = Data.Root.ChannelGroups(GZ)
For Cz = 1 To oGroup.Channels.Count
Set Chn = oGroup.Channels(Cz)
If ((Chn.Name= "Veh_Spd") and (Nbool=True)) then
Call ChnResampleFreqBased("[" & Gz & "]/time","[" & Gz & "]/Veh_Spd","[" & Gz & "]/Veh_Spd",10,"Automatic",0,0) ' Kanal "Veh_Spd" wird mit 10 Hz hier resmpeliert.
Set oMyGrp = Data.Root.ChannelGroups.Add("ZeitGroup",1)
Set oMyChn = oMyGrp.Channels.Add("Time", DataTypeFloat64)
Set MyUnit = oMyChn.Properties("unit_string")
myUnit.Value = "s"
oMyChn(1)=0
For s = 1 to Chn.Size-1
oMyChn(1)=(0)
oMyChn(s+1) = CDbl(s/10)
Next
Nbool=false
End if
Next
Next
End if
lCol = 1
For K = 1 To Data.Root.ChannelGroups.Count 'Part3 Resampling
Set oGroup = Data.Root.ChannelGroups(K)
For L = 1 To oGroup.Channels.Count
Set oChn = oGroup.Channels(L)
if oChn.Name = "Eng_Spd" or oChn.Name = "Eng_Trq" or oChn.Name = "Eng_Trq_indicated" or oChn.Name = "InjCrv_qSetUnBal" or oChn.Name ="Veh_Spd" or oChn.Name = "WhlSpdFrontRight" or oChn.Name = "WhlRPM_FR_ST3"then
if Editbox3.Text="5" then
if oChn.Name = "Eng_Spd" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/Eng_Spd","[" & K & "]/Eng_Spd",5,"Automatic",0,0)
Elseif oChn.Name = "Eng_Trq" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/Eng_Trq","[" & K & "]/Eng_Trq",5,"Automatic",0,0)
Elseif oChn.Name = "Eng_Trq_indicated" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/Eng_Trq_indicated","[" & K & "]/Eng_Trq_indicated",5,"Automatic",0,0)
Elseif oChn.Name = "InjCrv_qSetUnBal" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/InjCrv_qSetUnBal","[" & K & "]/InjCrv_qSetUnBal",5,"Automatic",0,0)
Elseif oChn.Name = "WhlSpdFrontRight" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/WhlSpdFrontRight","[" & K & "]/WhlSpdFrontRight",5,"Automatic",0,0)
Elseif oChn.Name = "WhlRPM_FR_ST3" then
Call ChnResampleFreqBased("[" & K & "]/time","[" & K & "]/WhlRPM_FR_ST3","[" & K & "]/WhlRPM_FR_ST3",5,"Automatic",0,0)
Elseif oChn.Name = "Veh_Spd" then
' Veh_Spd wurde resampliert.
End if
End if
end if
end sub
05-03-2019 04:56 AM
Hi FazelSCH,
You can use:
LoopInit() and LoopDeInit()
to Show/Hide the Progressbar in the DIAdem-Statusbar.
With LoopInc(50) you can set the value of the bar to a value from 1-100.
You can use MsgLineDisp("Hello World!") to display a message in the Statusbar. It won't be displayed on the Progressbar, but on the left end of the statusbar. Displaying a string directly on the Progressbar is not supported by DIAdem. Also be aware, that other functions (such as the Pause()-Function) may overwrite the text in the Statusbar. You should test it with your code. If any function overwrite the text in the statusbar you can simply set it back to "Task 1 executing ..." after that function.
Find attached a small example of a dialog that uses these functions.
Hope this helps!
Cheers,
Jan Göbel
Staff Technical Support Engineer
05-03-2019 05:53 AM
Thank you JGoebel
05-03-2019 06:02 AM
I want to use your example of a Dialog. it happens an error and i can not open file.
can you help me?
05-03-2019 06:16 AM
Hi FazelSCH,
the file works fine on my machine, can you open the VBS?
Maye its because of different DIAdem-Version, I used 2018 to create the dialog.
To make it fast, here are the scripts:
launcher.vbs------------------------------------
Option Explicit
Call SUDdlgShow("Dlg1", "dialog.SUD")
dialog.sud----------------------------------------
Option Explicit
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'IMPORTANT: Currently the Task-Names will not display in the statusbar. This is, because the "Pause()"-Funtion overwrites the value and displays the number of seconds to wait instead
'If you replace the Pause functions by your code the Strings should be displayed if no other functions overwrite the statusbar message
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub Button1_EventClick(ByRef This) 'Erzeugter Event-Handler
Dim numOfTasks
numOfTasks = 3
Call LoopInit() 'Show Progressbar
Call MsgLineDisp("Task1 executing ...") 'display current Task name
Call LoopInc(1/numOfTasks*100) 'increment progressbar
Call Pause(2) 'Task1 time to execute
Call MsgLineDisp("Task2 executing ...") 'display current Task name
Call LoopInc(2/numOfTasks*100) 'increment progressbar
Call Pause(1) 'Task2 time to execute
Call MsgLineDisp("Task3 executing ...") 'display current Task name
Call LoopInc(3/numOfTasks*100) 'increment progressbar
Call Pause(1) 'Task3 time to execute
Call LoopDeInit() 'Hide Progressbar
End Sub
I hope with this you can build the example yourself.
Cheers,
Jan Göbel
Staff Technical Support Engineer
National Instruments
05-03-2019 06:42 AM
Now I've got some but there is still little ptoblem with Call MsgLineDisp ("Task1 executing ..."). this does not work for me, for example I write Call MsgLineDisp ("Step 1/3") but I do not see this message in Status bar
05-03-2019 06:58 AM
Hi FazelSCH,
I guess what you see is what I described in this comment:
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'IMPORTANT: Currently the Task-Names will not display in the statusbar. This is, because the "Pause()"-Funtion overwrites the value and displays the number of seconds to wait instead
'If you replace the Pause functions by your code the Strings should be displayed if no other functions overwrite the statusbar message
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The Status-Message is not only updated by MsgLineDisp, but also by several functions in DIAdem. In the example the "Pause()" overwrites the User-Message rightaway. If you remove the Pause() you should see "Task3 executing ...", but not the first two, since they will be displayed very fast.
If you replace the Pause() with your code (that might take a few seconds) it should work!
Cheers,
Jan Göbel
Stapp Technical Support Engineer
National Instruments
05-03-2019 07:13 AM
thank you for your explanation
05-03-2019 07:25 AM
Sure, I hope it works now. If it does, feel free to mark my fist Reply as solution for future users to find this faster.
Have a good day!
Jan Göbel
Staff Technical Support Engineer
National Instruments
05-03-2019 07:41 AM
Thank you, it works perfect