def create_universe(self): """ This function creates a universe object that simulations will run in. The only asset in this \ simulation for an agent to use is a :class:`food.Food`. :return: the universe :rtype: universe.Universe """ # create the universe u = super(Eat_Lunch_Trial, self).create_universe() # this allows eating at work cafeteria = food.Food() cafeteria.location.local = location.OFF_SITE # allow the appropriate assets u.home.assets = { 'food': food.Food(), 'transport': transport.Transport(), 'workplace': workplace.Workplace(), 'cafeteria': cafeteria, } return u
def reset(self): '''mainly used for testing''' messaging.MessageManager.reset(self) self.objectIDMap = {} self.objectNameMap = {} self.clear_process_group() self.gid = 0 if transport.RAKNET_AVAILABLE: self.transport = transport.RakNetTransport() else: self.transport = transport.Transport() # not removing the auto-registered packet types # self.packet_types = {} self.groups = {} self.ipc_transport = transport.IPCTransport()
def create_universe(self): """ This function creates a universe object that simulations will run in. The only asset in this \ simulation for an agent to use is a :class:`transport.Transport` and :class:`workplace.Workplace`. :return: the universe :rtype: universe.Universe """ # create the universe u = super(Commute_To_Work_Trial, self).create_universe() # add a workplace and a transport u.home.assets = { 'transport': transport.Transport(), 'workplace': workplace.Workplace(), } return u
def create_universe(self): """ This function creates a universe object that simulations will run in. The assets that this simulation uses in :class:`workplace.Workplace` and :class:`transport.Transport()`. :return: the universe :rtype: universe.Universe """ # create the universe u = super(Work_Trial, self).create_universe() # the assets in the simulation u.home.assets = { 'workplace': workplace.Workplace(), 'transport': transport.Transport(), } return u
def __init__(self, addr, port=9000): """Context's __init__ method Args: addr (str): 目标机械臂控制系统的IP地址 port (int): 服务端口号,目前默认9000 Attributes: __addr (str): 目标机械臂控制系统的IP地址 __port (int): 服务端口号,目前默认9000 """ assert type(addr) == types.StringType assert type(port) == types.IntType self.__addr = addr self.__port = port addr = addr + ":" + str(port) self.tran = transport.Transport(addr)
def testsuite_init(): """Initialize OCCI testsuite Renderers from occi_libs needs to be initialized first. """ self = sys.modules[__name__] if 'pOCCI.occi_libs' in sys.modules: occi_libs = sys.modules['pOCCI.occi_libs'] else: occi_libs = sys.modules['occi_libs'] self.renderer = occi_libs.renderer self.renderer_big = occi_libs.renderer_big self.renderer_httpheaders = occi_libs.renderer_httpheaders if not self.renderer: print >> sys.stderr, 'No renderer (invalid mimetype?)' sys.exit(2) self.connection = transport.Transport(occi_config)
def __init__(self, clock): self.id = -1 self.category = APARTMENT self.population = 0 self.clock = clock self.location = loc.Location( loc.NORTH, loc.HOME) # list of assets all Homes have # recall need to set the location of the work asset wp1 = workplace.Workplace() # allows sleeping bed1 = bed.Bed() # allows commuting the_transport = transport.Transport() the_transport.max_users = 1 # food1 allows eating at home food1 = food.Food() # cafeteria allows eating at work cafeteria = food.Food() cafeteria.location.local = loc.OFF_SITE # store all of the assets self.assets = { 'workplace': wp1, 'bed': bed1, 'transport': the_transport, 'food': food1, 'cafeteria': cafeteria } # the revenue of the house self.revenue = 0.0 return
def __init__(self, args=default_args): self.prompt = PROMPTER self.scripts = [] self.arg_cmds = [] self.arg_flag = True self.cmd_proc = None self.done = False self.config = { 'exit-on-error': CV(C['exit-on-error']['false'], bool, 'Exit on error'), 'trace-on-error': CV(C['trace-on-error']['true'], bool, 'Print stack trace on error'), 'local-echo': CV(C['local-echo']['true'], bool, 'Echo command line locally'), 'log-level': CV(5, int, 'Set log level'), 'wav-prefix': CV('', str, 'Set wav prefix'), } self.transport = transport.Transport(args.showinit, args.wavprefix, args.framerate, args.sensitivity) self.kermit_cmd_proc = KermitCmds(self.transport) self.serial_cmd_proc = SerialCmds(self.transport) self.xmodem_cmd_proc = XmodemCmds(self.transport) init_file = args.init if init_file and (init_file != DEFAULT_INI_FILE or os.path.exists(init_file)): log.i('Reading init script {}'.format(init_file)) try: self.scripts = read_scripts(init_file) except IOError: log.e('Error reading {}'.format(init_file)) self.arg_cmds = self.proc_args(args)
async def main() -> None: t = transport.Transport(8005) s = server.Server(8017) aiml_kernel = aiml.Kernel() aiml_kernel.setTextEncoding(None) current_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'files', 'standard' ) aiml_kernel.bootstrap(learnFiles='startup.xml', commands='load aiml b', chdir=current_path) # chdir = os.path.join( aiml.__path__[0],'botdata','alice' ) # kern.bootstrap(learnFiles="startup.xml", commands="load alice", chdir=chdir) # kern.saveBrain(args.save) # kern.bootstrap(brainFile=args.brain) while True: data = s.listen() if len(data) == 0: continue if data['author'] == 1: # Jeff continue if len(data['content']) == 0: continue msg = aiml_kernel.respond(data['content']) if not len(msg): continue t.send_msg(msg)
[Caux, Faux, cc, ss, psi] = Chobj.post_process(sol) print(Caux) CR = Caux.T[0] print(CR) # ===================== Transport data recovery =============================# grid = ComPASS.Grid(shape=(nx, ny, nz), extent=(Lx, Ly, Lz), origin=(0, 0, 0)) Trobj = tr.Transport( rhow, b, rhocp, muf, porosity, perm, conduct, onecomp, exact_sol, grid, pleft, pright, a, CL, CR, ) # ===================== The simulation parameters ==========================# t = 0 # initial time dt = 360 # 720 #tr.final_time/1e3 final_time = 24 * 3600 # 12000 #72000 # 20 heures #29160 # ts_manager = FixedTimeStep(dt)
def main(): usage = "usage: %prog [options] name [-l | target message]" parser = optparse.OptionParser(usage=usage) parser.add_option("-v", "--verbose", dest="verbose", help=u._("Be verbose."), action="store_true", default=False) parser.add_option('--kite_host', help=u._('Kite server host address.'), default="localhost"), parser.add_option('--kite_port', help=u._('Kite server port number.'), default="9109"), parser.add_option('--key', "-k", help=u._('Optional base64 encoded key.')), parser.add_option('--queue', "-q", help=u._('Message queue url.'), default="rabbit://localhost"), parser.add_option('--listen', "-l", help=u._('Listen for incoming messages.'), action="store_true", default=False), (options, args) = parser.parse_args() if not args: parser.print_usage() return -1 # NOTE(tkelsey): using developer interface to remove the need to run # a keystone server. name = args[0] host = options.kite_host port = options.kite_port kite = "http://%s:%s/v1" % (host, port) auth = token_endpoint.Token(kite, 'aToken') transport_obj = transport.Transport(target=name, url=options.queue) session_obj = session.Session(auth=auth) client_obj = client.KiteClient(name, transport_obj, key=options.key, session=session_obj, verbose=options.verbose) if options.listen: try: message = client_obj.recv() print(message) except KeyboardInterrupt: pass else: if len(args) < 3: print("target and message are required when not listening") parser.print_usage() return -1 else: targ = args[1] body = args[2] resp = client_obj.send(body, targ) print(resp)
def transportPair(*args, **kwargs): s1, s2 = socket.socketpair() return transport.Transport(s1, *args, **kwargs), transport.Transport( s2, *args, **kwargs)
#!/usr/bin/env python import transport def try_locate(t: transport.Transport) -> bool: """""" import os.path if not os.path.exists('darknet'): # download darknet for linux/macos/windows, but now... # or download tensorflow lite for linux & other platforms. return False return True def main(t: transport:Transport) -> None: """""" import subprocess path = "" if path: subprocess.call(["./darknet", "detect", "cfg/yolov4-tiny.cfg", "yolov4-tiny.weights", path]) if __name__ == "__main__": t = transport.Transport(8005) if try_locate(t): main(t)
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import rclpy from rclpy.qos import qos_profile_default from geometry_msgs.msg import Twist import transport transport = transport.Transport() def chatter_callback(msg): if msg.angular.z == 0 and msg.linear.x == 0: transport.stop() print('Stopping') return if msg.linear.x > 0: transport.move_forward() print('Forward') return if msg.linear.x < 0: transport.move_reverse()