Comparing heating costs using Silverlight

Out of curiosity I’ve decided to compare actual heating costs versus theoretical heating costs. The calculation shows how much it would cost If I used a modern conditioner instead of a centralized heating provided by city and fuelled by natural gas. Hence I crafted a simple Silverlight application using DevExpress Silverlight components (which helped a lot, but that’s another story).

The default data is my data for January but you can enter your own. While the application is in Slovene you can pretty much understand the huge difference just by looking at the chart below. So much for naively believing that heat provided directly by fire is the cheapest one.

Follow this link to the heating cost calculator

Waiting for a tablet

It has been quite a while since I’ve started thinking about an e-Reader. The primary reason is that I have a bunch of e-books (many of them from Manning). I bought them with an e-reader in mind. However, they are in various formats, PDF among them.

The mainstream e-reader is still a 6” device with a single 9” out there - Kindle DX which is quite expensive and run by Amazon. This could be a worrisome fact – they demonstrated it twice at least: first they removed legally bought books from e-readers just like that (ironically those were Orwell’s) and they denied hosting Wikileaks on their cloud servers because of a single phone call made by a politician. Being at the mercy of such a company isn’t really something good, is it? Anyway, the thing is that 6” devices are suitable for displaying more or less e-books only, not all e-content (think PDF) due to the screen size. And e-readers with bigger screens are not coming yet, are they? During this time iPad happened  which shows that a tablet is a good alternative to e-readers if properly done (plus it can be used for many daily tasks where e-readers simply don+t work). Thanks for that, iPad. Hence I shifted my focus to tablets.

Here are my requirements for a tablet capable of displaying e-books in various formats, reading e-mail, surfing, etc:

  1. Real battery life at least 6hrs
  2. Screen resolution at least 1024x600
  3. Screen size at least 7” (not sure if I rather set it to 9” – have to check them in real world)
  4. Not being at the mercy of anybody for content installation
  5. Applications can be developed on PC (.net is preferred)
  6. A decent chipset (nVidia Tegra 2 looks the best bet right now)
  7. Open architecture with an option to install custom OS (when the manufacturer stops supporting it)

So let’s start with the eliminations.

iPad

I’ll never buy iPad due to the conflict with requirements 4, 5 and 7. My biggest problem with iPad is the Apple politics behind it. If you have it then you are at the mercy of Jobs who decides what are you allowed to run, install, share and read - Apple censors content for no reason, at least they don’t even try to explain it, Wikileaks application was one of them. From the hardware point of view it is a fine device though.

Windows 7 tablets aka slates

There are some and come in various forms and factors. However, none of them makes it over my first requirement. They are slow, too - thanks to Windows 7 not being optimized for tablet format. I could survive slowness but not being able to run over 3hrs straight is a complete showstopper. Imagine, you just boot Windows 7, open Word and your document within it and you have to recharge already. It is beyond me why the manufacturers even bother producing them. The only bright point here is that Microsoft announced support for ARM and SoC with forthcoming Windows 8. I guess I’ll have to re-evaluate Windows based tablets in two years or more.

Chrome

No idea.

Android

Which leaves the Android based tablets as the only alternative. Currently the only decent one is Samsung Galaxy Tab which is heavily overpriced. It is more expensive than iPad even though it features much smaller display (7” compared to iPad’s 9”) and a free open source OS. Furthermore it is running Gingerbread (or is it Froyo) without any upgrade commitment from Samsung (you can’t just use stock Android due to Samsung’s customization).

The real deal are many Tegra 2 based tablets running Honeycomb announced at CES and I guess many more are coming in the near future. I think this spring there will be enough tablets on the market to choose from. I don’t know yet which one I’ll buy but I am skeptic about Motorola and HTC. The first one because of Milestone fiasco .They released the same hardware as Droid in the US which is a Google reference device. Meaning Google support and stock Android. But they released its twin as Milestone in EU as completely closed system with rare and very late updates (requirement 7) as if EU doesn’t deserve and open device. Screw you Motorola. Nor do I trust HTC which, rather than supporting their phones or putting some effort and care into them, releases new and new models almost monthly. Not saying others are better or worse but I just don’t trust these two.

To be honest Samsung is very bad at supporting as well. Just look at their flagship Galaxy S phone which could be much better. Having a top notch hardware is FUBAR slow due to the incredible stupid decision to use RFS as their file system. You have to use one of the lagfixes to see it fly. OS customization bloat named Touch Wiz doesn’t help with upgrades - The OS upgrade speed shown so far is poor – upgrading to Froyo took them around 6 months.

I don’t know about other manufacturers but I assume they can be even worse. Hence I’d really appreciate a tablet running a stock Android or the possibility to install a stock Android. This way updates would be piece of cake. This is valid for phones as well, not just tablets.

