def __init__(self, name, passerNo, shooterNo): super(PassShoot, self).__init__(name) # 1 passerがボールに近づく FIRST = ParallelOne("FIRST") FIRST.add_child( Kick.SetPassTarget("Set pass target", passerNo, shooterNo)) FIRST.add_child(Kick.Approach("Passer approach", passerNo)) FIRST.add_child(BaseSkill.SuccessTimer("SuccessTimer1.0", 1.0)) self.add_child(FIRST) # 2 shooterがshoot位置に移動する SECOND = ParallelOne("SECOND") SECOND.add_child(BaseSkill.WaitToReceive("Shooter wait", shooterNo)) SECOND.add_child( Analyst.IsOnTarget("Shooter is on target", shooterNo, 0.5)) SECOND.add_child(BaseSkill.SuccessTimer("SuccessTimer2.0", 3.0)) self.add_child(SECOND) # # 3 passerがボールを蹴る THIRD = ParallelAll("THIRD") THIRD.add_child( Kick.SetPassTarget("Set pass target", passerNo, shooterNo)) THIRD.add_child(Kick.Pass("PASS", passerNo)) # 3 shooterが受け取りshootする THIRD.add_child(Kick.CalcuKickTarget("CalcuKickTarget", shooterNo)) THIRD.add_child(Kick.ReceiveShoot("ReceiveShoot", shooterNo)) THIRD.add_child(BaseSkill.FailureTimer("FailureTimer7.0", 10.0)) INVERT = Invert("Invert") INVERT.add_child(Analyst.IsBaller("IsBaller", shooterNo, 1.0)) THIRD.add_child(INVERT) self.add_child(THIRD)
def __init__(self, name): super(IndirectAction, self).__init__(name) limitTime = 30.0 # limitTime = 7.0 timerName = "SuccessTimer" + str(limitTime) TIMER = BaseSkill.SuccessTimer(timerName, limitTime) ACTION_SELECTOR = Selector("ACTION_SELECTOR") DO_PASS_SHOOT = Sequence("DO_PASS_SHOOT") DO_PASS_SHOOT.add_child(Analyst.BallIsEnemySide("BallIsEnemySide")) DO_PASS_SHOOT.add_child(Analyst.ThereAreThreeRobots("ThreeRobots")) DO_PASS_SHOOT.add_child(ComboSkill.PassShoot("PassShoot", 2, 1)) ACTION_SELECTOR.add_child(DO_PASS_SHOOT) DO_SHOOT = ParallelOne("DO_SHOOT") DO_SHOOT.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 1)) DO_SHOOT.add_child(Kick.SetplayShoot("Shoot", 1)) DO_SHOOT.add_child(Defender.Defense("DefenderDefense", 2)) ACTION_SELECTOR.add_child(DO_SHOOT) self.add_child(TIMER) self.add_child(ACTION_SELECTOR) self.add_child(GoalKeeper.Defense("GoalKeeperDefense", 0))
def __init__(self, name): super(InplaySwitch, self).__init__(name) INPLAY_DEFEND = ParallelOne("PARALLEL_DEFEND") INPLAY_DEFEND.add_child(Analyst.BallMoved("Ball moved")) EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child(Attacker.StopGame("AttackerStop", 0)) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child(GoalKeeper.Defense("GoalKeeperDefense",0)) # SOME_ROBOTS.add_child(Attacker.StopGame("AttackerStop", 1)) SOME_ROBOTS.add_child(Attacker.ChipKickGuard("ChipKickGuard", 1)) SOME_ROBOTS.add_child(Defender.Defense("DefenderDefense", 2)) EXE_SELECTOR.add_child(SOME_ROBOTS) INPLAY_DEFEND.add_child(EXE_SELECTOR) INPLAY = InPlay.Execute("Execute inplay") self.add_child(INPLAY_DEFEND) self.add_child(INPLAY)
def __init__(self, name): super(UltimateOffense, self).__init__(name) IS_ULTIMATE_OFFENSIVE = Analyst.IsUltimateOffensive( "IS_ULTIMATE_OFFENSIVE") EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child( GoalKeeper.UltimateOffense("GoalKeeperUltOffense", 0)) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child( GoalKeeper.UltimateOffense("GoalKeeperUltOffense", 0)) SOME_ROBOTS.add_child(Attacker.UltimateOffense("AttackerUltOffense", 1)) SOME_ROBOTS.add_child(Defender.UltimateOffense("DefenderUltOffense", 2)) EXE_SELECTOR.add_child(SOME_ROBOTS) self.add_child(IS_ULTIMATE_OFFENSIVE) self.add_child(EXE_SELECTOR)
def __init__(self, name, number): super(OngameShoot, self).__init__(name) GO_TO_BALL = ParallelOne("GO_TO_BALL") GO_TO_BALL.add_child(OngameApproach("OngameApproach",number)) GO_TO_BALL.add_child(Analyst.HasBall("HasBall",0)) KICKING = ParallelOne("OngameKicking") KICKING.add_child(Analyst.BallMoved("BallMoved",True)) KICKING.add_child(OngameGoKicking("OngameGoKicking", number, 8.0)) self.add_child(GO_TO_BALL) self.add_child(KICKING)
def __init__(self, name): super(GameMain, self).__init__(name) BALL_INFIELD = ParallelAll("BALL_INFIELD") BALL_INFIELD.add_child(Analyst.BallIsInField("BallIsInField")) BALL_INFIELD.add_child(AI_Parent("AI_PARENT")) BALL_INFIELD.add_child(Analyst.InfoUpdate("INFO_UPDATE")) BALL_OUTFIELD = ParallelAll("BALL_OUTFIELD") BALL_OUTFIELD.add_child(Analyst.BallIsOutField("BallIsOutField")) BALL_OUTFIELD.add_child(BaseSkill.AllRobots_Halt("AllRobots_Halt")) self.add_child(BALL_INFIELD) self.add_child(BALL_OUTFIELD)
def __init__(self, name): super(ExeNormal, self).__init__(name) self.add_child(Analyst.ThereAreRobots("ThereAreRobots")) self.add_child(GoalKeeper.StopGame("GoalKeeper", 0)) self.add_child(Attacker.StopGame("Attacker", 1)) self.add_child(Defender.StopGame("Defender", 2))
def __init__(self, name, number, x, y, yaw): super(GoToPosition, self).__init__(name) self.STAY = BaseSkill.Stay("Stay", number, x, y, yaw) self.IS_ON_TARGET = Analyst.IsOnTarget("IsOnTarget", number, 0.5) self.add_child(self.STAY) self.add_child(self.IS_ON_TARGET)
def __init__(self, name): super(ExeNormal_Pre, self).__init__(name) self.add_child(Analyst.ThereAreRobots("ThereAreRobots")) self.add_child(GoalKeeper.StopGame("GoalKeeperStop", 0)) self.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 1)) self.add_child(Kick.Approach("Approach", 1)) self.add_child(Defender.StopGame("DefenderStop", 2))
def __init__(self, name, number, timeout=0.5): super(Approach, self).__init__(name) self.CALC = CalcuApproachPosition("CalcApproachPos", number) self.IS_ON_TARGET = Analyst.IsOnTarget("Is On Target",number, timeout) self.add_child(self.CALC) self.add_child(self.IS_ON_TARGET)
def __init__(self, name): super(ExeNormal_Shoot, self).__init__(name) self.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SHOOT_ITERATOR = Iterator("SHOOT_ITERATOR") SHOOT_ITERATOR.add_child(Kick.SetplayShoot("Shoot", 1)) SHOOT_ITERATOR.add_child(InPlay.Execute("Execute inplay")) self.add_child(SHOOT_ITERATOR)
def __init__(self, name, number): super(OngameApproach, self).__init__(name) CALC = CalcuApproachPosition("CalcApproachPos", number) IS_BACKSIDE = Analyst.IsBackSide("Is BackSide", number) self.add_child(CALC) self.add_child(IS_BACKSIDE)
def __init__(self, name): super(DirectFriend, self).__init__(name) IS_DIRECT_FRIEND = IsDIRECT_FREE_FRIEND("Is direct friend") EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child(OneRobotExecute("OneRobotExecute")) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child(Execute("NormalExecute")) EXE_SELECTOR.add_child(SOME_ROBOTS) self.add_child(IS_DIRECT_FRIEND) self.add_child(EXE_SELECTOR)
def __init__(self, name, number): super(Shoot, self).__init__(name) self.APPROACH = OngameApproach("Approach", number) self.KICKING = ParallelOne("Kicking") self.KICKING.add_child(Analyst.BallMoved("BallMoved")) self.KICKING.add_child(GoKicking("GoKicking", number, 8.0)) self.add_child(self.APPROACH) self.add_child(self.KICKING)
def __init__(self, name, number): super(Pass, self).__init__(name) self.APPROACH = Approach("Approach", number, 0.5) self.KICKING = ParallelOne("Kicking") self.KICKING.add_child(GoKicking("GoKicking", number, 6.0)) # self.KICKING.add_child(SetplayGoKicking("GoKicking", number, 6.0)) self.KICKING.add_child(Analyst.BallMoved("BallMoved")) self.add_child(self.APPROACH) self.add_child(self.KICKING)
def __init__(self, name): super(Prepare, self).__init__(name) EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child(Attacker.StopGame("AttackerStop", 0)) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child(GoalKeeper.Defense("GoalKeeperDefense", 0)) # SOME_ROBOTS.add_child(Attacker.StopGame("AttackerStop", 1)) SOME_ROBOTS.add_child(Attacker.ChipKickGuard("ChipKickGuard", 1)) SOME_ROBOTS.add_child(Defender.SetplayDefense("DefenderDefense", 2)) EXE_SELECTOR.add_child(SOME_ROBOTS) self.add_child(IsKICKOFF_ENEMY("IsKICKOFF_ENEMY")) self.add_child(EXE_SELECTOR)
def __init__(self, name): super(Execute, self).__init__(name) EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 0)) ONE_ROBOT.add_child(Kick.SetplayShoot("Shoot", 0)) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child(GoalKeeper.StopGame("GoalKeeperStop", 0)) SOME_ROBOTS.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 1)) SOME_ROBOTS.add_child(Kick.SetplayShoot("Shoot", 1)) SOME_ROBOTS.add_child(Defender.StopGame("DefenderStop", 2)) EXE_SELECTOR.add_child(SOME_ROBOTS) self.add_child(IsNORMAL_START("IsNORMAL_START")) self.add_child(EXE_SELECTOR)
def __init__(self, name): super(Prepare, self).__init__(name) EXE_SELECTOR = Selector("EXE_SELECTOR") ONE_ROBOT = ParallelAll("ONE_ROBOT") ONE_ROBOT.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) ONE_ROBOT.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 0)) ONE_ROBOT.add_child(Kick.Approach("Approach", 0)) EXE_SELECTOR.add_child(ONE_ROBOT) SOME_ROBOTS = ParallelAll("SOME_ROBOTS") SOME_ROBOTS.add_child(Analyst.ThereAreRobots("ThereAreRobots")) SOME_ROBOTS.add_child(GoalKeeper.StopGame("GoalKeeperStop", 0)) SOME_ROBOTS.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 1)) SOME_ROBOTS.add_child(Kick.Approach("Approach", 1)) SOME_ROBOTS.add_child(Defender.StopGame("DefenderStop", 2)) EXE_SELECTOR.add_child(SOME_ROBOTS) self.add_child(IsPENALTY_FRIEND("IsPENALTY_FRIEND")) self.add_child(EXE_SELECTOR)
def __init__(self, name, num1, num2): super(PassAndPass, self).__init__(name) wait1X, wait1Y, wait1Yaw = (-2.0, 2.0, -math.pi*0.5) wait2X, wait2Y, wait2Yaw = (-2.0, -2.0, math.pi*0.5) PLAYER1 = Sequence("player1") wait_ = ParallelOne("wait1") wait_.add_child(Analyst.BallEnteringQuadrant("ballEntering",2)) wait_.add_child(BaseSkill.Stay("stay1", num1, wait1X, wait1Y, wait1Yaw)) pass_ = ParallelOne("pass1") pass_.add_child(Kick.SetPassTarget("setTarget1",num1, num2)) pass_.add_child(Kick.Pass("GoPassing1", num1)) pass_.add_child(Analyst.BallEnteringQuadrant("ballEntering",3)) PLAYER1.add_child(wait_) PLAYER1.add_child(pass_) PLAYER1.add_child(GoToPosition("goto1",num1,wait1X,wait1Y,wait1Yaw)) self.add_child(PLAYER1) PLAYER2 = Sequence("player2") wait_ = ParallelOne("wait2") wait_.add_child(Analyst.BallEnteringQuadrant("ballEntering",3)) wait_.add_child(BaseSkill.Stay("stay2", num2, wait2X, wait2Y, wait2Yaw)) pass_ = ParallelOne("pass2") pass_.add_child(Kick.SetPassTarget("setTarget2",num2, num1)) pass_.add_child(Kick.Pass("GoPassing2", num2)) pass_.add_child(Analyst.BallEnteringQuadrant("ballEntering",2)) PLAYER2.add_child(wait_) PLAYER2.add_child(pass_) PLAYER2.add_child(GoToPosition("goto2",num2,wait2X,wait2Y,wait2Yaw)) self.add_child(PLAYER2)
def __init__(self, name): super(Execute, self).__init__(name) IS_NORMAL_START = IsNORMAL_START('is_normal_start') INPLAY_SWITCH = Sequence("INPLAY_SWITCH") EXE_DEFEND = ParallelOne("EXE_DEFEND") EXE_DEFEND.add_child(Analyst.BallMoved("BallMoved")) EXE_DEFEND.add_child(GoalKeeper.PenaltyDefense("PenaltyDefense", 0)) EXE_DEFEND.add_child(BaseSkill.WaitPenaltyShoot("Wait1", 1)) EXE_DEFEND.add_child(BaseSkill.WaitPenaltyShoot("Wait2", 2)) INPLAY_SWITCH.add_child(EXE_DEFEND) EXE_SHOOT = ParallelAll("EXE_SHOOT") EXE_SHOOT.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 0)) EXE_SHOOT.add_child(Kick.Shoot("Shoot", 0)) EXE_SHOOT.add_child(BaseSkill.WaitPenaltyShoot("Wait1", 1)) EXE_SHOOT.add_child(BaseSkill.WaitPenaltyShoot("Wait2", 2)) INPLAY_SWITCH.add_child(EXE_SHOOT) self.add_child(IS_NORMAL_START) self.add_child(INPLAY_SWITCH)
def __init__(self, name): super(ExeOneRobot, self).__init__(name) self.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) self.add_child(Attacker.StopGame("Attacker", 0))
def RunClient(): # Criando canal para conexão com o servidor do lado cliente e instanciando stub dos serviços # IPV4 Address : 192.168.1.36 port - 50051 # Type pode ser external ou localhost type = "localhost" channel = grpc.insecure_channel('localhost:50051') stub = proto_grpc.ServicesStub(channel) test_cases = 10 # Teste 1 : Sem argumentos e retorno vazio array_results = [] for i in range(test_cases): start = time.time() stub.NoArgument_NoReturn(proto.Empty()) end = time.time() array_results.append(end - start) outputName = "T1Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.0 : Recebe String e devolve invertida(Tamanho 4) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn(proto.String(name="Luan")) end = time.time() array_results.append(end - start) outputName = "T2Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.1 : Recebe String e devolve invertida(Tamanho 8) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn( proto.String(name="LuanLuan")) end = time.time() array_results.append(end - start) outputName = "T2.1Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.2 : Recebe String e devolve invertida(Tamanho 16) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn( proto.String(name="LuanLuanLuanLuan")) end = time.time() array_results.append(end - start) outputName = "T2.2Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.3 : Recebe String e devolve invertida(Tamanho 32) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn( proto.String(name="LuanLuanLuanLuanLuanLuanLuanLuan")) end = time.time() array_results.append(end - start) outputName = "T2.3Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.4 : Recebe String e devolve invertida(Tamanho 64) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn( proto.String( name= "LuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuan" )) end = time.time() array_results.append(end - start) outputName = "T2.4Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.5 : Recebe String e devolve invertida(Tamanho 128) array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ReverseStringReturn( proto.String( name= "LuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuan" )) end = time.time() array_results.append(end - start) outputName = "T2.5Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 3.0 : Recebe um long e devolve um long long_number = 92233720368547 array_results = [] for i in range(test_cases): start = time.time() stub.OneLongArgument_OneLongReturn(proto.Long(a=long_number)) end = time.time() array_results.append(end - start) outputName = "T3Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 3.1 : Recebe um long em tempo de execução(oneOf) e devolve um long array_results = [] for i in range(test_cases): start = time.time() stub.OneLongArgument_OneOf_OneLongReturn( proto.OneofLong(d=long_number)) end = time.time() array_results.append(end - start) outputName = "T3.1Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 4.0 : Comparando envio de oito argumentos long com o envio de um argumento long array_results = [] for i in range(test_cases): start = time.time() stub.EightLongsArguments_OneLongReturn( proto.RealLong(a=long_number + 1, b=long_number + 2, c=long_number + long_number, d=long_number * 2, e=long_number * 3, f=long_number * 10, g=long_number * 15, h=long_number)) end = time.time() array_results.append(end - start) outputName = "T4Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 5.0 : Envia dois inteiros de tamanho 1 e retorna 1 inteiro array_results = [] for i in range(test_cases): start = time.time() stub.AddTwoIntValues(proto.AddRequest(a=5, b=6)) end = time.time() array_results.append(end - start) outputName = "T5Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 6.0 : Dois inteiros int32 x inteiros fixed array_results = [] for i in range(test_cases): int_bigger = 536870912 start = time.time() stub.AddTwoIntValues(proto.AddRequest(a=int_bigger, b=int_bigger)) end = time.time() array_results.append(end - start) outputName = "T6Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 6.1 : Adicionado dois inteiros fixed, comparação para valores acima de 2^28-1 com int32 array_results = [] for i in range(test_cases): start = time.time() stub.AddTwoIntValues_FixedInt( proto.AddRequest(a=int_bigger, b=int_bigger)) end = time.time() array_results.append(end - start) outputName = "T6.1Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 6.2 : Comparando signed int com int32 para valores negativos negative_a = -82102222 negative_b = -8900989 array_results = [] for i in range(test_cases): start = time.time() stub.AddTwoIntValues(proto.AddRequest(a=negative_a, b=negative_b)) end = time.time() array_results.append(end - start) outputName = "T6.2Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 6.3 : Adicionado dois inteiros signed negativos, comparando com int32 array_results = [] for i in range(test_cases): start = time.time() stub.AddTwoIntValues_SignedInt( proto.AddRequest(a=negative_a, b=negative_b)) end = time.time() array_results.append(end - start) outputName = "T6.3Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 7.0 : Três argumentos doubles, um retorno double array_results = [] for i in range(test_cases): start = time.time() stub.ThreeDoubleArgument_DoubleReturn( proto.RealDouble(a=4.562, b=4.632, c=23.43561)) end = time.time() array_results.append(end - start) outputName = "T7Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 8.0 : Serviço de busca binária que retorna um booleano array_results = [] for i in range(test_cases): start = time.time() stub.BinarySearch( proto.Tuple(a=[2, 3, 6, 7, 10, 15, 22, 34, 44, 52], b=66)) end = time.time() array_results.append(end - start) outputName = "T8Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 9.0 : Recebe um string e retorna uma array de strings array_results = [] for i in range(test_cases): start = time.time() stub.OneStringArgument_ArrayReturn(proto.String(name="Luan")) end = time.time() array_results.append(end - start) outputName = "T9Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 10.0 : Pega o valor no meio da array array_results = [] for i in range(test_cases): start = time.time() stub.GetMiddleArrayValue(proto.ItemQuery(i=[32, 66, 45, 33, 90])) end = time.time() array_results.append(end - start) outputName = "T10Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste 11.0 : Classe complexa, retorna o país do código de area do telefone array_results = [] for i in range(test_cases): home_phone = proto.Phone(code=55, ddd=11, number=45456545) start = time.time() stub.GetCountry_PersonPhone( proto.Person(name="Maria", age=22, phone=home_phone)) end = time.time() array_results.append(end - start) outputName = "T11Grpc-" + type anly.makeTestFile(array_results, outputName) # Teste Extra - Grpc : map e Classes complexa array_results = [] for i in range(test_cases): md5_algorithm = proto.Hash.Algorithm(name="MD5", output_size=128, block_size=512) md5_hash = proto.Hash(algorithms=[md5_algorithm], intern_size=128, rounds=64) sha1_algorithm = proto.Hash.Algorithm(name="SHA1", output_size=160, block_size=512) sha1_hash = proto.Hash(algorithms=[sha1_algorithm], intern_size=160, rounds=80) sha2_algorithm = proto.Hash.Algorithm(name="SHA-256", output_size=256, block_size=512) sha2_hash = proto.Hash(algorithms=[sha2_algorithm], intern_size=256, rounds=64) start = time.time() stub.SetHashFunction( proto.HashFunction(cryp_hashes={ 'MD5': md5_hash, 'SHA1': sha1_hash, "SHA-256": sha2_hash })) end = time.time() array_results.append(end - start) outputName = "T12Grpc-" + type anly.makeTestFile(array_results, outputName)
def RPC_CALL(): # IPV4 Address : 192.168.1.36 port - 50051 connection = rpyc.connect("localhost", 50051, config={"allow_all_attrs":True, "allow_setattr":True, "allow_delattr":True}) test_cases = 10 type = "localhost" # Teste 1 : Sem argumentos e retorno vazio array_results = [] for i in range(test_cases): # Inicializa um contador para medir o tempo decorrido da chamada start = time.time() # Operação 1 : Sem argumentos e Sem retorno connection.root.NoArgument_NoReturn() # Encerra a chamada do time inicializado na linha 11 e calcula a diferença end = time.time() array_results.append(end - start) outputName = "T1Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2 : Recebe String e devolve invertida(Tamanho 4) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("Luan") end = time.time() array_results.append(end - start) outputName = "T2Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.1 : Recebe String e devolve invertida(Tamanho 8) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("LuanLuan") end = time.time() array_results.append(end - start) outputName = "T2.1Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.2 : Recebe String e devolve invertida(Tamanho 16) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("LuanLuanLuanLuan") end = time.time() array_results.append(end - start) outputName = "T2.2Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.3 : Recebe String e devolve invertida(Tamanho 32) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("LuanLuanLuanLuanLuanLuanLuanLuan") end = time.time() array_results.append(end - start) outputName = "T2.3Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.4 : Recebe String e devolve invertida(Tamanho 64) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("LuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuan") end = time.time() array_results.append(end - start) outputName = "T2.4Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 2.5 : Recebe String e devolve invertida(Tamanho 128) array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ReverseStringReturn("LuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuanLuan") end = time.time() array_results.append(end - start) outputName = "T2.5Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 3 : Argumento Long e Retorno Long long_number = 92233720368547 array_results = [] for i in range(test_cases): start = time.time() connection.root.OneLongArgument_OneLongReturn(long_number) end = time.time() array_results.append(end - start) outputName = "T3Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 4 : Oito Argumentos Long e Retorno Long array_results = [] for i in range(test_cases): start = time.time() connection.root.EightLongsArguments_OneLongReturn(long_number+1, long_number+2, long_number+long_number, long_number*2, long_number*3, long_number*10, long_number*15, long_number ) end = time.time() array_results.append(end - start) outputName = "T4Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 5 : Soma de valores int 32 a e b array_results = [] for i in range(test_cases): start = time.time() connection.root.AddTwoIntValues((5, 6)) end = time.time() array_results.append(end - start) outputName = "T5Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 6.0 : Dois inteiros int32 com 9 digitos int_bigger = 536870912 array_results = [] for i in range(test_cases): start = time.time() connection.root.AddTwoIntValues((int_bigger, int_bigger)) end = time.time() array_results.append(end - start) outputName = "T6Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 7.0 : Três argumentos doubles, um retorno double array_results = [] for i in range(test_cases): start = time.time() connection.root.ThreeDoubleArgument_DoubleReturn(4.562, 4.632, 23.43561) end = time.time() array_results.append(end - start) outputName = "T7Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 8.0 : Serviço de busca binária que retorna um booleano array_results = [] for i in range(test_cases): start = time.time() connection.root.BinarySearch(([2, 3, 6, 7, 10, 15, 22, 34, 44, 52], 66)) end = time.time() array_results.append(end - start) outputName = "T8Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 9.0 : Recebe um string e retorna uma array de strings array_results = [] for i in range(test_cases): start = time.time() connection.root.OneStringArgument_ArrayReturn("Luan") end = time.time() array_results.append(end - start) outputName = "T9Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 10.0 : Pega o valor no meio da array array_results = [] for i in range(test_cases): start = time.time() connection.root.GetMiddleArrayValue([32, 66, 45, 33, 90]) end = time.time() array_results.append(end - start) outputName = "T10Rpc-" + type anly.makeTestFile(array_results, outputName) # Teste 11.0 : Classe complexa, retorna o país do código de area do telefone array_results = [] for i in range(test_cases): home_phone = Phone(55, 11, 45456545) person = Person("Maria", 22, home_phone) start = time.time() connection.root.GetCountry_PersonPhone(person) end = time.time() array_results.append(end - start) outputName = "T11Rpc-" + type anly.makeTestFile(array_results, outputName)
def __init__(self, name): super(ExeOneRobot_Pre, self).__init__(name) self.add_child(Analyst.ThereIsOnlyOneRobot("ThereIsOneRobot")) self.add_child(Kick.CalcuKickTarget("CalcuKickTarget", 0)) self.add_child(Kick.Approach("Approach", 0))