"""
__ballSingle_MDL.py_____________________________________________________

Automatically generated AToM3 Model File (Do not modify directly)
Author: kyle
Modified: Tue Apr 29 23:11:23 2008
________________________________________________________________________
"""
from stickylink import *
from widthXfillXdecoration import *
from Basic import *
from Hyperedge import *
from graph_Basic import *
from graph_Hyperedge import *
from ATOM3Enum import *
from ATOM3String import *
from ATOM3BottomType import *
from ATOM3Constraint import *
from ATOM3Attribute import *
from ATOM3Float import *
from ATOM3List import *
from ATOM3Link import *
from ATOM3Connection import *
from ATOM3Boolean import *
from ATOM3Appearance import *
from ATOM3Text import *
from ATOM3Action import *
from ATOM3Integer import *
from ATOM3Port import *
from ATOM3MSEnum import *

def ballSingle_MDL(self, rootNode, DChartsRootNode=None):

    # --- Generating attributes code for ASG DCharts ---
    if( DChartsRootNode ): 
        # variables
        DChartsRootNode.variables.setValue('\n')
        DChartsRootNode.variables.setHeight(15)

        # misc
        DChartsRootNode.misc.setValue('\n')
        DChartsRootNode.misc.setHeight(15)

        # event_clauses
        DChartsRootNode.event_clauses.setValue('\n')
        DChartsRootNode.event_clauses.setHeight(15)
    # --- ASG attributes over ---


    self.obj172=Basic(self)
    self.obj172.isGraphObjectVisual = True

    if(hasattr(self.obj172, '_setHierarchicalLink')):
      self.obj172._setHierarchicalLink(False)

    # is_default
    self.obj172.is_default.setValue((None, 1))
    self.obj172.is_default.config = 0

    # name
    self.obj172.name.setValue('init')

    # exit_action
    self.obj172.exit_action.setValue('\n')
    self.obj172.exit_action.setHeight(15)

    # enter_action
    self.obj172.enter_action.setValue('counter = 0\nmax = 160\nballs = {}\n')
    self.obj172.enter_action.setHeight(15)

    self.obj172.graphClass_= graph_Basic
    if self.genGraphics:
       new_obj = graph_Basic(195.0,257.0,self.obj172)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Basic", new_obj.tag)
       self.UMLmodel.coords(new_obj.gf3.handler,207.0,260.0,225.0,278.0)
       self.UMLmodel.itemconfig(new_obj.gf3.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, width='2.0')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, outline='DARKGREEN')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, fill='lightgray')
       self.UMLmodel.coords(new_obj.gf1.handler,218.125,287.0)
       self.UMLmodel.itemconfig(new_obj.gf1.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, fill='black')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, text='init')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, width='0')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, font='font87440840')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, anchor='center')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, justify='left')
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj172.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj172)
    self.globalAndLocalPostcondition(self.obj172, rootNode)
    self.obj172.postAction( rootNode.CREATE )

    self.obj173=Basic(self)
    self.obj173.isGraphObjectVisual = True

    if(hasattr(self.obj173, '_setHierarchicalLink')):
      self.obj173._setHierarchicalLink(False)

    # is_default
    self.obj173.is_default.setValue((None, 0))
    self.obj173.is_default.config = 0

    # name
    self.obj173.name.setValue('moving')

    # exit_action
    self.obj173.exit_action.setValue('\n')
    self.obj173.exit_action.setHeight(15)

    # enter_action
    self.obj173.enter_action.setValue('\n')
    self.obj173.enter_action.setHeight(15)

    self.obj173.graphClass_= graph_Basic
    if self.genGraphics:
       new_obj = graph_Basic(435.0,337.0,self.obj173)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Basic", new_obj.tag)
       self.UMLmodel.coords(new_obj.gf3.handler,447.0,340.0,465.0,358.0)
       self.UMLmodel.itemconfig(new_obj.gf3.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, width='2.0')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, outline='DARKBLUE')
       self.UMLmodel.itemconfig(new_obj.gf3.handler, fill='lightgray')
       self.UMLmodel.coords(new_obj.gf1.handler,458.125,367.0)
       self.UMLmodel.itemconfig(new_obj.gf1.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, fill='black')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, text='moving')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, width='0')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, font='font90189656')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, anchor='center')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, justify='left')
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj173.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj173)
    self.globalAndLocalPostcondition(self.obj173, rootNode)
    self.obj173.postAction( rootNode.CREATE )

    self.obj174=Hyperedge(self)
    self.obj174.isGraphObjectVisual = True

    if(hasattr(self.obj174, '_setHierarchicalLink')):
      self.obj174._setHierarchicalLink(False)

    # name
    self.obj174.name.setValue('')
    self.obj174.name.setNone()

    # broadcast
    self.obj174.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj174.broadcast.setHeight(15)

    # guard
    self.obj174.guard.setValue('1')

    # trigger
    self.obj174.trigger.setValue('start')

    # action
    self.obj174.action.setValue('ctl = [PARAMS]\nbid = counter\ncounter += 1\ngid, pos, speed = ctl.init(bid)\nballs[bid] = {\'pos\': pos, \'speed\': speed, \'gid\':gid}\nwidth = ctl.getWidth()\nheight = ctl.getHeight()\n')
    self.obj174.action.setHeight(15)

    # broadcast_to
    self.obj174.broadcast_to.setValue('')
    self.obj174.broadcast_to.setNone()

    # display
    self.obj174.display.setValue('start')

    self.obj174.graphClass_= graph_Hyperedge
    if self.genGraphics:
       new_obj = graph_Hyperedge(336.074772771,309.027520373,self.obj174)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [0.93999999999999961, 1.0399999999999998]
    else: new_obj = None
    self.obj174.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj174)
    self.globalAndLocalPostcondition(self.obj174, rootNode)
    self.obj174.postAction( rootNode.CREATE )

    self.obj175=Hyperedge(self)
    self.obj175.isGraphObjectVisual = True

    if(hasattr(self.obj175, '_setHierarchicalLink')):
      self.obj175._setHierarchicalLink(False)

    # name
    self.obj175.name.setValue('')
    self.obj175.name.setNone()

    # broadcast
    self.obj175.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj175.broadcast.setHeight(15)

    # guard
    self.obj175.guard.setValue('1')

    # trigger
    self.obj175.trigger.setValue('AFTER(0.01)')

    # action
    self.obj175.action.setValue('for b in balls: ctl.bounce(b, 0.01)\n')
    self.obj175.action.setHeight(15)

    # broadcast_to
    self.obj175.broadcast_to.setValue('')
    self.obj175.broadcast_to.setNone()

    # display
    self.obj175.display.setValue('AFTER(0.01)')

    self.obj175.graphClass_= graph_Hyperedge
    if self.genGraphics:
       new_obj = graph_Hyperedge(684.5,170.5,self.obj175)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj175.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj175)
    self.globalAndLocalPostcondition(self.obj175, rootNode)
    self.obj175.postAction( rootNode.CREATE )

    # Connections for obj172 (graphObject_: Obj46) named init
    self.drawConnections(
(self.obj172,self.obj174,[223.80634552792415, 273.43524907991576, 336.07477277111889, 309.02752037329122],"bezier", 2) )
    # Connections for obj173 (graphObject_: Obj47) named moving
    self.drawConnections(
(self.obj173,self.obj175,[460.33351264266958, 341.04309608307045, 580.99999999999977, 120.00000000000009, 684.5, 170.5],"bezier", 3) )
    # Connections for obj174 (graphObject_: Obj48) named 
    self.drawConnections(
(self.obj174,self.obj173,[336.07477277111889, 309.02752037329122, 448.34320001431365, 344.61979166666663],"bezier", 2) )
    # Connections for obj175 (graphObject_: Obj50) named 
    self.drawConnections(
(self.obj175,self.obj173,[684.49999999999989, 170.49999999999991, 787.99999999999977, 221.0, 463.92020890121103, 344.49479166666663],"bezier", 3) )

newfunction = ballSingle_MDL

loadedMMName = 'DCharts'

atom3version = '0.3'
