Using a mobile phone as GPS logger

Tags: , ,
No Comments »

With the Java software GPSLog you can use an ordinary Bluetooth GPS receiver with a Bluetooth enabled mobile Phone as a GPS Data logger. Only connect the two devices and start logging with the GPSLog software. It is very easy and you can simply create nmea log files and use it with other GPS software like PhotoTagStudio or translate these log files using GPS Babel.

I use GPSLog only to display the current position and the current time of my GPS Logger to take a photo of the display with the current time displayed. In PhotoTagStudio you can use such a picture to synchronize the GPS log time and the camera time.

I wrote more about my GPS logger and GPS Babel in this article and more about GPS earlier in this blog.

g-brief in LaTeX and “\Telefon already defined” problem

Tags:
3 Comments »

g-brief is a document class for LaTeX to write German standard letters. I like this document class very much and prefer it much over the Microsoft Word letter templates.
But on some machines I get the following error message when compiling the document using the MiKTeX packages:
   LaTeX Error: Command \Telefon already defined.

There is a simple solutions to resolve this error. You can just patch the package. Somewhere below the LaTeX directory you should find the marvosym.sty file. Open this file with a text editor of your choice an search for a line like this:
   \newcommand\Telefon{\mvchr{84}}
There you can change the name of the command \Telefon to something like \Telefonsymbol or the even better way (but I did not test this one): replace \newcommand with \def and leave Telefon as it is.

Another g-brief tip: you can define the following three elements on your document to turn on these various features:
\fenstermarken
\faltmarken
\trennlinien

Workaround for Known Issue with TypeConverters in DSL Tools for Visual Studio

Tags: , , , ,
6 Comments »

When I tried to add a Domain Property with a custom TypeConverter to my Domain Class I ran into serious problems. Sometimes it worked and this property was shown correctly in the properties window using the custom TypeConverter, but sometimes not. I was desperately searching for a bug in my code for hours but then I figured out: Each first build after a solution cleanup was working and all other builds not. Even when I start the working build a second time without rebuilding it, the custom TypeConverter was not used.

This looks very much like the number 1.10 (the second 1.10 😉 ) in the known issues list posted on the VSX Team blog:

1.10 TypeConverters and TypeDescriptors are not picked up during the build process or during toolbox initialization.
When adding a custom TypeConverter or TypeDescriptor and then building the DSL, the TypeConvertor or TypeDescriptor is not picked up. The workaround is to rebuild the solution with a clean build.

And as you see: I discovered this workaround for myself, too. But I also found another workaround. I’m not sure if it is working for all situations with the described known issue but if you have the same problem you might want to try it. If it works or not, please comment some feedback here.

I simply used another constructor of the TypeConverterAttribute. Instead of providing the type information I used the constructor with a string:

// this one does not work:

[TypeConverter(typeof(DynamicPropertiesTypeConverter))]

 

// this one is not nice, but works:

[TypeConverter(“BenjaminSchroeter.DynamicPropertiesTypeConverter”)]

public class DynamicProperties : ICustomTypeDescriptor

 

CopySourceAsHtml Add-In with Visual Studio 2008

Tags: , ,
No Comments »

CopySourceAsHtml (CSAH) is a small and nice add-in for Visual Studio 2005 to copy the selected source code html-formatted to the clipboard. This is very useful if you want to paste this code into your blog (as I do here sometimes).

Unfortunately the current version 2.0.0 does not work with Visual Studio 2008 out of the box, but it is very simple to get it running.

The add-ins are located in below documents-folder in a path like this: C:\Users \Benjamin \Documents \Visual Studio 2005 \Addins. Just copy all files beginning with CopySourceAsHtml*.* to the corresponding folder for Visual Studio 2008: C:\Users \Benjamin \Documents\ Visual Studio 2008 \Addins.

Now you have to edit the CopySourceAsHtml.AddIn file with a text editor: only change at two positions in this short xml-file the Version value from 8.0 to 9.0.

After a restart of Visual Studio 2008 you should find the CopySourceAsHtml add-in in the Tools / Add-in menu and of cause in the context menu of the code editor.

Please allow me to introduce myself…

Tags:
1 Comment »

… I’m a man of wealth and taste. (Stones)

