예제 #1
0
 def checkIfDutDraggedToExistingAssy(self, dut_id1, dut_id2):
     """Checks and raises exception if the source & target DuTs are in the
         same structure for the following cases
         case 1: If the source DuT is dropped to its immidiate parent, 
                 if not handled it goes recursively recursive. 
         case 2: If the source DuT is dropped to its immidiate child,
                 if not handled it goes recursively recursive.
         case 3: If the source DuT is dropped to its immidiate inner childs,
                 if not handled it goes recursively recursive.
         
         Args:
             dut_id1: The target DuT.
             dut_id2: The dragged DuT.
         Returns:
             No return value.
     """
     if (Mannhummelrelationdut.k == 0):
         Mannhummelrelationdut.dut_id1_del = dut_id1
         Mannhummelrelationdut.dut_id2_del = dut_id2
     existingRelRows1 = Mannhummelrelationdut.KeywordQuery(dut_id1=dut_id1,
                                                           dut_id2=dut_id2)
     if (len(existingRelRows1) > 0):
         if (existingRelRows1[0].dut_id1 == dut_id1):
             message = Mannhummelrelationdut.dut_id2_del + " is already in relation with " + Mannhummelrelationdut.dut_id1_del
             raise ue.Exception(1024, message)
     else:
         existingRelRows2 = Mannhummelrelationdut.KeywordQuery(
             dut_id1=dut_id2, dut_id2=dut_id1)
         if (len(existingRelRows2) > 0):
             if (existingRelRows2[0].dut_id1 ==
                     Mannhummelrelationdut.dut_id2_del):
                 message = Mannhummelrelationdut.dut_id2_del + " is already in relation with " + Mannhummelrelationdut.dut_id1_del
                 raise ue.Exception(1024, message)
         else:
             self.checkIfDutDroppedToExistingChildAssy(dut_id2)
예제 #2
0
    def checkIfAssyAlreadyExistInAssy(self, dut_id1, dut_id2):
        """When there are no sub-assembly then get all the parts of target & source DuT and 
        if the parts already exist then raise exception else call the fucnation recursively.
        
        Args:
            dut_id1: The target DuT.
            dut_id2: The dragged DuT.
        Returns:
            No return value
        """
        allAssysRows = Mannhummelrelationdut.KeywordQuery(dut_id1=dut_id2)
        # getAllAssysSQL = "SELECT * FROM MH_PVS_REL_DUT2DUT WHERE DUT_ID1= '" + dut_id2 + "' AND DUT_TYPE2='Assembly'"
        # allAssysRows = sqlapi.RecordSet2(sql=getAllAssysSQL)
        if (len(allAssysRows) == 0):
            # getAllAssyPartsSQL = "SELECT * FROM MH_PVS_REL_DUT2DUT WHERE DUT_ID1= '" + dut_id2 + "' AND DUT_TYPE2='Part'"
            # allAssyPartsRows = sqlapi.RecordSet2(sql=getAllAssyPartsSQL)
            allAssyPartsRows = Mannhummelrelationdut.KeywordQuery(
                dut_id1=dut_id2, dut_type2='Part')
            if (len(allAssyPartsRows) > 0):
                for rel in allAssyPartsRows:
                    # getting all inner parts
                    Mannhummelrelationdut.parts_list.append(rel.dut_id2)

        elif (len(allAssysRows) > 0):
            # call recursively
            for rel in allAssysRows:
                # self.checkIfPartAlreadyExistInAssy(rel.dut_id2, dut_id2)
                if (rel.dut_type2 == "Assembly"):
                    if (rel.dut_id2 in Mannhummelrelationdut.assy_list):
                        message = rel.dut_id2 + " is already in a relation with " + dut_id1
                        raise ue.Exception(1024, message)
                    self.checkIfAssyAlreadyExistInAssy(dut_id2, rel.dut_id2)
                elif (rel.dut_type2 == "Part"):
                    Mannhummelrelationdut.parts_list.append(rel.dut_id2)
        return Mannhummelrelationdut.parts_list
