Tags:
create new tag
view all tags

Logic

Below you will see a sample Logic. Java use the same 'extends' to extend the abstract class located in the Odyssey library (mssl.ucl.odyssey.logic.Juncture). As noted in the main Odyssey page and in the XML, you can define a Logic tag to be BEGIN, FIRST, MID, LAST, or END.
  • BEGIN - is the first thing called after the facade is instantiated and before any data is loaded, and is called before any Looping (if any).
  • FIRST - is the FIRST thing no data has been loaded and no facade has been called, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.
  • MID - All data has been loaded for the Facade nothing else, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.
  • POSTPRECONTROL -- Immediately called after preControl method.
  • POSTCALL -- Immediately called after call method.
  • POSTPOSTCONTROL -- Immediately after postcontrol method.
  • LAST - All Facade methods called, DM data written and Storage data will be written, but is always called in a Loop hence if you load multiple DM but your Facade uses Single DM this Logic is always called.
  • END - is the thing called and is after any looping (if any). This is the last thing called before going on to the next test.

 public void doTrek(ModuleFacade facade, Hashtable storage, TestJourney tj)
When you create a Logic class you must define this doTrek method and with it will come your ModuleFacade, your own personal Storage hashtable you can use, and a TestJourney class which is mostly used to pass to the goto methods. I ask you please do not change the TestJourney using the 'set' methods, although you might find the getHistory helpful to see how tests have been called or to see what test your currently on and the next test in the chain. Note the ModuleFacade depending on FIRST (no data), MID (INPUT and PARAM data loaded), LAST/END (ALL facade data located both input and output). It will have what you need from the Facade class.

GOTO

Below you will see two sample method calls of a goto:
They have 3 params. The first is just a TestJourney that is originally passed into your doTrek method, the second is testID that you need to give a String of the test you are going to, and finally the 'now' boolean, which says you want to go to it right now, as soon as this method is over. Hence if this logic was a FIRST or MID type logic, then don't even bother calling the Facade, you've found something in the data that is wrong and need to go to a test right now.
gotoTestKeepSequence(testjourney, testid, now)   
gotoTestNewSequence(testjourney, testid, now)   

You might be wondering why there are two different methods, a 'New' and a 'Keep' Sequence. Well, the 'NEW' which will probably be used the most and, typical of loops, means start a new sequence of tests from the one you are about to 'goto'. 'Keep' is for coming back. Best to show you in a alphabet example. lets say you have Tests A->B....->Z and you are currently on 'M'. You decide to go back to test B and start everything over hence M->B->C->D->.... and so on. Then you need the 'NewSequence' BUT What if you just want to go back to B and then come back to 'N', hence you want M->B->N->O->P.... and so on. There are a few cases where this would be nice, hence the 'KeepSequence' go to method.

Final Note: another method called 'skipTest()' is also available, that will simply skip to the next test in the sequence.

Handling Large Amounts of Data

As the datasets keep getting bigger and bigger, we can't hold everything in memory. In comes the 'TransitLoop' Logic class. See greater detail here: Odyssey LoopLogic

END

As noted below you will see one 'endChain' method which you give it a message and if this is an end for an error or not an error. Hence their is either Success or ERROR in this type of endChain.
public void endChain(TestJourney tj, String message,boolean error)

Common Logic classes

Below is a listing of common Logic classes that is so common they are now packaged with Odyssey:
  • mssl.ucl.odyssey.commonlogic.PrintStorageLogic -- prints out the Storage hashtable.

Logic Description

Now for a sample Logic class that does not really do much just iterates a counter - see attachments for better examples of goto and looping. MTASourceLoopLogic for instance uses values from a storage array to determine when and where to loop. The below sample demonstrated here is more about seeing the method signature and imports:
package mssl.ucl.odyssey.samplelogic;

//you will need all these imports.
import gaia.dpcc.facade.ModuleFacade;
import java.util.Hashtable;
import mssl.ucl.odyssey.TestJourney;
import mssl.ucl.odyssey.logic.Juncture;

//BE SURE TO EXTENDS THIS JUNCTURE. It is what defines the Interface and abstract methods along with 'goto' ability.
public class LoopLogic extends Juncture  {

    public void doTrek(ModuleFacade facade, Hashtable storage, TestJourney tj) {
       int loop = 0;
       if(storage.containsKey("loopindex")) {
          loop = (Integer)storage.get("loopindex");
          System.out.println("Found loop it was " + loop);
                         //typically you would do an endChain or goto statement on a certain loop number.  You can see these
                         // types of examples in the attached samples.
          loop++;
          
       }
                 //store it in the hashtable will be used later in another Logic or in the XML file.
       storage.put("loopindex", loop);
       System.out.println("Loop now at = " + loop);

                 

        }
   
}

-- KevinBenson - 02 Jul 2009

  • MTASourceLoopLogic.java: MTA Loop Logic that can be used as BEGIN or END. Uses Storage info to determine where and when to loop and when to stop.

  • GotoLogic.java: Goto Logic back to TestOne (from TestThree). Uses KeepSequence

  • GotoNewSequenceLogic.java: Goto Logic again but uses NewSequence and needs Storage use to make sure no infinite loop happens.

Topic attachments
I Attachment History ActionSorted ascending Size Date Who Comment
Java source code filejava EndChain.java r1 manage 1.8 K 2009-11-20 - 13:13 HowardHuckle Simply forces an end to the chain when used as an END logic class
Java source code filejava GotoLogic.java r1 manage 0.4 K 2009-08-07 - 16:05 KevinBenson Goto Logic back to TestOne (from TestThree). Uses KeepSequence
Java source code filejava GotoNewSequenceLogic.java r1 manage 0.6 K 2009-08-07 - 16:04 KevinBenson Goto Logic again but uses NewSequence and needs Storage use to make sure no infinite loop happens.
Java source code filejava LoopLogic.java r1 manage 0.6 K 2009-08-07 - 16:05 KevinBenson Simple Loop that just increments.
Java source code filejava MTASourceLoopLogic.java r1 manage 1.3 K 2009-11-20 - 11:44 KevinBenson MTA Loop Logic that can be used as BEGIN or END. Uses Storage info to determine where and when to loop and when to stop.
Java source code filejava MassageEtaZeta.java r1 manage 3.1 K 2009-11-20 - 13:12 HowardHuckle Alters input data 'on the fly' when used as a MID logic class
Java source code filejava SpectrumPeakValue.java r1 manage 2.8 K 2009-11-20 - 13:15 HowardHuckle Examines contents of output data 'on the fly' when used as a LAST logic class
Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | More topic actions
Topic revision: r9 - 2013-03-14 - KevinBenson
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback