<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>The Night Coder</title>
    <link>http://blog.minidev.se/</link>
    <description>Mikael Nilssons Development Blog</description>
    <language>en-us</language>
    <copyright>Mikael Nilsson</copyright>
    <lastBuildDate>Mon, 31 May 2010 22:05:14 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>dasblog@example.com</managingEditor>
    <webMaster>dasblog@example.com</webMaster>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=a71e16fd-bb40-4cd7-8b88-c530a14c8f5a</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,a71e16fd-bb40-4cd7-8b88-c530a14c8f5a.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,a71e16fd-bb40-4cd7-8b88-c530a14c8f5a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=a71e16fd-bb40-4cd7-8b88-c530a14c8f5a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My first Android application (actually my second, the first was a commercial one)
is released and published. The application is already downloaded more than 1000 times
and that's OK for a national application. The name of the application is inherited
from the excellent web site <a href="http://www.temperatur.nu/orter.html">Temperatur.nu</a> and
is TemperaturNu. Well it's hard to find a god name when you want to implement a excellent
idea.
</p>
        <p>
          <strong>
            <u>Architecture.</u>
          </strong>
          <br />
The TemperaturNu application is built with several of the Android OS cornerstones
that make up a rigid application. There are the MapView activity, together with a
location view, because that's what give this application a twist. Then there are the
service, handling data downloading from the web API. Nobody want to handle communication
exceptions in the UI, right? I have bad experience in that area from my previous Android
application and will not go down that road again!<br />
To join those parts together we need a content provider for data abstraction and a
broadcast handler for notification. The data provider also make it easy to handle
the asynchronous data download. And...  that's it!
</p>
        <p>
          <strong>
            <u>Details.</u>
          </strong>
          <br />
The TemperaturNu application uses the Android location API to determine your current
position. The position is sent in a request to the Temperatur.nu API, and position
and temperature for the nearest weather stations is returned together with some other
meta data. This result is coded as xml and are parsed by the data download service.
When the data is parsed it's sent to the content provider for storage and a broadcast
intent is sent. All of this is done in a 'fire and forget' thread in the service that
is started in the start server handler. It's essential to run this on a separate thread
because if you dot do that the request and parsing will run on the main activity UI
thread and that's not what we want.
</p>
        <p>
In the main activity the received broadcast trigger a reload of data from the content
provider and update  the items on the map overlay. Several overlays are used
in the main activity to handle the display of location and items
</p>
        <p>
The content provider just keep the data in memory because I judged the temperature
data to be to  transient to store in a database. The most important role of the
content provider is to decouple and abstract the data from the data down-loader<u>.</u></p>
        <p>
          <strong>
            <u>Temperatur.nu web API</u>
          </strong>
          <br />
Erik at temperatur.nu have been kind to set up a public API (<a href="http://wiki.temperatur.nu/index.php/API">description
here</a>) which the application use for data collection. The temperature data can
be requested either by geo position or by a station id. Up to five readings can be
requested in each request and the response is coded in xml and structured lika a rss
feed. The API can also provide a graph image of the last 24h readings from a station.
This feature will be exposed by the next release of temperaturNu. 
</p>
        <p>
          <br />
 
</p>
        <img border="0" src="http://blog.minidev.se/content/binary/TemperaturNu_2.png" />
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=a71e16fd-bb40-4cd7-8b88-c530a14c8f5a" />
      </body>
      <title>Android Application One</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,a71e16fd-bb40-4cd7-8b88-c530a14c8f5a.aspx</guid>
      <link>http://blog.minidev.se/2010/05/31/AndroidApplicationOne.aspx</link>
      <pubDate>Mon, 31 May 2010 22:05:14 GMT</pubDate>
      <description>&lt;p&gt;
My first Android application (actually my second, the first was a commercial one)
is released and published. The application is already downloaded more than 1000 times
and that's OK for a national application. The name of the application is inherited
from the excellent web site &lt;a href="http://www.temperatur.nu/orter.html"&gt;Temperatur.nu&lt;/a&gt; and
is TemperaturNu. Well it's hard to find a god name when you want to implement a excellent
idea.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;u&gt;Architecture.&lt;/u&gt;&lt;/strong&gt;
&lt;br&gt;
The TemperaturNu application is built with several of the Android OS cornerstones
that make up a rigid application. There are the MapView activity, together with a
location view, because that's what give this application a twist. Then there are the
service, handling data downloading from the web API. Nobody want to handle communication
exceptions in the UI, right? I have bad experience in that area from my previous Android
application and will not go down that road again!&lt;br&gt;
To join those parts together we need a content provider for data abstraction and a
broadcast handler for notification. The data provider also make it easy to handle
the asynchronous data download. And...&amp;nbsp; that's it!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;u&gt;Details.&lt;/u&gt;&lt;/strong&gt;
&lt;br&gt;
The TemperaturNu application uses the Android location API to determine your current
position. The position is sent in a request to the Temperatur.nu API, and position
and temperature for the nearest weather stations is returned together with some other
meta data. This result is coded as xml and are parsed by the data download service.
When the data is parsed it's sent to the content provider for storage and a broadcast
intent is sent. All of this is done in a 'fire and forget' thread in the service that
is started in the start server handler. It's essential to run this on a separate thread
because if you dot do that the request and parsing will run on the main activity UI
thread and that's not what we want.
&lt;/p&gt;
&lt;p&gt;
In the main activity the received broadcast trigger a reload of data from the content
provider and update&amp;nbsp; the items on the map overlay. Several overlays are used
in the main activity to handle the display of location and items
&lt;/p&gt;
&lt;p&gt;
The content provider just keep the data in memory because I judged the temperature
data to be to&amp;nbsp; transient to store in a database. The most important role of the
content provider is to decouple and abstract the data from the data down-loader&lt;u&gt;.&lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;u&gt;Temperatur.nu web API&lt;/u&gt;&lt;/strong&gt;
&lt;br&gt;
Erik at temperatur.nu have been kind to set up a public API (&lt;a href="http://wiki.temperatur.nu/index.php/API"&gt;description
here&lt;/a&gt;) which the application use for data collection. The temperature data can
be requested either by geo position or by a station id. Up to five readings can be
requested in each request and the response is coded in xml and structured lika a rss
feed. The API can also provide a graph image of the last 24h readings from a station.
This feature will be exposed by the next release of temperaturNu. 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img border=0 src="http://blog.minidev.se/content/binary/TemperaturNu_2.png"&gt;&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=a71e16fd-bb40-4cd7-8b88-c530a14c8f5a" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,a71e16fd-bb40-4cd7-8b88-c530a14c8f5a.aspx</comments>
      <category>Android</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=f796a86d-c80d-446b-a2c8-0a0e3f380816</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,f796a86d-c80d-446b-a2c8-0a0e3f380816.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,f796a86d-c80d-446b-a2c8-0a0e3f380816.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=f796a86d-c80d-446b-a2c8-0a0e3f380816</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font size="4">
            <strong>Passwords everywhere</strong>
          </font>
        </p>
        <p>