Yes, I am the new kid on the blog. Thanks to Benjamin for the first introduction. To introduce myself I tried to write a short version of my ‘computational biography’, but I ended up writing pages. If you really would like to read it, you will find the whole story here soon – with all comments and debug symbols. Now here is the compilied version:

Aged 33, I am living in the beautilful city of Düsseldorf (near Cologne) with my wonderful girl Grace. Thanks to my father I started programming 25years ago and couldn’t stop. In school I liked mathematics and languages, which was a strange but unique combination. Consequently (meaning ‘through wild twists in my personal life’ 🙂 ) I became a student of linguistics and quickly came to the field of computational linguistics. I graduated and after some more turbulences I started working for a nice company in Cologne. That’s where I first met Benjamin: The company was working on “java to .NET”-thing, Ben had already done the difficult tasks and I should type in some simple wrappings. I had learned C# like a week ago and felt dump like sh*t.
But I had time to improve and two year later we did the coolest project my working life so far: A converter from C#-Code to a special kind of process diagrams. I still like that tool a lot and realising it involved some of my major fields of interest like building parsers and pushing around graphs.
Since mid of 2006 I am a freelancer and currently I am working for a big German retail and logistics company.

I am interested in almost any subjects related to computers, except networking stuff :-). I am attracted most to games (boardgames as well, especially chess) and gaming theory, parsing, solving problems using graphs and .NET (of course).

My personal main task for 2008 is to lose some significant amounts of weight. I am not a fat guy, but during the last couple of years I gained the typical IT-belly.

I’ll come up soon with a nifty little post about comparing numbers. Stay tuned!

First steps on aspect oriented programming

Tags: , , ,
No Comments »

Since I saw the first implementation of aspect oriented programming (AOP) frameworks for java I became a fan of AOP but it took a long time till now before I could start using AOP in my projects. The main reason was that simply no good and easy to use AOP framework for .net existed. There was one research project but you weren’t allowed to use their utilities in project other then research projects.
But a few weeks ago I discovered PostSharp and it is really great and very simple. If you have no idea what’s all about AOP you should read the Wikipedia article or the start page of the PostSharp project. There you find a short example showing the usage of an aspect in C# code.
I also want to show you my first experience with some aspect oriented programming.

First: the problem I want to address
I sounds very simple: I’ve got a base-class and some sub-classes. All provide a method GetName(). All sub-classes within the same type should return the same name that is given at compile time. It’s just a const string for each class. The following code addresses these needs in a straight forward way:

class BaseClass

{

    public virtual string GetName()

    {

        return “-“;

    }

}

 

class ClassA : BaseClass

{

    public override string GetName()

    {

        return “A”;

    }

}

 

class ClassB : BaseClass

{

    public override string GetName()

    {

        return “b”;

    }

}

Second: what I don’t like with this solution
This seems good, but I’ve got some more special needs. All classes are generated by the DSL Tools that means they contain much other code and no line written by me. In my use case these classes are shape-objects.
Thanks to the partial keyword in C# I could extend every class within its own .cs-file, but I didn’t like this. It would mean I have to create many additional .cs-files only for providing a single string to the class. But all other definition is stored in the DSL-model described by the DSL Tools and some part of the shape declaration is located in the .cs-files.
In the DSL-model I can provide each class with a custom attribute, so I’m looking for a solution with no additional code in the sub-classes besides a custom attribute.
With the use of reflection it could be the following:

class NameTextAttribute : Attribute

{

    public NameTextAttribute(string name)

    {

        this.Name = name;

    }

 

    public string Name { get; set; }

}

 

class BaseClass

{

    private string name = null;

 

    public virtual string GetName()

    {

        if (name == null)

        {

            object[] a = this.GetType().GetCustomAttributes(

                            typeof(NameTextAttribute),

                            true);

 

            if (a.Length > 0)

                name = ((NameTextAttribute)a[0]).Name;

            else

                name = “-“;

        }

 

        return name;

    }

}

 

[NameTextAttribute(“A”)]

class ClassA : BaseClass {}

 

[NameTextAttribute(“b”)]

class ClassB : BaseClass {}

This is working and as you see, no additional code is needed in the sub-classes. But nevertheless I would like to avoid using reflection. Reflection seems to me inappropriate in this case.

Third: Using AOP
The idea of AOP is to add code to the class that you can write in another position, in the aspect. The aspect weaver (in my case the PostSharp Laos library) adds this code on compiletime (not runtime!) to the class.
My strategy is to add some code after the constructor execution that will initialize the name-property:

