Package trackerModule.core.datastructure

Examples of trackerModule.core.datastructure.Unit


   * @param illicitCargoPlan_shipName the illicit cargo plan_ship name
   */
  public void init(String shipType, String shipLocation, String illicitCargoPlan_shipName){
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Initialize ship's TDB
    Unit ships         = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS");
    Unit ship         = ships.create(getName());
    Unit mission      = ship.create("Mission");
    Unit departure       = ship.create("Departure");
    Unit location       = ship.create("Location");
    Unit destination    = ship.create("Destination");
    Unit type         = ship.create("Type");
    Unit InRoute         = ship.create("Route");
    Unit meeting       = ship.create("Meeting");
    Unit appearance       = ship.create("Appearance");
    Unit size         = ship.create("Size");
    Unit crew         = ship.create("Crew");
    Unit Latitude      = ship.create("Latitude");
    Unit Longitude      = ship.create("Longitude");
    Unit Speed        = ship.create("Speed");
    Unit soi         = ship.create("SOI");
    Unit state         = ship.create("State");
    Unit stateTime      = ship.create("StateTime");
    Unit stateTimeCount    = ship.create("StateTimeCount");
    Unit abnormalAction   = ship.create("AbnormalAction");
    Unit x           = ship.create("X");
    Unit y           = ship.create("Y");
    Unit IllicitCargoPlanShip  = ship.create("IllicitCargoPlan_Ship");
    Unit IllicitCargoPlanArea  = ship.create("IllicitCargoPlan_Area");
   
    // new continuous variables
//    Unit speedChange = ship.create("speedChange");
//    Unit turnRate = ship.create("turnRate");
//    Unit propellerTurnCount = ship.create("propellerTurnCount");
//    Unit cavitation = ship.create("cavitation");
//    Unit shipRCSChange = ship.create("shipRCSChange");
   
    // init the new continuous variables
//    speedChange.setData(0);
//    turnRate.setData(0);
//    propellerTurnCount.setData(0);
//    cavitation.setData(0);
//    shipRCSChange.setData(0);
   
    soi.setData(0.0);
   
    //set state
    state.setData("none");
    stateTime.setData(0);
    stateTimeCount.setData(0);
    Speed.setData(10.0);
    //set ship type
    if( shipType != null )
      type.setData(0, shipType);
    else
      type.setData(0, getShipType());
    //set mission
    mission.setData(0, getMission());
   
    //set information
    InRoute.setData(0, "Usual");
    meeting.setData(0, "none");
    IllicitCargoPlanArea.setData(0, "none");
    appearance.setData(0, "APP1");
    size.setData(0, getSize());
   
    //set initial location
    if( shipLocation!= null )
View Full Code Here


 
  /**
   * Initialize the rule.
   */
  public void initRule(){
    Unit type    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName()+".Type");
     
    //set rule set
    if(type.getData().equalsIgnoreCase("FishingShip")) {
      createRulesForNormalFishingShip();
    }else
    if(type.getData().equalsIgnoreCase("MerchantShip")) {
      createRulesForNormalMerchantShip();
    }else
    if(type.getData().equalsIgnoreCase("BombingFishingShip")) {
      createRulesForBombingFishingShip();
    }else
    if(type.getData().equalsIgnoreCase("BombingMerchantShip")) {
      createRulesForBombingMerchantShip();
    }else
    if(type.getData().equalsIgnoreCase("IllicitCargoMerchantShip")) {
      createRulesForIllicitCargoShip();
    }else
    if(type.getData().equalsIgnoreCase("IllicitCargoFishingShip")) {
      createRulesForIllicitCargoShip();
    }else
    if(type.getData().equalsIgnoreCase("NavyShip")) {
      createRulesForNavyShip();
   
  }
View Full Code Here

   * @param strFirstLocation the first location
   * @param time the time
   * @return the string
   */
  String newRulesStarting(Rule_Unit sRule, String strFirstLocation, int time){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Rule_Unit ru = null;
   
    //rule start
    ru = sRule.create();
    ru.setCondition("IsGlobalTime", 1 );
    ru.setAction( "SetState", "waitingAt"+location.getData(0), time);
   
    //rule wait at a port //////////////////////////////////////////////////////// 
    ru = sRule.create();
    ru.setCondition("IsState", "waitingAt"+location.getData(0));
    ru.setCondition("TimeFinished");
    ru.setAction("SetState", "movingTo" + strFirstLocation );
    //not
    ru = sRule.create();
    ru.setCondition("IsState", "waitingAt"+location.getData(0));
    ru.setCondition("NotTimeFinished");
    ru.setAction("Waiting" );
   
    return "movingTo" + strFirstLocation;
   
View Full Code Here

  // create rule for Normal Fishing Ship
   /**
   * Creates the rules for normal fishing ship.
   */
  void createRulesForNormalFishingShip(){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
  
    //Determine tree ports scenario
    String strPrevState = "";
    int randSceario = getRandomOnThree();
    Rule_Unit sRule = null;
    if( randSceario == 0 ){//one port scenario
      int randPort = getRandomOnThree();
      String strFirst = World.This().mapNearestFishingArea.get(location.getData()).get(randPort);
      sRule = newRules();
      strPrevState = newRulesStarting( sRule, strFirst, getStartTimeForFishingShip() );
      strPrevState = newRulesMoving( sRule, strPrevState, strFirst, location.getData(), "Fishing" , (int)(Math.random()*60)+100);
     }else
     if( randSceario == 1 ){//two port scenario
      int randPort = getRandomOnThree();
      String strFirst = World.This().mapNearestFishingArea.get(location.getData()).get(randPort);
      int randPort2 = getRandomOnThree(randPort);
      String strSecond = World.This().mapNearestFishingArea.get(location.getData()).get(randPort2);
      sRule = newRules();
      strPrevState = newRulesStarting(sRule, strFirst, getStartTimeForFishingShip() );
      strPrevState = newRulesMoving( sRule, strPrevState, strFirst, strSecond, "Fishing", (int)(Math.random()*60)+100 );
      strPrevState = newRulesMoving( sRule, strPrevState, strSecond, location.getData(), "Fishing", (int)(Math.random()*60)+100 );
     
     }else{//tree or more port scenario
      int randPort = getRandomOnThree();
      String strFirst = World.This().mapNearestFishingArea.get(location.getData()).get(randPort);
      int randPort2 = getRandomOnThree(randPort);
      String strSecond = World.This().mapNearestFishingArea.get(location.getData()).get(randPort2);
      int randPort3 = getRandomOnThree(randPort, randPort2);
      String strThird = World.This().mapNearestFishingArea.get(location.getData()).get(randPort3);
      sRule = newRules();
      strPrevState = newRulesStarting(sRule, strFirst, getStartTimeForFishingShip() );
      strPrevState = newRulesMoving( sRule, strPrevState, strFirst, strSecond, "Fishing", (int)(Math.random()*60)+100 );
      strPrevState = newRulesMoving( sRule, strPrevState, strSecond, strThird, "Fishing", (int)(Math.random()*60)+100 );
      strPrevState = newRulesMoving( sRule, strPrevState, strThird, location.getData(), "Fishing", (int)(Math.random()*60)+100 );
     }
   
    newRulesEnding( sRule, strPrevState, location.getData(), "Anchoring" );
    
  }
View Full Code Here

  // create rule for Normal Merchant Ship
  /**
    * Creates the rules for normal merchant ship.
    */
   void createRulesForNormalMerchantShip(){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Unit destination  = ship.get("Destination");
  
    ArrayList<String> arrayWayPoints;   
    if( isMerchantArea(location.getData()) || isMerchantArea(destination.getData()) ){
      arrayWayPoints = World.This().spaMerchant.getShortestPath(location.getData(), destination.getData());
    }else {
      arrayWayPoints = World.This().spaArea.getShortestPath(location.getData(), destination.getData());
    }
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
      if( i == 0 ){
        sRule = newRules();
        strPrevState = newRulesStarting( sRule, str, getStartTimeForMerchantShip() );
      }
      else
        strPrevState = newRulesMoving( sRule, strPrevState, strPrev, str, "Moving", 1 );
      strPrev = str;
      i++;
    }
   
    newRulesEnding( sRule, strPrevState, destination.getData(), "Anchoring" );
 
  }
View Full Code Here

  // create rule for Bombing Fishing Ship
   /**
   * Creates the rules for bombing fishing ship.
   */
  void createRulesForBombingFishingShip(){
     Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Unit destination  = ship.get("Destination");
  
    ArrayList<String> arrayWayPoints;   
    arrayWayPoints = World.This().spaUnusualArea.getShortestPath(location.getData(), destination.getData());
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
      if( i == 0 ){
        sRule = newRules();
        strPrevState = newRulesStarting( sRule, str, getStartTimeForFishingShip() );
      }
      else
        strPrevState = newRulesMoving( sRule, strPrevState, strPrev, str, "Moving", 0 );
      strPrev = str;
      i++;
    }
   
    newRulesEnding( sRule, strPrevState, destination.getData(), "Attacking" );
 
  }
