Jan 292010
 

I recently tried to find our manual for our “British Gas RC Plus Termostat” on the internet as we have lost our original manual.

Anyway, after some research, I found they British Gas just re-badged them from Drayton Digistat and here is the links to the pages that contain the .pdfs’.

http://www.gasapplianceguide.co.uk/DigistatPlus2.pdf
http://www.draytoncontrols.co.uk/WorkArea/DownloadAsset.aspx?id=4235

 

Microsoft have just updated the “Application Architecture”.  I can’t say I have read it from cover to cover but it is being downloaded to my ebook reader…

The guide helps you to:

  • Understand the underlying architecture and design principles and patterns for developing successful solutions on the Microsoft platform and the .NET Framework.
  • Identify appropriate strategies and design patterns that will help you design your solution’s layers, components, and services.
  • Identify and address the key engineering decision points for your solution.
  • Identify and address the key quality attributes and crosscutting concerns for your solution.
  • Create a candidate baseline architecture for your solution.
  • Choose the right technologies for your solution.
  • Identify patterns & practices solution assets and further guidance that will help you to implement your solution

The guide can be downloaded from: http://www.microsoft.com/downloads/details.aspx?FamilyID=ce40e4e1-9838-4c89-a197-a373b2a60df2&DisplayLang=en

 

My life seems to full of firmware updates, yesterday it was my iRiver Story ebook reader.. today I see my Olympus E-P1 camera which has been updated.

To update you use the “Olympus Master 2″ program, connect the cable from computer to camera.. click storage on the camera.. select camera… update and away you go…

If all goes well your camera should have the largest “OK” message on the LCD screen I seen in years…

Here is what they say has changed:

E-P1 Firmware Ver1.2 has incorporated the following upgrade.

[Modification]

  • Reduced time of the MF ASSIST enlarged display to improve operability.
  • REC VIEW enabled when the monitor’s backlight is set to off.
 

The use of scripting languages with other languages has increased over the last couple of years, from a simple case of interoperability, reuse of scripting code to allowing your code to customised via the user of external scripts. All of which are real world examples I have seen customers use.

Interoperability between languages is very important to COBOL environments just as much as other languages. Some platforms such as Microsoft’s .Net with their CLR makes life much easier by allowing all languages to share a common infrastructure ie: the instruction set and the VM (MSIL and CLR) along with a base class library to get you started.

Environments such as Sun’s VM (JVM) provide two different approaches to interoperability with Java, the first is via JNI/JNA and the second is producing bytecode that runs as is on the VM.

Although the Micro Focus COBOL compiler does not support JVM bytecode or Java source generation it does have support for invoking classes/methods via the OO invoke verb.

This mechanism is very simple to use, you just need to let our object COBOL runtime know the class is a Java class, which can be done by placing $JAVA$ before the name of the class and ensuring the class itself can be found by the JVM itself usually by adding an extra directories or .jar files to the CLASSPATH environment variable.

With Java 6.0 and JSR 223 support for Java based scripting languages were provided via the package javax.script.

Java has a wealth of scripting languages from awk to xlst. My favourites being jpython, jruby and javascript.

The java.net website has a comprehensive list of scripting languages -
https://scripting.dev.java.net/.

To use the scripting packages, you first need to create a ScriptEngineManager, then use this to create a specific ScriptEngine object for your chosen scripting language and use it.

For example:

  • Create a ScriptEngineManager object.
  • Retrieve a ScriptEngine object from the manager.
  • Evaluate a script using the ScriptEngine object.
  • In COBOL this is quite simply:


    *> ooctrl(+p) required for COM and Java classes
    *> ooctrl(-f) used to preserve case of method names for Java
    $set ooctrl(+p) ooctrl(-f)

    class-control.
    cls-Script-EngineManager is
    class "$JAVA$javax.script.ScriptEngineManager"
    cls-Script-Engine is
    class "$JAVA$javax.script.ScriptEngine"
    cls-object is
    class "$JAVA$java.lang.Object"
    cls-System is
    class "$JAVA$java.lang.System"
    cls-PrintStream is
    class "$JAVA$java.io.PrintStream"
    .

    working-storage section.
    01 ws-obj-sem object reference cls-Script-EngineManager.
    01 ws-javascript object reference cls-Script-Engine.
    01 ws-obj object reference cls-object.

    01 ws-pout object reference cls-PrintStream.
    procedure division.
    invoke cls-Script-EngineManager "new"
    returning ws-obj-sem
    end-invoke

    invoke ws-obj-sem "getEngineByName" using
    "JavaScript" returning ws-javascript
    end-invoke

    invoke ws-javascript "eval" using
    z"print('Hello, world!')"
    returning ws-obj
    end-invoke

    if ws-obj not equal null
    invoke cls-System "getout" returning ws-pout
    invoke ws-pout "println" using ws-obj
    invoke ws-pout "finalize" returning ws-pout
    invoke ws-obj "finalize" returning ws-obj
    end-if

    $if NO-FINALIZE not defined
    invoke ws-obj-sem "finalize" returning ws-obj-sem
    invoke ws-javascript "finalize" returning ws-javascript
    $end
    stop run.

    The actual Javascript being execute is contained in the invoke statement, which is simply:


    print('Hello, world!')

    To use the above example, we first need to compile the code and run it.. which is done as follows:


    C:jscriptingHelloWorld>cobol cbljscript.cbl int();
    Micro Focus Net Express V5
    Version 6.0.00059 Copyright (C) 1984-2009 Micro Focus (IP) Limited.
    URN AXCGG/AA0/00000
    * Checking complete with no errors - starting code generation
    * Generating cbljscript
    * Data: 848 Code: 1992 Literals: 904

    C:jscriptingHelloWorld>runm cbljscript
    Micro Focus Net Express V6.0.00059
    RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited.
    URN AXCGG/AA0/00000
    Hello, world!

    This is just the start, the next thing piece that is required with interoperability to another language is the ability to pass parameters to in and out of the script. Luckily for us the clever chaps on the jsr group have provided ‘put’ and ‘get’ methods that allows us to simply put a name parameter and get the resulting updated or new parameter.

    So consider the example, where we need to setup a parameter called ‘message’ for the script and then read a parameter called ‘replyMessage’ after the script has been executed. The javascript to do this is:


    /* Do some insanity checking! */
    if (typeof(message) == 'undefined')
    {
    message = "ERROR - 'message' has not been setup"
    }

    println(message)

    replyMessage = "Hello from javascript"

    To setup the message parameter, we just need todo.


    *> Put a variable in engine, so the javascript
    *> can use it.
    invoke ws-javascript "put" using
    z"message"
    z"Hello World from COBOL!"
    end-invoke

    The after the script has executed, we just need to use the ‘get’ method..


    *> get a variable in engine
    invoke ws-javascript "get" using
    z"replyMessage"
    returning ws-message
    end-invoke

    *> now display the replyMessage if it is available
    if ws-message not equal null
    invoke ws-pout "println" using ws-message
    else
    display "Javascript did not set a replyMessage var"

    The completed COBOL example below, uses a side file for the javascript too, the code is as follows:


    *> ooctrl(+p) required for COM and Java classes
    *> ooctrl(-f) used to preserve case of method names for Java
    $set ooctrl(+p) ooctrl(-f)

    class-control.
    cls-Script-EngineManager is
    class "$JAVA$javax.script.ScriptEngineManager"
    cls-Script-Engine is
    class "$JAVA$javax.script.ScriptEngine"
    cls-object is
    class "$JAVA$java.lang.Object"
    cls-System is
    class "$JAVA$java.lang.System"
    cls-PrintStream is
    class "$JAVA$java.io.PrintStream"
    cls-FileReader is
    class "$JAVA$java.io.FileReader"
    .

    working-storage section.
    01 ws-file object reference cls-FileReader.
    01 ws-obj-sem object reference cls-Script-EngineManager.
    01 ws-javascript object reference cls-Script-Engine.
    01 ws-obj object reference cls-object.
    01 ws-message object reference cls-object.

    01 ws-pout object reference cls-PrintStream.
    procedure division.
    *> setup ws-pout to be System.out object
    invoke cls-System "getout" returning ws-pout

    *> Setup a FileReader object for the external helloworld.js file
    invoke cls-FileReader "new" using
    z"helloworld.js"
    returning ws-file
    end-invoke

    *> Create a new script manager
    invoke cls-Script-EngineManager "new"
    returning ws-obj-sem
    end-invoke

    *> Find the javascript engine
    invoke ws-obj-sem "getEngineByName" using
    "JavaScript" returning ws-javascript
    end-invoke

    *> Put a variable in engine, so the javascript
    *> can use it.
    invoke ws-javascript "put" using
    z"message"
    z"Hello World from COBOL!"
    end-invoke

    *> do some javascript stuff!
    invoke ws-javascript "eval" using
    ws-file
    returning ws-obj-sem
    end-invoke

    *> get a variable in engine
    invoke ws-javascript "get" using
    z"replyMessage"
    returning ws-message
    end-invoke

    *> now display the replyMessage if it is available
    if ws-message not equal null
    invoke ws-pout "println" using ws-message
    else
    display "Javascript did not set a replyMessage var"
    end-if

    *> cleanup code, not strickly needed for the example but
    *> its good practice, to do it.
    $if NO-FINALIZE not defined
    if ws-message not equal null
    invoke ws-message "finalize" returning ws-message
    end-if
    if ws-pout not equal null
    invoke ws-pout "finalize" returning ws-pout
    end-if
    invoke ws-obj-sem "finalize" returning ws-obj-sem
    invoke ws-javascript "finalize" returning ws-javascript
    $end

    stop run.


    C:jscriptingHelloWorld3>cobol cbljscript.cbl int();
    Micro Focus Net Express V5
    Version 6.0.00059 Copyright (C) 1984-2009 Micro Focus (IP) Limited.
    URN AXCGG/AA0/00000
    * Checking complete with no errors - starting code generation
    * Generating cbljscript
    * Data: 888 Code: 2528 Literals: 1296

    C:jscriptingHelloWorld3>runm cbljscript
    Micro Focus Net Express V6.0.00059
    RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited.
    URN AXCGG/AA0/00000
    Hello World from COBOL!
    Hello from javascript

    As you can see from the code above, setting up parameter is pretty easy todo but sometimes we just want to execute a function in the scripting language such as:


    function testMessage(msg)
    {
    print("testMessage : " + msg);
    }

    The ScriptEngine object that we have created to use the scripting engine may implement an optional interface called javax.script.Invocable, if the scripting engine we are using does provide this interface then a method called invokeFunction(..) can be used.

    In order to reduce the size of the COBOL code, I have coded a simple utils class in java as a simple proxy layer, the code is pretty simple but does make it easier for the COBOL to use the invokeFunction() method.

    import javax.script.*;

    public class utils {
    public static Invocable getInvocable(ScriptEngine obj) {
    return (Invocable)obj;
    }

    public static Object invokeFunction(ScriptEngine obj, String function, Object p1) throws ScriptException, NoSuchMethodException {
    Invocable iObj = getInvocable(obj);
    return iObj.invokeFunction(function, p1);
    }
    }

    Then from the COBOL side, we can just use the invokeFunction above.

    For example:


    *> invoke a function with one parameter
    invoke cls-utils "invokeFunction" using
    ws-javascript
    z"testMessage"
    z"Hello to function testMessage from COBOL"

    Which gives us the following output when executed.


    C:jscriptingInvokeFunction>runm cbljscript
    Micro Focus Net Express V6.0.00059
    RUN TIME ENVIRONMENT Copyright (C) 1984-2009 Micro Focus (IP) Limited.
    URN AXCGG/AA0/00000

    testMessage : Hello to function testMessage from COBOL

    The completed example is as follows:


    *> ooctrl(+p) required for COM and Java classes
    *> ooctrl(-f) used to preserve case of method names for Java
    $set ooctrl(+p) ooctrl(-f)

    class-control.
    cls-Script-EngineManager is
    class "$JAVA$javax.script.ScriptEngineManager"
    cls-Script-Engine is
    class "$JAVA$javax.script.ScriptEngine"
    cls-object is
    class "$JAVA$java.lang.Object"
    cls-System is
    class "$JAVA$java.lang.System"
    cls-PrintStream is
    class "$JAVA$java.io.PrintStream"
    cls-FileReader is
    class "$JAVA$java.io.FileReader"
    cls-Utils is
    class "$JAVA$utils"
    .

    working-storage section.
    01 ws-file object reference cls-FileReader.
    01 ws-obj-sem object reference cls-Script-EngineManager.
    01 ws-javascript object reference cls-Script-Engine.
    01 ws-message object reference cls-object.

    01 ws-pout object reference cls-PrintStream.
    procedure division.
    *> setup ws-pout to be System.out object
    invoke cls-System "getout" returning ws-pout

    *> Setup a FileReader object for the external helloworld.js file
    invoke cls-FileReader "new" using
    z"helloworld.js"
    returning ws-file
    end-invoke

    *> Create a new script manager
    invoke cls-Script-EngineManager "new"
    returning ws-obj-sem
    end-invoke

    *> Find the javascript engine
    invoke ws-obj-sem "getEngineByName" using
    "JavaScript" returning ws-javascript
    end-invoke

    *> do some javascript function
    invoke ws-javascript "eval" using
    ws-file
    returning ws-obj-sem
    end-invoke

    *> invoke a function with one parameter
    invoke cls-utils "invokeFunction" using
    ws-javascript
    z"testMessage"
    z"Hello to function testMessage from COBOL"
    returning ws-message
    end-invoke

    *> cleanup code, not strickly needed for the example but
    *> its good practice, to do it.
    $if NO-FINALIZE not defined
    if ws-file not equal null
    invoke ws-file "finalize" returning ws-file
    end-if
    if ws-message not equal null
    invoke ws-message "finalize" returning ws-message
    end-if
    if ws-pout not equal null
    invoke ws-pout "finalize" returning ws-pout
    end-if
    if ws-obj-sem not equal null
    invoke ws-obj-sem "finalize" returning ws-obj-sem
    end-if
    if ws-javascript not equal null
    invoke ws-javascript "finalize" returning ws-javascript
    end-if
    $end

    stop run.

    Conclusions: Using a Java based scripting language from COBOL is quite easy, so feel free to use it. Now which scripting language should I use...?

     

    iRiver have again upgraded the firmware for the “iRiver Story” to revision 1.6.1 (previous v1.6.0 has been removed).

    So what is different?

    1. Added Functions
    a. Dithering function on PDF File and EPUB File
    b. FB2Viewer function

    2. Improvements

    a. Loading Speed improved on PDF File

    The firmware can be downloaded from [click on me].   Time to upgrade… fingers crossed it helps…

    I have updated the firmware and it seems to basically work, for those that download it, here are the checksums:

    Note: if you have downloaded v.1.6.1, the checksum’s should be:


    stephen-gennards-macbook:v1.6.1 spg$ sum ebook.hex
    32519 64116 ebook.hex
    stephen-gennards-macbook:v1.6.1 spg$ md5 ebook.hex
    MD5 (ebook.hex) = 456014efac1b638f8d3e4088f1a628be

    If however your checksum’s are… then you have the earlier v1.6.0 which appears to have been removed from the website, so you need togo back to the website and re-download it.


    $ sum ebook.hex
    33843 64116 ebook.hex
    $ md5 ebook.hex
    MD5 (ebook.hex) = 591e9274a476b8337f40b2ec30e21a50

     

    Since installing the latest firmware update aka version 1.5.   I have experience the odd issue but as I have tried to be analytical about what issues I see.

    I have been lucky enough to be reading a couple of books from O’Reilly which deliver their eBooks in multiple formats, as the iRiver supports both ePub and PDF.  I have chosen to install both versions of the same book, so if I experience a issue with one I can flip to the other.

    Here is what I have found so far:

    • Reading of PDF seems to be the most reliable
    • Reading of ePub documents seems to very slow in comparison
    • PDF reading can be pain with small text, reflow helps but destroys technical book formats that has embedded code in it
    • Battery life is much better

    I have had a couple of crashes/hangs of the iRiver but so far it has only been with ePub files.  So guess what… I will be avoiding them like the plague.

    Has other people had the similar issues?

     

    As a MacBook user who has used Virtualisation on the mac for sometime now but only usually with Linux based OS, I was forced to use it with Windows recently and I quickly found out how badly it handles UK Macbook keyboards.

    The default UK keyboard mapping on a MacBook are pretty much useless when using Virtual PC emulators such VirtualBox or VMWARE.

    With this in mind, have produced a custom keyboard layout which maps all the keys to right place.

    The only two exceptions are the two OPT keys, which I could only managed to map them to ALT-n keys, so the alternative mapping for these are:

    € aka left OPT 2 is mapped to right ALT 2

    # aka left OPT 3 is mapped to right ALT 3

    To use the customer keyboard mapping, download the .zip, unzip it.. and click on mbkbdsetup.exe and it will install the custom keyboard called “United Kindom – MacBook – Custom“.

    And this me using it… boy did this make more productive!

    This a screen shot me trying it out… :-)

    (link fixed)

     

    Today I got opened up ,y Amateur Photography magazaine and found an advert for a free flash for people who have purchased an Olympus E-P1 over the christmas period. I personally did not purchase one but someone near and dear to me did buy one for me to use as my travel camera rather than carrying my Nikon D300 + Lenses everywhere.

    The link to the Olympus website is here: http://www.olympus.co.uk/consumer/208_lighten-up_E-P1.htm.