PDA

View Full Version : Viewport DDE or DLL data or .NET object



henry99
07-02-2009, 01:01 AM
Is it possible to get the data to stream out of Viewport via DDE or a DLL call or .Net object?

The best would be a .NET object which can be imported into Matlab or C# or VB easily.

I would imagine the following format would be ideal:
Object.GetVariableNames -> List of Strings
Object.GetVariableValue("VariableName") -> Double Array
Object.SetVariableValue("VariableName") -> Double Array
Object.Connect(speed)
Object.Disconnect(speed)

Then data sharing can be much easier to implement.

I could write this myself but why bother if someone better than me like Hanna can do it quickly? :)

Also how does Viewport handle arrays?

henry99
07-02-2009, 01:07 AM
Even sweeter would to add the following events:

Object.DataChangedEvent

with the following support properties:

Object.ChangedEvent("VariableName",Threshold)
Object.ChangedEventEnable("VariableName")
Object.ChangedEventDisable("VariableName")

That would be the bomb because then I could use drop the object into my C# program and write a few callbacks when the data changed. Otherwise I guess I could just poll it in a timer .net component but the response would not be as good.

CounterRotatingProps
07-02-2009, 03:17 AM
henry,

do you think callbacks would always be faster? I mean flag/semaphore then burst might be fast too.

Just curious, even though you'd like this in viewport, have you messed around with propellent.dll ?



Hanno,

if you happen to read this, I'd like to second henry's very good suggestions - this would open up some very interesting instrumentation and applications independent of viewport addons.

cheers,
Howard

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Post Edited (CounterRotatingProps) : 7/1/2009 8:23:12 PM GMT

henry99
07-02-2009, 03:38 AM
In C# .NET, callbacks are easier to program.

If you check a flag, you'd need to setup a timer object with an expiry and that would bog things down.

I'm not that familiar with semaphores.

I think callbacks are much more intuitive also. For example, when the data changes past the threshold, the callback is triggered and I do some processing. Like if the voltage changes or the encoder value changes,

The fastest solution would probably be DMA like on the NI PCI cards but I hardly use it because of the added complexity. The key is to make it as easy as possible. A limited selection of methods and variables to get data in and out is better than 100 functions people will never use.

The code will be easy to write, you have one cog that sends out serial at the max speed and you can use the serial .net object from the .NET library to translate it to callbacks/update variables etc.

Again I'm sort of lazy and would rather pay someone $100 for an off the shelf product than spend time designing it myself.

Currently, I often have my matlab or c# program read in and parse serial data. However, this is definitely not as nice as a packaged .Net component that takes care of all those details that I take short cuts around.

henry99
07-02-2009, 03:41 AM
Also if someone is willing to write the propeller code, I can write the .NET component if we decide on a protocol.

It'd be very nice to add some basic data compression to get the fastest data stream over the USB as possible.

I'd be willing to donate my time to the open source project if someone was willing to write the prop ASM (which I haven't learned yet as I just use spin).

Hanno
07-02-2009, 03:43 AM
Hi,
Great inspiration Howard and excellent architecture Henry. This makes lots of sense and will make it into ViewPort soon- exactly as Henry has specified. I just have to finish up something that is so exciting I stayed up till 3am last night- will be out soon and rock your world!
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

henry99
07-02-2009, 03:49 AM
Excellent - thanks Hanno :)

Once I have a fast way to get data into Matlab or C#, there will be a lot of cool applications for sure! I would totally throw away most of my NI data cards.

The matlab image processing functions are much more advanced. Also you can write CUDA applications for faster processing.

You can buy an Asus EEE 900 netbook with Windows and Atom 1.6ghz processor for $150 on sale as the PC!

Hanno: I hope it comes as an easy to use .Net component like the .Net Serial component!

henry99
07-02-2009, 03:59 AM
Just a suggestion, I suggest the following changes to my original idea:

Make the event:

Object.DataChangedEvent

with the following support properties:

Object.ChangedEvent("VariableName",Threshold)
where Threshold>0 means the event is enabled, otherwise it is disabled (no need for enable/disable methods)

