Exemplo n.º 1
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKSoftwareReview data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSoftwareReview {0:d} " \
               "attributes.".format(self.software_id)

        try:
            self.answer = int(none_to_default(attributes[0], 0))
            self.value = int(none_to_default(attributes[1], 0))
            self.review_type = str(none_to_default(attributes[2], ''))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKSoftwareReview.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKSoftwareReview attributes."

        return _error_code, _msg
Exemplo n.º 2
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKSubCategory data model attributes.

        :param dict attributes: dict containing the key:values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSubCategory {0:d} attributes.". \
            format(self.subcategory_id)

        try:
            self.category_id = int(
                none_to_default(attributes['category_id'], -1))
            self.description = str(
                none_to_default(attributes['description'], ''))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 3
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKManufacturer data model attributes.

        :param dict attributes: dict containing the key:values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKManufacturer {0:d} attributes.". \
            format(self.manufacturer_id)

        try:
            self.description = str(
                none_to_default(attributes['description'],
                                'Manufacturer Description'))
            self.location = str(
                none_to_default(attributes['location'], 'unknown'))
            self.cage_code = str(
                none_to_default(attributes['cage_code'], 'CAGE Code'))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 4
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKCategory data model attributes.

        :param dict attributes: dict containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKCategory {0:d} attributes.". \
            format(self.category_id)

        try:
            self.name = str(
                none_to_default(attributes['name'], 'Category Name'))
            self.description = str(
                none_to_default(attributes['description'],
                                'Category Description'))
            self.cat_type = str(
                none_to_default(attributes['category_type'], 'unknown'))
            self.value = int(none_to_default(attributes['value'], 1))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKCategory.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 5
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKFailureMode data model attributes.

        :param dict attributes: dict containing the key:value pairs to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKFailureMode {0:d} attributes.". \
            format(self.mode_id)

        try:
            self.description = str(
                none_to_default(attributes['description'],
                                'Failure Mode Description'))
            self.mode_ratio = float(
                none_to_default(attributes['mode_ratio'], 1.0))
            self.source = str(none_to_default(attributes['source'], ''))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 6
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKMission data model attributes.

        :param tuple attributes: tuple containing the values to set.
        :return:
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKMission {0:d} attributes.". \
            format(self.mission_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], 'Description'))
            self.mission_time = float(
                none_to_default(attributes['mission_time'], 0.0))
            self.time_units = str(
                none_to_default(attributes['time_units'], 'hours'))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKMission.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 7
0
    def set_attributes(self, attributes):
        """
        Set the RAMSTKOpLoad data model attributes.

        :param dict attributes: values to assign to instance attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKOpLoad {0:d} attributes.". \
               format(self.load_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.damage_model = str(
                none_to_default(attributes['damage_model'], ''))
            self.priority_id = int(
                none_to_default(attributes['priority_id'], 0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKOpLoad.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 8
0
    def set_attributes(self, attributes):
        """
        Method to set the current values of the RAMSTKUnit data model
        attributes.

        :param tuple attributes: tuple containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKUnit {0:d} attributes.". \
            format(self.unit_id)

        try:
            self.code = str(none_to_default(attributes[0], 'Unit Code'))
            self.description = str(
                none_to_default(attributes[2], 'Unit Description'))
            self.unit_type = str(none_to_default(attributes[2], ''))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKUnit.set_attributes()."
        except TypeError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKUnit attributes."

        return _error_code, _msg