I’m getting to old to remember all those passwords sprinkled all over the web! 
Most embarrassing is that I can’t remember the password to my own private applications,
but there is a couple though: local mail server, homeserver user and admin, local
wiki and blog, several mail accounts to name a few.
</p>
        <p>
So to remedy this plethora of passwords I have joined the OpenId movement and try
to add OpenId login wherever I can. My DasBlog already have it but not my ScrewTurn
Wiki wiki. I really like the architecture of ScrewTurn Wiki with dynamically loaded
providers and it was fairly simple to write a new user storage provider for OpenId
users and adding the DotNetOpenId control to the login page. Unfortunately I have
not found a way to avoid changing the application when adding the OpenId login. The
alternatives are either to add a new sign-on page with the open id login control or
modify the existing login page.  If the login page is modified then I have to
apply the patch on every update but I get a direct login link from the main page.
Any way the application has to be re-compiled and I lose some of the benefit of loading
a provider dynamically. But I have not investigated other solutions so there might
be a simple fix for this.
</p>
        <p>
          <font size="4">
            <strong>Login page modifications:</strong>
          </font>
        </p>
        <p>
Download the DotNetOpenId control from <a href="http://code.google.com/p/dotnetopenid/">http://code.google.com/p/dotnetopenid/</a> and
set up a reference to it from the web application.<br />
Add the assembly import in the login.aspx page:<br /><font face="Courier New"><font color="#000080">&lt;%@ Register Assembly="DotNetOpenId"
Namespace="DotNetOpenId.RelyingParty" TagPrefix="cc1" %&gt;</font></font></p>
        <p>
Then the actual login control can be added anywhere on the page.<br /><font color="#000080" face="Courier New">&lt;hr /&gt;<br />
&lt;cc1:OpenIdLogin ID="OpenIdLogin1" runat="server" CssClass="openidLogin"<br />
      RequestEmail="Require"<br />
      RequestNickname="Require"<br />
      RequestFullName="Request"<br />
      RegisterVisible="false" 
<br />
      RememberMeVisible="True" 
<br />
      PolicyUrl="~/PrivacyPolicy.aspx" TabIndex="1" 
<br />
      onfailed="OpenIdLogin1_Failed"<br />
      onloggedin="OpenIdLogin1_LoggedIn"<br />
      onsetuprequired="OpenIdLogin1_SetupRequired"<br />
/&gt;</font></p>
        <p>
When using auto registration at least email and nick name shall be required and the
full name can be requested. Either the nick name or the full name can be used as display
name. The ScrewTurn Wiki username will be derived from the identifier as described
below.<br /></p>
        <p>
          <font size="4">
            <strong>Provider</strong>
          </font>
        </p>
        <p>
