Web UI and OLED: adding Support Devices (#666)

* Use the comparison operator that Python3 likes.

* Add SUPPORT_DEVICE_TYPES category, and add Host Service to it.

* Add webapp UI for attaching a support device.

* Make the OLED screen aware of the support device type.

* Tweak test to make it clear that this is experimental functionality.

* Tweak device type names
This commit is contained in:
Daniel Markstedt 2022-02-15 04:06:27 -08:00 committed by GitHub
parent 46d23a0d5d
commit b3bdd07fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 16 deletions

View File

@ -8,6 +8,7 @@ WORK_DIR = getcwd()
REMOVABLE_DEVICE_TYPES = ("SCCD", "SCRM", "SCMO")
NETWORK_DEVICE_TYPES = ("SCDP", "SCBR")
SUPPORT_DEVICE_TYPES = ("SCHS", )
# There may be a more elegant way to get the HOME dir of the user that installed RaSCSI
HOME_DIR = "/".join(WORK_DIR.split("/")[0:3])

View File

@ -46,6 +46,7 @@ from rascsi.socket_cmds import SocketCmds
from rascsi.common_settings import (
REMOVABLE_DEVICE_TYPES,
NETWORK_DEVICE_TYPES,
SUPPORT_DEVICE_TYPES,
)
parser = argparse.ArgumentParser(description="RaSCSI OLED Monitor script")
@ -186,8 +187,8 @@ def formatted_output():
f"{line['file']} {line['status']}")
else:
output.append(f"{line['id']} {line['device_type'][2:4]} {line['status']}")
# Special handling for network devices
elif line["device_type"] in NETWORK_DEVICE_TYPES:
# Special handling of devices that don't use image files
elif line["device_type"] in (NETWORK_DEVICE_TYPES + SUPPORT_DEVICE_TYPES):
output.append(f"{line['id']} {line['device_type'][2:4]} {line['vendor']} "
f"{line['product']}")
# Print only the Vendor/Product info if it's not generic RaSCSI

View File

@ -59,20 +59,22 @@ def extend_device_names(device_types):
"""
mapped_device_types = {}
for device_type in device_types:
if device_type is "SAHD":
device_name = _("SASI Hard Drive")
elif device_type is "SCHD":
device_name = _("SCSI Hard Drive")
elif device_type is "SCRM":
device_name = _("Removable Drive")
elif device_type is "SCMO":
device_name = _("Magneto-Optical Drive")
elif device_type is "SCCD":
device_name = _("CD-ROM Drive")
elif device_type is "SCBR":
if device_type == "SAHD":
device_name = _("SASI Hard Disk")
elif device_type == "SCHD":
device_name = _("SCSI Hard Disk")
elif device_type == "SCRM":
device_name = _("Removable Disk")
elif device_type == "SCMO":
device_name = _("Magneto-Optical")
elif device_type == "SCCD":
device_name = _("CD-ROM / DVD")
elif device_type == "SCBR":
device_name = _("X68000 Host Bridge")
elif device_type is "SCDP":
elif device_type == "SCDP":
device_name = _("DaynaPORT SCSI/Link")
elif device_type == "SCHS":
device_name = _("Host Service")
else:
device_name = _("Unknown Device")
mapped_device_types[device_type] = device_name

View File

@ -267,7 +267,7 @@
{{ _("Select device type") }}
</option>
{% for key, value in device_types.items() %}
{% if key not in NETWORK_DEVICE_TYPES %}
{% if key not in (NETWORK_DEVICE_TYPES + SUPPORT_DEVICE_TYPES) %}
<option value="{{ key }}">
{{ value }}
</option>
@ -360,6 +360,50 @@
<p><small>{{ _("Install <a href=\"%(url)s\">Macproxy</a> to browse the Web with any vintage browser. It's not just for Macs!", url="https://github.com/akuker/RASCSI/wiki/Vintage-Web-Proxy#macproxy") }}</small></p>
{% endif %}
<hr/>
<details>
<summary class="heading">
{{ _("Attach Support Device (EXPERIMENTAL)") }}
</summary>
<ul>
<li>Attach an experimental Support Device that may provide additional functionality for the Host system.
</li>
<li>Relies on driver software on the Host side that utilizes the exposed functionality.
</li>
</ul>
</details>
<table style="border: none">
<tr style="border: none">
<td style="border: none; vertical-align:top;">
<form action="/scsi/attach_support" method="post">
<label for="type">{{ _("Type:") }}</label>
<select name="type">
{% for type in SUPPORT_DEVICE_TYPES %}
<option value="{{ type }}">
{% for key, value in device_types.items() %}
{% if key == type %}
{{ value }}
{% endif %}
{% endfor %}
</option>
{% endfor %}
</select>
<label for="scsi_id">{{ _("SCSI ID:") }}</label>
<select name="scsi_id">
{% for id in scsi_ids %}
<option value="{{ id }}"{% if id == recommended_id %} selected{% endif %}>
{{ id }}
</option>
{% endfor %}
</select>
<label for="unit">{{ _("LUN") }}</label>
<input name="unit" type="number" size="2" value="0" min="0" max="31">
<input type="submit" value="{{ _("Attach") }}">
</form>
</td>
</tr>
</table>
<hr/>
<details>
<summary class="heading">

View File

@ -55,6 +55,7 @@ from rascsi.common_settings import (
PROPERTIES_SUFFIX,
REMOVABLE_DEVICE_TYPES,
NETWORK_DEVICE_TYPES,
SUPPORT_DEVICE_TYPES,
RESERVATIONS,
)
from rascsi.ractl_cmds import RaCtlCmds
@ -120,7 +121,7 @@ def index():
extended_image_files = []
for image in image_files["files"]:
if image["detected_type"] is not "UNDEFINED":
if image["detected_type"] != "UNDEFINED":
image["detected_type_name"] = mapped_device_types[image["detected_type"]]
extended_image_files.append(image)
@ -190,6 +191,7 @@ def index():
PROPERTIES_SUFFIX=PROPERTIES_SUFFIX,
REMOVABLE_DEVICE_TYPES=REMOVABLE_DEVICE_TYPES,
NETWORK_DEVICE_TYPES=NETWORK_DEVICE_TYPES,
SUPPORT_DEVICE_TYPES=SUPPORT_DEVICE_TYPES,
)
@ -493,6 +495,34 @@ def log_level():
return redirect(url_for("index"))
@APP.route("/scsi/attach_support", methods=["POST"])
@login_required
def attach_support_device():
"""
Attaches a support device
"""
scsi_id = request.form.get("scsi_id")
unit = request.form.get("unit")
device_type = request.form.get("type")
kwargs = {"unit": int(unit), "device_type": device_type}
process = ractl.attach_image(scsi_id, **kwargs)
process = ReturnCodeMapper.add_msg(process)
if process["status"]:
flash(_(
(
"Attached support device of type %(device_type)s "
"to SCSI ID %(id_number)s LUN %(unit_number)s"
),
device_type=device_type,
id_number=scsi_id,
unit_number=unit,
))
return redirect(url_for("index"))
flash(process["msg"], "error")
return redirect(url_for("index"))
@APP.route("/scsi/attach_network", methods=["POST"])
@login_required
def attach_network_adapter():