I am still optimistic for this spring. Am I too demanding?

Righthand DataSet Visualizer goes 1.0

As a New Year’s gift I’ve fixed few bugs in Righthand DataSet Visualizer and set its version to 1.0.

Here are some changes:

  • uncompressed assembly is a bit larger due to avoiding compression within merged assembly.
  • RowState is visible again
  • some grid drawing related fixes

Read more about Righthand DataSet Visualizer here.

Download the newest and older versions from download section.

2008 version is here.

2010 version is here.

Capture DirectX 10/11 debug output to Visual Studio

Working with default DirectX configuration in a Visual Studio project is like working with a black box. Even more so when you have a managed code project. Mostly you’ll get an ArgumentException saying “Additional information: Value does not fall within the expected range.” or something like that, almost totally not helpful. But fear not, there is a way to capture a ton of useful information right into Visual Studio’s Debug output window. And here is how:

0. I assume you have DirectX SDK already installed.

If not download if it from DirectX Developer Center.

1. Enable debug output in DirectX control panel

a) Go to Start/All Programs/Microsoft DirectX SDK ([Month] [Year])/DirectX Utilities [(64-bit)] and run DirectX Control Panel [(64-bit)]

image

b) Go to Direct3D 10.x/11 tab. Except for the Edit List… button everything is disabled. The reason is that you have to add applications you wish to debug beforehand you can alter the settings (this is not obvious and UI is really clumsy here).

image

c) Click Edit List… and add your application to the List of process or folders. Clicking on […] button and selecting application exe file does the trick. Click OK button to close this window.

d) Next step is to actually enable debugging of the application. This can be done in two ways – either select Debug Layer’s Force On or switch on debugging directly from code (shown later in step 2.). You can select which messages won’t be displayed through Mute settings.

image

2. Alternatively to enabling debugging from step 2d)

You can create the DirectX device in code with CreateDeviceOptions.Debug option, like the code below when using managed code and Windows API Codepack:

D3DDevice device = D3DDevice.CreateDevice(null, DriverType.Hardware, null, CreateDeviceOptions.SingleThreaded | CreateDeviceOptions.Debug, levels);

This option will work with both Applications Controlled and Force On Debug Layer settings but not with Force Off.

3. Enable unmanaged debug output in Visual Studio project

The final step is to allow showing unmanaged debug output in Visual Studio debug output window. This works by default in an unmanaged project but not in managed projects. Note that it is a per-project setting.

Open project properties, Debug tab and make sure that Enable unmanaged code debugging option is checked.

image

Here you go. You’ll see plenty of DirectX messages in Debug output window from DirectX such as:

image

Disabled post comments due to spam

Due to the massive spam amount I was getting these days I’ve opted to disable all comments to my posts for the time being. When I figure out a proper anti-spam system I’ll re-enable them, perhaps through reCaptcha or something.

You can still send me the feedback through the Contact form.

Stay tuned.

A good use of an old Windows Mobile phone

Before owning an Android phone (Samsung Galaxy S) I had a HTC TyTN II which is a Windows Mobile 6.1 device. Until recently it was lying in a drawer because I didn’t know what to do with it. I didn’t want to give it away because I was afraid to turn the new owner into an enemy due the the poor quality of the phone. Anyway I am a so-so happy Android user now.

But recently I had to travel to Italy here and there and I was really lost without an internet connection to my laptop. Sure, I could use roaming, but I am not that rich. I figured out that the cheapest way to get connected in Italy is to buy an Italian prepaid SIM card, from TIM in my case. During the buying process I encountered two peculiarities.

1. The vendor asked me for ID. ID? For prepaid SIM card? I learned that they have this fabulous anti terrorism law in Italy that forbids vending SIM cards to anonymous users. Never heard of it in Slovenia. They even forbid vending more than 4 cards to a single person if I recall correctly. Go figure.

2. The guy asked me whether I want to use internet on my phone or on my laptop. Phone of course, why would I pay a premium price? After all Galaxy S comes with a mobile access point and I though it would be fine. It worked in Croatia just fine. Surprise, surprise, it doesn’t work. It works if I access the internet from my phone but not through an access point. After speaking with a fellow MVP network guru Miha Pihler he figured out that they probably inspect TCP/IP packets for traces of NAT and in such cases block the traffic.

One solution to this problem was to switch my Slovene SIM card in Galaxy S with the Italian one each time I travelled to Italy. There are two shortcoming to this solution. It is annoying to switch them again and again and I still couldn’t access internet from my laptop. Hey, I could buy a cheap GPRS modem. Hm, those aren’t that cheap after all, specially because I don’t need it that often.

