Skip to content

Commit

Permalink
Provide method to associate Hardware items with Validation tasks.
Browse files Browse the repository at this point in the history
- Fixes issue #52 for Validation:Hardware.
- Add method to create/refresh matrix.
- Update method names to conform with RTK coding standards.
- Add Hardware:Requirement matrix.
- Add Hardware:Validation matrix.
- Add Validation:Requirement matrix.
- Add Validation:Hardware matrix.

Signed-off-by: Doyle Rowland <[email protected]>
  • Loading branch information
weibullguy committed Jul 13, 2018
1 parent 18cfa81 commit 78dced1
Show file tree
Hide file tree
Showing 24 changed files with 1,182 additions and 169 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
pip install matplotlib==1.4.3
- save_cache:
key: deps-{{ .Branch }}-{{ checksum "requirements/dev.txt" }}
key: deps-{{ .Branch }}-{{ checksum "requirements_dev.txt" }}
paths:
- ./venv

Expand Down
24 changes: 16 additions & 8 deletions src/rtk/dao/RTKProgramDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,30 +325,29 @@ def do_create_test_database(database):
_mode = RTKMode()
_mode.function_id = _function.function_id
_mode.hardware_id = -1
_mode.description = (
"Test Functional Failure Mode #{0:d}").format(i)
_mode.description = ("Test Functional Failure Mode #{0:d}").format(i)
session.add(_mode)
session.commit()

_cause = RTKCause()
_cause.mode_id = _mode.mode_id
_cause.mechanism_id = -1
_cause.description = ("Test Functional FMEA Cause "
"#{0:d} for Mode ID {1:d}").format(
i, _mode.mode_id)
"#{0:d} for Mode ID {1:d}").format(
i, _mode.mode_id)
session.add(_cause)
session.commit()

_control = RTKControl()
_control.cause_id = _cause.cause_id
_control.description = (
"Test Functional FMEA Control #{0:d} for Cause ID {1:d}"
).format(i, _cause.cause_id)
"Test Functional FMEA Control #{0:d} for Cause ID {1:d}").format(
i, _cause.cause_id)
_action = RTKAction()
_action.cause_id = _cause.cause_id
_action.action_recommended = (
"Test Functional FMEA Recommended "
"Action #{0:d} for Cause ID {1:d}").format(i, _cause.cause_id)
"Test Functional FMEA Recommended "
"Action #{0:d} for Cause ID {1:d}").format(i, _cause.cause_id)
session.add(_control)
session.add(_action)
_dic_rows[i] = _function.function_id
Expand Down Expand Up @@ -589,6 +588,15 @@ def do_create_test_database(database):
_matrix.row_id = _ckey
_matrix.row_item_id = _dic_cols[_ckey]
session.add(_matrix)
_matrix = RTKMatrix()
_matrix.revision_id = _revision.revision_id
_matrix.matrix_id = 5
_matrix.matrix_type = 'vldtn_hrdwr'
_matrix.column_id = _ckey
_matrix.column_item_id = _dic_cols[_ckey]
_matrix.row_id = 1
_matrix.row_item_id = 1
session.add(_matrix)
session.commit()

return False
2 changes: 1 addition & 1 deletion src/rtk/dao/commondb/RTKType.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RTKType(RTK_BASE):
__table_args__ = {'extend_existing': True}

