Passing parameters to Silverlight

Just found something potentially very useful – how to pass parameters to one of my Silverlight demos so it can start up in a different state, or with a different preset loaded, depending on how it is called. Turns out this is very simple, provided you know the library command to use, as many things are. For the record, this is the easiest way I know of (and is far simpler than using initParams for what I wanted to do).

Quote is from a post by Sergey Volk from http://forums.silverlight.net/t/16862.aspx:

“It’s much easier to use managed API for this, it will parse query string for you using browser conventions (e.g. it will split param=value pairs separated by ‘&’ symbol, it will unescape url-encoded characters, replace ‘+’ with space, etc). If you have html page, say MyHtmlPage.html, which contains your SL app, you could give user a link like MyHtmlPage.html?param1=abc&param2=def&param3=ghi, then in managed code you could access these parameters like this:

string abc = System.Windows.Browser.HtmlPage.Document.QueryString[“param1”];
string def = System.Windows.Browser.HtmlPage.Document.QueryString[“param2”];
string ghi = System.Windows.Browser.HtmlPage.Document.QueryString[“param3″];”

One issue is that it’s not clear what happens if the parameter is not in the query string, you might end up trying to set a string to null which could cause some problems later. So perhaps use something like:

string abc = System.Windows.Browser.HtmlPage.Document.QueryString[“param1”] ?? String.Empty;

I must remember this – this opens up a lot of possibilities…

Later note: in some cases the machine throws an exception when it can’t find the right item in the list of parameters, so I’ve been enclosing the call to QueryString in a try-catch block.

Posted in Uncategorized | Leave a comment

Time to wave my flag a bit?

Well, from the silence, it appears that no-one is there. Either no-one has any interest is what I’m doing, or no-one knows about it. To prevent an existential crisis of purpose I’ll assume the latter. Perhaps I need to be a bit more proactive in telling people about these things and this site.

It’s been a month since the last entry, mostly I’ve been busy on things. The good news is that the digital circuit simulator that I thought would take a few months to get working turned out to be quite a bit easier to program than I thought, and it’s now ready. I’m rather pleased with it – it’s always a good sign when, on finishing a demo, I keep playing with it rather than starting on the next one. Anyway, I’ll post that one up as soon as I get a few minutes. I really need to re-organise these demo pages as well and put them in some sort of order. I’ll have a think. I guess not much point writing any more yet, no-one’s reading.

Posted in Uncategorized | Leave a comment

Back again

Thankfully my shoulder is a lot better, and I can type again. I’ll get on with adding the new demos. There’s also a new version of the DANSE simulator almost ready to be released, this one has the interactive feature. I guess I should post the source code as well – I might as well, I doubt anyone will mind.

What else is new? Well, there’s a demo used to introduce the operation of an oscilloscope, a new one about mobile wireless channels, one demonstrating error detection schemes, a sliding windows demo, and a couple I might not post here since they’re only of very minor interest.

The next big one is likely to be a digital circuit simulator, but that’s likely to be a few months away, it’ll take a lot of work.

I guess I should start trying to publicise these as well. It seems that no-one is just finding them, and I’m getting the increasing feeling that I’m talking to myself…

…is anyone there?

Posted in Uncategorized | Leave a comment

Ow

There won’t be any more posts for a little while. I’ve done something to my shoulder and have to type with my left hand only at the moment, so everything is going very slowly. The biggest problem is the capitals; at least I now know why there are shift and control keys on both sides of the keyboard. It’s been harder to get used to using the mouse this way. The doctor says I should recover but it’ll take a few weeks. So it’s bye for now…

Posted in Uncategorized | Leave a comment

Powerpoint fun

I just figured out how to embed the Silverlight demos into Powerpoint presentations. This is quite cool – as well as making the transition from presentation to demo smoother (often an awkward moment) and keeping the audience awake (they’ll never know when a diagram on a slide is about to move unexpectedly). This could be a big incentive for me to get the rest of the demos into Silverlight.