The hardest thing was to adapt the way authorization works when using OpenId. The
user shall NOT be authorized when logging in to the application. The user is already
authorized; the application shall just set the access rights and eventually register
the user.  User data like user name and email is requested in the call to the
authorization service and are used to register the user. I used a trick to get the
claimed identifier (<a href="http://myuser.name.myopenid.com/">http://myuser.name.myopenid.com/</a>)
down to the OpenId provider. First attempt was to use the identifier as user name
but then the user name regular expression complained. Technically the user should
not be edited but the name is verified when the user is brought up for group assignment.
Anyway I needed a unique identifier for the user and want to use the claimed identifier.
</p>
        <p>
Well the way I resolved it was to use the password parameter instead. When an OpenId
user is created the identifier is modified to construct a new username: the http://
and .com part is removed and the dots replaced by spaces. This will give a user name
like ‘myuser name myopenid’ and that is unique enough. I chose to automatically register
the user if the login fails. The OpenId provider defines two default groups: OpenId_Users
and OpenId_Administrators and can be configured to automatically add a new user to
one of those groups. Users will be added to the anonymous group if they are not added
to any of the default groups.  
<br /></p>
        <p>
          <font size="4">
            <strong>Provider configuration:</strong>
          </font>
        </p>
        <p>
My primary goal was to enable me to logon as an administrator to my wiki so I added
a feature for automatically adding a user to a user group. The provider maintains
two predefined groups’ wher users can be added with the following configuration:<br /><font color="#000080" face="Courier New">addtoadmin=http://myuser.name.myopenid.com<br />
addtouser=http://myuser.name.myopenid.com<br /></font></p>
        <p>
          <font size="4">
            <strong>Installation:</strong>
          </font>
        </p>
        <p>
When the login page have been modified, or a new sign-on page added to the web application
it’s time to deploy. Start up the wiki and log on as an administrator to configure
the wiki for OpenId access.  Upload the OpenIdProvider.dll to add it to the framework
and configure the provider if you want the automatic logon feature (see above). 
Then go to the group administration page and set access rights for the two default
OpenId groups. That’s it! Logout and go to the login / sign on page and login via
OpenId.<br /></p>
        <p>
          <font size="4">
            <strong>Login problems</strong>
          </font>
        </p>
        <p>
Sometimes during the tests I have problem to get the sign in to work and gets Login_Failed.
The same thing happens on my DasBlog. Usually it works after a login/logout on myopenid.  
<br /></p>
        <p>
          <font size="4">
            <strong>Disclaimer</strong>
          </font>
        </p>
        <p>
This was not intended to be an industrial grade solution for OpenId implementation
on ScrewTurn Wiki but it can be used as a starting point for them who want to add
it to their installation.  The code is delivered ‘as is’ without any guaranties
regarding security etc.<br />
I got rid of another password to forget and can move on with next project 
<br />
The OpenId source code and dll can (soon) be downloaded from <a href="http://minidev/download/Openidprovider.zip">http://minidev/download/Openidprovider.zip</a><br /></p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=f796a86d-c80d-446b-a2c8-0a0e3f380816" />
      </body>
      <title>OpenId on ScrewTurn Wiki</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,f796a86d-c80d-446b-a2c8-0a0e3f380816.aspx</guid>
      <link>http://blog.minidev.se/2010/05/14/OpenIdOnScrewTurnWiki.aspx</link>
      <pubDate>Fri, 14 May 2010 18:43:38 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Passwords everywhere&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
I’m getting to old to remember all those passwords sprinkled all over the web!&amp;nbsp;
Most embarrassing is that I can’t remember the password to my own private applications,
but there is a couple though: local mail server, homeserver user and admin, local
wiki and blog, several mail accounts to name a few.
&lt;/p&gt;
&lt;p&gt;
So to remedy this plethora of passwords I have joined the OpenId movement and try
to add OpenId login wherever I can. My DasBlog already have it but not my ScrewTurn
Wiki wiki. I really like the architecture of ScrewTurn Wiki with dynamically loaded
providers and it was fairly simple to write a new user storage provider for OpenId
users and adding the DotNetOpenId control to the login page. Unfortunately I have
not found a way to avoid changing the application when adding the OpenId login. The
alternatives are either to add a new sign-on page with the open id login control or
modify the existing login page.&amp;nbsp; If the login page is modified then I have to
apply the patch on every update but I get a direct login link from the main page.
Any way the application has to be re-compiled and I lose some of the benefit of loading
a provider dynamically. But I have not investigated other solutions so there might
be a simple fix for this.
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Login page modifications:&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Download the DotNetOpenId control from &lt;a href="http://code.google.com/p/dotnetopenid/"&gt;http://code.google.com/p/dotnetopenid/&lt;/a&gt; and
set up a reference to it from the web application.&lt;br&gt;
Add the assembly import in the login.aspx page:&lt;br&gt;
&lt;font face="Courier New"&gt;&lt;font color=#000080&gt;&amp;lt;%@ Register Assembly="DotNetOpenId"
Namespace="DotNetOpenId.RelyingParty" TagPrefix="cc1" %&amp;gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Then the actual login control can be added anywhere on the page.&lt;br&gt;
&lt;font color=#000080 face="Courier New"&gt;&amp;lt;hr /&amp;gt;&lt;br&gt;
&amp;lt;cc1:OpenIdLogin ID="OpenIdLogin1" runat="server" CssClass="openidLogin"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestEmail="Require"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestNickname="Require"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestFullName="Request"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RegisterVisible="false" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RememberMeVisible="True" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PolicyUrl="~/PrivacyPolicy.aspx" TabIndex="1" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onfailed="OpenIdLogin1_Failed"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onloggedin="OpenIdLogin1_LoggedIn"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onsetuprequired="OpenIdLogin1_SetupRequired"&lt;br&gt;
/&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
When using auto registration at least email and nick name shall be required and the
full name can be requested. Either the nick name or the full name can be used as display
name. The ScrewTurn Wiki username will be derived from the identifier as described
below.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Provider&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The hardest thing was to adapt the way authorization works when using OpenId. The
user shall NOT be authorized when logging in to the application. The user is already
authorized; the application shall just set the access rights and eventually register
the user.&amp;nbsp; User data like user name and email is requested in the call to the
authorization service and are used to register the user. I used a trick to get the
claimed identifier (&lt;a href="http://myuser.name.myopenid.com/"&gt;http://myuser.name.myopenid.com/&lt;/a&gt;)
down to the OpenId provider. First attempt was to use the identifier as user name
but then the user name regular expression complained. Technically the user should
not be edited but the name is verified when the user is brought up for group assignment.
Anyway I needed a unique identifier for the user and want to use the claimed identifier.
&lt;/p&gt;
&lt;p&gt;
Well the way I resolved it was to use the password parameter instead. When an OpenId
user is created the identifier is modified to construct a new username: the http://
and .com part is removed and the dots replaced by spaces. This will give a user name
like ‘myuser name myopenid’ and that is unique enough. I chose to automatically register
the user if the login fails. The OpenId provider defines two default groups: OpenId_Users
and OpenId_Administrators and can be configured to automatically add a new user to
one of those groups. Users will be added to the anonymous group if they are not added
to any of the default groups.&amp;nbsp; 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Provider configuration:&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
My primary goal was to enable me to logon as an administrator to my wiki so I added
a feature for automatically adding a user to a user group. The provider maintains
two predefined groups’ wher users can be added with the following configuration:&lt;br&gt;
&lt;font color=#000080 face="Courier New"&gt;addtoadmin=http://myuser.name.myopenid.com&lt;br&gt;
addtouser=http://myuser.name.myopenid.com&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
When the login page have been modified, or a new sign-on page added to the web application
it’s time to deploy. Start up the wiki and log on as an administrator to configure
the wiki for OpenId access.&amp;nbsp; Upload the OpenIdProvider.dll to add it to the framework
and configure the provider if you want the automatic logon feature (see above).&amp;nbsp;
Then go to the group administration page and set access rights for the two default
OpenId groups. That’s it! Logout and go to the login / sign on page and login via
OpenId.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Login problems&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Sometimes during the tests I have problem to get the sign in to work and gets Login_Failed.
The same thing happens on my DasBlog. Usually it works after a login/logout on myopenid.&amp;nbsp; 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=4&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This was not intended to be an industrial grade solution for OpenId implementation
on ScrewTurn Wiki but it can be used as a starting point for them who want to add
it to their installation.&amp;nbsp; The code is delivered ‘as is’ without any guaranties
regarding security etc.&lt;br&gt;
I got rid of another password to forget and can move on with next project 
&lt;br&gt;
The OpenId source code and dll can (soon) be downloaded from &lt;a href="http://minidev/download/Openidprovider.zip"&gt;http://minidev/download/Openidprovider.zip&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=f796a86d-c80d-446b-a2c8-0a0e3f380816" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,f796a86d-c80d-446b-a2c8-0a0e3f380816.aspx</comments>
      <category>OpenId</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=23777ba1-a94a-4fd7-892e-578015dab2b5</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,23777ba1-a94a-4fd7-892e-578015dab2b5.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,23777ba1-a94a-4fd7-892e-578015dab2b5.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=23777ba1-a94a-4fd7-892e-578015dab2b5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Well this is a thing that I have been thinking about for a while: I want to use UTC
times in the rrdb to be able to handle when time change from summer time (day light
saving) to winter time. It must be better to always use UTC time internally and convert
on data insert and fetch. That will take care of the exception I get when the
clock is set back one hour and I try to insert 'old' data. I will also remove the
conversion to and from epoch time and just store seconds from the DateTime class.
</p>
        <p>
The problem is that I need to restructure the code in several places. I have never
liked the connection between the classes where one class store a reference to
a 'parent' instance like the Archive have a parent RrdDb and the ArcState have a reference
to a parent Archive. Then the ArcState access members in the parent.parent instance
like <font size="2"><font color="#000000" size="2" face="Courier New">Header</font></font><font size="2"><font color="#000000" face="Courier New"> header
= parentArc.getParentDb().getHeader();</font></font> I don't think that the ArcState
should have any knowledge about the Archive and absolutely not about the relation
between Archive and RrdDb!  Why not? Because I plan to use local time outside
the RrdDb and UTC time inside and I must be sure that all access to time
variables are converted correctly.
</p>
        <p>
Example:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">public</span>
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">long</span> getLastUpdateTime()
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">lock</span> (sync)
{ <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">return</span> header.getLastUpdateTime();
} } </span>
        </pre>
        <p>
Here I want to do a conversion to local time but in Archive there are code like this:
</p>
        <pre>
          <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px">
            <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">long</span> lastUpdateTime <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> parentDb.getHeader().getLastUpdateTime(); </span>
        </pre>
        <font size="2">
          <p>
          </p>
        </font>What happens if someone refactor it to:
<pre><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"><span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px">long</span> lastUpdateTime <span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px">=</span> parentDb.getLastUpdateTime(); </span></pre><p>
Well if I put the local time conversion in RrdDb.getLastUpdateTime() it will generate
some nasty bugs that are hard to track! 
</p><p><strong>But</strong> according to the text above I don't want the Archive class to
have knowledge about the RrdDb to Header relation so the refactoring is correct! Thats
why I want to remove all relations to the 'parent' object and supply all needed data
as parameters in the method call. Anyway it looks strange to me that a RrdDb instance
call into an Archive instance that call back, via it's parent reference, into the
RrdDb instance to get some parameter that could have been sent into the call!
</p><p>
I'm not sure how to handle the changes in the Google code repository. I still keep
the code in my private SVN repository and I will do the changes on trunk there. I
will try to update the Google repository when I'm done.
</p><p>
 
</p><img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=23777ba1-a94a-4fd7-892e-578015dab2b5" /></body>
      <title>Time for major (time) refactoring in rrd4n</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,23777ba1-a94a-4fd7-892e-578015dab2b5.aspx</guid>
      <link>http://blog.minidev.se/2010/02/16/TimeForMajorTimeRefactoringInRrd4n.aspx</link>
      <pubDate>Tue, 16 Feb 2010 21:12:13 GMT</pubDate>
      <description>&lt;p&gt;
Well this is a thing that I have been thinking about for a while: I want to use UTC
times in the rrdb to be able to handle when time change from summer time (day light
saving) to winter time. It must be better to always use UTC time internally and convert
on data insert and fetch. That will take care of the exception&amp;nbsp;I get when the
clock is set back one hour and I try to insert 'old' data. I will also remove the
conversion to and from epoch time and just store seconds from the DateTime class.
&lt;/p&gt;
&lt;p&gt;
The problem is that I need to restructure the code in several places. I have never
liked the connection between the classes where one class&amp;nbsp;store a reference to
a 'parent' instance like the Archive have a parent RrdDb and the ArcState have a reference
to a parent Archive. Then the ArcState access members in the parent.parent instance
like &lt;font size=2&gt;&lt;font color=#000000 size=2 face="Courier New"&gt;Header&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#000000 face="Courier New"&gt; header
= parentArc.getParentDb().getHeader();&lt;/font&gt;&lt;/font&gt;&amp;nbsp;I don't think that the ArcState
should have any knowledge about the Archive and absolutely not about the relation
between Archive and RrdDb!&amp;nbsp;&amp;nbsp;Why not? Because I plan to use local time outside
the RrdDb and UTC time&amp;nbsp;inside&amp;nbsp;and I must be sure that all access to time
variables are converted correctly.
&lt;/p&gt;
&lt;p&gt;
Example:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;public&lt;/span&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;long&lt;/span&gt; getLastUpdateTime()
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;lock&lt;/span&gt; (sync)
{ &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;return&lt;/span&gt; header.getLastUpdateTime();
} } &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Here I want to do a conversion to local time but in Archive there are code like this:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;long&lt;/span&gt; lastUpdateTime &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; parentDb.getHeader().getLastUpdateTime(); &lt;/span&gt;&lt;/pre&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;What happens if someone refactor it to:&gt;
&lt;pre&gt;&lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: black; FONT-SIZE: 11px"&gt; &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: blue; FONT-SIZE: 11px"&gt;long&lt;/span&gt; lastUpdateTime &lt;span style="BACKGROUND-COLOR: transparent; FONT-FAMILY: Courier New; COLOR: red; FONT-SIZE: 11px"&gt;=&lt;/span&gt; parentDb.getLastUpdateTime(); &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Well if I put the local time conversion in RrdDb.getLastUpdateTime() it will generate
some nasty bugs that are hard to track! 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;But&lt;/strong&gt; according to the text above I don't want the Archive class to
have knowledge about the RrdDb to Header relation so the refactoring is correct! Thats
why I want to remove all relations to the 'parent' object and supply all needed data
as parameters in the method call. Anyway it looks strange to me that a RrdDb instance
call into an Archive instance that call back, via it's parent reference, into the
RrdDb instance to get some parameter that could have been sent into the call!
&lt;/p&gt;
&lt;p&gt;
I'm not sure how to handle the changes in the Google code repository. I still keep
the code in my private SVN repository and I will do the changes on trunk there. I
will try to update the Google repository when I'm done.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=23777ba1-a94a-4fd7-892e-578015dab2b5" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,23777ba1-a94a-4fd7-892e-578015dab2b5.aspx</comments>
      <category>Refactoring</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=20b07866-d894-4670-a74a-5ac9ee03ef08</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,20b07866-d894-4670-a74a-5ac9ee03ef08.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,20b07866-d894-4670-a74a-5ac9ee03ef08.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=20b07866-d894-4670-a74a-5ac9ee03ef08</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Rrd4n(et) are public at last. After a long and painful time of ambivalence and un-determination