Object.ChangedVariables(List of Strings with names of variables that have changed so that you don't need to read all the variables in)

Also modify or overload:

Object.GetVariableValue("VariableName") -> Double Array + Long Integer Timestamp (always good to know what time the sample was at)

CounterRotatingProps
07-02-2009, 04:06 AM
Oh cool !

Yes, do it as a .NET serial component by all means --- they're easy across all the languages.

> CUDA

Very interesting, henry, CUDA in many ways is like the opposite end of the spectrum of dev. platforms on micros. (Hard to imagine a Propeller running more than 8 "threads" much less 12,000!) I like CUDA a lot --- if I wasn't stuck on a boring set of projects right now, I'd be codin' cuda ;0


cheers
-Howard

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

henry99
07-02-2009, 04:14 AM
CUDA is sweet especially on image processing when you have lots of parallel process data. My Quadro FX has 240 cores and 4gb of very fast memory!

I tried Jacket from Accelereyes for matlab and you only need very minimal changes.

Most of my data acquistion needs are pretty simple and it's much easier to write advanced algorithms in matlab than prop asm so can't wait for the .NET component :)

henry99
07-02-2009, 04:19 AM
Also not sure if Viewport does on the fly data compression, thresholding and buffering currently but all 3 will increase the throughput dramatically.

Hanno
07-02-2009, 04:22 AM
Thanks Henry for refining the api- I'll get to it in a couple days- so feel free to continue improving it, better now than when I'm finished :)
Yes, CUDA is awesome- and already built into a prototype of a ViewPort feature. See my google tech talk for details- basically I integrated the Nvidia PhysX physics simulation package with ViewPort. The idea is that people can model their robots and environments within the simulated world, controlled by spin running on the propeller, all managed by ViewPort. It's like a "dreamworld"- the spin program gets sensor readings from the simulated world and controls actuators that act on the simulated world. Then, when everything works, you just replace the simulated sensors/actuators with real ones and you're robot is set! It's working- just have to get time to productize it..
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

CounterRotatingProps
07-02-2009, 04:26 AM
Viewport can do 2Mbps with the right setup.

I think someone also wrote a OCX wrapper (yuk!) for the propellent dll, but I've not tried it. (Because it would probably hang.)

