def PATCH_getControlSurfaceCount(tixi, comp_seg_uid):
    """
    Function to get the number of Control Surfaces

    Function 'getControlSurfaceCount' returns the number of control surface
    (only TED) on a given component segment.

    Args:
        :tixi (TIXI Handle): TIXI Handle of the CPACS file
        :comp_seg_uid (str): UID of the component segment

    Returns:
        :contrl_surf_count (integer): Number of control surfaces on the component segment

    Note:
        * Written by Aidan Jungo
    """

    if not tixi.checkDocumentHandle():
        ValueError('Probleme with TIXI handle')

    if not tixi.uIDCheckExists(comp_seg_uid):
        raise ValueError(f"No UID named '{comp_seg_uid}' has been found!")

    comp_sec_xpath = tixi.uIDGetXPath(comp_seg_uid)
    contrl_surf_xpath = comp_sec_xpath + '/controlSurfaces/trailingEdgeDevices/trailingEdgeDevice'

    # tixi.xPathEvaluateNodeNumber() raises an error if the path does not exist
    if tixi.checkElement(contrl_surf_xpath):
        contrl_surf_count = tixi.xPathEvaluateNodeNumber(contrl_surf_xpath)
    else:
        contrl_surf_count = 0

    return contrl_surf_count