WEB开发网
开发学院软件开发Java 使用 Sun SPOT 作为构建监视器 阅读

使用 Sun SPOT 作为构建监视器

 2009-12-22 00:00:00 来源:WEB开发网   
核心提示: updateBuildStatus() 方法处理 MIDlet 的主要工作,如清单 5 所示:清单 5. 侦听 CanaryHandler 发送的消息的方法/***Reflectthestatusofthecontinuousbuildprocesstakingplaceonthe*hostPC

updateBuildStatus() 方法处理 MIDlet 的主要工作,如清单 5 所示:


清单 5. 侦听 CanaryHandler 发送的消息的方法
/** 
 * Reflect the status of the continuous build process taking place on the 
 * host PC by setting the colours of the SPOT's LEDs appropriately. 
 */ 
private void updateBuildStatus() throws IOException { 
 
  setColour(LEDColor.WHITE, ""); 
 
  String baseStationAddress = getAppProperty("BaseStationAddress"); 
  String portNumber = getAppProperty("PortNumber"); 
  String connectionString = "radiostream://" + baseStationAddress + ':' + 
      portNumber; 
 
  // Open a connection to the base station. 
  connection = (RadiostreamConnection) Connector.open(connectionString); 
  dis = connection.openDataInputStream(); 
  dos = connection.openDataOutputStream(); 
 
  while (true) { 
 
    // dis will block here forever until it has something from the host 
    // to read. 
    String buildStatus = dis.readUTF(); 
 
    if (buildStatus.equals("RUN")) { 
 
      setColour(LEDColor.BLUE, buildStatus); 
 
    } else if (buildStatus.equals("SUCCESS")) { 
 
      setColour(LEDColor.GREEN, buildStatus); 
 
    } else if (buildStatus.equals("FAIL")) { 
 
      setColour(LEDColor.RED, buildStatus); 
 
    } else { 
      throw new IllegalArgumentException("The build status of " + 
          buildStatus + " isn't recognised."); 
    } 
 
    dos.writeUTF("Build status updated to " + buildStatus); 
    dos.flush(); 
  } 
} 

上一页  3 4 5 6 7 8 9 10  下一页

Tags:使用 Sun SPOT

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接