Exemplo n.º 9
0
    def set_attributes(self, attributes):
        """
        Set the current value of the RAMSTKProgramStatus data model attributes.

        :param tuple attributes: dicte of values to assign to the instance
                                 attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKProgramStatus {0:d} attributes.". \
               format(self.revision_id)

        try:
            self.cost_remaining = float(
                none_to_default(attributes['cost_remaining'], 0.0))
            self.date_status = none_to_default(attributes['date_status'],
                                               date.today())
            self.time_remaining = float(
                none_to_default(attributes['time_remaining'], 0.0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKProgramStatus.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 10
0
    def set_attributes(self, attributes):
        """
        RPN to set the current values of the RAMSTKRPN data model
        attributes.

        :param tuple attributes: tuple containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKRPN {0:d} attributes.". \
            format(self.rpn_id)

        try:
            self.name = str(none_to_default(attributes[0], 'RPN Name'))
            self.description = str(
                none_to_default(attributes[1], 'RPN Description'))
            self.rpn_type = str(none_to_default(attributes[2], ''))
            self.value = int(none_to_default(attributes[3], 0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKRPN.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKRPN attributes."

        return _error_code, _msg
Exemplo n.º 11
0
    def set_attributes(self, values):
        """
        Set the Stress data model attributes.

        :param dict values: values to assign to instance attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKOpStress {0:d} attributes.". \
               format(self.stress_id)

        try:
            self.description = str(none_to_default(values['description'], ''))
            self.load_history = str(none_to_default(values['load_history'],
                                                    ''))
            self.measurable_parameter = str(
                none_to_default(values['measurable_parameter'], ''))
            self.remarks = str(none_to_default(values['remarks'], ''))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKOpStress.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 12
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKUser data model attributes.

        :param dict attributes: dict containing the key:values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKUser {0:d} attributes.".\
            format(self.user_id)

        try:
            self.user_lname = str(
                none_to_default(attributes['user_lname'], 'Last Name'))
            self.user_fname = str(
                none_to_default(attributes['user_fname'], 'First Name'))
            self.user_email = str(
                none_to_default(attributes['user_email'], 'EMail'))
            self.user_phone = str(
                none_to_default(attributes['user_phone'], '867.5309'))
            self.user_group_id = str(
                none_to_default(attributes['user_group_id'], '0'))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 13
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKMissionPhase data model attributes.

        :param tuple attributes: tuple containing the values to set.
        :return:
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKMissionPhase {0:d} attributes.". \
            format(self.phase_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.name = str(none_to_default(attributes['name'], ''))
            self.phase_start = float(
                none_to_default(attributes['phase_start'], 0.0))
            self.phase_end = float(
                none_to_default(attributes['phase_end'], 0.0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKMissionPhase.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 14
0
    def set_attributes(self, attributes):
        """
        Set the RAMSTKTestMethod data model attributes.

        :param dict attributes: values to assign to instance attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKTestMethod {0:d} attributes.". \
               format(self.test_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.boundary_conditions = str(
                none_to_default(attributes['boundary_conditions'], ''))
            self.remarks = str(none_to_default(attributes['remarks'], ''))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKTestMethod.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 15
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKCondition data model attributes.

        :param tuple attributes: tuple containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKCondition {0:d} attributes.". \
            format(self.condition_id)

        try:
            self.description = str(
                none_to_default(attributes['description'],
                                'Condition Description'))
            self.cond_type = str(
                none_to_default(attributes['condition_type'], 'unknown'))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKCondition.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 16
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKEnvironment data model attributes.

        :param dict attributes: dict containing {attr name:attr value} pairs
                                of the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKEnvironment {0:d} attributes.". \
            format(self.environment_id)

        try:
            self.name = str(
                none_to_default(attributes['name'], 'Condition Name'))
            self.units = str(none_to_default(attributes['units'], 'Units'))
            self.minimum = float(none_to_default(attributes['minimum'], 0.0))
            self.maximum = float(none_to_default(attributes['maximum'], 0.0))
            self.mean = float(none_to_default(attributes['mean'], 0.0))
            self.variance = float(none_to_default(attributes['variance'], 0.0))
            self.ramp_rate = float(
                none_to_default(attributes['ramp_rate'], 0.0))
            self.low_dwell_time = float(
                none_to_default(attributes['low_dwell_time'], 0.0))
            self.high_dwell_time = float(
                none_to_default(attributes['high_dwell_time'], 0.0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKEnvironment.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 17
0
    def set_attributes(self, attributes):
        """
        Set the current values of the Mechanism data model attributes.

        :param dict attributes: values to assign to instance attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKMechanism {0:d} attributes.". \
               format(self.mechanism_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.pof_include = int(
                none_to_default(attributes['pof_include'], 1))
            self.rpn = int(none_to_default(attributes['rpn'], 0))
            self.rpn_detection = int(
                none_to_default(attributes['rpn_detection'], 1))
            self.rpn_detection_new = int(
                none_to_default(attributes['rpn_detection_new'], 1))
            self.rpn_new = int(none_to_default(attributes['rpn_new'], 0))
            self.rpn_occurrence = int(
                none_to_default(attributes['rpn_occurrence'], 1))
            self.rpn_occurrence_new = int(
                none_to_default(attributes['rpn_occurrence_new'], 1))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKMechanism.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 18
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKFailureDefinition attributes.

        :param dict attributes: dict containing {attr name:attr value} pairs
                                of the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKFailureDefinition {0:d} attributes.".\
            format(self.definition_id)

        try:
            self.definition = str(
                none_to_default(attributes['definition'],
                                'Failure Definition'))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKFailureDefinition.set_attributes().".format(_err)
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKFailureDefinition attributes."

        return _error_code, _msg
Exemplo n.º 19
0
    def set_attributes(self, values):
        """
        Set the RAMSTKMatrix data model attributes.

        :param tuple values: tuple of values to assign to the instance
                             attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKMatrix {0:d} attributes.". \
               format(self.matrix_id)

        try:
            self.column_id = int(none_to_default(values['column_id'], 0))
            self.column_item_id = int(
                none_to_default(values['column_item_id'], 0))
            self.matrix_type = str(none_to_default(values['matrix_type'], ''))
            self.parent_id = int(none_to_default(values['parent_id'], 0))
            self.row_id = int(none_to_default(values['row_id'], 0))
            self.row_item_id = int(none_to_default(values['row_item_id'], 0))
            self.value = float(none_to_default(values['value'], 0.0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKMatrix.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 20
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKSiteInfo data model attributes.

        :param dict attributes: dict containing the key:values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKSiteInfo attributes."

        try:
            self.product_key = str(
                none_to_default(attributes['product_key'], '0000'))
            self.expire_on = none_to_default(attributes['expire_on'],
                                             date.today() + timedelta(30))
            self.function_enabled = int(
                none_to_default(attributes['function_enabled'], 0))
            self.requirement_enabled = int(
                none_to_default(attributes['requirement_enabled'], 0))
            self.hardware_enabled = int(
                none_to_default(attributes['hardware_enabled'], 0))
            self.vandv_enabled = int(
                none_to_default(attributes['vandv_enabled'], 0))
            self.fmea_enabled = int(
                none_to_default(attributes['fmea_enabled'], 0))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 21
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKAction data model attributes.

        :param dict attributes: values to assign to instance attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKAction {0:d} attributes.".\
            format(self.action_id)
        _date = date.today() + timedelta(days=30)

        try:
            self.action_recommended = str(
                none_to_default(attributes['action_recommended'], ''))
            self.action_category = str(
                none_to_default(attributes['action_category'], ''))
            self.action_owner = str(
                none_to_default(attributes['action_owner'], 0))
            self.action_due_date = none_to_default(
                attributes['action_due_date'], _date)
            self.action_status = str(
                none_to_default(attributes['action_status'], 0))
            self.action_taken = str(
                none_to_default(attributes['action_taken'], ''))
            self.action_approved = int(
                none_to_default(attributes['action_approved'], 0))
            self.action_approve_date = none_to_default(
                attributes['action_approve_date'], _date)
            self.action_closed = int(
                none_to_default(attributes['action_closed'], 0))
            self.action_close_date = none_to_default(
                attributes['action_close_date'], _date)
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKAction.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 22
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKControl data model attributes.

        :param dict attributes: values to assign to instance attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKControl {0:d} attributes.". \
               format(self.control_id)

        try:
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.type_id = str(none_to_default(attributes['type_id'], ''))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKControl.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 23
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKStakeholders data model attributes.

        :param dict attributes: dict containing the key:values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKStakeholders {0:d} attributes.". \
            format(self.stakeholders_id)

        try:
            self.stakeholder = str(
                none_to_default(attributes['stakeholder'], 'Stakeholder'))
        except KeyError as _err:
            _error_code = 40
            _msg = ("RAMSTK ERROR: Missing attribute {0:s} in attribute "
                    "dictionary passed to "
                    "{1:s}.set_attributes().").format(_err,
                                                      self.__class__.__name__)

        return _error_code, _msg
Exemplo n.º 24
0
    def set_attributes(self, attributes):
        """
        Method to set the RAMSTKGrowthTest data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                 attributes.
        :return: (_code, _msg); the error code and error message.
        :rtype: tuple
        """

        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKGrowthTest {0:d} attributes.". \
               format(self.phase_id)

        try:
            self.i_mi = float(none_to_default(attributes[0], 0.0))
            self.i_mf = float(none_to_default(attributes[1], 0.0))
            self.i_ma = float(none_to_default(attributes[2], 0.0))
            self.i_num_fails = int(none_to_default(attributes[3], 0))
            self.p_growth_rate = float(none_to_default(attributes[4], 0.0))
            self.p_ms = float(none_to_default(attributes[5], 0.0))
            self.p_fef_avg = float(none_to_default(attributes[6], 0.0))
            self.p_prob = float(none_to_default(attributes[7], 0.0))
            self.p_mi = float(none_to_default(attributes[8], 0.0))
            self.p_mf = float(none_to_default(attributes[9], 0.0))
            self.p_ma = float(none_to_default(attributes[10], 0.0))
            self.p_test_time = float(none_to_default(attributes[11], 0.0))
            self.p_num_fails = float(none_to_default(attributes[12], 0.0))
            self.p_start_date = none_to_default(attributes[13], date.today())
            self.p_end_date = none_to_default(attributes[14], date.today())
            self.p_weeks = float(none_to_default(attributes[15], 0.0))
            self.p_test_units = int(none_to_default(attributes[16], 0))
            self.p_tpu = float(none_to_default(attributes[17], 0.0))
            self.p_tpupw = float(none_to_default(attributes[18], 0.0))
            self.o_growth_rate = float(none_to_default(attributes[19], 0.0))
            self.o_ms = float(none_to_default(attributes[20], 0.0))
            self.o_fef_avg = float(none_to_default(attributes[21], 0.0))
            self.o_mi = float(none_to_default(attributes[22], 0.0))
            self.o_mf = float(none_to_default(attributes[23], 0.0))
            self.o_ma = float(none_to_default(attributes[24], 0.0))
            self.o_test_time = float(none_to_default(attributes[25], 0.0))
            self.o_num_fails = int(none_to_default(attributes[26], 0))
            self.o_ttff = float(none_to_default(attributes[27], 0.0))
        except IndexError as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Insufficient number of input values to " \
                   "RAMSTKGrowthTest.set_attributes()."
        except (TypeError, ValueError) as _err:
            _error_code = error_handler(_err.args)
            _msg = "RAMSTK ERROR: Incorrect data type when converting one or " \
                   "more RAMSTKGrowthTest attributes."

        return _error_code, _msg
Exemplo n.º 25
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKHardware data model attributes.

        :param tuple attributes: tuple of attribute values to assign to the
                                 Hardware instance attributes.
        :return: (_code, _msg; the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKHardware {0:d} attributes.". \
               format(self.hardware_id)

        try:
            self.alt_part_number = str(
                none_to_default(attributes['alt_part_num'], ''))
            self.attachments = str(
                none_to_default(attributes['attachments'], ''))
            self.cage_code = str(none_to_default(attributes['cage_code'], ''))
            self.category_id = int(
                none_to_default(attributes['category_id'], 0))
            self.comp_ref_des = str(
                none_to_default(attributes['comp_ref_des'], ''))
            self.cost = float(none_to_default(attributes['cost'], 0.0))
            self.cost_failure = float(
                none_to_default(attributes['cost_failure'], 0.0))
            self.cost_hour = float(
                none_to_default(attributes['cost_hour'], 0.0))
            self.cost_type_id = int(
                none_to_default(attributes['cost_type_id'], 0))
            self.description = str(
                none_to_default(attributes['description'], ''))
            self.duty_cycle = float(
                none_to_default(attributes['duty_cycle'], 100.0))
            self.figure_number = str(
                none_to_default(attributes['figure_number'], ''))
            self.lcn = str(none_to_default(attributes['lcn'], ''))
            self.level = int(none_to_default(attributes['level'], 0))
            self.manufacturer_id = int(
                none_to_default(attributes['manufacturer_id'], 0))
            self.mission_time = float(
                none_to_default(attributes['mission_time'], 100.0))
            self.name = str(none_to_default(attributes['name'], ''))
            self.nsn = str(none_to_default(attributes['nsn'], ''))
            self.page_number = str(
                none_to_default(attributes['page_number'], ''))
            self.parent_id = int(none_to_default(attributes['parent_id'], 0))
            self.part = int(none_to_default(attributes['part'], 0))
            self.part_number = str(
                none_to_default(attributes['part_number'], ''))
            self.quantity = int(none_to_default(attributes['quantity'], 1))
            self.ref_des = str(none_to_default(attributes['ref_des'], ''))
            self.remarks = str(none_to_default(attributes['remarks'], ''))
            self.repairable = int(none_to_default(attributes['repairable'], 0))
            self.specification_number = str(
                none_to_default(attributes['specification_number'], ''))
            self.subcategory_id = int(
                none_to_default(attributes['subcategory_id'], 0))
            self.tagged_part = int(
                none_to_default(attributes['tagged_part'], 0))
            self.total_cost = float(
                none_to_default(attributes['total_cost'], 0.0))
            self.total_part_count = int(
                none_to_default(attributes['total_part_count'], 0))
            self.total_power_dissipation = float(
                none_to_default(attributes['total_power_dissipation'], 0.0))
            self.year_of_manufacture = int(
                none_to_default(attributes['year_of_manufacture'],
                                date.today().year))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKHardware.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 26
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKProgramInfo data model attributes.

        :param dict attributes: dict containing the values to set.
        :return: (_error_code, _msg)
        :rtype: (int, str)
        """
        _error_code = 0
        _msg = ("RAMSTK SUCCESS: Updating RAMSTKProgramInfo attributes.")

        try:
            self.function_active = int(
                none_to_default(attributes['function_active'], 1))
            self.requirement_active = int(
                none_to_default(attributes['requirement_active'], 1))
            self.hardware_active = int(
                none_to_default(attributes['hardware_active'], 1))
            self.vandv_active = int(
                none_to_default(attributes['vandv_active'], 1))
            self.fmea_active = int(
                none_to_default(attributes['fmea_active'], 1))
            self.software_active = int(
                none_to_default(attributes['software_active'], 1))
            self.testing_active = int(
                none_to_default(attributes['testing_active'], 1))
            self.fraca_active = int(
                none_to_default(attributes['fraca_active'], 1))
            self.survival_active = int(
                none_to_default(attributes['survival_active'], 1))
            self.rcm_active = int(none_to_default(attributes['rcm_active'], 0))
            self.rbd_active = int(none_to_default(attributes['rbd_active'], 0))
            self.fta_active = int(none_to_default(attributes['fta_active'], 0))
            self.created_on = none_to_default(attributes['created_on'],
                                              date.today())
            self.created_by = str(
                none_to_default(attributes['created_by'], ''))
            self.last_saved = none_to_default(attributes['last_saved'],
                                              date.today())
            self.last_saved_by = str(
                none_to_default(attributes['last_saved_by'], ''))
            self.method = str(
                none_to_default(attributes['method'], 'STANDARD'))
        except KeyError as _err:
            _error_code = 1
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKProgramInfo.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 27
0
def test_none_to_default():
    """ none_to_default() should return the default value if the original value is None. """
    assert none_to_default(None, 10) == 10
Exemplo n.º 28
0
    def set_attributes(self, attributes):
        """
        Set the cuurent values of the RAMSTKDesignElectric data model attributes.

        :param tuple attributes: tuple of values to assign to the instance
                                attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKDesignElectric {0:d} attributes.". \
               format(self.hardware_id)

        try:
            self.hardware_id = int(
                none_to_default(attributes['hardware_id'], 0))
            self.application_id = int(
                none_to_default(attributes['application_id'], 0))
            self.area = float(none_to_default(attributes['area'], 0.0))
            self.capacitance = float(
                none_to_default(attributes['capacitance'], 0.0))
            self.configuration_id = int(
                none_to_default(attributes['configuration_id'], 0))
            self.construction_id = int(
                none_to_default(attributes['construction_id'], 0))
            self.contact_form_id = int(
                none_to_default(attributes['contact_form_id'], 0))
            self.contact_gauge = int(
                none_to_default(attributes['contact_gauge'], 0))
            self.contact_rating_id = int(
                none_to_default(attributes['contact_rating_id'], 0))
            self.current_operating = float(
                none_to_default(attributes['current_operating'], 0.0))
            self.current_rated = float(
                none_to_default(attributes['current_rated'], 0.0))
            self.current_ratio = float(
                none_to_default(attributes['current_ratio'], 0.0))
            self.environment_active_id = int(
                none_to_default(attributes['environment_active_id'], 0))
            self.environment_dormant_id = int(
                none_to_default(attributes['environment_dormant_id'], 0))
            self.family_id = int(none_to_default(attributes['family_id'], 0))
            self.feature_size = float(
                none_to_default(attributes['feature_size'], 0.0))
            self.frequency_operating = float(
                none_to_default(attributes['frequency_operating'], 0.0))
            self.insert_id = int(none_to_default(attributes['insert_id'], 0))
            self.insulation_id = int(
                none_to_default(attributes['insulation_id'], 0))
            self.manufacturing_id = int(
                none_to_default(attributes['manufacturing_id'], 0))
            self.matching_id = int(
                none_to_default(attributes['matching_id'], 0))
            self.n_active_pins = int(
                none_to_default(attributes['n_active_pins'], 0))
            self.n_circuit_planes = int(
                none_to_default(attributes['n_circuit_planes'], 1))
            self.n_cycles = int(none_to_default(attributes['n_cycles'], 0))
            self.n_elements = int(none_to_default(attributes['n_elements'], 0))
            self.n_hand_soldered = int(
                none_to_default(attributes['n_hand_soldered'], 0))
            self.n_wave_soldered = int(
                none_to_default(attributes['n_wave_soldered'], 0))
            self.operating_life = float(
                none_to_default(attributes['operating_life'], 0.0))
            self.overstress = int(none_to_default(attributes['overstress'], 0))
            self.package_id = int(none_to_default(attributes['package_id'], 0))
            self.power_operating = float(
                none_to_default(attributes['power_operating'], 0.0))
            self.power_rated = float(
                none_to_default(attributes['power_rated'], 0.0))
            self.power_ratio = float(
                none_to_default(attributes['power_ratio'], 0.0))
            self.reason = str(none_to_default(attributes['reason'], ''))
            self.resistance = float(
                none_to_default(attributes['resistance'], 0.0))
            self.specification_id = int(
                none_to_default(attributes['specification_id'], 0))
            self.technology_id = int(
                none_to_default(attributes['technology_id'], 0))
            self.temperature_active = float(
                none_to_default(attributes['temperature_active'], 35.0))
            self.temperature_case = float(
                none_to_default(attributes['temperature_case'], 0.0))
            self.temperature_dormant = float(
                none_to_default(attributes['temperature_dormant'], 25.0))
            self.temperature_hot_spot = float(
                none_to_default(attributes['temperature_hot_spot'], 0.0))
            self.temperature_junction = float(
                none_to_default(attributes['temperature_junction'], 0.0))
            self.temperature_knee = float(
                none_to_default(attributes['temperature_knee'], 25.0))
            self.temperature_rated_max = float(
                none_to_default(attributes['temperature_rated_max'], 0.0))
            self.temperature_rated_min = float(
                none_to_default(attributes['temperature_rated_min'], 0.0))
            self.temperature_rise = float(
                none_to_default(attributes['temperature_rise'], 0.0))
            self.theta_jc = float(none_to_default(attributes['theta_jc'], 0.0))
            self.type_id = float(none_to_default(attributes['type_id'], 0.0))
            self.voltage_ac_operating = float(
                none_to_default(attributes['voltage_ac_operating'], 0.0))
            self.voltage_dc_operating = float(
                none_to_default(attributes['voltage_dc_operating'], 0.0))
            self.voltage_esd = float(
                none_to_default(attributes['voltage_esd'], 0.0))
            self.voltage_rated = float(
                none_to_default(attributes['voltage_rated'], 0.0))
            self.voltage_ratio = float(
                none_to_default(attributes['voltage_ratio'], 0.0))
            self.weight = float(none_to_default(attributes['weight'], 0.0))
            self.years_in_production = int(
                none_to_default(attributes['years_in_production'], 1))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKDesignElectric.set_attributes().".format(_err)

        return _error_code, _msg
Exemplo n.º 29
0
def test_none_to_default_not_none():
    """ none_to_default() should return the original value if it is not missing. """
    assert none_to_default(40, 10) == 40
Exemplo n.º 30
0
    def set_attributes(self, attributes):
        """
        Set the current values of the RAMSTKDesignMechanic data model attributes.

        :param dict attributes: dict of values to assign to the instance
                                attributes.
        :return: (_error_code, _msg); the error code and error message.
        :rtype: tuple
        """
        _error_code = 0
        _msg = "RAMSTK SUCCESS: Updating RAMSTKDesignMechanic {0:d} attributes.". \
               format(self.hardware_id)

        try:
            self.altitude_operating = float(
                none_to_default(attributes['altitude_operating'], 0.0))
            self.application_id = int(
                none_to_default(attributes['application_id'], 0))
            self.balance_id = int(none_to_default(attributes['balance_id'], 0))
            self.clearance = float(
                none_to_default(attributes['clearance'], 0.0))
            self.casing_id = int(none_to_default(attributes['casing_id'], 0))
            self.contact_pressure = float(
                none_to_default(attributes['contact_pressure'], 0.0))
            self.deflection = float(
                none_to_default(attributes['deflection'], 0.0))
            self.diameter_coil = float(
                none_to_default(attributes['diameter_coil'], 0.0))
            self.diameter_inner = float(
                none_to_default(attributes['diameter_inner'], 0.0))
            self.diameter_outer = float(
                none_to_default(attributes['diameter_outer'], 0.0))
            self.diameter_wire = float(
                none_to_default(attributes['diameter_wire'], 0.0))
            self.filter_size = float(
                none_to_default(attributes['filter_size'], 0.0))
            self.flow_design = float(
                none_to_default(attributes['flow_design'], 0.0))
            self.flow_operating = float(
                none_to_default(attributes['flow_operating'], 0.0))
            self.frequency_operating = float(
                none_to_default(attributes['frequency_operating'], 0.0))
            self.friction = float(none_to_default(attributes['friction'], 0.0))
            self.impact_id = int(none_to_default(attributes['impact_id'], 0))
            self.leakage_allowable = float(
                none_to_default(attributes['leakage_allowable'], 0.0))
            self.length = float(none_to_default(attributes['length'], 0.0))
            self.length_compressed = float(
                none_to_default(attributes['length_compressed'], 0.0))
            self.length_relaxed = float(
                none_to_default(attributes['length_relaxed'], 0.0))
            self.load_design = float(
                none_to_default(attributes['load_design'], 0.0))
            self.load_id = int(none_to_default(attributes['load_id'], 0))
            self.load_operating = float(
                none_to_default(attributes['load_operating'], 0.0))
            self.lubrication_id = int(
                none_to_default(attributes['lubrication_id'], 0))
            self.manufacturing_id = int(
                none_to_default(attributes['manufacturing_id'], 0))
            self.material_id = int(
                none_to_default(attributes['material_id'], 0))
            self.meyer_hardness = float(
                none_to_default(attributes['meyer_hardness'], 0.0))
            self.misalignment_angle = float(
                none_to_default(attributes['misalignment_angle'], 0.0))
            self.n_ten = int(none_to_default(attributes['n_ten'], 0))
            self.n_cycles = int(none_to_default(attributes['n_cycles'], 0))
            self.n_elements = int(none_to_default(attributes['n_elements'], 0))
            self.offset = float(none_to_default(attributes['offset'], 0.0))
            self.particle_size = float(
                none_to_default(attributes['particle_size'], 0.0))
            self.pressure_contact = float(
                none_to_default(attributes['pressure_contact'], 0.0))
            self.pressure_delta = float(
                none_to_default(attributes['pressure_delta'], 0.0))
            self.pressure_downstream = float(
                none_to_default(attributes['pressure_downstream'], 0.0))
            self.pressure_rated = float(
                none_to_default(attributes['pressure_rated'], 0.0))
            self.pressure_upstream = float(
                none_to_default(attributes['pressure_upstream'], 0.0))
            self.rpm_design = float(
                none_to_default(attributes['rpm_design'], 0.0))
            self.rpm_operating = float(
                none_to_default(attributes['rpm_operating'], 0.0))
            self.service_id = int(none_to_default(attributes['service_id'], 0))
            self.spring_index = float(
                none_to_default(attributes['spring_index'], 0.0))
            self.surface_finish = float(
                none_to_default(attributes['surface_finish'], 0.0))
            self.technology_id = int(
                none_to_default(attributes['technology_id'], 0))
            self.thickness = float(
                none_to_default(attributes['thickness'], 0.0))
            self.torque_id = int(none_to_default(attributes['torque_id'], 0))
            self.type_id = int(none_to_default(attributes['type_id'], 0))
            self.viscosity_design = float(
                none_to_default(attributes['viscosity_design'], 0.0))
            self.viscosity_dynamic = float(
                none_to_default(attributes['viscosity_dynamic'], 0.0))
            self.water_per_cent = float(
                none_to_default(attributes['water_per_cent'], 0.0))
            self.width_minimum = float(
                none_to_default(attributes['width_minimum'], 0.0))
        except KeyError as _err:
            _error_code = 40
            _msg = "RAMSTK ERROR: Missing attribute {0:s} in attribute " \
                   "dictionary passed to " \
                   "RAMSTKDesignMechanic.set_attributes().".format(_err)

        return _error_code, _msg