예제 #3
0
 def checkIfDutDroppedToExistingChildAssy(self, dut_id2):
     """check if the source DuT is dropped to its immidiate inner childs,
         if exist raise exception
        
        Args:
            dut_id2: The source DuT.
         Returns:
             No return value
     """
     existingRelRows3 = Mannhummelrelationdut.KeywordQuery(dut_id1=dut_id2)
     if (len(existingRelRows3) > 0):
         for rel in existingRelRows3:
             if (rel.dut_id2 == Mannhummelrelationdut.dut_id1_del):
                 message = Mannhummelrelationdut.dut_id2_del + " is already in relation with " + Mannhummelrelationdut.dut_id1_del
                 raise ue.Exception(1024, message)
             Mannhummelrelationdut.k += 1
             self.checkIfDutDroppedToExistingChildAssy(rel.dut_id2)
예제 #4
0
 def checkIfPartAlreadyExistInAssy(self, dut_id1, dut_id2):
     """Checks if the top assembly dut_id1 has parts, if found create a list of parts.
     
     Args:
         dut_id1: The target DuT.
         dut_id2: The dragged DuT.
         
     Returns:
         A list of Part DuTs.
         
     """
     allAssysRows = Mannhummelrelationdut.KeywordQuery(dut_id1=dut_id1)
     # getAllAssysSQL = "SELECT * FROM MH_PVS_REL_DUT2DUT WHERE DUT_ID1= '" + dut_id1 + "' AND DUT_TYPE2='Assembly'"
     # allAssysRows = sqlapi.RecordSet2(sql=getAllAssysSQL)
     '''When there are no sub-assembly then get all the parts and 
     if the parts contians the dragged element then raise exception
     else call the fucnation recursively. 
     '''
     if (len(allAssysRows) == 0):
         # getAllAssyPartsSQL = "SELECT * FROM MH_PVS_REL_DUT2DUT WHERE DUT_ID1= '" + dut_id1 + "' AND DUT_TYPE2='Part'"
         # allAssyPartsRows = sqlapi.RecordSet2(sql=getAllAssyPartsSQL)
         allAssyPartsRows = Mannhummelrelationdut.KeywordQuery(
             dut_id1=dut_id1, dut_type2='Part')
         if (len(allAssyPartsRows) > 0):
             for rel in allAssyPartsRows:
                 # getting all inner parts
                 Mannhummelrelationdut.parts_list.append(rel.dut_id2)
     elif (len(allAssysRows) > 0):
         # call recursively
         for rel in allAssysRows:
             '''checking if the same assembly is dropped again, if so raise exception else call again
             '''
             if (rel.dut_type2 == "Assembly"):
                 Mannhummelrelationdut.assy_list.add(rel.dut_id2)
                 if (rel.dut_id2 == dut_id2 or rel.dut_id2 == dut_id1):
                     message = "Assembly " + dut_id2 + " is already in a relation with " + rel.dut_id1
                     raise ue.Exception(1024, message)
                 self.checkIfPartAlreadyExistInAssy(rel.dut_id2, dut_id2)
             elif (rel.dut_type2 == "Part"):
                 Mannhummelrelationdut.parts_list.append(rel.dut_id2)
     return Mannhummelrelationdut.parts_list
