'''KcsStructure.py Author: Yang Guang and Zhan Qi Date: 2005-10-18 ''' import aadAssDataExtraction class Structure: '''Get the data of Tribon structure by data extraction.''' def __init__(self, structure, module = ''): self.Structure = structure self.dt = aadAssDataExtraction.DataExtraction() if module == '': self.GetModuleName() else: self.Module = module self.GetNPart() self.GetCompName() self.GetType() self.GetWeight() def GetModuleName(self): st = "str.ite('%s').mod.nam" % self.Structure self.dt.ExtractData(st) self.Module = self.dt.DataResult[0] def GetWeight(self): st = "str.ite('%s').group(1).weight" % self.Structure self.dt.ExtractData(st) self.Weight = self.dt.DataResult[0] self.Weight = round(self.Weight, 2) def GetNPart(self): st = "str.ite('%s').group(1).NPart" % self.Structure self.dt.ExtractData(st) self.NPart = self.dt.DataResult[0] def GetCompName(self): '''Get a list of all the component name in the structure.''' st = "str.ite('%s').group(1).part(1:%s).comp_n" % (self.Structure, self.NPart) self.dt.ExtractData(st) self.CompNames = self.dt.DataResult def GetType(self): '''Get a list of all the component type in the structure.''' st = "str.ite('%s').group(1).part(1:%s).type" % (self.Structure, self.NPart) self.dt.ExtractData(st) self.Types = self.dt.DataResult if __name__ == "__main__": import KcsStructure import kcs_ui import kcs_util S = KcsStructure.Structure('T3314_BHR1710N_201_1') # Test GetNPart num = S.NPart # Test GetCompName compnames = S.CompNames # Test GetType types = S.Types # Test GetWeight weight = S.Weight if num == 5 \ and compnames == ['RB25-17', 'RB16-17', 'ES65X16-2', 'RB25-17', 'RB16-17'] \ and types == ['RBAR', 'RBAR', 'Pl', 'RBAR', 'RBAR'] \ and weight == 17.71 \ and S.Module == '3314': kcs_ui.message_confirm('OK') else: kcs_ui.message_confirm('Not OK') kcs_util.exit_program()