Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PV_PREFIX=
DEVICE_PITCH_URI= # xi-com:///...
DEVICE_YAW_URI= # xi-com:///...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ lockfiles/
.ruff_cache/

.env
gui/
bob/
bob_custom/
virt/
home.yaml
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ version_file = "src/fastcs_standa_mirror/_version.py"

[tool.pyright]
typeCheckingMode = "standard"
reportMissingImports = false # Ignore missing stubs in imported modules
reportMissingImports = false # Ignore missing stubs in imported modules

[tool.pytest.ini_options]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
Expand Down Expand Up @@ -113,7 +113,7 @@ commands = [
description = "Run tests with coverage"
commands = [
[
"pytest",
"pytest",
"--cov=fastcs_standa_mirror",
"--cov-report",
"term",
Expand Down
34 changes: 24 additions & 10 deletions src/fastcs_standa_mirror/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,39 @@ def main() -> None:
version=__version__,
)
parser.add_argument(
"--use-virtual",
"--sim",
action="store_true",
dest="use_virtual",
help="Enable virtual mode",
dest="use_sim",
help="Use simulated device",
)

parsed_args = parser.parse_args()
use_virtual = parsed_args.use_virtual
use_sim = parsed_args.use_sim

# initial varaiables setup
load_dotenv()
# Validate device URIs and PV_PREFIX only if not using simulation
if not use_sim:
load_dotenv()

pv_prefix = os.getenv("PV_PREFIX")
print(pv_prefix)
if pv_prefix is None:
raise ValueError("PV_PREFIX environment variable must be set")

device_pitch_uri = os.getenv("DEVICE_PITCH_URI")
device_yaw_uri = os.getenv("DEVICE_YAW_URI")
if device_pitch_uri is None or device_yaw_uri is None:
raise ValueError("DEVICE_PITCH_URI and DEVICE_YAW_URI must be set")

else:
pv_prefix = "MIRROR-SIM-001"
logging.info(f"Simulated device PV_PREFIX -> {pv_prefix}")

pv_prefix = os.getenv("PV_PREFIX", "STANDA-MIRROR")
home_positions = load_or_create_home_pos()
uris = load_devices(use_virtual=use_virtual)
uris = load_devices(use_sim=use_sim)

# epics setupo
# epics setup
gui_options = EpicsGUIOptions(
output_path=Path(".") / "gui/Mirror.bob", title="Mirror Controller"
output_path=Path(".") / "bob/Mirror.bob", title="Mirror Controller"
)

epics_ca = EpicsCATransport(
Expand Down
2 changes: 1 addition & 1 deletion src/fastcs_standa_mirror/motor_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, name: str, device_uri: str):
self.motor = ximc.Axis(self._device_uri)
self.motor.open_device()
logging.info(
f"Successfully opened device\n'{self._name}' at {self._device_uri}"
f"Successfully opened device -> '{self._name}' at {self._device_uri}"
)

except Exception as e:
Expand Down
12 changes: 6 additions & 6 deletions src/fastcs_standa_mirror/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class DeviceNotFoundError(Exception):
pass


def load_devices(use_virtual: bool) -> dict:
def load_devices(use_sim: bool) -> dict:
"""Load device uris for pitch and yaw controllers"""

return create_virtual_devices() if use_virtual else load_real_devices()
return create_simulated_devices() if use_sim else load_real_devices()


def load_real_devices() -> dict:
Expand Down Expand Up @@ -55,13 +55,13 @@ def load_real_devices() -> dict:
return target_uris


def create_virtual_devices() -> dict:
"""Create virtual devices and return uris"""
logging.info("Creating virtual standa devices")
def create_simulated_devices() -> dict:
"""Create simulated devices and return uris"""
logging.info("Creating simulated standa devices")

virt_dir = Path.cwd() / "virt"

device_uri_base = f"xi-emu:///{virt_dir}/virtual_motor_controller"
device_uri_base = f"xi-emu:///{virt_dir}/simulated_motor_controller"

return {
"pitch": f"{device_uri_base}_pitch.bin",
Expand Down