12-09-2009 03:34 AM
I am new to DIADEM. So, I created a gui which loads a video and a curve into DIAdem and is supposed to play those sync, but neither the curve nor the video will play. I added a button to test the play-function as described in the DIAdem-help, but it won't play either.
Sub Button1_EventClick() Dim This : Set This = Button1 Dim oMySheet: Set oMySheet = View.ActiveSheet oMySheet.ActiveArea.DisplayObjType = "Video" oMySheet.ActiveArea.DisplayObj.FileName = "D:\PathToMyVideo\myvideo.avi" oMySheet.Cursor.XRangeMode = "automatic" Call oMySheet.Cursor.GotoStart Call WndOpen("VIEW") Call oMySheet.Cursor.Play(FALSE) End Sub
What else do I have to consider before I can start the cursor from a script?
Solved! Go to Solution.
12-09-2009 09:57 AM
Hi LucasG,
When I run your posted code in DIAdem SCRIPT, it seems to work fine with an example AVI file and data file in DIAdem 11.1. What version of DIAdem are you using? I don't see anything in your code that shows the curve you loaded-- do you see the data curve on your computer?
It could be that the time synchronization between your data curve and the video file needs to be tweaked in VIEW. What is the first value and the last value of the Time channel of your data curve? How many frames are in your video file and what is the frame rate?
Are you able to post your video and data files for me to play with?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-10-2009 02:15 AM - edited 12-10-2009 02:19 AM
Hello Brad,
thank you very much for your response. I am running DIAdem 11.1.0f3806. I am trying to descibe my setup a little more in detail. I have a gui with a button, which is supposed to start the Video and the cursor on my curve, but neither one is moving. They are both loaded into DIAdem and visible. If I press the play-button in DIAdem itself, they both play perfectly in sync. To increase the usabillity of my script for my co-workers, who don't use DIAdem in their work, I would like to make everything accessible from my little gui that is necessary for them.
I reduced my gui to demonstrate my problem. It only has to buttons called "Open" and "Start". This is how my code from the button "Open" to load the curve and video into the DIAdem view looks like.
Sub Open_EventClick()
Dim This : Set This = Open
Call DataFileLoad("path of my tdm file")
Call View.Sheets.RemoveAll()
Dim oMySheet: Set oMySheet = View.Sheets.Add("NewSheet")
'Load curve
Dim oCurveArea: Set oCurveArea = oMySheet.ActiveArea
oCurveArea.DisplayObjType = "CurveChart2D"
Call oCurveArea.DisplayObj.Curves.Add(1,3)
Call oCurveArea.DisplayObj.LegendItems.Add("Name")
'...some code to locate the path of the video etc.
'load video from area
Dim oVideoArea: Set oVideoArea = oMySheet.ActiveArea.SplitTop("VideoArea",0.5)
oVideoArea.DisplayObjType = "Video"
oVideoArea.DisplayObj.FileName = videoPath
End Sub
After this, everything is loaded nicely into my view of DIAdem and if I press "play" inside of DIAdem the video plays. Now I would like to start the video out of my gui and I have the "Start" button to achieve that.
Sub Start_EventClick()
Dim This : Set This = Start
Dim oMySheet
Set oMySheet = View.ActiveSheet
oMySheet.Areas(1).Active = True
oMySheet.Cursor.XRangeMode = "automatic"
Call oMySheet.Cursor.GotoStart
Call oMySheet.Cursor.Play(False)
End Sub
The video will start to play a split second, the first time I press the "Start"-button, but then won't do anything.
I am hesitant to post my data. It is quiet a large file and I am not sure what our workpolicy on posting our data online is.
EDIT: To clarify, the code in my first example won't work either. I assume, that there must be something fundemantally wrong in my setup.
12-10-2009 11:13 AM
Hi Lucas,
I don't think your data is important to debugging this problem. It's also easier to debug an issue like this in SCRIPT than in a SUDialog, so I transplanted your code and wired it up to a standard example data set and video that ships with DIAdem (Sawstopper). You didn't answer my questions about the synchronization details, yet my guess is that this is exactly the issue. In the attached example your Subroutines each run exactly twice-- the first time without setting the synchronization details (FrameRate, StartTime, Speed), the second time setting them correctly. In the first case the video finishes way too early, while in the second case the video runs the full time that the data does. I also added a StopCursor() Subroutine to make a quick end to the program cleaner.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-11-2009 02:54 AM
Hi Brad,
Thank you very much for your detailed response. But it seems like my problem stems from the gui. When I run my data and video with your script it works fine, so I copied your script into my gui-functions and I get the same problem. It shows maybe one frame for a split second and then stops. My complete gui-file Test.SUD looks as follows now, which is basically just copied from your example:
'(Declarations) '------------------------------------------------------------------------------- '-- SUD script file '-- Created on '-- Author: '-- Comment: '------------------------------------------------------------------------------- Option Explicit 'Forces the explicit declaration of all the variables in a script. 'Note: In the Declarations area you can program auxiliary variables and functions that you can use in the entire dialog box. Sub ShowView(VideoPath, FrameRate, StartTime, Speed) Call View.Sheets.RemoveAll() Dim oMySheet: Set oMySheet = View.Sheets.Add("NewSheet") 'Load curve into VIEW area Dim oCurveArea: Set oCurveArea = oMySheet.ActiveArea oCurveArea.DisplayObjType = "CurveChart2D" Call oCurveArea.DisplayObj.Curves.Add(1,3) Call oCurveArea.DisplayObj.LegendItems.Add("Name") 'load video into new VIEW area Dim oVideoArea: Set oVideoArea = oMySheet.ActiveArea.SplitTop("VideoArea", 0.5) oVideoArea.DisplayObjType = "Video" oVideoArea.DisplayObj.FileName = VideoPath IF FrameRate <> "" THEN oVideoArea.DisplayObj.FrameRate = FrameRate IF StartTime <> "" THEN oVideoArea.DisplayObj.StartTime = StartTime IF Speed <> "" THEN oMySheet.Cursor.Speed = Speed Call WndShow("VIEW") End Sub ' ShowView() Sub RunCursor() Dim oMySheet: Set oMySheet = View.ActiveSheet oMySheet.Areas(1).Active = True oMySheet.Cursor.XRangeMode = "automatic" oMySheet.Cursor.Type = "Crosshair" oMySheet.Cursor.Mode = "GraphPoints" Call oMySheet.Cursor.GotoStart Call oMySheet.Cursor.Play(False) End Sub ' RunCursor() Sub StopCursor() Dim oMySheet: Set oMySheet = View.ActiveSheet Call oMySheet.Cursor.Stop End Sub ' StopCursor() 'End of (Declarations) Sub StartVideo_EventClick() Dim This : Set This = StartVideo Dim DataPath, VideoPath DataPath = AutoActPath & "VD4.5_complete.TDM" VideoPath = AutoActPath & "VD4-5.avi" Call DataDelAll Call DataFileLoad(DataPath) Call ShowView(VideoPath, "", "", "") Call RunCursor() MsgBox "Cursor Running withOUT synch details" Call ShowView(VideoPath, 1000, 0, 0.01) ' -0.052 Call RunCursor() MsgBox "Cursor Running WITH synch details" Call StopCursor() End Sub
And this is how I call the gui from a script:
Option Explicit 'Forces the explicit declaration of all the variables in a script. Dim path Call WndShow("VIEW","MAXIMIZE") 'Call View.Sheets("myview").Activate path = AutoActPath & "Test.SUD" Call SudDlgShow("TestDlg", path)
So my gui only has one button to start the video at this point. I just started using DIAdem and I assume something very basic might go wrong here.
Lucas
12-11-2009 09:38 PM
Hey Lucas,
Would you please post your *.SUD file that has that code in it? That would make it easier for me to track down what's going on on your end.
Thanks,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-14-2009 01:13 AM
Hello Brad,
sorry for my slow response. I had a busy weekend. I am attaching my Test.SUD file. I hope this will be helpful. Thanks a lot for the help you are providing.
Lucas
12-14-2009 10:25 AM
Hi Lucas,
Thank you for the SUDialog and script files-- with them I was able to immediately reproduce the effect you've been describing. I found that the problem disappears when I call your SUDialog as a non-modal dialog instead of as a regular modal SUDialog. I think it's entirely possible that you will prefer having a non-modal SUDialog, so I am attaching edited SUD and VBS files to call the dialog so that it persists even after the calling VBScript file has ended.
If you decide that you need a modal SUDialog, I will continue to investigate this issue and see if we can avoid the problem with a modal dialog.
Cheers,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-15-2009 01:10 AM
Hi Brad,
Thank you very much. This is perfect. In fact a non-modal dialog is preferable for my use. I appreciate you taking the time.
Lucas