Example #1
0
 public void GetLabels()
 {
     for (int i = 0; i < HotVectors.Length; i++)
     {
         if (TModule.SampleFrame[i] < 1 || TModule.SampleFrame[i] > TModule.Data.GetTotalFrames())
         {
             ActionModule module = (ActionModule)TModule.Data.GetModule(Module.ID.Action);
             HotVectors[i]      = String.Empty;
             FloatHotVectors[i] = new float[module.Actions.Length];
             for (int j = 0; j < module.Actions.Length - 1; j++)
             {
                 HotVectors[i]        += "0 ";
                 FloatHotVectors[i][j] = 0.0f;
             }
             HotVectors[i] += "0";
             FloatHotVectors[i][module.Actions.Length - 1] = 0.0f;
         }
         else
         {
             ActionModule module = (ActionModule)TModule.Data.GetModule(Module.ID.Action);
             HotVectors[i]      = module.GetHotVector(TModule.SampleFrame[i] - 1);
             FloatHotVectors[i] = module.GetHotVectorArray(TModule.SampleFrame[i] - 1);
         }
     }
 }
Example #2
0
 public static void WriteAction(ActionsLog action, string username, ActionModule module)
 {
     var parameters = new Dictionary<string, object>();
     parameters.Add("@created_by", username);
     parameters.Add("@action", action.ToString());
     parameters.Add("@module", module.ToString());
     parameters.Add("@action_history_id", 0);
     parameters.Add("@remarks", string.Empty);
     dataBL.SaveData(StoredProcedure.Action_save,parameters);
 }
Example #3
0
 private void LoadModules()
 {
     Action      = LoadModule <ActionModule>(EnableAction, ActionConfig);
     Brain       = LoadModule <BrainModule>(EnableBrain, BrainConfig);
     Inventory   = LoadModule <InventoryModule>(EnableInventory, InventoryConfig);
     Interaction = LoadModule <InteractionModule>(EnableInteraction, InteractionConfig);
     Movement    = LoadModule <MovementModule>(EnableMovement, MovementConfig);
     Physics     = LoadModule <PhysicsModule>(EnablePhysics, PhysicsConfig);
     Stacking    = LoadModule <StackingModule>(EnableStacking, StackingConfig);
     Stats       = LoadModule <StatsModule>(EnableStats, StatsConfig);
     TagList     = LoadModule <TagListModule>(true, TagListConfig);
 }
 public UnitDefinition()
 {
     m_name = string.Empty;
     m_artBundle = null;
     //m_coreSprite = null;
     //m_coreAnimation = null;
     //m_bodySprite = null;
     //m_bodySprites = null;
     m_modules = new BaseUnitModule[0];
     Movement = 0;
     MaxHealth = 0;
     ActionModules = new ActionModule[0];
     TotalCost = 0;
 }
        public static void Action(NagibatorTank me, MessageEvent e)
        {
            Console.WriteLine($"{nameof(OnMessageReceivedModule)}: {e.Message}");

            var message = MessageHelper.ReadMessage(e.Message.ToString());

            switch (message[MessageType])
            {
            case EnemyPositionMessage.Type:
                ActionModule.NewTargetAction(me, message);
                break;

            default:
                return;
            }
        }
        private IWebModule CreateFolderModule(string location, string baseRoute, string missingFolderErrorMessage)
        {
            IWebModule module = null;

            if (!Directory.Exists(location))
            {
                _logger.Log(missingFolderErrorMessage, LogLevel.Warning);
                module = new ActionModule(baseRoute, HttpVerbs.Any, c =>
                {
                    c.Response.StatusCode = 500;
                    return(c.SendStringAsync(missingFolderErrorMessage, "text", Encoding.UTF8));
                });
            }

            return(module ?? new FileModule(baseRoute, new FileSystemProvider(location, false)).WithDirectoryLister(DirectoryLister.Html));
        }
Example #7
0
        public void ChangeModule(ActionModule actionModule)
        {
            switch (actionModule)
            {
            case ActionModule.Next:
                GetNextModule();
                break;

            case ActionModule.Perv:
                GetPervModule();
                break;

            default:
                break;
            }
        }
