コード例 #1
0
    public IEnumerator OnSendRestServer(string strURI, byte[] arrSendByte, System.Action <ReturnCodeEnum, string> OnRecvJson)
    {
        UnityWebRequest pRequest = Create_WebRequest(strURI);

        pRequest.uploadHandler = new UploadHandlerRaw(arrSendByte);

        yield return(pRequest.SendWebRequest());

        ReturnCodeEnum pReturnCode = ReturnCodeEnum.None;

        if (pRequest.isNetworkError)
        {
            pReturnCode = ReturnCodeEnum.NetworkError.DoAddContents(pRequest.error);
        }

        OnRecvJson?.Invoke(pReturnCode, pRequest.downloadHandler.text);
    }
コード例 #2
0
 public static string ToUpperString(this ReturnCodeEnum returnCode)
 {
     return(returnCode.ToString().ToUpper());
 }
コード例 #3
0
 public static int ToInt(this ReturnCodeEnum returnCode)
 {
     return((int)returnCode);
 }
コード例 #4
0
        public override void Evaluate(int spreadMax)
        {
            // initialize UnitedStates
            FPolicy.Sync();

            var unitedStates = new ReturnCodeEnum[FAgents.Count];

            if (FPolicy[0] == Policy.SuccessIfAnySucceeds)
            {
                for (int i = 0; i < FAgents.Count; i++)
                {
                    unitedStates[i] = ReturnCodeEnum.Failure;
                }
            }
            else
            {
                for (int i = 0; i < FAgents.Count; i++)
                {
                    unitedStates[i] = ReturnCodeEnum.Success;
                }
            }


            // initialize with all agents
            for (int index = 0; index < FInputCount[0]; index++)
            {
                var pin = FInputs[index].IOObject;



                if (IsPinValid(pin))
                {
                    pin[0].Agents.AddRange(FAgents); // add all that are still unsucessful
//                    pin[0].Agents.Sort(); // sort in any running agents already in the target list

                    pin.Sync(); // call child

                    // treat all running agents
                    var running = from agents in pin[0].Agents
                                  where agents.ReturnCode == ReturnCodeEnum.Running
                                  select agents;
                    foreach (var agent in running)
                    {
                        agent.AddRunning(this, pin);
                    }


                    int i = 0;
                    foreach (var agent in FAgents)
                    {
                        switch (unitedStates[i])
                        {
                        case ReturnCodeEnum.Running:
                            break;

                        case ReturnCodeEnum.Success:
                            if (agent.ReturnCode == ReturnCodeEnum.Running)
                            {
                                unitedStates[i] = ReturnCodeEnum.Running;
                            }
                            else if (FPolicy[0] == Policy.FailIfAnyFails && agent.ReturnCode == ReturnCodeEnum.Failure)
                            {
                                unitedStates[i] = ReturnCodeEnum.Failure;
                            }
                            break;

                        case ReturnCodeEnum.Failure:
                            if (agent.ReturnCode == ReturnCodeEnum.Running)
                            {
                                unitedStates[i] = ReturnCodeEnum.Running;
                            }
                            else if (FPolicy[0] == Policy.SuccessIfAnySucceeds && agent.ReturnCode == ReturnCodeEnum.Success)
                            {
                                unitedStates[i] = ReturnCodeEnum.Success;
                            }
                            break;
                        }


                        if (agent.ReturnCode == ReturnCodeEnum.Running)
                        {
                            unitedStates[i] = ReturnCodeEnum.Running;
                        }

                        i++;
                    }


                    // treat all running agents that changed their ReturnCode.
                    var resetRunning = from agents in pin[0].Agents
                                       where agents.RunningNodes.ContainsKey(this) && agents.RunningNodes[this].Contains(pin) && agents.ReturnCode != ReturnCodeEnum.Running
                                       select agents;
                    foreach (var agent in resetRunning)
                    {
                        agent.RemoveRunning(this, pin);
                    }
                }
            }

            for (int i = 0; i < FAgents.Count; i++)
            {
                FAgents[i].ReturnCode = unitedStates[i];
            }
            FinishEvaluation();
        }
コード例 #5
0
        public override void Evaluate(int spreadMax)
        {
            // initialize UnitedStates
            FPolicy.Sync();

            var unitedStates = new ReturnCodeEnum[FAgents.Count];

            if (FPolicy[0] == Policy.SuccessIfAnySucceeds)
            {
                for (int i = 0; i < FAgents.Count; i++) unitedStates[i] = ReturnCodeEnum.Failure;
            } else
            {
                for (int i = 0; i < FAgents.Count; i++) unitedStates[i] = ReturnCodeEnum.Success;
            }

            // initialize with all agents
            for (int index = 0; index < FInputCount[0]; index++)
            {
                var pin = FInputs[index].IOObject;

                if (IsPinValid(pin))
                {
                    pin[0].Agents.AddRange(FAgents); // add all that are still unsucessful
            //                    pin[0].Agents.Sort(); // sort in any running agents already in the target list

                    pin.Sync(); // call child

                    // treat all running agents
                    var running = from agents in pin[0].Agents
                              where agents.ReturnCode == ReturnCodeEnum.Running
                              select agents;
                    foreach (var agent in running) agent.AddRunning(this, pin);

                    int i = 0;
                    foreach (var agent in FAgents)
                    {
                        switch (unitedStates[i])
                        {
                            case ReturnCodeEnum.Running:
                                break;
                            case ReturnCodeEnum.Success:
                                if (agent.ReturnCode == ReturnCodeEnum.Running) unitedStates[i] = ReturnCodeEnum.Running;
                                else if (FPolicy[0] == Policy.FailIfAnyFails && agent.ReturnCode == ReturnCodeEnum.Failure)
                                    unitedStates[i] = ReturnCodeEnum.Failure;
                                break;
                            case ReturnCodeEnum.Failure:
                                if (agent.ReturnCode == ReturnCodeEnum.Running) unitedStates[i] = ReturnCodeEnum.Running;
                                else if (FPolicy[0] == Policy.SuccessIfAnySucceeds && agent.ReturnCode == ReturnCodeEnum.Success)
                                    unitedStates[i] = ReturnCodeEnum.Success;
                                break;
                        }

                        if (agent.ReturnCode == ReturnCodeEnum.Running) unitedStates[i] = ReturnCodeEnum.Running;

                        i++;
                    }

                    // treat all running agents that changed their ReturnCode.
                    var resetRunning = from agents in pin[0].Agents
                                       where agents.RunningNodes.ContainsKey(this) && agents.RunningNodes[this].Contains(pin) && agents.ReturnCode != ReturnCodeEnum.Running
                                       select agents;
                    foreach (var agent in resetRunning) agent.RemoveRunning(this, pin);
                }
            }

            for (int i = 0; i < FAgents.Count; i++) FAgents[i].ReturnCode = unitedStates[i];
            FinishEvaluation();
        }