Пример #1
0
    private RequestResult CheckActionParameters(Base.ActionMetadata actionMetadata)
    {
        //TODO - otestovat
        RequestResult result = new RequestResult(true);
        bool          poseError = false, jointsError = false, dynamicValueError = false;
        bool          anyOrientation = ProjectManager.Instance.AnyOrientationInTheProject();
        bool          anyJoints      = ProjectManager.Instance.AnyJointsInTheProject();

        foreach (ParameterMetadata param in actionMetadata.ParametersMetadata.Values)
        {
            if (!poseError && param.Type == ParameterMetadata.POSE)
            {
                int poseParemetersCount = 0;
                if (anyOrientation)
                {
                    foreach (ParameterMetadata parameter in actionMetadata.ParametersMetadata.Values)
                    {
                        if (parameter.Type == ParameterMetadata.POSE)
                        {
                            if (++poseParemetersCount > 1)
                            {
                                break;
                            }
                        }
                    }
                }

                if (poseParemetersCount == 1 && !currentActionPoint.AnyOrientation())
                {
                    result.Success  = false;
                    result.Message += "(there is no available orientation in the selected AP and this action requires it)\n";
                    poseError       = true;
                }
                else if (!anyOrientation)
                {
                    result.Success  = false;
                    result.Message += "(there is no available orientation in the project and this action requires it)\n";
                    poseError       = true;
                }
            }
            if (!jointsError && param.Type == ParameterMetadata.JOINTS && !anyJoints)
            {
                result.Success  = false;
                result.Message += "(there are no available robot joints in the project and this action requires them)\n";
                jointsError     = true;
            }
            if (!dynamicValueError && !SceneManager.Instance.SceneStarted && param.DynamicValue)
            {
                result.Success    = false;
                result.Message   += "(actions with dynamic parameters could only be created when online)\n";
                dynamicValueError = true;
            }
        }
        return(result);
    }