You need to put a Microsoft WebBrowser object onto the slide, then point it at the demo page. This is fairly straightforward if you don’t mind pressing a button to navigate to the web-page containing the demo, but it’s not obvious how to do this if you want the demo to load automatically with the slide. The simplest method seems to be to get the LiveWeb plug-in (from http://skp.mvps.org/liveweb.htm), and use the wizard. I have no idea how this works, but it does. Thank-you, Shyam Pillai.

If I don’t want to trust the live Internet for an important presentation, I’ll point the web browser at a local copy of the demo files: note don’t do this by entering “file:///J:/Projects/…” when LiveWeb asks for the URL, just input “J:/Projects/…” otherwise LiveWeb gets confused.

I’ll try this out in my lectures next week and see what the reaction is – I suspect most people won’t have seen anything like this done before. I certainly haven’t.

Posted in Uncategorized | Leave a comment

The trouble is, programming is just more fun…

…which is why there is so much badly-documented code out there, I suppose. As well as explaining why I seem to be spending time writing demos that no-one will probably ever use, rather than writing book chapters that no-one will ever read. Ah, what it is to have a meaningful life.

In my new job I’ll still be teaching, but I’ll no longer be teaching communications engineering (apart from one module on Internet Protocols), and I’ll be helping out in labs and workshops rather than doing conventional lectures. That changes the nature of the programs I’ll be writing; they’ll have to be intuitive for a student to use, and helpful for working things out in a lab, rather than just demonstrating ideas and concepts in lectures. So there will be more like the Lissajous demo, and less like the refraction demo. The next new one I’ve been thinking about will take a while though: I’ve been planning a digital circuit simulator where you can wire up gates and flip-flops and see what happens; plotting output traces and so on. This could turn into a major bit of software that’s useful in both lectures and labs.

However, I’ve still got all these old comms-related demos that I’d like to get updated and released before I get too involved in my new job. There’s a new one that I’ve just put on the web-site now – called Baseband Transmit. In the old VB6 days there was a corresponding receiver program that could calculate bit error rates, but I doubt I’ll get round to that again for Silverlight; it was always a bit too complex to use in lectures, and the only thing I used it for was demonstrating the performance of matched filters; I might write a simpler one just to do that. This one took a while, but then it’s the first one to plot graphs, and do any signal processing. Having got this going, the channel demo and Doppler demo should be much faster to convert over – a week or so each, I reckon. If I can stop myself working on the digital one, that is…

Posted in Uncategorized | Leave a comment

At last, a logo

The good news is that I now have a logo, I just have to find out how to get it into the rest of the site and the demos. The silverlight demos should be easy; the VB stuff it’ll just go in in a static form. The site banner, that’ll have to wait a bit until I have a photo I can use. Trouble with this is that I rather like the ferns. Maybe I should go out with a camera and try and find a fern.

My latest excuse for being slow with this site is that I got invited to join a scratch band for a one-off gig in July, and if there’s one thing more fun than programming demos, it’s playing bass. Since I haven’t picked up my bass for a couple of years this will take a bit of practice. Still, in August I start my new job, and then I should have more time.

Posted in Uncategorized | Leave a comment

Logos

Why no new demo for a while? Well, I’ve been convinced that before I try and publicise this site, I should have a strong visual identity. Replace the default picture that comes with this WordPress theme, and get a logo that I can put on all the demos. Seems like a good idea – but logos are proving more difficult than I thought.

I’ve often laughed with others about stories in the press of organisations spending ludicrous sums of money on design consultants who then come up with ordinary-looking logos. So I tried myself, and… ah. Coming up with something that I like is rather harder than I imagined. Especially as I rather liked the idea of it being animated – it fits in the concept behind the whole site. How to do something simple, clean, elegant, initially eye-catching but not distractingly so, memorable and relevant? When I succeed, I’ll get back to the demos.

The next one coming up is a demo of sliding windows, after that I might have a go at queueing in routers and the token bucket algorithm (it looks like I might still be teaching one communications course next year after all, and these will be useful for that module).

Posted in Uncategorized | Leave a comment

Interactive Danseing?

After a request, there’s a cool new feature coming soon in DANSE: you can pause the simulation, change an entry in a routeing table, or a timer in the MAC protocol, or anything else the protocol designer has provided the facility for, and then carry on. It’s in the development version now, it’ll be in the release version as soon as it gets a bit more testing, As far as I know, DANSE is the only simulator that allows you to do this.

In other news – I’ve been looking at other development frameworks for writing small animations and simulations for the book. Silverlight, much as I like it, isn’t as widely supported as some other frameworks, and I’ve been looking to see what can be done in JavaScript, Java Applets, Flash, and so on. After a weekend of frantic learning and experimenting, I’m back at Silverlight again. Java Applets and Flash would work on a wider range of hardware, but still not everything (the most notable example being the iPad). So why learn a whole new technology which isn’t universally supported either?

I’ll stick to Silverlight for now. When the world gets itself sorted out and agrees on a way to run powerful client-side apps on everything (which I still hope someday it might), I’ll start converting. In the meantime, anyone who wants to read the book with all the examples and demonstrations on a tablet will just have to get an Android device. (Not that I’ve tested Moonlight… I can’t afford a Xoom… but if I get the chance to test things out, I will.)

Posted in Uncategorized | Leave a comment

End of April becons

This book thing – I’m having some ideas about incorporating the demos into the text of the book itself. Which I think will be a great way to learn things, but it will mean a delay in getting the chapters written, as I have to write a lot of new demos and learn how to integrate them with the chapters.

In the meantime, there are some new demos up here, including linear modulation, refraction, cellular systems and possibly the most popular demo I’ve written – the layers demo.

Next, I’ll put the old VB6 ones up here.

Posted in Uncategorized | Leave a comment