I decided to publish my rrd4n lib at <a href="http://rrd4net.googlecode.com/svn/trunk">Google
code</a>. I hope I made the right thing and selected the right license type. Well
time will tell. The project name on Google is rrd4net and not rrd4n because I manage
to register rrd4n on my professional Google account.
</p>
        <p>
          <u>And now the disclaimers: The software isn’t finished! </u>
        </p>
        <p>
Especially the configuration tool need a lot of work until it is usable, but I needed
a tool to set up the rrd databases and view the graphs during development. There are
several menus that don’t work anymore and it’s not obvious or intuitive to use. There
is one nice feature though: you can drag an rrd database from the left tree wiew and
drop it in the graph definition area to make a quick test of the data in the register.<br /><br />
The separation of the data storage from the graphing is a bit over complicated. It’s
nice to be able configure the data source in the app.config file but I’m not sure
if it’s worth the effort. But it was really nice when I wrote a MySql accessor 
(not in the Google code repository right now) to feed data from my MySql database
into the graph. That experiment also made me realize why RRD is such a good idea:
the MySql database contain temperature readings from 4 sensors with a resolution of
1 minute for about 3 years i.e. a huge amount of useless data with high resolution.
It takes for ever to get the data out of the database. So now I have to write a program
that feed the data from the MySql database into a RRD database.
</p>
        <p>
