Tuesday, October 1, 2013

Symmetricds Cookies support

My problem : we need cookies support for SymmetricDS client in order to authenticate against central SymmetricDS.
Solution :
Create an extension point class
 package com.synch.extension;  
 import java.net.CookieHandler;  
 import java.net.CookieManager;  
 import java.net.CookiePolicy;  
 import org.jumpmind.extension.IExtensionPoint;  
 import org.slf4j.Logger;  
 import org.slf4j.LoggerFactory;  
 public class CookieManagerConf implements IExtensionPoint{  
      protected final Logger log = LoggerFactory.getLogger(getClass());  
      public CookieManagerConf() {  
           System.out.println("Cookie manager initialized ------------------------>");  
           log.info("Cookie manager initialized ---------------------->");  
           CookieManager manager = new CookieManager(null,CookiePolicy.ACCEPT_ALL);  
           CookieHandler.setDefault(manager);  
      }  
 }  

Create extension XML in {classpath}\conf\symmetric-extensions.xml as follow :
 <?xml version="1.0" encoding="UTF-8"?>  
 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xmlns:lang="http://www.springframework.org/schema/lang"  
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
             http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd" default-lazy-init="true">  
      <bean id="cookieManager" class="com.synch.extension.CookieManagerConf">  
      </bean>  
 </beans>  

Kalman filter with dspic33f : fixed point vs floating point speed comparison

Initially, I implemented Kalman filter for Microchip dspic33f MPU with floating point arithmetic calculations(mainly 2x2 float matrices) to measure inclination angle. The filter works brilliantly. However, I knew that fixed point calculation can greatly speed up the floating point Kalman filter. Hence, I decided to implement my Kalman filter in Q16 format. After that, I compared speed of 2 algorithms by using an oscilloscope. The output pin is set at the beginning and cleared at the end of the Kalman process.
Floating point Kalman filter :

Fixed point Kalman filter :

From above pictures, the fixed Kalman filter uses only ~46% time taken by floating point Kalman filter. Note : My dspic33f runs at 80 MHz.