View Full Code Here

           
            String curName = (String)node.getUserObject();
            String parentName = (String)node.getParent().toString();
            
            if( parentName.equals("Entity")){
              Unit ship = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS." + curName);
             
              parentDlg.setCurEntity(ship);
              parentDlg.moveViewport(ship);
            }else{
              parentDlg.map.setCurTile(curName);
View Full Code Here

    */
   private DefaultMutableTreeNode createEntityTree() {
     DefaultMutableTreeNode t = new DefaultMutableTreeNode("Entity");
     DefaultMutableTreeNode temp = null;
    
     Unit ships = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS");
   
     if( ships != null )
     for( Unit ship : ships.getList() ){ 
       temp = new DefaultMutableTreeNode(ship.getName()); t.add(temp);  
     }
          
     return t;
   }
View Full Code Here

  // create rule for Bombing Merchant Ship
  /**
   * Creates the rules for bombing merchant ship.
   */
  void createRulesForBombingMerchantShip(){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Unit destination= ship.get("Destination");
  
    ArrayList<String> arrayWayPoints;   
    arrayWayPoints = World.This().spaUnusualArea.getShortestPath(location.getData(), destination.getData());
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    for( String str : arrayWayPoints ){
      if( i == 0 ){
        sRule = newRules();
        strPrevState = newRulesStarting( sRule, str, getStartTimeForMerchantShip() );
      }
      else
        strPrevState = newRulesMoving( sRule, strPrevState, strPrev, str, "Moving", 0 );
      strPrev = str;
      i++;
    }
   
    newRulesEnding( sRule, strPrevState, destination.getData(), "Attacking" );
     
  }
View Full Code Here

  // create rule for navy Ship
  /**
   * Creates the rules for navy ship.
   */
  void createRulesForNavyShip(){
    Unit ship    = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS."+getName());
    Unit location  = ship.get("Location");
    Unit destination  = ship.get("Destination");
  
    ArrayList<String> arrayWayPoints1;
    ArrayList<String> arrayWayPoints2;
    arrayWayPoints1 = World.This().spaArea.getShortestPath(location.getData(), destination.getData());
    arrayWayPoints2 = World.This().spaArea.getShortestPath(destination.getData(), location.getData());
   
    //System.out.println(location.getData() + " to " + destination.getData());
    //System.out.println(arrayWayPoints1.toString());
    //System.out.println(arrayWayPoints2.toString());
   
    Rule_Unit sRule = null;
   
    String strPrevState = "";
    String strPrev = "";
    int i = 0;
    int turning = 10; // how many patrol
   
    for( int k = 0; k < turning; k++ ){
      for( String str : arrayWayPoints1 ){
        if( i == 0 ){
          sRule = newRules();
          strPrevState = newRulesStarting( sRule, str, getStartTimeForMerchantShip() );
        }
        else
          strPrevState = newRulesMoving( sRule, strPrevState, strPrev, str, "Moving", 1 );
        strPrev = str;
        i++;
      }
     
      for( String str : arrayWayPoints2 ){
        if( i == 0 ){
          sRule = newRules();
          strPrevState = newRulesStarting( sRule, str, getStartTimeForMerchantShip() );
        }
        else
          strPrevState = newRulesMoving( sRule, strPrevState, strPrev, str, "Moving", 1 );
        strPrev = str;
        i++;
      }
    }
   
    newRulesEnding( sRule, strPrevState, destination.getData(), "Anchoring" );
  }
View Full Code Here

TOP

Related Classes of trackerModule.core.datastructure.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.