Well right now I’m planning for an Android project so I will not spend that much time
on rrd4n for a while.
</p>
        <p>
Happy Round Robin
</p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=20b07866-d894-4670-a74a-5ac9ee03ef08" />
      </body>
      <title>Rrd4Net are public</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,20b07866-d894-4670-a74a-5ac9ee03ef08.aspx</guid>
      <link>http://blog.minidev.se/2010/02/10/Rrd4NetArePublic.aspx</link>
      <pubDate>Wed, 10 Feb 2010 20:52:30 GMT</pubDate>
      <description>&lt;p&gt;
Rrd4n(et) are public at last. After a long and painful time of ambivalence and un-determination
I decided to publish my rrd4n lib at &lt;a href="http://rrd4net.googlecode.com/svn/trunk"&gt;Google
code&lt;/a&gt;. I hope I made the right thing and selected the right license type. Well
time will tell. The project name on Google is rrd4net and not rrd4n because I manage
to register rrd4n on my professional Google account.
&lt;/p&gt;
&lt;p&gt;
&lt;u&gt;And now the disclaimers: The software isn’t finished! &lt;/u&gt;
&lt;/p&gt;
&lt;p&gt;
Especially the configuration tool need a lot of work until it is usable, but I needed
a tool to set up the rrd databases and view the graphs during development. There are
several menus that don’t work anymore and it’s not obvious or intuitive to use. There
is one nice feature though: you can drag an rrd database from the left tree wiew and
drop it in the graph definition area to make a quick test of the data in the register.&lt;br&gt;
&lt;br&gt;
The separation of the data storage from the graphing is a bit over complicated. It’s
nice to be able configure the data source in the app.config file but I’m not sure
if it’s worth the effort. But it was really nice when I wrote a MySql accessor&amp;nbsp;
(not in the Google code repository right now) to feed data from my MySql database
into the graph. That experiment also made me realize why RRD is such a good idea:
the MySql database contain temperature readings from 4 sensors with a resolution of
1 minute for about 3 years i.e. a huge amount of useless data with high resolution.
It takes for ever to get the data out of the database. So now I have to write a program
that feed the data from the MySql database into a RRD database.
&lt;/p&gt;
&lt;p&gt;
Well right now I’m planning for an Android project so I will not spend that much time
on rrd4n for a while.
&lt;/p&gt;
&lt;p&gt;
Happy Round Robin
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=20b07866-d894-4670-a74a-5ac9ee03ef08" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,20b07866-d894-4670-a74a-5ac9ee03ef08.aspx</comments>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=5302a730-6c5d-4ef7-a61c-72c0dde5f447</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,5302a730-6c5d-4ef7-a61c-72c0dde5f447.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,5302a730-6c5d-4ef7-a61c-72c0dde5f447.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=5302a730-6c5d-4ef7-a61c-72c0dde5f447</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have some plans to make the source code public in the near feature. The original
java package was published under <font color="#008000" size="2"><font color="#008000" size="2">GNU
Lesser General Public License<font color="#000000"> and as I understand it it's OK
if I do the same as long as the files contain the license text. I have to do some
more testing and there are some 'technical debt' collected during the development.
I think I will put the source code in a Google code repository when I'm ready.</font></font></font></p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=5302a730-6c5d-4ef7-a61c-72c0dde5f447" />
      </body>
      <title>Rrd4n going public?</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,5302a730-6c5d-4ef7-a61c-72c0dde5f447.aspx</guid>
      <link>http://blog.minidev.se/2009/11/11/Rrd4nGoingPublic.aspx</link>
      <pubDate>Wed, 11 Nov 2009 23:12:38 GMT</pubDate>
      <description>&lt;p&gt;
I have some plans to make the source code public in the near feature. The original
java package was published under &lt;font color=#008000 size=2&gt;&lt;font color=#008000 size=2&gt;GNU
Lesser General Public License&lt;font color=#000000&gt; and as I understand it it's OK if
I do the same as long as the files contain the license text. I have to do some more
testing and there are some 'technical debt' collected during the development. I think
I will put the source code in a Google code repository when I'm ready.&lt;/font&gt;
&lt;/p&gt;
&gt;&gt;&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=5302a730-6c5d-4ef7-a61c-72c0dde5f447" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,5302a730-6c5d-4ef7-a61c-72c0dde5f447.aspx</comments>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=7ea77d39-8c7f-4a6d-8586-30aac66ea40e</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,7ea77d39-8c7f-4a6d-8586-30aac66ea40e.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,7ea77d39-8c7f-4a6d-8586-30aac66ea40e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=7ea77d39-8c7f-4a6d-8586-30aac66ea40e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At last, after a lot of refactoring and polishing the configuration tool is finished,
or good enough, for now. I added some nice docking features (thanks to <font size="2">WeifenLuo <a href="http://dockpanelsuite.sourceforge.net/">DockPanel
Suite</a>) to enable a bit of plug-in behavior (more on that later). The docking view
made it possible to show both database properties and graphs in a natural way. And
as a frosting on the cake I added a drag and drop feature: a database definition can
be dragged into the graph definition text box. The database definition then converted
to a graph definition with a DEF declaration and a line definition for each data source
in the database, a convenient way to do a quick view of the data in the database.</font></p>
        <font size="2">
          <p>
