Exemplo n.º 1
0
def run(x):
    gl.clearLog()
    project = Application.getInstance().getProjectsManager().getActiveProject()
    SEM = project.getSymbolElementMap()
    
    possibilities = None
    id = JOptionPane.showInputDialog(
                                    None,
                                    "Element ID",
                                    "Find Element",
                                    JOptionPane.PLAIN_MESSAGE,
                                    None,
                                    possibilities,
                                    None)

    if id and len(id)>0:
        id = id.strip()
        id = id.lstrip("sig")
        gl.log("looking for %s" % id)
        try: element = project.getElementByID(id)
        except:
            MPUtils.handleException("Can't find an element matching this ID.")
            return
        if not element: 
            gl.log("Can't find element matching this ID.")
            return
        gl.log("Found Element with ID = " + str(id) + ": ")
        try: gl.log("    Name: %s" % element.name)
        except: 
            try: gl.log("    HumanName: %s" % element.humanName)
            except: pass
        gl.log("    Type: %s" % element.humanType)
        try: symbols = SEM.getAllPresentationElements(element)
        except:
            MPUtils.handleException("Can't find symbols matching this ID.")
            return
        if symbols:
                if len(symbols)>1:
                    for s in symbols:
                        if s: gl.log("MULTIPLE SYMBOLS!! " + str(s) + " in diagram " + str(s.getDiagramPresentationElement()))
                        else: gl.log("MULTIPLE SYMBOLS!! " + str(s) )
                    gl.log("choosing first symbol")
                if len(symbols)>0:
                    sym = symbols[0]
                    if sym:
                        diagram = sym.getDiagramPresentationElement()
                        diagram.open()
                        sym.setSelected(True)  
                    else: gl.log("wtf?") 
        else: gl.log("No symbols found for componentId=" + str(id))
    else: gl.log("barrrf")
Exemplo n.º 2
0
 def run(self):
     global filepath
     try:
         mode = 0
         if mode == 0:
             mda = MagicDrawAnimatorUtils2.MagicDrawAnimator2()
             #filepath = "c:\\Users\\bclement\\Desktop\\medium2.txt"
             #filepath = "c:\\Users\\bclement\\git\\bae\\simulationSnapshot.Scenario_Smaller_2012.txt"
             #filepath = "c:\\Users\\bclement\\git\\bae\\Smaller2012_2.console.txt"
             #filepath = "/Users/mjackson/Desktop/MedSim.txt"
             gl.log("default filepath = %s" % filepath)
             #possibilities = None
             filepath = JOptionPane.showInputDialog(
                                             None,
                                             "Element ID",
                                             "Find Element",
                                             JOptionPane.PLAIN_MESSAGE,
                                             None,
                                             None,
                                             filepath)
             gl.log("reading events from " + filepath)
             try: f = open(filepath,"r")
             except:
                 gl.log("can't find file @ %s" % filepath)
                 return
             lastTime = 0
             elementsNotEnded = []
             for line in f.readlines():
                 #gl.log("read line = " + line)
                 #x = re.search(" (\S*) -> (\S*)\s*(\S*) ==>",line)
                 x = re.search("(\d*)[^0-9: \t\n\r\f\v]*\s*:\s*\S*\s*(\S*) -> (\S*)\s*(\S*) ==>",line)
                 y = re.search("(\S*) -> (\S*)\s*(\S*) ==>",line)
                 if x:
                     eventTime=x.groups()[0]
                     action=x.groups()[2]
                     cid = x.groups()[3]
                     ctype = x.groups()[1]
                 elif y:
                     eventTime=lastTime
                     action=y.groups()[1]
                     cid = y.groups()[2]
                     ctype = y.groups()[0]
                 elif line.startswith("---"): 
                     gl.log(line)
                     continue
                 else: continue
                 if eventTime != lastTime:
                     mda.doThePaint()
                     lastTime = eventTime
                     time.sleep(self.timeStep)
                 gl.log("%s: %s %s (%s)" % (eventTime, action.upper(), cid, ctype))
                 if any([x in cid for x in ["Main","TimeVaryingMap"]]): 
                     gl.log("    ---> Skipping - can't animate Main or TimeVaryingMap")
                     continue
                 if re.search("(_)?Activity(_.*)?(?!\S)",ctype): 
                     gl.log("    ---> Skipping - can't animate the Activity object!")
                     continue
                 if ctype.startswith("sig") and "ObjectFlow" in cid:
                     sid = ctype.strip("sig")
                     if "null" in action and sid in elementsNotEnded:
                         gl.log("    ---> ENDING SIGNAL %s" % sid)
                         mda.end(sid)
                         elementsNotEnded.remove(sid)
                     elif "null" not in action: 
                         gl.log("    ---> STARTING SIGNAL %s" % sid)
                         mda.start(sid)
                         if sid not in elementsNotEnded: elementsNotEnded.append(sid)
                 elif "start" in action: 
                     gl.log("    ---> STARTING")
                     mda.start(cid)
                     if cid not in elementsNotEnded: elementsNotEnded.append(cid)
                 elif "end" in action: 
                     gl.log("    ---> ENDING")
                     mda.end(cid)
                     if cid in elementsNotEnded: elementsNotEnded.remove(cid)
             time.sleep(self.timeStep)
             mda.doThePaint()
             gl.log("sleeping 3 seconds before reset")
             time.sleep(3)
             for sig in elementsNotEnded:
                 gl.log("ending %s " % sig)
                 mda.end(sig)
             mda.doThePaint()
                 
         elif mode == 1:
             e = "_17_0_5_edc0357_1346893970422_843838_14398"
             mda = MagicDrawAnimatorUtils2.MagicDrawAnimator2()
             gl.log("Starting e (%s)" % e)
             mda.start(e)
         
             i = 3
             while i > 0:
                 i-=1
                 gl.log(".")
                 time.sleep(self.timeStep)
             
             gl.log("ending e")
             mda.end(e)
             mda.doThePaint()
     except:
         MPUtils.handleException()
Exemplo n.º 3
0
# -*- coding: utf-8 -*-

# https://github.com/mogira/MP4Pythonista

from __future__ import print_function, unicode_literals
from objc_util import ObjCClass
from DBGUtils import *
import MPUtils

if __name__ == '__main__':
    MPUtils.init()

    printItemCollections(MPUtils.getNowPlayingQueue())

    player = MPUtils.getPlayer()
    mq = ObjCClass('MPMediaQuery').songsQuery()

    f0 = MPUtils.createFilter('isCloudItem', False)
    mq.addFilterPredicate(f0)

    player.setQueueWithQuery(mq)
    player.prepareToPlay()
    #player.play()

    print('↑ will be rewrited to ↓\n')
    printItemCollections(player.queueAsQuery().items())