Skip to content

Commit

Permalink
Merge pull request #6 from ut-issl/feature/add_send_utl_cmd
Browse files Browse the repository at this point in the history
tl_cmdとutl_cmdも打てるようにする
  • Loading branch information
chutaro authored Jan 19, 2022
2 parents c057a61 + 8ece823 commit b7f59ad
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
36 changes: 36 additions & 0 deletions isslwings/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ def send_bl_cmd(self, ti: int, cmd_code: int, cmd_params_value: tuple, component

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)

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)

time.sleep(0.1)

def get_obc_info(self) -> dict:
return self.obc_info

Expand Down Expand Up @@ -280,6 +292,30 @@ def _send_bl_cmd(self, ti: int, command: dict) -> None:
if response["ack"] == 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"] == 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
response = self.client.post(
"{}/api/operations/{}/cmd".format(self.url, self.operation_id),
json={"command": command},
headers=self.authorized_headers
).json()

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


if __name__ == "__main__":
ope = Operation(auto_connect=False)
Expand Down
14 changes: 14 additions & 0 deletions isslwings/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ def send_bl_cmd_and_confirm(
return _send_cmd_and_confirm(ope, func_send_cmd, cmd_code, cmd_args, tlm_code_hk)


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


# TODO: HK で confirm する過程を追加する
def send_utl_cmd(
ope: Operation, unixtime: float, cmd_code: int, cmd_args: tuple
) -> str:
ope.send_utl_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 b7f59ad

Please sign in to comment.