예제 #5
0
def drag_drop_relation_creation(self, ctx):
    """ Checks the following points and validates if a relation between two DuTs is valid.
    RULES:
    1. Assembly to Assembly : Possible
    2. Assembly to Part : Possible, not the reverse
    3. Part to Sub-Part : Possible, not the reverse
    4. Assembly to Subpart : Not Possible
    5. A Sub-Part of a Part can't be added to other Part
    6. A Part can be part of many Assemblys
    7. When making Assy to Assy & Assy to Part relation within same structure the old Assy rel should be deleted & new Assy rel shoud be created
    8. When making Assy to Assy & Assy to Part relation not within same structure the old Assy rel should be copied & new Assy rel shoud be created
    9. A Structure should only contain unique Parts, Sub-Parts, Assemblys
    10. Sub-Part to Sub-Part : Not possible
    """
    rel_list = []
    dut_id1 = ctx.dialog['dut_id1']
    dut_id2 = ctx.dialog['dut_id2']
    dut_type1 = ctx.dialog['dut_type1']
    dut_type2 = ctx.dialog['dut_type2']
    '''1st check'''
    # If a source and target DuT are same.
    if (dut_id1 == dut_id2):
        message = "A relation connot established between same objects"
        raise ue.Exception(1024, message)
    '''2nd check'''
    Mannhummelrelationdut.k = 0
    self.checkIfDutDraggedToExistingAssy(dut_id1, dut_id2)

    result = sqlapi.RecordSet2("mh_pvs_dut", "dut_id='" + dut_id1 + "'")
    idvalue = result[0]
    dut_type1 = getattr(idvalue, "dut_type")
    ctx.set('dut_type1', dut_type1)
    '''3rd check'''
    self.checkattributevalues(ctx)
    '''4th check'''
    if (dut_type2 == "Sub-Part"):
        # sql = "SELECT * FROM MH_PVS_REL_DUT2DUT WHERE DUT_ID2 = '" + dut_id2 + "' and DUT_TYPE2='Sub-Part'"
        # result = sqlapi.RecordSet2(sql=sql)
        result = Mannhummelrelationdut.KeywordQuery(dut_id2=dut_id2,
                                                    dut_type2='Sub-Part')
        if (len(result) > 0):
            message = dut_id2 + " is already in a relation with " + result[
                0].dut_id1
            raise ue.Exception(1024, message)

    if (dut_type2 == "Part"):
        '''adding chek for drag-drop within the same structure'''
        Mannhummelrelationdut.top_assy_list.append(dut_id1)
        Mannhummelrelationdut.k = 0
        existing_assys_list = self.getAllTopAsseyDuts(dut_id1, dut_id2)
        Mannhummelrelationdut.top_assy_list = []
        is_same_struct = self.isOperationInSameStruct(dut_id1, dut_id2,
                                                      existing_assys_list)
        Mannhummelrelationdut.is_same_struct_global = False
        if (not is_same_struct):
            existing_parts_list = self.checkIfPartAlreadyExistInAssy(
                dut_id1, dut_id2)
            if (dut_id2 in existing_parts_list):
                message = "Part " + dut_id2 + " already exist in Assembly " + dut_id1
                raise ue.Exception(1024, message)

    if (dut_type2 == "Assembly"):
        Mannhummelrelationdut.assy_list.clear()
        Mannhummelrelationdut.k = 0
        Mannhummelrelationdut.top_assy_list.append(dut_id1)
        existing_assys_list = self.getAllTopAsseyDuts(dut_id1, dut_id2)
        Mannhummelrelationdut.top_assy_list = []
        is_same_struct = self.isOperationInSameStruct(dut_id1, dut_id2,
                                                      existing_assys_list)
        Mannhummelrelationdut.is_same_struct_global = False
        if (not is_same_struct):
            # get the parts list of the target DuT
            existing_parts_list = self.checkIfPartAlreadyExistInAssy(
                dut_id1, dut_id2)
            Mannhummelrelationdut.parts_list = []
            # get the parts list of the source DuT
            dragged_parts_list = self.checkIfAssyAlreadyExistInAssy(
                dut_id1, dut_id2)
            Mannhummelrelationdut.parts_list = []
            duts_already_exist = set(existing_parts_list) & set(
                dragged_parts_list)
            if (len(duts_already_exist) > 0):
                messages = []
                for ele in duts_already_exist:
                    message = "Part " + ele + " already exist in Assembly " + dut_id1
                    messages.append(message)
                if (len(messages) > 0):
                    raise ue.Exception(1024, '\n'.join(messages))