Example #8
0
        private void CreateSearchTree(List <SearchTreeEntry> treeEntries, ActionModule module, ActionSchema schema, int depth)
        {
            var entries = new List <SearchTreeEntry>();

            foreach (var action in schema[module.definitionAsset])
            {
                entries.Add(new SearchTreeEntry(new GUIContent(action.Name))
                {
                    level    = depth,
                    userData = new EntryData {
                        actionId = module.action, identifier = action.identifier, fieldOp = false, actionType = module.definitionAsset.delegateType
                    }
                });
            }
            entries.Sort((entryA, entryB) => entryA.name.CompareTo(entryB.name));
            treeEntries.AddRange(entries);
        }
        public static void Action(NagibatorTank me, ScannedRobotEvent e)
        {
            try
            {
                if (me.IsTeammate(e.Name))
                {
                    return;
                }
                Console.WriteLine($"{nameof(OnScannedRobotModule)}: spotted [{e.Name}]. My target is [{me.Target}]");

                var enemyPosition = CoordHelper.GetEnemyCoordinate(me.Heading, me.Status, e);
                if (string.IsNullOrWhiteSpace(me.Target))
                {
                    Console.WriteLine($"{nameof(OnScannedRobotModule)}: Setting team target {e.Name}");
                    me.Target = e.Name;
                }

                if (me.Target.Equals(e.Name))
                {
                    //me.SetTurnRadarRight(2.0 * Utils.NormalRelativeAngleDegrees(me.Heading + e.Bearing - me.RadarHeading));
                    ActionModule.Action(me);
                    Console.WriteLine($"{nameof(OnScannedRobotModule)}: Fire to {e.Name}");
                    me.Fire(FireHelper.GetFirePower(me, e, enemyPosition));
                    MessageHelper.SendMessage(me, new Dictionary <string, string>
                    {
                        [Constants.MessageType] = Constants.EnemyPositionMessage.Type,
                        [Name]     = e.Name,
                        [X]        = enemyPosition.X.ToString(CultureInfo.InvariantCulture),
                        [Y]        = enemyPosition.Y.ToString(CultureInfo.InvariantCulture),
                        [Bearing]  = e.Bearing.ToString(CultureInfo.InvariantCulture),
                        [Distance] = e.Distance.ToString(CultureInfo.InvariantCulture)
                    });

                    me.TargetPoint = enemyPosition;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{nameof(OnScannedRobotModule)}: {ex}");
            }
        }
Example #10
0
        /// <summary>
        /// 反射获取系统所有action
        /// </summary>
        /// <returns></returns>
        public static IList <ActionModule> GetAllActionByAssembly()
        {
            var result = new List <ActionModule>();

            var types = Assembly.Load("Do.Web.Backend").GetTypes();

            foreach (var type in types)
            {
                if (type.BaseType.Name == "BaseController")//如果是Controller
                {
                    var members = type.GetMethods();
                    foreach (var member in members)
                    {
                        if (member.ReturnType.Name == "ActionResult")//如果是Action
                        {
                            var ap = new ActionModule();

                            ap.ActionName     = member.Name;
                            ap.ControllerName = member.DeclaringType.Name.Substring(0, member.DeclaringType.Name.Length - 10); // 去掉“Controller”后缀

                            //object[] attrs = member.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), true);
                            object[] attrs = member.GetCustomAttributes(typeof(ModuleAttribute), true);

                            if (attrs.Length > 0)
                            {
                                ap.Name = (attrs[0] as ModuleAttribute).Name;
                                ap.Code = (attrs[0] as ModuleAttribute).Code;
                            }
                            //ap.Description = (attrs[0] as ModuleAttribute).Desc;

                            result.Add(ap);
                        }
                    }
                }
            }
            return(result);
        }
Example #11
0
        public void AddModule(ActionModule module)
        {
            var port = Port.Create <Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, CreateActionPortType(module.definitionAsset.delegateType));

            port.viewDataKey = module.guid;
            port.AddToClassList(MasterNodePortClassName);
            port.portName     = module.name;
            port.portColor    = module.definitionAsset.delegateType.Value.GetColor(Color.white);
            this.capabilities = Capabilities.Collapsible | Capabilities.Movable | Capabilities.Resizable | Capabilities.Selectable;
            port.RegisterCallback <PortUpdateEvent>(evt =>
            {
                var self  = (Port)evt.target;
                var other = evt.portA == self ? evt.portB : evt.portA;

                var graphView = self.GetFirstAncestorOfType <ActionGraphView>();
                if (graphView == null)
                {
                    return;
                }
                var node = graphView.model[other.node.viewDataKey];
                if (node is ActionNodeData actionNode)
                {
                    switch (evt.type)
                    {
                    case PortUpdateEventType.Connected:
                        actionNode.moduleHint = self.viewDataKey;
                        break;

                    case PortUpdateEventType.Disconnected:
                        actionNode.moduleHint = null;
                        break;
                    }
                }
            });
            this.inputContainer.Add(port);
            this.RefreshExpandedState();
        }
