Ejemplo n.º 1
0
  /** main loop - periodically copy location data into Lua and evaluate zone positions */
  private void mainloop() {
    try {
      while (!end) {
        try {
          if (gps.getLatitude() != player.position.latitude
              || gps.getLongitude() != player.position.longitude
              || gps.getAltitude() != player.position.altitude) {
            player.refreshLocation();
          }
          cartridge.tick();
        } catch (Exception e) {
          stacktrace(e);
        }

        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
      }
      if (log != null) log.close();
    } catch (Throwable t) {
      ui.end();
      stacktrace(t);
    } finally {
      instance = null;
      state = null;
      if (eventRunner != null) eventRunner.kill();
      eventRunner = null;
    }
  }
Ejemplo n.º 2
0
        @Override
        public void run() {

          if (locationService != null) {

            current_location = locationService.getLatLngLocation();
            if (current_location != null) {

              //                        if (!httpRequested) {
              //                            googleMap.animateCamera(CameraUpdateFactory.newLatLng(
              // new LatLng(current_location.getLatitude(), current_location.getLongitude())));
              //                        }

              if (bDirUpdates) {
                Double asOften = (howOften <= 0.0 || howOften == null) ? 0.01 : howOften;
                if (LocationService.distanceTraveled(current_location, last_used_location)
                    >= asOften) {
                  if (dataConnected) {
                    drawDirections();
                  }
                }
              } else {

                drawCurrentLocation(current_location);
              }
            }
          }

          if (!paused) handler.postDelayed(this, (current_location == null) ? 1000 : 10000);
        }
Ejemplo n.º 3
0
 /** Gets a Location entity by its exact name. */
 public static Location getLocationByName(String locationName, Location parent) {
   LocationService locationService = Context.getLocationService();
   Location location = locationService.getLocation(locationName);
   if (location == null) {
     location = new Location();
     location.setName(locationName);
     location.setDescription(locationName);
     if (parent != null) {
       location.setParentLocation(parent);
     }
     locationService.saveLocation(location);
   }
   return location;
 }
Ejemplo n.º 4
0
 public LocationProviderImpl(Context ctx, LocationService locationService) {
   loc = new Location();
   loc.setProvider(getProviderName());
   loc.setAccurancy(-1);
   this.ctx = ctx;
   locationService.registerProvider(this);
 }
Ejemplo n.º 5
0
 /**
  * Instantiates a new razor server, its services, and starts the scheduler. This can be replaced
  * by a dynamic handler manager but has the benefit of simplicity.
  */
 public RazorServer() {
   super();
   SERVICES.put(Service.ACCOUNT, AccountService.getInstance());
   SERVICES.put(Service.ALERT, AlertService.getInstance());
   SERVICES.put(Service.ASSET, AssetService.getInstance());
   SERVICES.put(Service.ATTRIBUTE, AttributeService.getInstance());
   SERVICES.put(Service.AUDIT, AuditService.getInstance());
   SERVICES.put(Service.CONTRACT, ContractService.getInstance());
   SERVICES.put(Service.FINANCE, FinanceService.getInstance());
   SERVICES.put(Service.JOURNAL, JournalService.getInstance());
   SERVICES.put(Service.IMAGE, ImageService.getInstance());
   SERVICES.put(Service.IMAGETEXT, ImageTextService.getInstance());
   SERVICES.put(Service.LICENSE, LicenseService.getInstance());
   SERVICES.put(Service.LOCATION, LocationService.getInstance());
   SERVICES.put(Service.MAIL, MailService.getInstance());
   SERVICES.put(Service.MONITOR, MonitorService.getInstance());
   SERVICES.put(Service.PARTNER, PartnerService.getInstance());
   SERVICES.put(Service.PARTY, PartyService.getInstance());
   SERVICES.put(Service.PRICE, PriceService.getInstance());
   SERVICES.put(Service.PRODUCT, ProductService.getInstance());
   SERVICES.put(Service.RATE, RateService.getInstance());
   SERVICES.put(Service.REPORT, ReportService.getInstance());
   SERVICES.put(Service.RESERVATION, ReservationService.getInstance());
   SERVICES.put(Service.SESSION, SessionService.getInstance());
   SERVICES.put(Service.SMS, SmsService.getInstance());
   SERVICES.put(Service.TASK, TaskService.getInstance());
   SERVICES.put(Service.TAX, TaxService.getInstance());
   SERVICES.put(Service.TEXT, TextService.getInstance());
   SERVICES.put(Service.WORKFLOW, WorkflowService.getInstance());
   //		startScheduler();
   //		PartnerService.startSchedulers();
 }
Ejemplo n.º 6
0
  private void updateLocation() {

    Log.d(TAG, "updateLocation");

    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if (mLastLocation != null) {
      locationService.getLocation(mLastLocation);
    }
  }
  /**
   * Update the value of isActive to 0.
   *
   * @param pref
   */
  public void deactivatePreference(String appName) {

    String strFilter = "appName = '" + appName + "'";
    ContentValues args = new ContentValues();
    args.put("isActive", "0");
    database.update("preferences", args, strFilter, null);

    // update Location service activeSockets
    Log.v("DB interface", "deactivating");
    LocationService.deactivateSocket(appName);
  }