[EDIT - Hanno, you're a genius ! ]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

henry99
07-02-2009, 04:42 AM
The FTDI chip does 3mbps I think. USB 2 is supposed to support 12mbps I think. So 2mbps isn't that fast.

Honestly I don't know what I'd be streaming that much data besides video or audio (which is much easier using a usb webcam or audio card).

Pairing with those low cost netbooks is great. For 150 you get a tiny notebook with a battery to power the prop from the usb port and can do all the processing.

I've also used the the Intel D945GCLF2D mini-ITX Atom 2x1.6Ghz to great success which is < $100.

Hanno
07-02-2009, 05:02 AM
Yes, the FTDI chip does 3mbps. It's pretty straightforward to bit bang from the Propeller at 2 or 3mbps. What's hard is making sure that the data arrives through all the buffers and protocols in a windows environment. ViewPort's 2mbps transfer rate let's it quickly update the display for the instruments, measure many variables at high time resolution, stream vision processed video from the Propeller, and transfer the entire 32kb of memory at every whenever you step with the debugger.
Yes, low cost netbooks are awesome with the Propeller- particularly with ViewPort.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

henry99
07-02-2009, 05:20 AM
Those usb cameras can run at 640*480*30 fps at 8bit greyscale=9mbps. Sustained data transfer at 12mbps doesn't seem like a problem for my computer when downloading from the internet and file copies from HD to HD probably are on the order of 1000mbps without any data loss.

Maybe it would require special purpose drivers/code but it certainly seems possible without any special PC mods.

Data packets should be time stamped with the counter clk count from the propeller then transferred asynch to the PC.

Hanno
07-02-2009, 05:48 AM
Completely agree with you that sending a couple mbps to a pc should be non-trivial. However, poor support for fast serial communication in windows, buggy ftdi drivers, and lack of hardware handshaking makes it a big pain. It's much easier to get two Propeller chips to talk to each other- there it's easy to understand what's going on.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
07-13-2009, 04:46 AM
I'm making progress on building a DDE server into ViewPort. As Henry and Howard discussed above, this will make it much easier for other applications to interact with the Propeller.

As a teaser, to continually get the current value of a spin variable called "temperature" into your excel spreadsheet you just need to type this into a cell:
"=viewport|getvalue!temperature"

Isn't that beautiful?
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Mike Huselton
07-13-2009, 06:22 AM
Hanno,

You da man!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

henry99
07-18-2009, 09:32 AM
Hi Hanno,
Thanks for your updates.

Sorry for the delay as I've been traveling.

DDE might work ok but I think the .NET component is still the way to go.

Since the FTDI chip just emulates a serial port and the serial output commands are already easily communicated in C#, VB, Matlab, etc, making the interface easy to use for programmers is def the way to go.

Hanno: let me know if you need any clarifications for my suggestions

Hanno
07-18-2009, 10:27 AM
I've done some testing with my DDE server and it easily passes even the 24kByte video buffer to DDE clients without any problems. So, even though DDE is ancient, I believe it's the best communication tool for this application. It's just so easy to integrate into things like Excel! I'll provide a number of interfaces to retrieve the various arrays and variables that can be shared as well as metadata.
If you really want to program in .net, check out ViewPort's developer's kit: http://mydancebot.com/viewport/dkhelp.php
Once the DDE communication is set up, it should be easy to use that to integrate into pretty much anything.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
07-18-2009, 10:34 AM
One more thing... Yes, the FTDI chip provides a serial interface. And yes, doing very basic communication at slow datarates isn't too bad with all the baggage that programming on modern OS entails. Supporting high datarates with all of ViewPort's functionality was very difficult and took me a long time. Here some buzzwords: packets, markers, escape sequence, variable packetsize, interleaved data, markers, magic bytes, full-duplex....

A dde client by contrast is trivial. To get the live value of a spin variable into excel just type this into a cell:
"=viewport|getvalue!temperature"
Do this for whatever variables you want to calculate/graph!
Coming soon....
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

henry99
07-18-2009, 02:40 PM
DDE may be trivial in Excel but it's a pain in something modern like C#, VB or matlab when .net is available. Maybe you can make some C#, VB and Matlab examples available when you have the chance. Then again, if a .Net component were supplied, no such example would be necessary as it'd be self explanatory.

I'm sure quite a bit of work went into Viewport, I'm not doubting that and that's why I didn't want to tackle writing a .Net component myself.

However, again a drop in .Net component makes it much better to use and if one isn't available, I can just use the drop in microsoft .Net serial port and use standard serial comm to send data back and forth.

Hanno, maybe you would consider writing the .net component and selling it as a different product when you have the chance. Certainly you already worked out the communication protocol and data transfer so that's the hard part.

Hanno
07-19-2009, 03:12 AM
Henry,
Working on it!
Next release will have a built-in DDE server, a sample Excel spreadsheet which shows how to do engine performance tuning, a VB.net sample client, and a C# sample project.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Mike Huselton
07-19-2009, 06:31 AM
Hey, Hanno! It's been too long...

DDE is just fine for data transfers - Dynamic Data Exchange is, after all, what we are talking about.
C# or VB wrappers add little, if any, utility. Your idea to post some example code is all that the average person needs.

Great Job! Say hey to the folks...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

henry99
07-19-2009, 11:11 AM
IMHO I disagree with James. A .net component makes programming much easier over DDE.

I used to know how to use DDE in C++ but I have no idea how to do it in now and I don't think it's event driven so you need to parse individually DDE messages.

Often times you want to update the display when the variable changes.

How are you going to know when the variable changes? In C# with a .Net control, you just write the callback function.

In DDE I'm pretty sure you need poll for a DDE event or write a special DDE callback and parse it then stick all your code into the one massive callback.

Polling works fine in single thread programs but not for windows.

Without callback support, I'd just stick with the included free microsoft .Net serial component.

Maybe I should write it myself :)

Hanno
07-20-2009, 02:28 AM
Thanks jmh and henry for the good discussion. I'll do my best to make everyone happy. The C#/VB samples will show how to program using events- making it easy to know when things change.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
07-24-2009, 05:56 AM
I've integrated a DDE server and client into ViewPort that supports the following commands:



dde.init("vp","system"): connects to ViewPort DDE server

dde.execute("connect"): connects to Propeller

dde.execute("disconnect"): disconnects Propeller- releases com port

dde.request("list"): returns a list of variables whose values can be read/written

dde.request("detail(var)"): returns information about a variable, for example,
detail("io") returns "io|array[400]|base 16"

dde.poke("var",value): sets a Propeller variable to a value, for example, poke(servo,1500)
sets the servo variable to a value of 1500.

dde.execute("link(var,ddecommand)"): links a Propeller variable to a DDE variable, for
example, link(servo,excel|sheet1.xls!r1c1) links the servo variable on the Propeller to the
contents of the top, left cell of sheet1.xls in Excel. When you change that cell in Excel, the
servo variable will change on your Propeller- potentially moving a servo.