I'm planning to add logger configuration to the tool but to keep it separate it will
be added as a plug-in. The plug-in will be added by changing the app.config file.
</p>
        </font>
        <p>
          <font size="3">
            <strong>Database view:</strong>
          </font>
        </p>
        <p>
          <img border="0" src="http://blog.minidev.se/content/binary/rrd config database1.png" />
        </p>
        <p>
          <font size="3">
            <strong>Graph view:</strong>
          </font>
        </p>
        <p>
          <img border="0" src="http://blog.minidev.se/content/binary/rrd config graph.png" />
        </p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=7ea77d39-8c7f-4a6d-8586-30aac66ea40e" />
      </body>
      <title>Rrd4n configuration tool (almost) finished</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,7ea77d39-8c7f-4a6d-8586-30aac66ea40e.aspx</guid>
      <link>http://blog.minidev.se/2009/11/11/Rrd4nConfigurationToolAlmostFinished.aspx</link>
      <pubDate>Wed, 11 Nov 2009 23:00:55 GMT</pubDate>
      <description>&lt;p&gt;
At last, after a lot of refactoring and polishing the configuration tool is finished,
or good enough, for now. I added some nice docking&amp;nbsp;features (thanks to &lt;font size=2&gt;WeifenLuo &lt;a href="http://dockpanelsuite.sourceforge.net/"&gt;DockPanel
Suite&lt;/a&gt;) to enable a bit of plug-in behavior (more on that later). The docking view
made it possible to show both database properties and graphs in a natural way. And
as a frosting on the cake I added a drag and drop feature: a database definition can
be dragged into the graph definition text box. The database definition then converted
to a graph definition with a DEF declaration and a line definition for each data source
in the database, a convenient way to do a quick view of the data in the database.&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
I'm planning to add logger configuration to the tool but to keep it separate it will
be added as a plug-in. The plug-in will be added by changing the app.config file.
&lt;/p&gt;
&lt;/font&gt; 
&lt;p&gt;
&lt;font size=3&gt;&lt;strong&gt;Database view:&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://blog.minidev.se/content/binary/rrd config database1.png"&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=3&gt;&lt;strong&gt;Graph view:&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img border=0 src="http://blog.minidev.se/content/binary/rrd config graph.png"&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=7ea77d39-8c7f-4a6d-8586-30aac66ea40e" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,7ea77d39-8c7f-4a6d-8586-30aac66ea40e.aspx</comments>
      <category>logger</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=e4be5279-4f9e-480e-8bad-a2f2a92c2020</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,e4be5279-4f9e-480e-8bad-a2f2a92c2020.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,e4be5279-4f9e-480e-8bad-a2f2a92c2020.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=e4be5279-4f9e-480e-8bad-a2f2a92c2020</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have spent a some time on my RRD code package. Porting the graphics and
formatting, specially the date time formatting, was pretty straight forward but I
have spent a lot of time on the configuration tool. I didn't realized that there was
a fairly good implementation in Java until I was half way through! But my tool is
fully visual (and still a bit buggy) and fully functional for setting up the database,
import cvs data and test the graphing.
</p>
        <p>
I have also made some serious refactoring on the core rrdb code, separating the storage
part from the actual data access. I assumed that if an asp.net application should
be able to access the rrdb files on another computer there could be some security
issues! So I created a rrdb file server application where the graph processor could
fetch the data by .net remoting (yes I know it's slow and over-complicated but it
works). There are also a local file provider so I don't have to run on the server during
testing. And naturally the right access provider is injected into the graph processor
depending on the configuration file! The service has also a data store interface for
data collecting that i plan to use in the data logger.
</p>
        <p>
Talking about the logger it's up and running now. For the moment I collect data from
my geo-thermal-heat-exchanger, or heater for short, where I measure compressor
run time, hot water production and return water temperature. I need to get some more
DS1820 sensors to measure brine temperature as well
</p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=e4be5279-4f9e-480e-8bad-a2f2a92c2020" />
      </body>
      <title>RRDtool for .NET Part II</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,e4be5279-4f9e-480e-8bad-a2f2a92c2020.aspx</guid>
      <link>http://blog.minidev.se/2009/11/03/RRDtoolForNETPartII.aspx</link>
      <pubDate>Tue, 03 Nov 2009 20:39:26 GMT</pubDate>
      <description>&lt;p&gt;
I have spent a&amp;nbsp;some&amp;nbsp;time on my RRD code package. Porting the graphics and
formatting, specially the date time formatting, was pretty straight forward but I
have spent a lot of time on the configuration tool. I didn't realized that there was
a fairly good implementation in Java until I was half way through! But my tool is
fully visual (and still a bit buggy) and fully functional for setting up the database,
import cvs data and test the graphing.
&lt;/p&gt;
&lt;p&gt;
I have also made some serious refactoring on the core rrdb code, separating the storage
part from the actual data access. I assumed that if an asp.net application should
be able to access the rrdb files on another computer there could be some security
issues! So I created a rrdb file server application where the graph processor could
fetch the data by .net remoting (yes I know it's slow and over-complicated but it
works). There are also a local file provider so I don't have to run on&amp;nbsp;the server&amp;nbsp;during
testing. And naturally the right access provider is injected into the graph processor
depending on the configuration file! The service has also a data store interface for
data collecting that i plan to use in the data logger.
&lt;/p&gt;
&lt;p&gt;
Talking about the logger it's up and running now. For the moment I collect data from
my geo-thermal-heat-exchanger, or heater for short, where&amp;nbsp;I measure compressor
run time, hot water production and return water temperature. I need to get some more
DS1820 sensors to measure brine temperature as well
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=e4be5279-4f9e-480e-8bad-a2f2a92c2020" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,e4be5279-4f9e-480e-8bad-a2f2a92c2020.aspx</comments>
      <category>logger</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=c1882562-becc-41fc-b8f5-065a4b3dc9ba</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,c1882562-becc-41fc-b8f5-065a4b3dc9ba.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,c1882562-becc-41fc-b8f5-065a4b3dc9ba.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=c1882562-becc-41fc-b8f5-065a4b3dc9ba</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight I added the graphing to my rrd4n configuration tool and generated the first