Ejemplo n.º 8
0
  /*To add a rcm to a particular rmos*/
  public Message addRcm(String name, String location, double capacity, double cashValue) {
    LocationService locationService = new LocationService();
    RcmService rcmService = new RcmService();

    Message msg = new Message();
    msg.setSuccessful(true);

    Rcm rcm = rcmService.getRcmByName(name);
    if (rcm != null) {
      msg.setSuccessful(false);
      msg.setMessage("Rcm Already exists");
      return msg;
    }

    rcm = new Rcm();
    rcm.setName(name);
    rcm.setLocation(locationService.getLocationByCity(location));
    rcm.setTotalCapacity(capacity);
    rcm.setTotalCashValue(cashValue);
    rcm.setStatus(RcmStatus.ACTIVE);
    rcm.setReason("Admin Change");

    RmosRcmMapping mapping = new RmosRcmMapping();
    mapping.setRcm(rcm);
    mapping.setRmos(this.rmos);
    mapping.setValid(true);

    this.rmos.addRmosRcmMapping(mapping);

    msg.setSuccessful(repository.updateRmos(this.rmos));
    if (!msg.isSuccessful()) msg.setMessage("Internal Error");
    else {
      this.rmos = repository.getRmosById(this.rmos.getId());
    }
    setChanged();
    notifyObservers();

    return msg;
  }
Ejemplo n.º 9
0
 /** tries to log the specified message, if verbosity is higher than its level */
 public static void log(String s, int level) {
   if (instance == null || instance.log == null) return;
   if (level < instance.loglevel) return;
   synchronized (instance.log) {
     Calendar now = Calendar.getInstance();
     instance.log.print(now.get(Calendar.HOUR_OF_DAY));
     instance.log.print(':');
     instance.log.print(now.get(Calendar.MINUTE));
     instance.log.print(':');
     instance.log.print(now.get(Calendar.SECOND));
     instance.log.print('|');
     instance.log.print((int) (gps.getLatitude() * 10000 + 0.5) / 10000.0);
     instance.log.print('|');
     instance.log.print((int) (gps.getLongitude() * 10000 + 0.5) / 10000.0);
     instance.log.print('|');
     instance.log.print(gps.getAltitude());
     instance.log.print('|');
     instance.log.print(gps.getPrecision());
     instance.log.print("|:: ");
     instance.log.println(s);
     instance.log.flush();
   }
 }
  @Test
  public void return_the_fallback_when_running_in_development_mode() throws Exception {
    ActorSystem system = ActorSystem.create("MySystem");

    URI fallback = new URI("/fallback");
    LocationCache cache = new LocationCache();
    ConnectionContext cc = ConnectionContext.create(system);
    Timeout timeout = new Timeout(Duration.create(5, "seconds"));
    assertEquals(
        Await.result(
            LocationService.getInstance().lookupWithContext("/whatever", fallback, cache, cc),
            timeout.duration()),
        Option.some(fallback));
  }
Ejemplo n.º 11
0
  public void onFind() {
    log.debug("changeOn : {}, findKeyItemDescription : {}", statusOnShow, findKeyItemDescription);
    log.debug("{},{},{}", warehouseMode.getId(), workingAreaModel.getId(), msLocationModel.getId());
    int warehouseId = 0;
    int waokingAreaId = 0;
    int locationId = 0;
    int combine = 0;
    int foil = 0;
    palletMeanegementView = new PalletManagementView();

    if (!Utils.isNull(warehouseMode.getId())) {
      msLocationModelList = locationService.getLocationByWarehouse(warehouseMode.getId());
      warehouseId = warehouseMode.getId();
    }

    if (!Utils.isNull(workingAreaModel.getId())) {
      waokingAreaId = workingAreaModel.getId();
    }

    if (!Utils.isNull(msLocationModel.getId())) {
      locationId = msLocationModel.getId();
    }

    log.debug("isCombine : {}", isCombine);

    if (isCombine == true) {
      combine = 1;
    }

    if (isFoil == true) {
      foil = 1;
    }

    palletManegamentViewList =
        palletService.findByChang(
            statusOnShow,
            warehouseId,
            waokingAreaId,
            locationId,
            findKeyItemDescription,
            combine,
            foil);
  }
Ejemplo n.º 12
0
  @Override
  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

    String[] colorArray = TrainColor.TRAIN_COLORS_ARRAY;
    if (position < 0 || position >= colorArray.length) {
      return;
    }

    if (!httpRequested || current_location == null) {
      return;
    }

    String trainColor = colorArray[position];
    color = (trainColor.equals("Any")) ? null : trainColor;
    firstTimeCameraMove = true;

    if (cachedJSONHash.size() != 0) {
      JSONObject closest_station = cachedJSONHash.get(trainColor);
      parseJSON(closest_station);
      if (dataConnected) {
        drawDirections();
      } else {
        noDataMessage();
      }
    }

    if (locationService.distanceTraveled(current_location, last_used_location) > 0.5) {
      httpRequested = false;
      if (dataConnected) {
        progressValue = 0;
        initializeProgressDialog();
        new HttpAsyncTask().execute();
      } else {
        noDataMessage();
      }
    }

    setColorTVText();
  }
 /**
  * Deletes the given preference object.
  *
  * @param pref
  */
 public void deleteApp(String namespace) {
   database.delete("apps", "namespace = '" + namespace + "'", null);
   database.delete("preferences", "appName = '" + namespace + "'", null);
   LocationService.deactivateSocket(namespace);
 }