Пример #1
0
 def creMenu(self):
     # File
     tMenu=self.menuBar().addMenu(self.tr('File'))
     ## Open Ctrl+O  
     sItem=QAction(self.tr('Open'),self) 
     sItem.setShortcut('Ctrl+O'); 
     sItem.setStatusTip('Open a OpenSAR configure file.')
     sItem.triggered.connect(self.mOpen)
     tMenu.addAction(sItem) 
     ## Save Ctrl+S
     sItem=QAction(self.tr('Save'),self) 
     sItem.setShortcut('Ctrl+S'); 
     sItem.setStatusTip('Save the OpenSAR configure file.')
     sItem.triggered.connect(self.mSave) 
     tMenu.addAction(sItem)  
     ## Save Ctrl+G
     sItem=QAction(self.tr('Generate'),self) 
     sItem.setShortcut('Ctrl+G'); 
     sItem.setStatusTip('Convert the OpenSAR configure file to C Code.')
     sItem.triggered.connect(self.mGen)  
     tMenu.addAction(sItem)
     # easySAR Module
     tMenu=self.menuBar().addMenu(self.tr('Module'))
     for desc in self.systemDescriptor:
         sItem=ArgAction(self.tr(desc.tag),self) 
         sItem.setStatusTip('Open easy%s console.'%(desc.tag)) 
         tMenu.addAction(sItem)
         module = ArgModule(Arxml(desc),self)
         self.modules.append(module)
         self.docks.append(None)
Пример #2
0
 def modifyPduRbyCANDBC(self, dbc):
     self.root.onAction('PduR')
     pdur = self.root.getModule('PduR')
     arxml = pdur.toArxml()
     R = []
     for msg in dbc['boList']:
         R.append(msg['bo']['name'])
     RoutineList = arxml.find('RoutineList')
     self.root.removeXml(RoutineList, R)
     for msg in dbc['boList']:
         msg = msg['bo']
         src = ET.Element('Source')
         src.attrib['Name'] = msg['name']
         src.attrib['PduRef'] = msg['name']
         if (msg['node'] == self.CAN_SELF_DBC_NODE):
             src.attrib['Module'] = 'Com'
         else:
             src.attrib['Module'] = 'CanIf'
         dlist = ET.Element('DestinationList')
         dst = ET.Element('Destination')
         dst.attrib['Name'] = msg['name']
         dst.attrib['PduRef'] = msg['name']
         if (msg['node'] == self.CAN_SELF_DBC_NODE):
             dst.attrib['Module'] = 'CanIf'
         else:
             dst.attrib['Module'] = 'Com'
         dlist.append(dst)
         src.append(dlist)
         RoutineList.append(src)
         pdur.reloadArxml(
             Arxml(self.root.systemDescriptor.find('PduR'), arxml))
Пример #3
0
 def modifyCombyCANDBC(self, dbc):
     self.root.onAction('Com')
     com = self.root.getModule('Com')
     arxml = com.toArxml()
     R = []
     for msg in dbc['boList']:
         R.append(msg['bo']['name'])
     IPduList = arxml.find('IPduList')
     self.root.removeXml(IPduList, R)
     for msg in dbc['boList']:
         msg = msg['bo']
         ipdu = ET.Element('IPdu')
         ipdu.attrib['Name'] = msg['name']
         ipdu.attrib['PduRef'] = msg['name']
         if (msg['node'] == self.CAN_SELF_DBC_NODE):
             ipdu.attrib['Direction'] = 'SEND'
         else:
             ipdu.attrib['Direction'] = 'RECEIVE'
         slist = ET.Element('SignalList')
         for sg in msg['sgList']:
             sg = sg['sg']
             sig = ET.Element('Signal')
             sig.attrib['Name'] = sg['name']
             sig.attrib['Endianess'] = 'BIG_ENDIAN'
             sig.attrib['StartBit'] = str(sg['start'])
             sig.attrib['Size'] = str(sg['size'])
             try:
                 sig.attrib['InitialValue'] = str(sg['init'])
             except KeyError:
                 pass
             slist.append(sig)
         ipdu.append(slist)
         IPduList.append(ipdu)
     com.reloadArxml(Arxml(self.root.systemDescriptor.find('Com'), arxml))