graph from the logged data. The logger have been running for almost 48 hours but the
photosensor get out of position on the heat exchanger so there are some hour missing
in the data. Still it's up and running!
</p>
        <p>
 
</p>
        <p align="center">
          <img src="http://blog.minidev.se/content/binary/run.png" border="0" />
        </p>
        <p align="left">
Now I want to put this data on my webserver but I'm not sure how to get access
to the RRD file from the web application. And before that I have to get te hardware
ready so I can detect when the heat exchanger produce hot water. Some tasks for the
weekend. 
</p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=c1882562-becc-41fc-b8f5-065a4b3dc9ba" />
      </body>
      <title>First graph from the logger</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,c1882562-becc-41fc-b8f5-065a4b3dc9ba.aspx</guid>
      <link>http://blog.minidev.se/2009/10/23/FirstGraphFromTheLogger.aspx</link>
      <pubDate>Fri, 23 Oct 2009 21:28:19 GMT</pubDate>
      <description>&lt;p&gt;
Tonight I added the graphing to my rrd4n configuration tool and generated the first
graph from the logged data. The logger have been running for almost 48 hours but the
photosensor get out of position on the heat exchanger so there are some hour missing
in the data. Still&amp;nbsp;it's up and running!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p align=center&gt;
&lt;img src="http://blog.minidev.se/content/binary/run.png" border=0&gt;
&lt;/p&gt;
&lt;p align=left&gt;
Now I want to put this data on my webserver but I'm not sure&amp;nbsp;how to get access
to the RRD file from the web application. And before that I have to get te hardware
ready so I can detect when the heat exchanger produce hot water. Some tasks for the
weekend.&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=c1882562-becc-41fc-b8f5-065a4b3dc9ba" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,c1882562-becc-41fc-b8f5-065a4b3dc9ba.aspx</comments>
      <category>logger</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=52adb902-316e-4ef9-90a8-eb8b893ffb10</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,52adb902-316e-4ef9-90a8-eb8b893ffb10.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,52adb902-316e-4ef9-90a8-eb8b893ffb10.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=52adb902-316e-4ef9-90a8-eb8b893ffb10</wfw:commentRss>
      <title>It Was An Exciting Night</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,52adb902-316e-4ef9-90a8-eb8b893ffb10.aspx</guid>
      <link>http://blog.minidev.se/2009/10/22/ItWasAnExcitingNight.aspx</link>
      <pubDate>Thu, 22 Oct 2009 21:53:36 GMT</pubDate>
      <description>&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;It was an exciting night
last night when I got the logger running for the first time. I manage to port the &lt;a href="https://rrd4j.dev.java.net/"&gt;rrd4j&lt;/a&gt; package
to c# in about 20h but then I start to write an administration tool to manage the
rrd visually and that took almost as long time as the porting.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Well
now I have a visual too that I can use to create and manage my rrd databases. Written
with a MVC pattern and using &lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle
Windsor&lt;/a&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt; IOC
framework and all!&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;The data logger was developed
in parallel with the porting and in a highly Agile fashion every decision was delayed
until the last feasible moment i.e. the model was changed underway. The logger started
as a highly generic logger but moved toward a logger for rrd databases with a SQL
backing database. The configuration of devices and data channels is stored in a SQL
database (&lt;a href="http://www.sqlite.org/"&gt;SOLite&lt;/a&gt; for the moment) and the Logger
read this configuration at startup. The logger creates a set of data points from the
configuration data and start sample the devices, process the data in a sample processor
and persist the result at regular intervals. 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;Right now the most important
thing is to collect data and tune the settings of the rrd data bases. I have to find
out how to set tick intervals and what archives needed to store relevant data. Right
now I have rrd databases for heat exchange compressor runtime, heat exchange compressor
start count and return temperature.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The
heat exchange compressor runs for about 20 minutes per hour so I have set the database
tick time to 3600. This will give a value around 0.3 in the rrd. 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;font color=#000000&gt;&lt;span style="mso-ansi-language: EN-US"&gt;First I wanted to sample
the runtime more often, like every 10 minutes, but then there would be several values
stored as 1 in the database because the heater would run for the whole sample interval
i.e. value overflow. Storing 1 in a ratio value (running seconds/ second) make a MAX
archive useless! So I have to be patient and wait for an hour before the firs result
show up! Same thing for the start count database, the compressor start 1 to 2 times
an hour and the database tick must be set to at least 2 hours to avoid 0 values (making
MIN archive useless). &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;The run time counter
store a &lt;/span&gt;&lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;
&lt;st1:place&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;NaN&lt;/span&gt;
&lt;/st1:place&gt;
&lt;span style="mso-ansi-language: EN-US"&gt; value at start up and then a 0 value to handle
counter restart. The max value is set to 4000 and a counter restart will be detected
as a counter wrap. I’m not sure if this behavior I correct thou. The counter restart
is a counter wrap and will generate a huge value outside max, and a &lt;/span&gt;
&lt;st1:place&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;NaN&lt;/span&gt;
&lt;/st1:place&gt;
&lt;span style="mso-ansi-language: EN-US"&gt; value is stored in the archive. I have to
figure this one out tomorrow.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=52adb902-316e-4ef9-90a8-eb8b893ffb10" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,52adb902-316e-4ef9-90a8-eb8b893ffb10.aspx</comments>
      <category>logger</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=fa9a80c4-15e2-4a21-a5eb-c625a2b79c42</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,fa9a80c4-15e2-4a21-a5eb-c625a2b79c42.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,fa9a80c4-15e2-4a21-a5eb-c625a2b79c42.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=fa9a80c4-15e2-4a21-a5eb-c625a2b79c42</wfw:commentRss>
      <title>The Data Logger</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,fa9a80c4-15e2-4a21-a5eb-c625a2b79c42.aspx</guid>
      <link>http://blog.minidev.se/2009/10/20/TheDataLogger.aspx</link>
      <pubDate>Tue, 20 Oct 2009 21:37:36 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;The data logger project