dde.request(varlist): returns a list of comma separated values for the list of variables you
specified. For example, vp|get|temp_wind_time can return "20,15,8:05"

dde.StartAdvise(varlist): your dde client will be advised 10 times/second with a list of comma
separated values for the list of variables you specified. For example, a varlist of
vp|get|temp_wind_time will result in events with a parameter of "20,15,8:05"

dde.StartAdvise(trigger): sets a trigger. When the condition is valid, the trigger result is set
to the values of the variables in the varlist. For example, StartAdvise("rise!temp_20_temp_time")
will set up a new trigger that fires when the Propeller variable "temp" rises above 20. The
application will get notified with a comma-delimmeted string of values- for example, "21,90,8:05".



Variables that you can read/write/advise/trigger include the video and io arrays, as well as the configuration strings. I've included support for both synchronous read/write, as well as the "advise" event based callback feature for read/write. Here's some Visual Basic code that works for Excel macros- I'll post a C#.net example later.




Dim a, b, channel As Integer
Sub StartVP()
'Start DDE connection to ViewPort
channel = DDEInitiate("vp", "system")
'Connect ViewPort to Propeller
DDEExecute channel, "connect"
'Set cell to list of names of Propeller variables
ActiveSheet.Cells(5, 5).Value = DDERequest(channel, "list")
'Set cell to detail of variable "a"
ActiveSheet.Cells(3, 2).Value = DDERequest(channel, "detail(a)")
'Set servo variable to value of cell
DDEPoke channel, "servo", Sheets("Sheet1").Range("A1")
'Link servo variable to cell- when the cell changes, the variable on the Propeller will be updated
DDEExecute channel, "link(servo,excel|sheet1.xls!r1c1)]"
'Read temp variable into cell
ActiveSheet.Cells(4, 2).Value = DDERequest(channel, "temp")
'Continually update cell with value of "temp" variable from Propeller
ActiveSheet.Cells(6, 2).Value = "=vp|get!temp"
ActiveWorkbook.SetLinkOnData "vp|get!temp", "gotData"
'Start a trigger that fires when "temp" rises above 20. Then, return temp and time
ActiveSheet.Cells(7, 2).Value = "=vp|rise!temp_20_temp_time"
ActiveWorkbook.SetLinkOnData "vp|rise!temp_20_temp_time", "gotTrigger"
End Sub
Sub gotData()
'Data received, update cell
ActiveSheet.Cells(4, 5).Value = a
a = a + 1
End Sub
Sub gotTrigger()
'Trigger received, update cell
ActiveSheet.Cells(5, 5).Value = b
b = b + 1
End Sub
Sub StopVP()
'Stop getting trigger/value updates
ActiveSheet.Cells(6, 2).Value = ""
ActiveSheet.Cells(7, 2).Value = ""
'Disconnect Propeller and terminate DDE
DDEExecute channel, "disconnect"
DDETerminate channel
End Sub




Am I missing anything?
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

henry99
07-24-2009, 06:03 AM
Hi Hanno,
Looks good!

I'd be very interested to see the C#/Matlab example. Can you increase that refresh rate to more than 10Hz reliably? Matlab in particular will be cool to do a lot of hardcore math easily and send back to the prop.

Also, I saw a demo of your Viewport controlling a DC motor + optical encoder using a PID loop. What motor driver did you use for it? I'm trying to find something that is as much plug and play as possible.

Hanno
07-24-2009, 06:14 AM
I'll make the refresh rate configurable- I tested a 24,000 byte array at 10hz with no visible cpu usage- so shouldn't be a problem. I'll post a full C# sample project soon, Matlab should be easy, but would take me a while to learn- maybe you can give it a shot?
I use the LMD18200, beware that the minimum voltage is 12V, otherwise it's perfect.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

TreeLab
07-25-2009, 04:15 AM
Hi Hanno;
This looks terrific, and will serve our needs perfectly. Is the data in the longer arrays/vectors buffered? If a request for data is received while VP is reading data from the Conduit, will it receive a 'pure' snapshot of the data as recieved in one transfer from the prop, or will it be an overlay of some old/some new results?

Do you sleep?

Cheers!
Paul Rowntree

PS : WHen would you expect to post this version?

Cheers!

