コード例 #1
0
 public void ShutdownAllClientServicers() {
   sf.VERBOSE("CLIENTSERVICER: Shutting down all client connections");
   ClientServicer crrntServicer;
   while (vctServicers.size() != 0) {
     crrntServicer = (ClientServicer) vctServicers.firstElement();
     crrntServicer.Shutdown();
     try {
       crrntServicer.join(1000);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
     ;
   }
 }
コード例 #2
0
 public void run() {
   boolean status;
   sf.DEBUG("Listen server running.");
   // open up our server socket
   try {
     m_serverSocket = new ServerSocket(m_nPort);
   } catch (IOException e) {
     sf.VERBOSE("Could not listen on port: " + m_nPort);
     if (sf.cntrlWndw != null) {
       sf.cntrlWndw.ClearListenServer();
     }
     return;
   }
   sf.VERBOSE("Listening for client connections on port " + m_nPort);
   // if (SerialForward.bSourceSim)
   // {
   SetDataSource();
   sf.InitSerialPortIO();
   // }
   // start listening for connections
   try {
     ClientServicer rcv;
     Socket currentSocket;
     while (!m_bShutdown) {
       currentSocket = m_serverSocket.accept();
       ClientServicer newServicer = new ClientServicer(currentSocket, sf, this);
       newServicer.start();
       vctServicers.add(newServicer);
     }
     m_serverSocket.close();
   } catch (IOException e) {
     /*try { this.sleep(500); }
     catch (Exception e2) { }*/
     sf.VERBOSE("Server Socket closed");
   } finally {
     ShutdownAllClientServicers();
     if (sf.serialPortIO != null) sf.serialPortIO.Shutdown();
     sf.VERBOSE("--------------------------");
     if (sf.cntrlWndw != null) {
       sf.cntrlWndw.ClearListenServer();
     }
   }
 }
コード例 #3
0
 private void SetDataSource() {
   if (sf.useDummyData) {
     sf.dataSource = new DummySource(sf);
   } else if (sf.bSourceSim) {
     try {
       sf.dataSource =
           (DataSource)
               (Class.forName("net.tinyos.sf.old.nido.SimNetworkDataSource").newInstance());
       sf.dataSource.setSerialForward(sf);
     } catch (Exception e) {
       System.err.println("Cannot instantiate SimNetworkDataSource - did you compile it? " + e);
       return;
     }
   } else if (sf.bNidoSerialData) {
     // Doing it this way to avoid having to compile NidoSerialDataSource
     // which requires all of the TOSSIM event classes
     // sf.dataSource = new NidoSerialDataSource(sf);
     try {
       sf.dataSource =
           (DataSource)
               (Class.forName("net.tinyos.sf.old.nido.NidoSerialDataSource").newInstance());
       sf.dataSource.setSerialForward(sf);
     } catch (Exception e) {
       System.err.println("Cannot instantiate NidoSerialDataSource - did you compile it? " + e);
       return;
     }
   } else if (sf.bSourceDB) {
     sf.dataSource = new DBSource(sf);
   } else if (sf.bQueuedSerial) {
     System.out.println("USING QUEUED SERIAL SOURCE");
     sf.dataSource = new QueuedSerialSource(sf);
   } else if (sf.commPort_is_socket) {
     sf.dataSource = new NetworkSource(sf);
   } else {
     sf.dataSource = new SerialSource(sf);
   }
 }
コード例 #4
0
 public void RestartDataSource() {
   SetDataSource();
   sf.InitSerialPortIO();
 }