4 from robot.api
import logger
5 from robot.utils
import DotDict
6 from robot.utils
import timestr_to_secs
9 from ModDaqsimif.Daqsimif.SimCtl
import SimCtlSync
15 uris = arg.split(
"@")[1]
16 return uris.split(
",")[0]
21 if isinstance(arg, list):
27 """Robot library providing keywords for the SimCtl interface"""
31 ROBOT_LIBRARY_SCOPE =
"GLOBAL"
34 logger.debug(
"Loading MAL and creating factory")
35 self.
mal = pymal.loadMal(
"zpb", {})
36 self.
factory = pymal.CiiFactory.getInstance()
38 logger.debug(
"Loading MAL and creating factory done")
41 """Creates a list of clients with a given ReplyTime timeout."""
42 logger.info(
"Create clients raw arg: %r, type=%s" % (uris, type(uris)))
43 timeout = timestr_to_secs(timeout)
if timeout
is not None else 3
49 if replace_from
and replace_to:
50 uri = uri.replace(replace_from, replace_to)
51 logger.info(
"Create client for uri %s with timeout %d" % (uri, timeout))
52 client = self.
factory.getClient(
53 uri, SimCtlSync, pymal.rr.qos.ReplyTime(datetime.timedelta(seconds=timeout))
55 clients.append(client)
59 """Creates a client with a given ReplyTime timeout."""
60 timeout = timestr_to_secs(timeout)
if timeout
is not None else 3
62 logger.info(
"Create client for uri %s with timeout %d" % (uri, timeout))
63 client = self.
factory.getClient(
64 uri, SimCtlSync, pymal.rr.qos.ReplyTime(datetime.timedelta(seconds=timeout))
68 def __setup(self, clients, arg):
69 logger.info(
"Sending setup: %s to %d clients" % (arg, len(clients)))
71 for client
in clients:
72 reply = client.Setup(arg)
73 logger.info(
"Received reply: %s" % reply)
74 replies.append(json.loads(reply, object_pairs_hook=DotDict))
78 if not isinstance(clients, list):
79 return self.
__setup([clients], arg)[0]
80 return self.
__setup(clients, arg)
83 logger.info(
"Sending reset")
84 if not isinstance(clients, list):
85 return self.
__reset([clients])[0]
88 def __reset(self, clients):
89 logger.debug(
"Sending reset")
91 for client
in clients:
92 replies.append(client.Reset())
93 logger.debug(
"Received replies")
97 if not isinstance(clients, list):
101 def __force_exit(self, clients):
102 logger.debug(
"Sending ForceExit. A reply is not expected.")
103 for client
in clients: