private Set<Quirks> quirks;
- private int storageDevice;
+ private StorageDeviceEnum storageDevice;
public DiskConfig(
Type type,
this.quirks = new HashSet<Quirks>();
- this.storageDevice = 0;
+ this.storageDevice = StorageDeviceEnum.S2S_STORAGE_SD;
}
public DiskConfig(byte[] in) {
this.quirks = Quirks.fromBitmask(BitUtil.letohs(in, 62));
- storageDevice = BitUtil.uint8ToInt(in[64]);
+ storageDevice = StorageDeviceEnum.fromValue(in[64]);
}
out[62] = BitUtil.longToUint8(quirksMask);
out[63] = BitUtil.longToUint8(quirksMask >> 8);
- out[64] = BitUtil.intToUint8((this.scsiId & 0x07) == 1 ? 1 : 0);
+ out[64] = BitUtil.intToUint8(this.storageDevice.getValue());
return out;
}
}
}
+ public StorageDeviceEnum getStorageDevice()
+ {
+ return this.storageDevice;
+ }
+
+ public void setStorageDevice(StorageDeviceEnum storageDevice)
+ {
+ this.storageDevice = storageDevice;
+ }
+
+
public DiskUnit getBestUnit() {
var scsiSize = this.scsiSectors * this.bytesPerSector;
} catch (NumberFormatException e) {
}
- this.storageDevice = 0;
+ this.storageDevice = StorageDeviceEnum.S2S_STORAGE_SD;
var storageDeviceText = children.getOrDefault("storageDevice", "0");
try {
- var intValue = Integer.valueOf(storageDeviceText);
- if (intValue >= 0 && intValue < 256) {
- this.storageDevice = intValue;
+ var radix = 10;
+ if (devTypeText.toLowerCase().startsWith("0x")) {
+ radix = 16;
+ storageDeviceText = devTypeText.substring(2);
}
+
+ var byteValue = Byte.valueOf(storageDeviceText, radix);
+ this.storageDevice = StorageDeviceEnum.fromValue(byteValue);
} catch (NumberFormatException e) {
}
.append(" 0 SD.\n")
.append(" 1 Flash.\n")
.append(" ********************************************************* -->\n")
- .append(" <storageDevice>").append(this.storageDevice).append("</storageDevice>\n")
+ .append(" <storageDevice>").append(this.storageDevice.getValue()).append("</storageDevice>\n")
.append("\n\n")
.append("\n\n")
private TextField sdStartingByte;
@FXML ComboBox scsiDeviceType;
+ @FXML ComboBox storageDevice;
+
@FXML private TextField vendor;
@FXML private TextField prodId;
this.scsiBytesPerSector.focusedProperty().addListener((obs, wasFocussed, isNowFocussed) -> {if (!isNowFocussed) this.setBytesPerSector();});
this.scsiDeviceType.setOnAction((e) -> this.setDeviceType());
+ this.storageDevice.setOnAction((e) -> this.setStorageDevice());
this.vendor.setOnAction((e) -> this.setVendor());
this.vendor.focusedProperty().addListener((obs, wasFocussed, isNowFocussed) -> {if (!isNowFocussed) this.setVendor();});
this.scsiSizeUnit.getItems().addAll(DiskUnit.values());
this.scsiDeviceType.getItems().addAll(Arrays.stream(DeviceTypeEnum.values()).filter(dt -> dt != DeviceTypeEnum.S2S_CFG_SEQUENTIAL).toArray());
+ this.storageDevice.getItems().addAll(StorageDeviceEnum.values());
this.quirksMode.getItems().addAll(Quirks.values());
this.scsiSizeStr.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.scsiBytesPerSector.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.scsiDeviceType.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
+ this.storageDevice.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.vendor.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.prodId.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.revision.setDisable(this.selectedConfig.getType() != DiskConfig.Type.DISK);
this.scsiBytesPerSector.setText(Integer.toString(this.selectedConfig.getBytesPerSector()));
this.sdStartingByte.setText(Long.toString(this.selectedConfig.getSdSectorStart() * DiskConfig.SD_SECTOR_SIZE));
this.scsiDeviceType.setValue(this.selectedConfig.getDeviceType());
+ this.storageDevice.setValue(this.selectedConfig.getStorageDevice());
this.deviceTypeModifier.setText(String.valueOf(this.selectedConfig.getDeviceTypeModifier()));
this.vendor.setText(this.selectedConfig.getVendor());
this.prodId.setText(this.selectedConfig.getProdId());
}
}
+ private void setStorageDevice()
+ {
+ if (this.selectedConfig != null)
+ {
+ this.selectedConfig.setStorageDevice((StorageDeviceEnum) this.storageDevice.getValue());
+
+ this.activeDocument.setModified(DiskConfigController.class.getName(), true);
+ this.refreshList();
+ }
+ }
+
private void setVendor()
{
if (this.selectedConfig != null)
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
+import javafx.stage.Modality;
import javafx.stage.Stage;
+import javafx.stage.StageStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private void loadDefault()
{
- writeImageToDevice();
-
var root = new ConfigRoot();
root.setBoardConfig(new BoardConfig());
root.setDiskList(new DiskList(2l*1024*1024*1024/512));
}
Stage stage = new Stage();
- try {
- // TODO allow selection of device.
-
- //Scene scene = new Scene(this.window.getScene().getRoot(), 300, 75);
- Scene scene = new Scene(new Group(), 300, 75);
- stage.setScene(scene);
- stage.setTitle("Image Progress");
-
- final ProgressBar pb = new ProgressBar(0);
- final HBox hb = new HBox();
- hb.setSpacing(5);
- hb.setAlignment(Pos.CENTER);
- hb.getChildren().addAll(new Label("Writing Image"), pb);
-
- final VBox vb = new VBox();
- vb.setSpacing(5);
- vb.getChildren().addAll(new Label(), hb);
- scene.setRoot(vb);
- stage.show();
-
- this.getDevice().writeImage(
- deviceList.get(0).getStorageDevices().size() - 1,
- theFile,
- 0);
- } catch (Exception e) {
- e.printStackTrace();
- Alert alert = new Alert(Alert.AlertType.ERROR);
- alert.setTitle("Imaging failed");
- alert.setContentText(e.getLocalizedMessage());
- alert.show();
- } finally {
- stage.hide();
- }
+
+ // TODO allow selection of device.
+
+ //Scene scene = new Scene(this.window.getScene().getRoot(), 300, 75);
+ Scene scene = new Scene(new Group(), 300, 75);
+ stage.setScene(scene);
+ stage.setTitle("Image Progress");
+
+ final ProgressBar pb = new ProgressBar(0);
+ final HBox hb = new HBox();
+ hb.setSpacing(5);
+ hb.setAlignment(Pos.CENTER);
+ var progresssLabel = new Label("Writing Image 0.00%");
+ hb.getChildren().addAll(progresssLabel, pb);
+
+ final VBox vb = new VBox();
+ vb.setSpacing(5);
+ vb.getChildren().addAll(new Label(), hb);
+ scene.setRoot(vb);
+
+ stage.initOwner(this.window);
+ stage.initModality(Modality.APPLICATION_MODAL);
+ stage.initStyle(StageStyle.UNDECORATED);
+
+ stage.show();
+
+ new Thread(() -> {
+ try {
+ this.getDevice().writeImage(
+ deviceList.get(0).getStorageDevices().size() - 1,
+ theFile,
+ 0,
+ progress -> Platform.runLater(() -> {
+ pb.setProgress(progress);
+ progresssLabel.setText(String.format("Writing Image %.2f %%", progress * 100));
+ }));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ Platform.runLater(() -> {
+ Alert alert = new Alert(Alert.AlertType.ERROR);
+ alert.setTitle("Imaging failed");
+ alert.setContentText(e.getLocalizedMessage());
+ alert.show();
+ });
+ } finally {
+ Platform.runLater(() -> stage.hide());
+ }
+ }).start();
}
}
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
+ <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="SCSI ID" />
<Label text="Enabled" GridPane.rowIndex="2" />
<CheckBox fx:id="enabled" prefHeight="25.0" prefWidth="270.0" GridPane.columnIndex="1" GridPane.rowIndex="2" />
+ <Label text="Storage Device" GridPane.rowIndex="3" />
+ <ComboBox fx:id="storageDevice" prefHeight="25.0" prefWidth="270.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
+
</children>
</GridPane>
</children>