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); }
public static string ToUpperString(this ReturnCodeEnum returnCode) { return(returnCode.ToString().ToUpper()); }
public static int ToInt(this ReturnCodeEnum returnCode) { return((int)returnCode); }
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(); }
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(); }