Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UI #1086

Merged
merged 3 commits into from
Sep 29, 2023
Merged

Fix UI #1086

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,15 @@ BlacklistData blacklistFetch(
*
* @param boardId
* Which board to get the data for.
* @param bmpId
* The BMP that controls the board.
* @return the model and view in a future
*/
@GetMapping(value = TEMPERATURE_PATH)
@ResponseBody
BoardTemperatures getTemperatures(
@Valid @RequestParam("board_id") int boardId);
@Valid @RequestParam("board_id") int boardId,
@Valid @RequestParam("bmp_id") int bmpId);

/**
* Provide the form for uploading a machine definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ public ModelAndView board(BoardRecord board, ModelMap model) {
inflateBoardRecord(board, bs);
addBoard(model, board);
addMachineList(model, getMachineNames(true));
addUrl(model, TEMP_URI, uri(admin().getTemperatures(board.getId())));
addUrl(model, TEMP_URI, uri(admin().getTemperatures(
board.getId(), board.getBmpId())));
return addStandardContext(BOARD_VIEW.view(model));
}

Expand Down Expand Up @@ -750,10 +751,10 @@ public BlacklistData blacklistFetch(int boardId, int bmpId) {

@Override
@Action("getting board temperature data from the machine")
public BoardTemperatures getTemperatures(int boardId) {
public BoardTemperatures getTemperatures(int boardId, int bmpId) {
try {
return new BoardTemperatures(
machineController.readTemperatureFromMachine(boardId)
machineController.readTemperatureFromMachine(boardId, bmpId)
.orElseThrow(() -> new WebApplicationException(
Status.NOT_FOUND)));
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ public String getSerialNumber(BoardState board)
*
* @param boardId
* Which board to read the temperature data of.
* @param bmpId
* The BMP that controls the board.
* @return The board's temperature data.
* @throws DataAccessException
* If access to the DB fails.
Expand All @@ -786,9 +788,10 @@ public String getSerialNumber(BoardState board)
* @throws InterruptedException
* If interrupted.
*/
public Optional<ADCInfo> readTemperatureFromMachine(int boardId)
public Optional<ADCInfo> readTemperatureFromMachine(int boardId, int bmpId)
throws InterruptedException {
try (var op = new Op(CREATE_TEMP_READ_REQ, boardId)) {
bmpController.triggerSearch(List.of(bmpId));
return op.getResult(serial("data", ADCInfo.class));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ boolean tryProcessRequest(SpiNNakerControl controller)
epochs.machineChanged(machineId);
}, e -> {
failed(e);
epochs.blacklistChanged(boardId);
epochs.machineChanged(machineId);
}, ppe -> {
takeOutOfService(ppe);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ public abstract class SQLQueries {
*
* @see BMPController
*/
@Parameter("machine_id")
@Parameter("bmp_id")
@ResultColumn("op_id")
@ResultColumn("board_id")
@ResultColumn("bmp_serial_id")
Expand All @@ -2063,7 +2063,7 @@ public abstract class SQLQueries {
+ "JOIN boards USING (board_id) JOIN bmp USING (bmp_id) "
+ "LEFT JOIN board_serial USING (board_id) "
+ "WHERE op = 3 AND NOT completed "
+ "AND boards.machine_id = :machine_id";
+ "AND boards.bmp_id = :bmp_id";

/**
* Set the BMP and physical serial IDs based on the information actually
Expand Down
48 changes: 32 additions & 16 deletions SpiNNaker-allocserv/src/main/typescript/spinnaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,18 +895,22 @@ function prettyDuration(elementId: string) {
* @param elementId
* Which element to replace the contents of with with the rendered result.
*/
function loadTemperature(sourceUri: string, boardId: number, elementId: string) {
function loadTemperature(sourceUri: string, boardId: number, bmpId: number, elementId: string) {
const element = document.getElementById(elementId);
if (element == null) {
return;
}
const r = new XMLHttpRequest();
r.open("GET", sourceUri + "?board_id=" + boardId);
r.open("GET", sourceUri + "?board_id=" + boardId + "&bmp_id=" + bmpId);
r.onload = () => {
const result = JSON.parse(r.response) as object;
if (result?.hasOwnProperty("boardTemperature")) {
const t = result["boardTemperature"] as number;
element.innerHTML = t + "&deg;C";
if (r.status == 200) {
const result = JSON.parse(r.response) as object;
if (result?.hasOwnProperty("boardTemperature")) {
const t = result["boardTemperature"] as number;
element.innerHTML = t + "&deg;C";
}
} else {
element.innerHTML = "Failed to load temperature: " + r.status + " - " + r.statusText + ": " + r.response;
}
};
r.send();
Expand Down Expand Up @@ -940,15 +944,22 @@ function loadBlacklist(sourceUri: string, boardId: number, bmpId: number, elemen
const r = new XMLHttpRequest();
r.open("GET", sourceUri + "?board_id=" + boardId + "&bmp_id=" + bmpId);
r.onload = () => {
const result = JSON.parse(r.response) as object;
if (result?.hasOwnProperty("blacklist")) {
const blacklist = result["blacklist"] as string;
element.value = blacklist;
if (r.status == 200) {
const result = JSON.parse(r.response) as object;
if (result?.hasOwnProperty("blacklist")) {
const blacklist = result["blacklist"] as string;
element.value = blacklist;
}
status.innerHTML = "Blacklist loaded";
element.disabled = false;
saveButton.disabled = false;
loadButton.disabled = false;
} else {
status.innerHTML = "Failed load blacklist: " + r.status + " - " + r.statusText + ": " + r.response;
element.disabled = true;
saveButton.disabled = true;
loadButton.disabled = false;
}
status.innerHTML = "Blacklist loaded";
element.disabled = false;
saveButton.disabled = false;
loadButton.disabled = false;
};
r.onerror = () => {
status.innerHTML = "Error reading blacklist!";
Expand Down Expand Up @@ -998,13 +1009,18 @@ function saveBlacklist(sourceUri: string, boardId: number, bmpId: number, elemen
r.setRequestHeader(header.content, token.content);
r.send(JSON.stringify({ "boardId": boardId, "bmpId": bmpId, "present": true, "synched": true, "blacklist": element.value}));
r.onload = () => {
status.innerHTML = "Blacklist saved";
if (r.status == 200) {
status.innerHTML = "Blacklist saved";
} else {
status.innerHTML = "Failed save blacklist: " + r.status + " - " + r.statusText + ": " + r.response;
}

element.disabled = false;
saveButton.disabled = false;
loadButton.disabled = false;
};
r.onerror = () => {
element.value = "Error saving blacklist!";
status.innerHTML = "Error saving blacklist!";
element.disabled = false;
saveButton.disabled = false;
loadButton.disabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ limitations under the License.
Temperature: <span id="temperatureDisplay">Reading...</span>
<!-- ${tempDataUri}?board_id=${board.id} -->
<script defer="defer">
loadTemperature("${ tempDataUri }", ${board.id}, "temperatureDisplay");
loadTemperature("${ tempDataUri }", ${board.id}, ${board.bmpId}, "temperatureDisplay");
</script>
<p>
Current job:
Expand Down
Loading