/** * Rendering of a single frame. Here we update and render the detected trackable list. * * @param gl Unused context. */ @Override public void onDrawFrame(GL10 gl) { if (MainInterface.DEBUG_FRAME_LOGGING) log.pushTimer(this, "opengl frame"); // Clear: GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); // If new markerlist, get: if (mainInterface.getListUpdateStatus()) { this.toRender = mainInterface.getList(); if (toRender == null) { log.log(TAG, "Error getting list!"); toRender = new ArrayList<Trackable>(); } else log.debug(TAG, "Updated list – found " + this.toRender.size() + " " + "trackables."); } // ------------------------ RENDER ------------------------ if (!toRender.isEmpty()) { for (Trackable trackable : toRender) { // Reset model matrix to identity Matrix.setIdentityM(mModelMatrix, 0); Matrix.multiplyMM(mModelMatrix, 0, trackable.getTRANSLATION(), 0, mModelMatrix, 0); drawObject(trackable.getFloatbuffer()); } } if (MainInterface.DEBUG_FRAME_LOGGING) { log.debug(TAG, "OpenGL rendered frame in " + log.popTimer(this).time + "ms."); } }
public void onCreate(ViewGroup groupView) { log.pushTimer(this, "start"); // Create OpenCV part: if (RUN_OPENCV) { opencv = new OpenCVInterface(this, this.mainActivity); JavaCameraView cameraView = new JavaCameraView(mainActivity, JavaCameraView.CAMERA_ID_ANY); cameraView.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); cameraView.enableFpsMeter(); cameraView.setVisibility(JavaCameraView.GONE); groupView.addView(cameraView); opencv.onCreate(cameraView); } // Create OpenGL render part: if (RUN_RENDERER) { render = new RenderInterface(this); GLSurfaceView renderView = new GLSurfaceView(mainActivity.getApplicationContext()); renderView.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); groupView.addView(renderView); render.onCreate(renderView); } // Set layout things: mainActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); log.log(TAG, "Framework created in " + log.popTimer(this).time + "ms."); }
public MainInterface(Activity mainActivity, float[][] camMatrix, float[] distortionCoefficients) { this.log = Messenger.getInstance(); log.log(TAG, "Constructing framework."); this.mainActivity = mainActivity; this.listeners = new ArrayList<HomographyListener>(); this.allTrackables = new ArrayList<Entity>(); this.detectedTrackables = new ArrayList<Trackable>(); // Set camera matrix: this.camMatrix = camMatrix; this.distCoef = distortionCoefficients; }
/** * Method for modifying the binary threshold for Detector. Only use after checking with * DEBUG_PREP_FRAME if the binarization actually is the error! Used to set all 3 binarization * methods, including Canny! * * @param value The value to set it to. */ @SuppressWarnings("UnusedDeclaration") public void setBinaryThreshold(int value) { if (value >= 0 && value <= 255) { log.debug(TAG, "Setting theshold to " + value); this.threshold = value; } else this.threshold = 100; }
public void run() throws MqttException { // register MQTT and connect publisher = new Messenger(CLIENT_ID + "Pub", publisherCallBack()); subscriber = new Messenger(CLIENT_ID, subscriberCallBack()); subscriber.connect(); // subscribe to all required topics try { subscriber.subscribe("RouteList"); subscriber.subscribe("Monitor/#"); // messenger.subscribe("Call/Floor/#"); // messenger.subscribe("Call/Hall/#"); } catch (MqttException e) { e.printStackTrace(); } }
public void shutdown() { stop = true; LOG.debug("Shutting down connection manager"); manager.halt(); LOG.debug("Shutting down messenger"); messenger.halt(); LOG.debug("FLE is down"); }
/** * Helper function for setting flags. * * @param value The flag to set. * @param bool The value to set that flag at. */ @SuppressWarnings("UnusedDeclaration") public void setFlag(Flags value, boolean bool) { switch (value) { case ALLOW_DUPLICATE_MARKERS: this.ALLOW_DUPLICATE_MARKERS = bool; break; case ALLOW_UNCERTAIN_HAMMING: MarkerPatternHelper.hammingDeforce = bool; break; case ONLY_HOMOGRAPHY: this.RUN_RENDERER = !bool; this.ONLY_HOMOGRAPHY = bool; break; case RUN_OPENCV: this.RUN_OPENCV = bool; break; case RUN_RENDERER: this.RUN_RENDERER = bool; break; case DEBUG_FRAME_LOGGING: MainInterface.DEBUG_FRAME_LOGGING = bool; break; case DEBUG_LOGGING: MainInterface.DEBUG_LOGGING = bool; break; case DEBUG_FRAME: this.DEBUG_FRAME = bool; break; case USE_CANNY: Detector.USE_CANNY = bool; break; case USE_ADAPTIVE: Detector.USE_ADAPTIVE = bool; break; case DEBUG_PREP_FRAME: Detector.DEBUG_PREP_FRAME = bool; break; case DEBUG_CONTOURS: Detector.DEBUG_CONTOURS = bool; break; case DEBUG_POLY: Detector.DEBUG_POLY = bool; break; case DEBUG_DRAW_MARKERS: Detector.DEBUG_DRAW_MARKERS = bool; break; case DEBUG_DRAW_SAMPLING: Detector.DEBUG_DRAW_SAMPLING = bool; break; case DEBUG_DRAW_MARKER_ID: Detector.DEBUG_DRAW_MARKER_ID = bool; break; default: log.log(TAG, "Failed to set flag " + value + "!"); break; } }
/** Main message reader loop. */ public void run() { logger.debug("Starting message reader"); while (!interrupted()) { processOneMessage(); } responseMap.clear(); messenger.close(); }
@Override public boolean execute(ArenaMaster am, CommandSender sender, String... args) { if (TFM_SuperadminList.isUserSuperadmin(sender)) { if (args.length < 1) { return false; } Arena arena; String point; if (args.length == 1) { if (am.getArenas().size() > 1) { Messenger.tell(sender, "There are multiple arenas."); return true; } arena = am.getArenas().get(0); point = args[0]; } else { arena = am.getArenaWithName(args[0]); if (arena == null) { Messenger.tell(sender, "There is no arena named " + args[0]); return true; } point = args[1]; } if (arena.getRegion().removeSpawn(point)) { Messenger.tell( sender, "Spawnpoint " + point + " removed for arena '" + arena.configName() + "'"); } else { Messenger.tell( sender, "Could not find the spawnpoint " + point + " for the arena '" + arena.configName() + "'"); } } else { sender.sendMessage(ChatColor.RED + "You do not have permission to use this command."); } return true; }
/** * Starts the <tt>msofficecomm</tt> bundle in a specific {@link BundleContext}. * * @param bundleContext the <tt>BundleContext</tt> in which the <tt>msofficecomm</tt> bundle is to * be started * @throws Exception if anything goes wrong while starting the <tt>msofficecomm</tt> bundle in the * specified <tt>BundleContext</tt> */ public void start(BundleContext bundleContext) throws Exception { // The msofficecomm bundle is available on Windows only. if (!OSUtils.IS_WINDOWS) return; if (logger.isInfoEnabled()) logger.info("MsOfficeComm plugin ... [STARTED]"); Messenger.start(bundleContext); boolean stopMessenger = true; try { int hresult = OutOfProcessServer.start(); if (logger.isInfoEnabled()) logger.info("MsOfficeComm started OutOfProcessServer HRESULT:" + hresult); if (hresult < 0) throw new RuntimeException("HRESULT " + hresult); else stopMessenger = false; } finally { if (stopMessenger) Messenger.stop(bundleContext); } }
/** * Stops the <tt>msofficecomm</tt> bundle in a specific {@link BundleContext}. * * @param bundleContext the <tt>BundleContext</tt> in which the <tt>msofficecomm</tt> bundle is to * be stopped * @throws Exception if anything goes wrong while stopping the <tt>msofficecomm</tt> bundle in the * specified <tt>BundleContext</tt> */ public void stop(BundleContext bundleContext) throws Exception { // The msofficecomm bundle is available on Windows only. if (!OSUtils.IS_WINDOWS) return; try { int hresult = OutOfProcessServer.stop(); if (hresult < 0) throw new RuntimeException("HRESULT " + hresult); } finally { Messenger.stop(bundleContext); } if (logger.isInfoEnabled()) logger.info("MsOfficeComm plugin ... [UNREGISTERED]"); }
@Override public void handlePacket(PacketCustom packet, NetClientHandler nethandler, Minecraft mc) { World world = mc.theWorld; switch (packet.getType()) { case 1: handleTilePacket(world, packet, packet.readCoord()); return; case 2: Messenger.addMessage( packet.readDouble(), packet.readDouble(), packet.readDouble(), packet.readString()); return; } }
private String login(String messengerName, String userId, String password) { JamMessengerListener messengerListener = new JamMessengerListener(); if (messengerName.equals(TestMessenger.DISPLAY_NAME)) { messenger = new TestMessenger(messengerListener); } else { throw new RuntimeException("Unsupported messenger: " + messengerName); } String errorMessage = messenger.login(userId, password); if (errorMessage == null) { setUserId(userId); displayMainJamPanel(); } return errorMessage; }
private String sendBlocks(String sessionName, String buffer) { int offset = 0; int bytesRemaining = buffer.length(); int blockCount = (bytesRemaining + (BLOCK_SIZE - 1)) / BLOCK_SIZE; for (int i = 1; i <= blockCount; i++) { if (i > 1) { try { Thread.sleep(100); } catch (InterruptedException e) { throw new RuntimeException(e); } } int blockSize = Math.min(BLOCK_SIZE, bytesRemaining); String block = buffer.substring(offset, offset + blockSize); String midiMessage = RSJM + i + "," + blockCount + "=" + block; String errorMessage = messenger.sendMessage(sessionName, midiMessage); if (errorMessage != null) { return errorMessage; } offset += blockSize; bytesRemaining -= blockSize; } return null; }
/** * Constructor. * * @param mainInterface Pointer to MainInterface. */ protected OpenGLRenderer(MainInterface mainInterface) { this.log = Messenger.getInstance(); this.mainInterface = mainInterface; this.toRender = new ArrayList<Trackable>(); }
public void onDestroy() { if (RUN_OPENCV) opencv.onDestroy(); log.log(TAG, "Stopping."); }
@Test public void checkSendingMessage_NullServer_WrongMessage() { assertEquals(2, messenger.sendMessage(null, INVALID_MESSAGE)); }
@Test public void checkSendingMessage_NullServer_NullMessage() { assertEquals(2, messenger.sendMessage(null, null)); }
@Test public void checkSendingMessage_CorrectServer_NullMessage() { assertEquals(2, messenger.sendMessage(VALID_SERVER, null)); }
@Test public void testConnection_WrongServer_WithoutConnection() { msm.setConnection(false); assertEquals(1, messenger.testConnection(INVALID_SERVER)); }
@Test public void testConnection_NullServer_WithoutConnection() { msm.setConnection(false); assertEquals(1, messenger.testConnection(null)); }
@When("messager sends message") public void whenMessengerSendsMessage() { result = msn.sendMessage(server, message); }
@When("connection is tested") public void whenConnectionIsTested() { result = msn.testConnection(server); }
@Test public void checkSendingMessage_WrongServer_WrongMessage() { assertEquals(2, messenger.sendMessage(INVALID_SERVER2, INVALID_MESSAGE)); }
private void logout() { setUserId(null); messenger.logout(); displayLoginPanel(); }
@Test public void testConnection_CorrectServer_WithConnection() { msm.setConnection(true); assertEquals(0, messenger.testConnection(VALID_SERVER)); }
@Override public String morning() { return "Good " + messenger.morning(); }
@Test public void checkSendingMessage_CorrectAll_MessageNotSent() { msm.setMessageSent(false); assertEquals(1, messenger.sendMessage(VALID_SERVER, VALID_MESSAGE)); }