At this point I remembered my old crappy TyTN II lying in the drawer. I also remembered that there is a really nice internet tethering application out there called WMWiFiRouter. Combining the two and using Bluetooth PAN feature it was a matter of minutes for connecting my laptop through bluetooth to TyTN II to the Italian internet. It is just that easy - a matter of starting the application and clicking a button. Besides Bluetooth PAN WMWiFiRouter can share cellular internet connection through USB and WiFi and much much more, see the features list.

The bottom line is that I finally found a good use for TyTN II and found a good internet tethering application as well which I’d definitely recommended.

Logging exceptions with NLog

A feature of my nice WPF application is to log exceptions that bring it down when running standalone. Of course this never happens but still, if such an event occurs I want to understand the cause. Why exceptions in plural? Because an exception might have an InnerException and this InnerException might have another InnerException and so forth.

I use NLog as logging framework. Nice and slick. Here is my really simple configuration:

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File" fileName="log.txt" layout="${longdate}:${message} ${exception:format=message,stacktrace:separator=*}" />
<target name="ds" xsi:type="Debugger"/>
</targets>
<rules>
<logger name="*" writeTo="file" minLevel="Warn"/>
<logger name="*" writeTo="ds" />
</rules>
</nlog>

Basically I log exceptions to log.txt file (as well as pretty much everything to debugger’s output). The layout to write the exception is this: layout="${longdate}:${message} ${exception:format=message,stacktrace:separator=*}". It is a pretty much standard NLog’s format for exceptions. However, the problem with it is that it won’t log InnerExceptions at all.

Hence I need to use the following code:

private bool showingFatal;
private void Application_DispatcherUnhandledException(object sender, 
    DispatcherUnhandledExceptionEventArgs e)
{
    if (showingFatal)
    {
        e.Handled = true;
        return;
    }
    showingFatal = true;
    logger.Error(LogCategory.Engine, "Fatal exception start ********************** ");
    try
    {
        int level = 0;
        Exception ex = e.Exception;
        while (ex != null)
        {
            logger.Error(LogCategory.Engine, 
                string.Format("Fatal exception level {0}: ", level++), ex);
            ex = ex.InnerException;
        }
    }
    finally
    {
        logger.Error(LogCategory.Engine, "Fatal exception end ********************** ");
    }
    Shutdown();
}

I use the flag showingFatal to prevent duplicate entry into the method (not sure why it happens but it happens) and a loop to log all, really all, exceptions and callstacks there are.

This way I have a good information about the exception that caused the crash. If it happens someday…

Managing DVBLink IPTV channels

I’ve been using DVBLink 3.1 for IPTV and Server Network Pack for a week or two now. It is a software that makes IPTV stream available to various clients, Windows Media Center among of them. It works very well with my IPTV provider SIOL (note the SIOL’s IPTV service quality is crap nevertheless) and thus I am quite happy.

While it streams fine DVBLink for IPTV’s UI is a very ascetic one. Very. Imagine having 165 channels and you have to sort them by entering a number for any of them. Horrible, just horrible. Furthermore adding or modifying channels is not easy either if not impossible (luckily channel import works).

And hence here is the first step to the UI solution: Righthand’s DVBLink Editor v1.0.0. It is an application that will let you sort all those channels easily.

editor in action

First you have to load the channels configuration file (application will try to locate it and load automatically upon the start) if it isn’t loaded yet – no channels are listed and no file name is present in the config file editor. Click on […] or enter its full path manually and then hit Load button to load the content. Configuration file is named DVBLinkChannelStorage.xml and is usually found in [Program Files]\DVBLogic\DVBLink2 folder.

Once channels configuration is loaded you can order them. But before sorting the channels make sure grid sorts them by number (default) and they have unique numbers. Reorder button will assign them unique numbers while preserving the original sort order if any (it sorts by exisiting number and then by name). Basically Reorder button is a big friend of yours. Once you have them sorted you can change their order.

You can change channels order in various ways:

  • by rotating mouse wheel while holding Shift key
  • by pressing up or down key while holding Shift key
  • by entering the number directly – the two channels will swap position

Once you’ve done with ordering you have to save the changes by clicking on Save button. By default Stop service checkbox is checked which means that editor will try to stop DVBLink Server service before saving and it will restart it (only if it was running before) afterwards. When unchecked no service will be touched. If you wonder why a service restart is necessary, there is a simple explanation: DVBLink Server won’t pick changes otherwise.

System requirements

.net 4.0 (you will be prompted to downloaded and install it if it is not installed yet on your OS).

Possible problem

DVBLogic stores configuration file under Program Files folder which is a very problematic practice. Due to the security concerns no writable configuration file should be placed in there. Period. Furthermore you’ll need administrator privileges to change the file in question.

Happy sorting and keep an eye on this blog for further improvements to the Righthand’s DVBLink Editor! Feedback is appreciated.

Find the application here.