Example #12
0
        public void RetryServerErrorWithDefaultMaxRetryTimeTestNetStandard20()
        {
            Stopwatch watch          = new Stopwatch();
            string    DummyServerUrl = "http://localhost:8181";

            using (var DummyServer = new WebServer(DummyServerUrl))
            {
                // Set invalid host address and make timeout to 1s
                var config = new RudderConfig().SetAsync(false);
                config.SetHost(DummyServerUrl);
                config.SetTimeout(new TimeSpan(0, 0, 1));
                RudderAnalytics.Initialize(Constants.WRITE_KEY, config);

                var TestCases = new RetryErrorTestCase[]
                {
                    // The errors (500 > code >= 400) doesn't require retry
                    new RetryErrorTestCase()
                    {
                        ErrorMessage  = "Server Gone",
                        ResponseCode  = HttpStatusCode.Gone,
                        ShouldRetry   = false,
                        Timeout       = 10000,
                        BaseActionUrl = "/ServerGone"
                    },
                    // 429 error requires retry
                    new RetryErrorTestCase()
                    {
                        ErrorMessage  = "Too many requests",
                        ResponseCode  = (HttpStatusCode)429,
                        ShouldRetry   = true,
                        Timeout       = 10000,
                        BaseActionUrl = "/TooManyRequests"
                    },
                    // Server errors require retry
                    new RetryErrorTestCase()
                    {
                        ErrorMessage  = "Bad Gateway",
                        ResponseCode  = HttpStatusCode.BadGateway,
                        ShouldRetry   = true,
                        Timeout       = 10000,
                        BaseActionUrl = "/BadGateWay"
                    }
                };

                foreach (var testCase in TestCases)
                {
                    // Setup Action module which returns error code
                    var actionModule = new ActionModule(testCase.BaseActionUrl, HttpVerbs.Any, (ctx) =>
                    {
                        return(ctx.SendStandardHtmlAsync((int)testCase.ResponseCode));
                    });
                    DummyServer.WithModule(actionModule);
                }

                DummyServer.RunAsync();

                foreach (var testCase in TestCases)
                {
                    RudderAnalytics.Client.Config.SetHost(DummyServerUrl + testCase.BaseActionUrl);
                    // Calculate working time for Identiy message with invalid host address
                    watch.Reset();
                    watch.Start();
                    Actions.Identify(RudderAnalytics.Client);
                    watch.Stop();

                    Assert.AreEqual(0, RudderAnalytics.Client.Statistics.Succeeded);

                    // Handling Identify message will less than 10s because the server returns GONE message.
                    // That's because it retries submit when it's failed.
                    if (testCase.ShouldRetry)
                    {
                        Assert.IsTrue(watch.ElapsedMilliseconds > testCase.Timeout);
                    }
                    else
                    {
                        Assert.IsFalse(watch.ElapsedMilliseconds > testCase.Timeout);
                    }
                }
            }
        }
