Skip to content

Commit

Permalink
add frame for adding list commands
Browse files Browse the repository at this point in the history
  • Loading branch information
d-perl committed Nov 13, 2024
1 parent b7055f2 commit f3364a5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
13 changes: 6 additions & 7 deletions src/rtc6_fastcs/bindings/rtc6_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ int load_program_and_correction_files(uint card, char *programFilePath, char *co
}

// Real functions which we expect to use and expose
void clear_all_errors() { reset_error(-1); }

void check_conection()
{
const int connection = eth_check_connection();
Expand All @@ -160,18 +162,17 @@ std::string get_error_string()
int connect(const char *ipStr, char *programFilePath, char *correctionFilePath)
{
init_dll();

// The library allows for connecting to multiple cards, but we just use one
// See manual page 855 for info about the conversion of IP address to an int
int cardNo = eth_assign_card_ip(eth_convert_string_to_ip(ipStr), 0);
int result = select_rtc(cardNo);
int error = get_error();
if (result != cardNo || error != 0)
if (result != cardNo)
{
throw RtcError(str(format("select_rtc for card %1% failed with error: %2%. Most likely, a card was not found at the given IP address: %3%. Alternatively, it may already be acquired by another process. Error code: %4%. Description: %5%") % cardNo % result % ipStr % error % parse_error(error)));
const int error = get_error();
throw RtcError(str(format("select_rtc for card %1% failed with result: %2%. Most likely, a card was not found at the given IP address: %3%. Alternatively, it may already be acquired by another process. Error code: %4%. Description: %5%") % cardNo % result % ipStr % error % parse_error(error)));
}
return load_program_and_correction_files(cardNo, programFilePath, correctionFilePath);
error = get_error();
const int error = get_error();
if (error)
{
throw RtcError(str(format("Error loading program files: %1%") % parse_error(error)));
Expand Down Expand Up @@ -249,8 +250,6 @@ void close_connection()
}
}

void clear_all_errors() { reset_error(-1); }

// Definition of our exposed python module - things must be registered here to be accessible
PYBIND11_MODULE(rtc6_bindings, m)
{
Expand Down
Binary file not shown.
45 changes: 36 additions & 9 deletions src/rtc6_fastcs/controller/rtc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
from rtc6_fastcs.controller.rtc_connection import RtcConnection


class RtcInfoController(SubController):
class ConnectedSubController(SubController):
def __init__(self, conn: RtcConnection) -> None:
super().__init__()
self._conn = conn


class RtcInfoController(ConnectedSubController):
firmware_version = AttrR(Int(), group="Information")
serial_number = AttrR(Int(), group="Information")
ip_address = AttrR(String(), group="Information")
Expand All @@ -22,13 +28,9 @@ async def proc_cardinfo(self) -> None:
self.is_acquired.set(info.is_acquired),
)

def __init__(self, conn: RtcConnection) -> None:
super().__init__()
self._conn = conn


class RtcControlSettings(SubController):
# laser_mode = AttrR(Float(), group="Information") should be an enum
class RtcControlSettings(ConnectedSubController):
# laser_mode = AttrR(String(), group="LaserControl") should be an enum - do with allowed_values=
jump_speed = AttrW(Float(), group="LaserControl") # set_jump_speed_ctrl
mark_speed = AttrW(Float(), group="LaserControl") # set_mark_speed_ctrl
# set_scanner_delays(jump, mark, polygon) in 10us increments
Expand All @@ -37,9 +39,23 @@ class RtcControlSettings(SubController):
polygon_delay = AttrW(Int(), group="LaserControl")
sky_writing_mode = AttrW(Int(), group="LaserControl") # set_sky_writing_mode


class RtcListOperations(ConnectedSubController):
class AddJump(ConnectedSubController):
x = AttrW(Int(), group="LaserControl")
y = AttrW(Int(), group="LaserControl")

class AddArc(ConnectedSubController):
x = AttrW(Int(), group="LaserControl")
y = AttrW(Int(), group="LaserControl")
angle = AttrW(Float(), group="LaserControl")

class AddLine(ConnectedSubController):
x = AttrW(Int(), group="LaserControl")
y = AttrW(Int(), group="LaserControl")

def __init__(self, conn: RtcConnection) -> None:
super().__init__()
self._conn = conn
super().__init__(conn)


class RtcController(Controller):
Expand All @@ -57,6 +73,17 @@ def __init__(
self._info_controller = RtcInfoController(self._conn)
self.register_sub_controller("INFO", self._info_controller)
self.register_sub_controller("CONTROL", RtcControlSettings(self._conn))
list_controller = RtcListOperations(self._conn)
self.register_sub_controller("LIST", list_controller)
list_controller.register_sub_controller(
"ADDJUMP", list_controller.AddJump(self._conn)
)
list_controller.register_sub_controller(
"ADDARC", list_controller.AddArc(self._conn)
)
list_controller.register_sub_controller(
"ADDLINE", list_controller.AddLine(self._conn)
)

async def connect(self) -> None:
await self._conn.connect()
Expand Down

0 comments on commit f3364a5

Please sign in to comment.