class BaseClass

{

    public virtual string Name { get; internal set; }

 

    public virtual string GetName()

    {

        return this.Name;

    }

}

 

[NameAspect(“a”)]

class ClassA : BaseClass

{

    public void someMethodInA()   { }

}

 

[NameAspect(“b”)]

class ClassB : BaseClass {}

 

[Serializable]

class NameAspect : OnMethodBoundaryAspect

{

    private string name = “-“;

    public NameAspect(string name)

    {

        this.name = name;

    }

 

    override bool CompileTimeValidate(MethodBase m)

    {

        return m.IsConstructor;

    }

 

    override void OnSuccess(MethodExecutionEventArgs args)

    {

        BaseClass obj = args.Instance as BaseClass;

        if (obj != null)

            obj.Name = name;

    }

}

The base-class now provides a property name (declared with the new C# 3.0 syntax) and the GetName() method returning the property value. As in the last example the sub-classes have the attribute declared and contain no other code.
The magic happens in the attribute (or, if you like, somewhere in the PostSharp.dll). It is derived from OnMethodBoundaryAspect, an aspect base type where I can add code to a method in another class before and after the method call and on exception and on success of the method call.
My constructor of this aspect gets only the name string and stores it in a variable.
The code that should be executed every time a constructor of a class with this aspect is calls can be find in the OnSuccess()-method. Here only the property of the BaseClass will be set.
With the CompileTimeValidate()-method I can specify at compiletime for witch methods the code should be injected. For my needs this is only the constructor. All other methods of my class will not be changes by this aspect.

Fourth: behind the scene
With adding the PostSharp references to my project the PostSharp postcompiler is called automatically after compiling my assembly and the code is added. If you take a look with the Reflector you will see the following:

class ClassA : BaseClass

{

    static ClassA()

    {

        if (!~PostSharp~Laos~Implementation.initialized)

            LaosNotInitializedException.Throw();

        ~PostSharp~Laos~Implementation.~targetMethod~3 =

                methodof(ClassA..ctor);

        ~PostSharp~Laos~Implementation.NameAspect~3.RuntimeInitialize

                (~PostSharp~Laos~Implementation.~targetMethod~3);

    }

 

    public ClassA()

    {

        MethodExecutionEventArgs ~laosEventArgs~1;

        try

        {

            ~laosEventArgs~1 = new MethodExecutionEventArgs(

                    methodof(ClassA..ctor, ClassA), this, null);

            ~PostSharp~Laos~Implementation.NameAspect~3.OnEntry(~laosEventArgs~1);

            if (~laosEventArgs~1.FlowBehavior != FlowBehavior.Return)

                ~PostSharp~Laos~Implementation.NameAspect~3.OnSuccess(~laosEventArgs~1);

        }

        catch (Exception ~exception~0)

        {

            ~laosEventArgs~1.Exception = ~exception~0;

            ~PostSharp~Laos~Implementation.NameAspect~3.OnException(~laosEventArgs~1);

            switch (~laosEventArgs~1.FlowBehavior)

            {

                case FlowBehavior.Continue:

                case FlowBehavior.Return:

                    return;

            }

            throw;

        }

        finally

        {

            ~PostSharp~Laos~Implementation.NameAspect~3.OnExit(~laosEventArgs~1);

        }

    }

 

    public void someMethodInA() {}

}

I really don’t know what’s that all about but I can see that there is code added only to the constructor, someMethed() is empty as in my given source code.

In the next weeks I will try to cover more examples and solutions with PostSharp and AOP.

GPS Logger Wintec G-Rays 2 and GPS Babel

Tags: , ,
1 Comment »

Previously I wrote about geotagging and my photo tagging software PhotoTagStudio has build in support to tag photos with GPS coordinates from nmea files. I used to generate these nmea log files with a Windows CE PDA and imported the log files into my photos with PhotoTagStudio.

Now I bought a small GPS receiver with a build in datalogger. It’s named Wintec G-Rays 2 or WBT-201. And by the way: it is a great idea giving one product one or more name nobody can remember. For some reason Apple products always have only one name everybody can always remember. Back to my new WBT-201: it is very small, cost about 100 €, has a build in rechargeable battery and can be used as an ordinary Bluetooth GPS receiver. But besides this it can act as a GPS logger and store up to 130000 GPS positions.
I bought this device only for logging and combining these data with photos using PhotoTagStudio.

The software for configuring and getting the logged data is called Time Machine X and looks and acts like crap. It looks like written by an amateur programmer using Visual Basic 3 on Windows 3.11. But you need this software to configure the logger. I set it to capture every 2 seconds the position. That’s it. To use the logger you need only turn the power on and it’s working. With the track button you can record some waypoints at the given position but I didn’t use this feature.

To read the logs you can use Time Machine X, but I don’t like it and you cannot script this application. An alternative is the open source software GPS Babel. GPS Babel can read and write nearly every GPS related file format. So you can read the data directly from a serial COM port (this can be the USB or a Bluetooth connection to the WBT) and write it as a nmea file.

The following command reads from COM10 (this is a Bluetooth serial port an my computer) and writes a nmea file named out.nmea:
gpsbabel.exe -t -w -i wbt -f com10 -o nmea -F out.nmea

To delete the logged date from the WBT device you can use the following command:
gpsbabel.exe -t -w -i wbt,erase -f com10 -o nmea -F out.nmea

The -t parameter reads the whole logged track and the -w parameter reads the recorded waypoints.
The output file can be read by PhotoTagStudio v.6.2 and above and other software that is capable of reading nmea files. Or you can use GPS Babel to create files with other formats. For example kml files for Google Earth and Google Maps.

Now is only one thing missing: a display device for the GPS date and status when I am not caring my PDA or notebook with me. In will write another article where I will show how to use a mobile phone to display the data of a Bluetooth GPS receiver.

Something going on in 2008

Tags:
No Comments »

I started this blog in November 2006 as a secondary blog besides my private Livejournal and didn’t know where it was going. I posted a few random links and news stories from the web and later some technical articles.

In the past year I posted more and more (but not on a regular basis) technical articles. Technical article means something I discovered or learned while working with computers, windows, programming and thing like that. Now I will turn this blog in a real tech blog.

First we changed the name: now this blog is called “Ticklish Techs – a mostly .NET but also some other cool techs blogâ€? and the name is pretty much a vague description of the upcoming content. Every time I have something to say about computers, software, programming (especially .NET) I will blog it here. And I will try to do this on a regular basis.

And of cause with a new name the blog needs a new domain: www.ticklishtechs.net

The second news: I have to introduce my new co writer: Wolfram. He’s a colleague and friend of mine from Düssledorf, Germany. We used to work together for different clients and still work on our private projects together. From my point of view he is one of the top 20 percent programmers I know. The first time he appeared here in September last year on an article regarding the Win32 shell. He will start to write more articles worth reading here soon.
I think 2008 will be interesting for us and this blog. Let’s see what’s coming. As a small outlook I will write some more articles on GPS and NMEA the next days and when I begin to work on my diploma thesis the next month I will certainly write some articles about Visual Studio 2008 (Orcas) Extensibility (VSX) and the DSL tools.

Setup Microsoft Help Explorer (Visual Studio Combined Help Collection)

Tags: ,
1 Comment »

As we all know, the main resource for help on Visual Studio and .net is the Microsoft Help Explorer that is installed with Visual Studio. Sometimes it is called the Visual Studio Combined Help Collection. Most of the Microsoft development tools (for example SDKs for Office and Visual Studio) but also tools from other vendors install their help resources into this Explorer.
It is really nice if it works. But on my system I ended up with not only one central Help Explorer but with three, each containing different content. One came with Visual Studio 2005, one with Orcas and another with the Visual Studio SDK. For some reason only the last one showed up the .net-framework help, but every time I pressed F1 in Studio the first one – without the content – opened.
I knew that there is somewhere a settings dialog where you can see the installed content of the Explorer and enable or disable some of it. But Microsoft does a very good job in hiding this dialog. It is shown like any page of the help. To find it just go to the Index and look for “Visual Studio 2005 Combined Help Collection Manager” or for Orcas Beta 2 “…2007…” – I think they will change the name in the final Visual Studio 2008.

PhotoTagStudio 0.6 released

Tags: , ,
No Comments »

Today I released the new version of PhotoTagStudio with some new features (Copy photos from memory card, Macro and Plugins).

See http://phototagstudio.irgendwie.net/

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in