A Software Technologist's Blog (Wanna Email Me?)

My Experience with Using CLIPS

March 25, 2011 By miketeo

(A chinese translation of this post is available here)

I had the opportunity to incorporate a CLIPS expert system in one of my recent projects for bill plans logics and monitoring of health of our system modules. Both of them are classical sore-points for OO/procedural programming methodologies. We had made an attempt to implement the bill plan logics in an initial version using python, but it ended up in a meshed-up code with half-dozen levels of nested-if-then-else control structures. The system would have eventually ended up to become an excellent case study for project maintenance failure if we had persisted in using an OO/procedural language for the implementation.

Even though CLIPS has worked well for us, I still feel that it may not be suitable for all projects.

Requires radical change in programming paradigm.
Instead of executing your operations in a procedural manner, you have to “train” yourself to re-think your operations as separate rules; these rules operate in tandem in a series of recognize-act cycles. When a group of rules matches, a series of actions can be performed which may change the conditions of the rules in some manner. This may lead to other rulesets (or even the current ruleset) being triggered.
Another issue you would face is how to get these rulesets to “fire” in the order that you want without imposing too much restrictions on them. The conditions in each ruleset should not depend on previous states of other rulesets, i.e. they should not be coupled to each other.

Requires deep understanding of the knowledge domain.
To model the rules, you will need to arrange your knowledge on how things operate in your problem domain into a series of rules/patterns. Usually, you can attempt to perform this knowledge modeling process yourself, or to engage a knowledge modeling expert to assist you.

Execution should be data-driven or pattern-driven.
If you encounter a need to perform lots of if-conditional statements on many variables, the execution process is most likely data-driven or pattern-driven. Any non-trivial knowledge domain usually involves more than a dozen variables to work with. In OO/procedural, this means your source code will end up in meshed-up manner with multi-levels of nested if-else statements. CLIPS language syntax allows you to specify the conditions (i.e. rules) for a group of tasks to be executed in an organized manner.
However, one must be careful to plan and organize the data structure of the CLIPS facts and classes. Every datum in each CLIPS class and facts should be well-encapsulated using the same data-encapsulation principles in OO development methdology).

SingTel Huawei E169 3G Modem on Windows 7

January 30, 2010 By miketeo

I have recently upgraded my laptop from Windows Vista 32-bit to Windows 7 Home Premium. I have performed the following steps to get my Huawei E169 3G modem working in Windows 7 again.

  1. Uninstall the SingTel Broadband on Mobile software and unplug your 3G modem from your PC/laptop
  2. Download this patch from Huawei (Local Mirror), extract the setup file and run it.
  3. Reboot your PC/laptop
  4. Plug back your 3G modem. Wait for the SingTel CD drive to appear in your “My Computer”
  5. Install the SingTel Broadband on Mobile software again. Your 3G modem should be automatically be detected after the software has been installed.

PS. SingTel Broadband on Mobile web site has some firmwares and Windows 7 fixes for Huawei E169 modem. But these softwares keep giving some code 2 errors indicating that I do not have administrator permission or the data card is being used by other software on the PC/laptop. Well, in all cases, I have gotten my 3G modem working without these “upgrades”. Thank goodness.

The protocol is inferred by reading the source code of egd version 0.9. It is a simple binary protocol which contains 4 commands. When the client connects to EGD via unix sockets or TCP sockets, the client will initiate the communication by sending the request. The format of the request is dependent upon the nature of request; the first byte of the request will be the command code (0x01 to 0x04) that will tell the service the nature of the request.

Read the rest of this entry »

Calculating MD5 Digest with iPhone SDK

September 22, 2008 By miketeo

The code originates from http://blog.andrewpaulsimmons.com/2008/07/md5-hash-on-iphone.html.
I have copied it here for mirroring purposes. Please express your appreciations to Andrew for his efforts.

#import <CommonCrypto/CommonDigest.h>

NSString* md5( NSString *str )
   const char *cStr = [str UTF8String];
   unsigned char result[CC_MD5_DIGEST_LENGTH];
   CC_MD5( cStr, strlen(cStr), result );
   return [NSString  stringWithFormat:
       result[0], result[1], result[2], result[3], result[4],
       result[5], result[6], result[7],
       result[8], result[9], result[10], result[11], result[12],
       result[13], result[14], result[15]

Simple iPhone Tutorial (Part 3)

August 31, 2008 By miketeo

With the completion of Part 2, the user interface of your application is almost ready. However, it does not serve much purpose since it does not interact with the users. In this last part of the tutorial, you will add in action handlers using addTarget API and @selector to capture user actions.

Read the rest of this entry »