Пример #4
0
    def modifyCanIfbyCANDBC(self, dbc, bus):
        self.onAction('CanIf')
        for s in [' ', '-']:
            bus = bus.replace(s, '')
        canif = self.getModule('CanIf')
        arxml = canif.toArxml()
        chlList = arxml.find('ChannelList')
        chl = None
        for c in chlList:
            if (c.attrib['Name'] == bus):
                chl = c
                break
        if (chl is None):
            chl = ET.Element('Channel')
            chl.attrib['Name'] = bus
            chl.append(ET.Element('HthList'))
            chl.append(ET.Element('HrhList'))
            chlList.append(chl)
        rxList = []
        rR = []
        txList = []
        tR = []
        for msg in dbc['boList']:
            msg = msg['bo']
            if (msg['node'] == self.CAN_SELF_DBC_NODE):
                txList.append(msg)
                tR.append(msg['name'])
            else:
                rxList.append(msg)
                rR.append(msg['name'])
        HthList = chl.find('HthList')
        HrhList = chl.find('HrhList')
        self.removeXml(HthList, tR)
        self.removeXml(HrhList, rR)

        def appendHOHList(HohList, xList, name):
            for msg in xList:
                hoh = ET.Element(name)
                hoh.attrib['Name'] = msg['name']
                pduList = ET.Element('PduList')
                hoh.append(pduList)
                pdu = ET.Element('Pdu')
                pdu.attrib['Name'] = msg['name']
                pdu.attrib['EcuCPduRef'] = msg['name']
                pdu.attrib['DataLengthCode'] = str(msg['length'])
                pdu.attrib['Identifier'] = str(msg['id'])
                pduList.append(pdu)
                HohList.append(hoh)

        appendHOHList(HthList, txList, 'Hth')
        appendHOHList(HrhList, rxList, 'Hrh')
        canif.reloadArxml(Arxml(self.systemDescriptor.find('CanIf'), arxml))
Пример #5
0
 def modifyEcuCbyCANDBC(self, dbc):
     self.root.onAction('EcuC')
     ecuc = self.root.getModule('EcuC')
     arxml = ecuc.toArxml()
     R = []
     for msg in dbc['boList']:
         R.append(msg['bo']['name'])
     PduList = arxml.find('PduList')
     self.root.removeXml(PduList, R)
     for msg in dbc['boList']:
         pdu = ET.Element('Pdu')
         pdu.attrib['Name'] = msg['bo']['name']
         pdu.attrib['Size'] = str(msg['bo']['length'] * 8)
         PduList.append(pdu)
     ecuc.reloadArxml(Arxml(self.root.systemDescriptor.find('EcuC'), arxml))
Пример #6
0
 def mOpen(self,default=None):
     if(default == None):
         self.pdir = QFileDialog.getExistingDirectory(None,'Open OpenSAR Config',gDefault_GEN,QFileDialog.DontResolveSymlinks)
         if(self.pdir == ''):
             return
     else:
         self.pdir = default
     wfxml = '%s/autosar.arxml'%(self.pdir)
     if(os.path.exists(wfxml)==False):
         return
     root = ET.parse(wfxml).getroot();
     for module in self.modules:
         if(root.find(module.tag) != None):
             module.reloadArxml(Arxml(self.systemDescriptor.find(module.tag),
                                      root.find(module.tag)))
             self.onAction(module.tag)
     if(default == None):
         QMessageBox(QMessageBox.Information, 'Info', 
                     'Open OpenSAR Configuration arxml Successfully !').exec_();