Example #13
0
 public Action(ActionModule module, string name)
 {
     Module = module;
     Name   = name;
     Values = new float[module.Data.GetTotalFrames()];
 }
    public string[] GenerateLines(MotionData data)
    {
        string[] result = new string[data.Frames.Length - 60];

        for (int i = 30; i < data.Frames.Length - 30; i++)
        {
            if (data.Modules != null)
            {
                for (int k = 0; k < data.Modules.Length; k++)
                {
                    switch (data.Modules[k].GetID())
                    {
                    case Module.ID.Velocity:
                    {
                        VelocityModule module = (VelocityModule)data.GetModule(Module.ID.Velocity);
                        module.GetTransformations(data.GetFrame(i));
                        module.GetVelocities(data.GetFrame(i), 1.0f);
                        for (int j = 0; j < data.Root.Bones.Length; j++)
                        {
                            if (module.Selected[j])
                            {
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetPosition().z.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetForward().z.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().x.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().y.ToString() + " ";
                                result[i - 30] += data.Frames[i].GetBoneTransformation(j, data.Mirrored).GetUp().z.ToString() + " ";
                                result[i - 30] += module.Velocities[j].x.ToString() + " ";
                                result[i - 30] += module.Velocities[j].y.ToString() + " ";
                                result[i - 30] += module.Velocities[j].z.ToString() + " ";
                            }
                        }
                        break;
                    }

                    case Module.ID.Action:
                    {
                        ActionModule module = (ActionModule)data.GetModule(Module.ID.Action);
                        result[i - 30] += module.GetHotVector(i) + " ";

                        break;
                    }

                    case Module.ID.Phase:
                    {
                        PhaseModule module = (PhaseModule)data.GetModule(Module.ID.Phase);
                        result[i - 30] += module.Phases[1].LocalPhase.Phase[i] + " ";
                        result[i - 30] += module.Phases[2].LocalPhase.Phase[i] + " ";
                        break;
                    }

                    case Module.ID.Trajectory:
                    {
                        TrajectoryModule module = (TrajectoryModule)data.GetModule(Module.ID.Trajectory);
                        for (int j = 0; j < module.Pivots.Length; j++)
                        {
                            for (int p = 0; p < module.Pivots[j].Transformations.Length; p++)
                            {
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().x.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().y.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Transformations[p].GetPosition().z.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].x.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].y.ToString() + " ";
                                result[i - 30] += module.Pivots[j].Velocities[p].z.ToString() + " ";
                                result[i - 30] += module.Pivots[j].HotVectors[p] + " ";
                                result[i - 30] += module.Pivots[j].Phases[p].ToString() + " ";
                            }
                        }
                        break;
                    }
                    }
                }
            }
        }

        return(result);
    }
    public void ExportLabels(MotionData data)
    {
        Lines = new string[0];
        if (data.Modules != null)
        {
            for (int k = 0; k < data.Modules.Length; k++)
            {
                switch (data.Modules[k].GetID())
                {
                case Module.ID.Velocity:
                {
                    VelocityModule module = (VelocityModule)data.GetModule(Module.ID.Velocity);
                    for (int j = 0; j < data.Root.Bones.Length; j++)
                    {
                        if (module.Selected[j])
                        {
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "PositionZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "ForwardZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "UpZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + data.Root.Bones[j].Name + "VelocityZ");
                        }
                    }
                    break;
                }

                case Module.ID.Action:
                {
                    ActionModule module = (ActionModule)data.GetModule(Module.ID.Action);
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action Neutral");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action CrossArms");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action LHOnHip");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Action RHOnHip");

                    break;
                }

                case Module.ID.Phase:
                {
                    PhaseModule module = (PhaseModule)data.GetModule(Module.ID.Phase);
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Phase LeftHand");
                    ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Phase RightHand");
                    break;
                }

                case Module.ID.Trajectory:
                {
                    TrajectoryModule module = (TrajectoryModule)data.GetModule(Module.ID.Trajectory);
                    for (int j = 0; j < module.Pivots.Length; j++)
                    {
                        for (int p = 0; p < module.Pivots[j].Transformations.Length; p++)
                        {
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "PositionZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityX");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityY");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "VelocityZ");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action Neutral");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action CrossArms");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action LHOnHip");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Action RHOnHip");
                            ArrayExtensions.Add(ref Lines, "[" + Lines.Length.ToString() + "] " + "Pivot" + j.ToString() +
                                                module.Pivots[j].Name + "Trajectory" + p.ToString() + "Phase");
                        }
                    }
                    break;
                }
                }
            }
        }

        string FileName = Destination + "/" + "Labels.txt";

        if (!File.Exists(FileName))
        {
            using (FileStream fs = File.Create(FileName)) { }
            Debug.Log("Create new file: " + FileName);
            File.AppendAllLines(FileName, Lines);
        }
        else
        {
            File.WriteAllLines(FileName, Lines);
        }

        Debug.Log("Export Labels Successfully!");
    }