public EvaluationOutput Evaluate(EvaluationInput input) { var expressions = new List <MappingExpression>(input.Expressions); PreEvaluate(expressions, input.Fields); var results = Evaluate(expressions, input.Sources); PostEvaluate(expressions, results); var response = new EvaluationOutput() { Total = expressions.Count(o => !string.IsNullOrEmpty(o.Expression)), Errors = results.Count(o => !string.IsNullOrEmpty(o.Error)), Results = results }; return(response); }
/// <summary> /// posts a vehicle to the evaluation service /// </summary> /// <param name="vehicle"></param> public void PostEvaluation(Vehicle vehicle) { StartCoroutine(SessionLib.FullWebRequest(GetCentralServiceEndpoint() + "ai/uavdesign2traj/", "POST", request => { EvaluationInput input = new EvaluationInput(); input.config = vehicle.config; string postData = JsonConvert.SerializeObject(input); Debug.Log(postData); request.redirectLimit = 0; byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(postData); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); request.SetRequestHeader("Content-Type", "application/json"); }, request => { Debug.Log(request.downloadHandler.text); uavEvaluation = JsonConvert.DeserializeObject <EvaluationOutput>(request.downloadHandler.text); resultstr = " Evaluation : " + getServerResponse(request.responseCode); // currently the trajectory is offset by the below x and z values float yoffset = 1035.0f; float zoffset = 2000.0f; Vector3 lastPosition = new Vector3(0, 0, 0); foreach (Trajectory trajectory in uavEvaluation.trajectory) { trajectory.position[1] = trajectory.position[1] - yoffset; trajectory.position[2] = trajectory.position[2] - zoffset; Vector3 nextPosition = new Vector3( (float)trajectory.position[0], (float)trajectory.position[1], (float)trajectory.position[2]); } })); }