type_id = Column(
'fld_model_id',
'fld_type_id',
Integer,
primary_key=True,
autoincrement=True,
Expand Down
4 changes: 4 additions & 0 deletions src/rtk/dao/programdb/RTKValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class RTKValidation(RTK_BASE):
date_start = Column('fld_date_start', Date, default=date.today())
description = Column('fld_description', BLOB, default='')
measurement_unit = Column('fld_measurement_unit', String(256), default='')
name = Column('fld_name', String(256), default='')
status = Column('fld_status', Float, default=0.0)
task_type = Column('fld_type', String(256), default='')
task_specification = Column(
Expand Down Expand Up @@ -103,6 +104,7 @@ def get_attributes(self):
'date_start': self.date_start,
'description': self.description,
'measurement_unit': self.measurement_unit,
'name': self.name,
'status': self.status,
'task_type': self.task_type,
'task_specification': self.task_specification,
Expand Down Expand Up @@ -161,6 +163,8 @@ def set_attributes(self, attributes):
none_to_default(attributes['description'], ''))
self.measurement_unit = str(
none_to_default(attributes['measurement_unit'], ''))
self.name = str(
none_to_default(attributes['name'], ''))
self.status = float(none_to_default(attributes['status'], 0.0))
self.task_type = str(none_to_default(attributes['task_type'], ''))
self.task_specification = str(
Expand Down
33 changes: 22 additions & 11 deletions src/rtk/gui/gtk/matrixviews/FunctionHardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def __init__(self, controller, **kwargs):

pub.subscribe(self._on_select_revision, 'selectedRevision')

def _do_request_create(self, __button):
"""
Save the currently selected Validation:Requirement Matrix row.
:param __button: the gtk.ToolButton() that called this method.
:type __button: :py:class:`gtk.ToolButton`
:return: False if successful or True if an error is encountered.
:rtype: bool
"""
return self._dtc_data_controller.request_do_create(
self._revision_id, self._matrix_type)

def _do_request_update(self, __button):
"""
Save the currently selected Function:Hardware Matrix row.
Expand All @@ -82,7 +94,7 @@ def _do_request_update(self, __button):
return self._dtc_data_controller.request_do_update_matrix(
self._revision_id, self._matrix_type)

def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument
"""
Make the buttonbox for the Function:Hardware Matrix View.
Expand All @@ -93,13 +105,10 @@ def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument
_tooltips = [
_(u"Save the Function:Hardware Matrix to the open RTK "
u"Program database."),
_(u'Create or refresh the Function:Hardware Matrix.')
]
_callbacks = [
self._do_request_update,
]
_icons = [
'save',
]
_callbacks = [self._do_request_update, self._do_request_create]
_icons = ['save', 'save']

_buttonbox = rtk.RTKBaseMatrix._make_buttonbox(
self,
Expand All @@ -118,15 +127,17 @@ def _on_select_revision(self, module_id):
:param int revision_id: the Revision ID to select the Function:Hardware
matrix for.
:return: False if successful or True if an error is encountered.
:rtype: bool
:return: None
:rtype: None
"""
self._revision_id = module_id

self._dtc_data_controller = self._mdcRTK.dic_controllers['function']
(_matrix, _column_hdrs,
_row_hdrs) = self._dtc_data_controller.request_do_select_all_matrix(
self._revision_id, self._matrix_type)
if _matrix is not None:
rtk.RTKBaseMatrix.do_load_matrix(self, _matrix, _column_hdrs,
_row_hdrs, _(u"Function"))

return rtk.RTKBaseMatrix.do_load_matrix(self, _matrix, _column_hdrs,
_row_hdrs, _(u"Function"))
return None
144 changes: 144 additions & 0 deletions src/rtk/gui/gtk/matrixviews/HardwareRequirement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# -*- coding: utf-8 -*-
#
# rtk.gui.gtk.matrixviews.HardwareRequirement.py is part of the RTK
# Project
#
# All rights reserved.
# Copyright 2007 - 2017 Andrew Rowland andrew.rowland <AT> reliaqual <DOT> com
"""The Hardware:Requirement Matrix View Module."""

from pubsub import pub

# Import other RTK modules.
from rtk.gui.gtk.rtk.Widget import _, gtk
from rtk.gui.gtk import rtk


class MatrixView(gtk.HBox, rtk.RTKBaseMatrix):
"""
This is the Hardware:Requirement RTK Matrix View.
Attributes of the Hardware:Requirement Matrix View are:
"""

def __init__(self, controller, **kwargs):
"""
Initialize the Hardware:Requirement Matrix View.
:param controller: the RTK master data controller instance.
:type controller: :py:class:`rtk.RTK.RTK`
"""
gtk.HBox.__init__(self)
rtk.RTKBaseMatrix.__init__(self, controller, **kwargs)

# Initialize private dictionary attributes.

# Initialize private list attributes.

# Initialize private scalar attributes.
self._dtc_data_controller = None
self._revision_id = None
self._matrix_type = kwargs['matrix_type']

# Initialize public dictionary attributes.

# Initialize public list attributes.

# Initialize public scalar attributes.
self.hbx_tab_label = gtk.HBox()

_label = gtk.Label()
_label.set_markup("<span weight='bold'>" +
_(u"Hardware\nRequirement") + "</span>")
_label.set_alignment(xalign=0.5, yalign=0.5)
_label.set_justify(gtk.JUSTIFY_CENTER)
_label.show_all()
_label.set_tooltip_text(
_(u"Displays hardware/requirement matrix for the "
u"selected revision."))

# self.hbx_tab_label.pack_start(_image)
self.hbx_tab_label.pack_end(_label)
self.hbx_tab_label.show_all()

_scrolledwindow = gtk.ScrolledWindow()
_scrolledwindow.add(self.matrix)

self.pack_start(self._make_buttonbox(), expand=False, fill=False)
self.pack_end(_scrolledwindow, expand=True, fill=True)

self.show_all()

pub.subscribe(self._on_select_revision, 'selectedRevision')

def _do_request_create(self, __button):
"""
Save the currently selected Hardware:Requirement Matrix row.
:param __button: the gtk.ToolButton() that called this method.
:type __button: :py:class:`gtk.ToolButton`
:return: False if successful or True if an error is encountered.
:rtype: bool
"""
return self._dtc_data_controller.request_do_create(
self._revision_id, self._matrix_type)

def _do_request_update(self, __button):
"""
Save the currently selected Hardware:Requirement Matrix row.
:param __button: the gtk.ToolButton() that called this method.
:type __button: :py:class:`gtk.ToolButton`
:return: False if successful or True if an error is encountered.
:rtype: bool
"""
return self._dtc_data_controller.request_do_update_matrix(
self._revision_id, self._matrix_type)

def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument
"""
Create the buttonbox for the Hardware:Requirement Matrix View.
:return: _buttonbox; the gtk.ButtonBox() for the Hardware:Requirement
Matrix View.
:rtype: :class:`gtk.ButtonBox`
"""
_tooltips = [
_(u"Save the Hardware:Requirement Matrix to the open RTK "
u"Program database."),
_(u"Create or refresh the Hardware:Requirement Matrix.")
]
_callbacks = [self._do_request_update, self._do_request_create]
_icons = ['save', 'save']

_buttonbox = rtk.RTKBaseMatrix._make_buttonbox(
self,
icons=_icons,
tooltips=_tooltips,
callbacks=_callbacks,
orientation='vertical',
height=-1,
width=-1)

return _buttonbox

def _on_select_revision(self, module_id):
"""
Load the Hardware:Requirement Matrix View with matrix information.
:param int revision_id: the Revision ID to select the
Hardware:Requirement matrix for.
:return: None
:rtype: None
"""
self._revision_id = module_id

self._dtc_data_controller = self._mdcRTK.dic_controllers['hardware']
(_matrix, _column_hdrs,
_row_hdrs) = self._dtc_data_controller.request_do_select_all_matrix(
self._revision_id, self._matrix_type)
if _matrix is not None:
rtk.RTKBaseMatrix.do_load_matrix(self, _matrix, _column_hdrs,
_row_hdrs, _(u"Hardware"))

return None
Loading

0 comments on commit 78dced1

Please sign in to comment.