started as a generic data logger for just everything like gasoline usage of my car
to outdoor temperature, but has narrowed in to a data source for my RRD databases.
The architecture is still flexible and will allow for some extensions in the future
(I know it’s over complex but it’s elegant). The components are described by an interface
description and the IOC framework (&lt;a href="http://www.castleproject.org/container/index.html"&gt;Castle
Windsor&lt;/a&gt;) takes care of the component injection. Used components are described
in the app.config file. This means that I can configure if I want to use the RRD or
SQL data repository, or both and what device handlers to use. At the moment there
is only an OneWire device handler and I’m planning for a serial handler to read from
my old data collector.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000 size=3 face="Times New Roman"&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal align=center&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000 size=3 face="Times New Roman"&gt;&lt;img border=0 src="http://blog.minidev.se/content/binary/Logger.png"&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000 size=3 face="Times New Roman"&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face="Times New Roman"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;The biggest advantage by
using configurable components is that it’s possible to mock some components when testing
other components. Using a mock device handler enable me to test without the real OneWire
network. By using ActiveRecord/NHibernate I can test against an in memory SQLite database
without destroying the live database.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;Sample processors are used
for special handling of the data read from the devices and perform functions for running
average filtering, runtime counters and start counters. Running average is used for
smoothing of analog signals like temperature, removing the spike in heater output
when the heater switch from hot water production to heating. Run time counter detect
the digital input that indicate that a device is on, the heat exchange compressor,
and count seconds running. The starts counter processor count number of changes from
0 to 1 on a digital input. And then there is the null processor for no processing.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0cm 0cm 10pt" class=MsoNormal&gt;
&lt;span style="mso-ansi-language: EN-US"&gt;&lt;font color=#000000&gt;The device handlers are
supposed to be able to scan their devices and report any newly added devices to the
configuration database. In the case of the OneWire network this means that the device
handler scan the network and report the unique address of each device newly added
to the network. The new devices have to be configured by adding ‘data channels’ to
them to enable data collection. The channels define the database and data source in
the (RRD)database used to store the data together with sample and storage interval.
After configuration the logger is restarted, or set to start logging new devices. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;At
the moment the biggest problem is that there are time intervals all over the place! &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;The
logger runs for the moment &lt;font color=#ff0000&gt;every second&lt;/font&gt; then the channel
have a &lt;font color=#ff0000&gt;sample interval&lt;/font&gt;, indicating how often the device
must be read, a &lt;font color=#ff0000&gt;tick interval&lt;/font&gt; determine how often the data
shall be written to the database. The tick interval must be the same as the &lt;font color=#ff0000&gt;tick
parameter&lt;/font&gt; on the RRD database.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I’m
thinking of creating a configuration application to make it easier but this is done
very seldom and I’m not sure if it’s worth the effort. But I have to do something
for all the intervals!&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=fa9a80c4-15e2-4a21-a5eb-c625a2b79c42" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,fa9a80c4-15e2-4a21-a5eb-c625a2b79c42.aspx</comments>
      <category>logger</category>
      <category>RRD</category>
    </item>
    <item>
      <trackback:ping>http://blog.minidev.se/Trackback.aspx?guid=a7d18263-2a96-47a8-ba44-1b7256bf4f58</trackback:ping>
      <pingback:server>http://blog.minidev.se/pingback.aspx</pingback:server>
      <pingback:target>http://blog.minidev.se/PermaLink,guid,a7d18263-2a96-47a8-ba44-1b7256bf4f58.aspx</pingback:target>
      <dc:creator>Mikael Nilsson</dc:creator>
      <wfw:comment>http://blog.minidev.se/CommentView,guid,a7d18263-2a96-47a8-ba44-1b7256bf4f58.aspx</wfw:comment>
      <wfw:commentRss>http://blog.minidev.se/SyndicationService.asmx/GetEntryCommentsRss?guid=a7d18263-2a96-47a8-ba44-1b7256bf4f58</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Works done! Almost all code in rrd4j is ported to C# and I have run the tutorial
examples. The trickiest part was the polygon drawing for bar charts. It
took some time to figure out how to do it in GDI+ but in the end it was easier
than in Java. After adjusting NaN values and adding missing segment at the end of the
data series I just feed the segments into a Drawing.GraphicsPath object
and call FillPath at the end. Works like charm!
</p>
        <p>
There are still a lot of test to run on the package and I guess I can't resist to
do some refactoring to apply some more C# style and remove the Java syntax that remains
in the code. The refactoring will be done on a 'need to be done' basis. 
</p>
        <p>
So now I'm moving on to my logger project so I'll get some data to feed into the RRD
</p>
        <img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=a7d18263-2a96-47a8-ba44-1b7256bf4f58" />
      </body>
      <title>RRD ported to C#</title>
      <guid isPermaLink="false">http://blog.minidev.se/PermaLink,guid,a7d18263-2a96-47a8-ba44-1b7256bf4f58.aspx</guid>
      <link>http://blog.minidev.se/2009/10/07/RRDPortedToC.aspx</link>
      <pubDate>Wed, 07 Oct 2009 19:57:31 GMT</pubDate>
      <description>&lt;p&gt;
Works done! Almost all code in rrd4j is ported to C# and&amp;nbsp;I have run the tutorial
examples. The trickiest part&amp;nbsp;was the&amp;nbsp;polygon drawing for bar charts. It
took some time&amp;nbsp;to figure out how to do it in GDI+ but in the end it was easier
than in Java. After adjusting NaN values and adding missing segment at the end of&amp;nbsp;the
data series&amp;nbsp;I just feed the segments into a&amp;nbsp;Drawing.GraphicsPath object
and call FillPath at the end. Works like charm!
&lt;/p&gt;
&lt;p&gt;
There are still a lot of test to run on the package and I guess I can't resist to
do some refactoring to apply some more C# style and remove the Java syntax that remains
in the code. The refactoring will be done on a 'need to be done' basis. 
&lt;/p&gt;
&lt;p&gt;
So now I'm moving on to my logger project so I'll get some data to feed into the RRD
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.minidev.se/aggbug.ashx?id=a7d18263-2a96-47a8-ba44-1b7256bf4f58" /&gt;</description>
      <comments>http://blog.minidev.se/CommentView,guid,a7d18263-2a96-47a8-ba44-1b7256bf4f58.aspx</comments>
      <category>logger</category>
    </item>
  </channel>
</rss>