Skip to content

Commit

Permalink
Merge pull request #17 from ut-issl/feature/add_tl_mis_and_utl_mis
Browse files Browse the repository at this point in the history
TL_MIS, UTL_MIS をpytestで使えるようにした
  • Loading branch information
chutaro authored Apr 25, 2022
2 parents 146913c + b26d676 commit f21ff67
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
74 changes: 32 additions & 42 deletions isslwings/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,31 +204,58 @@ def get_latest_tlm(self, tlm_code_id: int) -> Tuple[dict, str]:

def send_rt_cmd(self, cmd_code: int, cmd_params_value: tuple, component: str = "") -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
self._send_rt_cmd(command_to_send)
command_to_send["execType"] = "RT"
self._send_cmd(command_to_send)

time.sleep(0.1)

def send_bl_cmd(
self, ti: int, cmd_code: int, cmd_params_value: tuple, component: str = ""
) -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
self._send_bl_cmd(ti, command_to_send)
command_to_send["execType"] = "BL"
command_to_send["execTime"] = ti
self._send_cmd(command_to_send)

time.sleep(0.1)

def send_tl_cmd(
self, ti: int, cmd_code: int, cmd_params_value: tuple, component: str = ""
) -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
self._send_tl_cmd(ti, command_to_send)
command_to_send["execType"] = "TL"
command_to_send["execTime"] = ti
self._send_cmd(command_to_send)

time.sleep(0.1)

def send_utl_cmd(
self, unixtime: float, cmd_code: int, cmd_params_value: tuple, component: str = ""
) -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
self._send_utl_cmd(unixtime, command_to_send)
command_to_send["execType"] = "UTL"
command_to_send["execTime"] = unixtime
self._send_cmd(command_to_send)

time.sleep(0.1)

def send_tl_mis_cmd(
self, ti: int, cmd_code: int, cmd_params_value: tuple, component: str = ""
) -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
command_to_send["execType"] = "TL_MIS"
command_to_send["execTime"] = ti
self._send_cmd(command_to_send)

time.sleep(0.1)

def send_utl_mis_cmd(
self, unixtime: float, cmd_code: int, cmd_params_value: tuple, component: str = ""
) -> None:
command_to_send = self._generate_cmd_dict(cmd_code, cmd_params_value, component)
command_to_send["execType"] = "UTL_MIS"
command_to_send["execTime"] = unixtime
self._send_cmd(command_to_send)

time.sleep(0.1)

Expand Down Expand Up @@ -271,44 +298,7 @@ def _generate_cmd_dict(

return command_to_send

def _send_rt_cmd(self, command: dict) -> None:
command["execType"] = "RT"
response = self.client.post(
"{}/api/operations/{}/cmd".format(self.url, self.operation_id),
json={"command": command},
headers=self.authorized_headers,
).json()

if response["ack"] is False:
raise Exception('send_cmd failed.\n" + "command "{}"'.format(command))

def _send_bl_cmd(self, ti: int, command: dict) -> None:
command["execType"] = "BL"
command["execTime"] = ti
response = self.client.post(
"{}/api/operations/{}/cmd".format(self.url, self.operation_id),
json={"command": command},
headers=self.authorized_headers,
).json()

if response["ack"] is False:
raise Exception('send_cmd failed.\n" + "command "{}"'.format(command))

def _send_tl_cmd(self, ti: int, command: dict) -> None:
command["execType"] = "TL"
command["execTime"] = ti
response = self.client.post(
"{}/api/operations/{}/cmd".format(self.url, self.operation_id),
json={"command": command},
headers=self.authorized_headers,
).json()

if response["ack"] is False:
raise Exception('send_cmd failed.\n" + "command "{}"'.format(command))

def _send_utl_cmd(self, unixtime: float, command: dict) -> None:
command["execType"] = "UTL"
command["execTime"] = unixtime
def _send_cmd(self, command: dict) -> None:
response = self.client.post(
"{}/api/operations/{}/cmd".format(self.url, self.operation_id),
json={"command": command},
Expand Down
10 changes: 10 additions & 0 deletions isslwings/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def send_utl_cmd(ope: Operation, unixtime: float, cmd_code: int, cmd_args: tuple
ope.send_utl_cmd(unixtime, cmd_code, cmd_args)


# TODO: HK で confirm する過程を追加する
def send_tl_mis_cmd(ope: Operation, ti: int, cmd_code: int, cmd_args: tuple) -> str:
ope.send_tl_mis_cmd(ti, cmd_code, cmd_args)


# TODO: HK で confirm する過程を追加する
def send_utl_mis_cmd(ope: Operation, unixtime: float, cmd_code: int, cmd_args: tuple) -> str:
ope.send_utl_mis_cmd(unixtime, cmd_code, cmd_args)


def _send_cmd_and_confirm(
ope: Operation,
func_send_cmd: Callable[[int, tuple], None],
Expand Down

0 comments on commit f21ff67

Please sign in to comment.