Hanno
07-25-2009, 11:19 AM
Hi Paul,
Thanks, glad you're happy with it- I'm really excited about this new method of integrating ViewPort into all sorts of applications. While DDE is ancient, it's perfect for this purpose- it's simple and it works! Yes, the data in ViewPort is pure- arrays are from one sample(the conduit provides an indicator that tells when you should burst your samples into the array- similar to the vertical refresh signal from monitors) and values are atomic and use out of band markers. Lots of complex stuff behind the scenes that makes it trivial to share data from the Propeller with Windows applications. Sleeping is overrated, raising kids the right way takes time... ViewPort's DDE client and server are working well- will do a bit more testing/documentation/samples. Am working on Spinner/PropScope/book/ViewPort in parallel, but expect a new release end of this week (end of July).
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
08-12-2009, 05:00 PM
Here's the complete VB.NET code to do pretty much anything with programs running on a Propeller. You can load a spin file, list variables, get details for variables, retrieve values and change values- for single variables as well as arrays. Also, triggers and callbacks and a variety of formats... DLL source code will be open... Now I need to sleep- tomorrow some last testing and then it's baked!
Hanno




'vpClient Sample Application
'August 2009 v0.5 mydancebot.com
'This program demonstrates how to use the vpclient dll to interface with the ViewPort library.
'Your program needs to include the "vpclient.dll" as a reference.
'This program maps each vpclient function to a button to allow you to try out the full functionality.
'
'You typically start and stop each session by calling "connect" and "disconnect".
'During a session use: "execute" to perform commands- like telling ViewPort to load a spin file.
' Use "request" to retrieve data from ViewPort- like the value of a Spin variable or array.
' Use "poke" to send data to ViewPort, for example- changing a Spin variable to a new number.
' Use "startAdvise" to start an advise loop, the "advise" event will fire with your requested data
'
'Each function returns with a status string. If an error has occured, the status will start with an exclamation mark
'The "advise" and "request" functions require a "format". Use 1 to get numbers in scientific notation with units
' Use 2 to get raw integers. Use 4 to get raw bytes.
'View the "mainform_load" function to see what commands you can use
Imports vpClient
Public Class MainForm
Dim WithEvents vp As vpClient.Main
Private Sub connectB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connectB.Click
statusT.Text = vp.connect()
End Sub
Private Sub disconnectB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles disconnectB.Click
statusT.Text = vp.disconnect()
End Sub
Private Sub executeB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles executeB.Click
statusT.Text = vp.execute(executeC.Text)
End Sub
Private Sub requestB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles requestB.Click
Dim format As Integer = Val(requestformat.Text)
Dim b As Byte() = Nothing
statusT.Text = vp.request(requestC.Text, format, b)
resultT.Text = vp.decode(b, format)
End Sub
Private Sub pokeB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pokeB.Click
statusT.Text = vp.poke(pokeC.Text, pokeDataT.Text)
End Sub
Private Sub startAdviseB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startAdviseB.Click
statusT.Text = vp.startAdvise(adviseC.Text, Val(AdviseFormatT.Text))
End Sub
Private Sub stopAdvise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stopAdvise.Click
statusT.Text = vp.stopAdvise(adviseC.Text, Val(AdviseFormatT.Text))
End Sub
Private Sub doAdvise(ByVal b As Byte(), ByVal format As Integer) Handles vp.advise
AdviseT.Text = vp.decode(b, format)
End Sub
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
vp = New vpClient.Main(Me)
Dim file As String = Application.StartupPath + "\ddesample.spin"
executeC.Items.Add("connect disconnect".Split) 'connect/disconnect ViewPort to/from the Propeller
executeC.Items.Add("link(n,myserver|get!n)") 'when the dde server's value changes, ViewPort variable "n" will change
executeC.Items.Add("unlink unadvise".Split) 'clear all "links" or "advise" loops
executeC.Items.Add("load(" + file + ")") 'compile and load the file to the Propeller and connect
requestC.Items.Add("list") 'lists all variables available to poke/request/advise
requestC.Items.Add("detail(n)") 'provides details on variable "n"
requestC.Items.AddRange("n m n_m".Split) 'retrieves the value of 1 or more variable values
requestC.Items.AddRange("$spacer $update".Split) 'use these special variables to set the spacer between variables, and the update rate in milliseconds
pokeC.Items.AddRange("m n $spacer $update".Split) 'set the value of a single variable
adviseC.Items.AddRange("n m n_m rise_n_5000_n_m".Split) 'rise_n_5000_n_m sets a trigger which returns the value of "n" and "m"
'a trigger starts with "rise" or "fall" followed by the variable and the trigger value. Specify the result at the end
adviseC.SelectedIndex = 0
executeC.SelectedIndex = 0
requestC.SelectedIndex = 0
pokeC.SelectedIndex = 0
End Sub
End Class


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

TreeLab
08-12-2009, 09:29 PM
Outstanding Hanno, Outstanding!
I am not a VB coder, but it should be easy to connect to your dll from my Delphi or LabView drivers. I will post the results.

1) Do you know if your .NET dll requires .NET compatible calling codes? I think my Delphi has a .NET variant, not LabView.
2) An option with ViewPort closes the Conduit if VP loses the focus. Is the DDE system still active in this case?
3) Does your VP code call the propellant dll to compile/load? Could this be made user selectable (eg bst, homespun) since these variants are starting to show some very interesting options etc.

See, sleep does have some practical aspects!
Cheers!
Paul Rowntree

Mike Huselton
08-12-2009, 11:34 PM
Hanno,

Outstanding job! That is the code I wrote for handling DDE callback messages myself, after referring to code I wrote 10 years ago for an international bank.
Simple, reliable and fast. Yay!

Family First - everything else second.

Have a good one, Hanno.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
JMH

Hanno
08-13-2009, 11:48 AM
Woohoo- another milestone...

Beta of ViewPort v4.2 is here: mydancebot.com/viewport/beta.php (http://mydancebot.com/viewport/beta.php)

A video and link to download the sample clients is here: mydancebot.com/viewport/clients.php (http://mydancebot.com/viewport/clients.php)

This morning I whipped together a Python client for ViewPort- lots of fun, here it is:



#open the connection to ViewPort
import win32ui,dde,sys,time
ddeClient = dde.CreateServer()
ddeClient.Create("")
vp = dde.CreateConversation(ddeClient)
vp.ConnectTo("vp", "system")

#compile, load, and connect to a spin file
vp.Exec("load("+sys.path[0]+"\sample.spin)")
print "Spin file is sharing these:"+vp.Request("list")
#request and poke a variable
print "Variable m's value is:"+vp.Request("m")
vp.Poke("m","1234")
time.sleep(.1)
print "After a poke, its value is:"+vp.Request("m")
raw_input("Press Enter to exit")




Enjoy!
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

Hanno
09-22-2009, 01:49 AM
On another thread http://forums.parallax.com/showthread.php?p=841655 heater and CRM requested that ViewPort include a web server to allow cross-network/cross platform api access. dMajo brought up the excellent point that DDE already supports a "network service", so in theory, ViewPort should already support DDE access by multiple clients, connecting from multiple machines in multiple languages. From quick googling, it looks like non-windows os's support DDE- including non-windows applications- including OpenOffice.
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

heater
09-22-2009, 02:16 AM
My Google for "linux dde" only comes up with this:

"the problem with what you are trying to
do (and why you don't find it) is this : DDE and OLE and DCOM are
proprietary MS interfaces. The support for them exists only on MS
platforms (Windows)."

and then stuff about the Linux "Device Driver Environment".

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Hanno
09-22-2009, 02:28 AM
I'm not an expert on this- but these links suggest to me that DDE is supported by OpenOffice, Ubuntu, Mac:
https://bugs.launchpad.net/ubuntu/+source/openoffice.org/+bug/49163
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/mann/dde.ntcl.html
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Download (http://mydancebot.com) a free trial of ViewPort- the premier visual debugger for the Propeller
Includes full debugger, simulated instruments, fuzzy logic, and OpenCV for computer vision. Now a Parallax Product!

heater
09-22-2009, 02:45 AM
Your second link there is a Tcl man page and says " This command allows an application to send Dynamic Data Exchange (DDE) command when running under
Microsoft Windows."

Not sure what the first one is about:(

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

TreeLab
09-22-2009, 03:58 AM
For what it is worth, I have searched for DDE support under Lazarus (Free Pascal Compiler) but no joy so far. I take this to mean that no-one has created a look-alike for the linux os. On my LabVIEW system the DDE support is buried under the 'Platform' set of vi's, which are supposed to be platform-specific.
Cheers!
Paul Rowntree

CounterRotatingProps
09-22-2009, 04:13 AM
DDE was, IMO, MS's anwser to unix shared mem and named pipes (although pipes do exist in windows too).

It's an OLD technology, came out about the time of "drag and drop" - actually, that might be DDE based.

StoneKnives -> DDE -> COM ->DCOM ->.Net

(and not necessarily an "evolutionary" step forward :))

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