from graph_ASG_ERmetaMetaModel import *
from stickylink import *
from widthXfillXdecoration import *
from ASG_DCharts import *
from ASG_DCharts import *
from Composite import *
from Basic import *
from History import *
from Orthogonal import *
from visual_settings import *
from Port import *
from Server import *
from contains import *
from Hyperedge import *
from orthogonality import *
from connection import *
from ATOM3BottomType import *
from ATOM3String import *
from ATOM3Constraint import *
from ATOM3Attribute import *
from ATOM3Enum import *
from ATOM3Appearance import *
from ATOM3Float import *
from ATOM3Connection import *
from ATOM3Boolean import *
from ATOM3Link import *
from ATOM3Text import *
from ATOM3Integer import *
from ATOM3List import *
from ATOM3Port import *
from ATOM3MSEnum import *

def Client(self, rootNode):

    self.globalPrecondition( rootNode )

    self.obj29=Basic(self)

    self.obj29.is_default.setValue((None, 1))
    self.obj29.is_default.config = 0
    self.obj29.name.setValue('NOCHAT')
    self.obj29.exit_action.setValue('\n')
    self.obj29.enter_action.setValue('import random\nSelfID=random.randint(0, 65535)\nRandomMessages=["Hello, everyone!", "Have a nice day!", "How are you today?", "I feel very well today!", "The same to you!"]\nRequestMin=1\nRequestMax=3\nSendMin=1\nSendMax=5\n')
    self.obj29.graphClass_= graph_Basic
    if self.genGraphics:
       from graph_Basic import *
       new_obj = graph_Basic(106.0,170.0,self.obj29)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Basic", new_obj.tag)
       self.UMLmodel.coords(new_obj.gf3.handler,118.0,173.0,136.0,191.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,129.0,200.0)
       self.UMLmodel.itemconfig(new_obj.gf1.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, width='0')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, fill='black')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, text='NOCHAT')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, font='Helvetica -12')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, anchor='center')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, justify='left')
    else: new_obj = None
    self.obj29.graphObject_ = new_obj
    rootNode.addNode(self.obj29)
    self.globalAndLocalPostcondition(self.obj29, rootNode)

    self.globalPrecondition( rootNode )

    self.obj30=Basic(self)

    self.obj30.is_default.setValue((None, 0))
    self.obj30.is_default.config = 0
    self.obj30.name.setValue('CONNECTED')
    self.obj30.exit_action.setValue('\n\n')
    self.obj30.enter_action.setValue('\n\n')
    self.obj30.graphClass_= graph_Basic
    if self.genGraphics:
       from graph_Basic import *
       new_obj = graph_Basic(261.0,168.0,self.obj30)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Basic", new_obj.tag)
       self.UMLmodel.coords(new_obj.gf3.handler,273.0,171.0,291.0,189.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,284.0,198.0)
       self.UMLmodel.itemconfig(new_obj.gf1.handler, stipple='')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, width='0')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, fill='black')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, text='CONNECTED')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, font='Helvetica -12')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, anchor='center')
       self.UMLmodel.itemconfig(new_obj.gf1.handler, justify='left')
    else: new_obj = None
    self.obj30.graphObject_ = new_obj
    rootNode.addNode(self.obj30)
    self.globalAndLocalPostcondition(self.obj30, rootNode)

    self.globalPrecondition( rootNode )

    self.obj31=Port(self)

    self.obj31.is_out.setValue((None, 1))
    self.obj31.is_out.config = 0
    self.obj31.name.setValue('request')
    self.obj31.is_in.setValue((None, 1))
    self.obj31.is_in.config = 0
    self.obj31.graphClass_= graph_Port
    if self.genGraphics:
       from graph_Port import *
       new_obj = graph_Port(75.0,299.0,self.obj31)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Port", new_obj.tag)
    else: new_obj = None
    self.obj31.graphObject_ = new_obj
    rootNode.addNode(self.obj31)
    self.globalAndLocalPostcondition(self.obj31, rootNode)

    self.globalPrecondition( rootNode )

    self.obj32=Port(self)

    self.obj32.is_out.setValue((None, 1))
    self.obj32.is_out.config = 0
    self.obj32.name.setValue('message')
    self.obj32.is_in.setValue((None, 1))
    self.obj32.is_in.config = 0
    self.obj32.graphClass_= graph_Port
    if self.genGraphics:
       from graph_Port import *
       new_obj = graph_Port(75.0,370.0,self.obj32)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Port", new_obj.tag)
    else: new_obj = None
    self.obj32.graphObject_ = new_obj
    rootNode.addNode(self.obj32)
    self.globalAndLocalPostcondition(self.obj32, rootNode)

    self.globalPrecondition( rootNode )

    self.obj33=Server(self)

    self.obj33.id.setValue('ChatRoom')
    self.obj33.name_pattern.setValue('ChatRoom')
    self.obj33.graphClass_= graph_Server
    if self.genGraphics:
       from graph_Server import *
       new_obj = graph_Server(151.0,329.0,self.obj33)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Server", new_obj.tag)
    else: new_obj = None
    self.obj33.graphObject_ = new_obj
    rootNode.addNode(self.obj33)
    self.globalAndLocalPostcondition(self.obj33, rootNode)

    self.globalPrecondition( rootNode )

    self.obj34=Hyperedge(self)

    self.obj34.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj34.guard.setValue('1')
    self.obj34.trigger.setValue('AFTER(random.uniform(RequestMin, RequestMax))')
    self.obj34.name.setValue('')
    self.obj34.action.setValue('room=random.randint(0, 1)\n[DUMP(time.ctime(time.time()))]\n[DUMP("(Client %d) A connection request is sent to chat room %d." % (SelfID, room))]\n[EVENT("request.Request", [room, SelfID])]\n')
    self.obj34.broadcast_to.setValue('')
    self.obj34.display.setValue('after(...)')
    self.obj34.graphClass_= graph_Hyperedge
    if self.genGraphics:
       from graph_Hyperedge import *
       new_obj = graph_Hyperedge(128.0,172.0,self.obj34)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
    else: new_obj = None
    self.obj34.graphObject_ = new_obj
    rootNode.addNode(self.obj34)
    self.globalAndLocalPostcondition(self.obj34, rootNode)

    self.globalPrecondition( rootNode )

    self.obj35=Hyperedge(self)

    self.obj35.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj35.guard.setValue('[PARAMS][0]==SelfID')
    self.obj35.trigger.setValue('request.Reject')
    self.obj35.name.setValue('')
    self.obj35.action.setValue('[DUMP(time.ctime(time.time()))]\n[DUMP("(Client %d) Rejected by chat room %d." % (SelfID, [PARAMS][1]))]\n')
    self.obj35.broadcast_to.setValue('')
    self.obj35.display.setValue('request.Reject')
    self.obj35.graphClass_= graph_Hyperedge
    if self.genGraphics:
       from graph_Hyperedge import *
       new_obj = graph_Hyperedge(129.0,190.0,self.obj35)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
    else: new_obj = None
    self.obj35.graphObject_ = new_obj
    rootNode.addNode(self.obj35)
    self.globalAndLocalPostcondition(self.obj35, rootNode)

    self.globalPrecondition( rootNode )

    self.obj36=Hyperedge(self)

    self.obj36.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj36.guard.setValue('[PARAMS][0]==SelfID')
    self.obj36.trigger.setValue('request.Accept')
    self.obj36.name.setValue('')
    self.obj36.action.setValue('RoomNo=[PARAMS][1]\n[DUMP(time.ctime(time.time()))]\n[DUMP("(Client %d) Accepted by chat room %d." % (SelfID, RoomNo))]\n')
    self.obj36.broadcast_to.setValue('')
    self.obj36.display.setValue('request.Accept')
    self.obj36.graphClass_= graph_Hyperedge
    if self.genGraphics:
       from graph_Hyperedge import *
       new_obj = graph_Hyperedge(169.0,221.0,self.obj36)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
    else: new_obj = None
    self.obj36.graphObject_ = new_obj
    rootNode.addNode(self.obj36)
    self.globalAndLocalPostcondition(self.obj36, rootNode)

    self.globalPrecondition( rootNode )

    self.obj37=Hyperedge(self)

    self.obj37.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj37.guard.setValue('1')
    self.obj37.trigger.setValue('AFTER(random.uniform(SendMin, SendMax))')
    self.obj37.name.setValue('')
    self.obj37.action.setValue('msg=RandomMessages[random.randint(0, len(RandomMessages)-1)]\n[DUMP(time.ctime(time.time()))]\n[DUMP("(Client %d) Says: " % SelfID + msg)]\n[EVENT("message.Send", [RoomNo, SelfID, msg, time.time()])]\n')
    self.obj37.broadcast_to.setValue('')
    self.obj37.display.setValue('after(...)')
    self.obj37.graphClass_= graph_Hyperedge
    if self.genGraphics:
       from graph_Hyperedge import *
       new_obj = graph_Hyperedge(286.0,165.0,self.obj37)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
    else: new_obj = None
    self.obj37.graphObject_ = new_obj
    rootNode.addNode(self.obj37)
    self.globalAndLocalPostcondition(self.obj37, rootNode)

    self.globalPrecondition( rootNode )

    self.obj38=Hyperedge(self)

    self.obj38.broadcast.setValue('# return an instance of DEVSevent or None\nreturn None\n')
    self.obj38.guard.setValue('[PARAMS][0]==SelfID')
    self.obj38.trigger.setValue('message.Broadcast')
    self.obj38.name.setValue('')
    self.obj38.action.setValue('sender=[PARAMS][1]\nmsg=[PARAMS][2]\n[DUMP(time.ctime(time.time()))]\n[DUMP("(Client %d) Received message \\"" % SelfID + msg + "\\" from client %d." % sender)]\n')
    self.obj38.broadcast_to.setValue('')
    self.obj38.display.setValue('message.Broadcast')
    self.obj38.graphClass_= graph_Hyperedge
    if self.genGraphics:
       from graph_Hyperedge import *
       new_obj = graph_Hyperedge(304.0,184.0,self.obj38)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("Hyperedge", new_obj.tag)
    else: new_obj = None
    self.obj38.graphObject_ = new_obj
    rootNode.addNode(self.obj38)
    self.globalAndLocalPostcondition(self.obj38, rootNode)

    self.globalPrecondition( rootNode )

    self.obj39=connection(self)

    self.obj39.server_port.setValue('request')
    self.obj39.graphClass_= graph_connection
    if self.genGraphics:
       from graph_connection import *
       new_obj = graph_connection(141.0,318.5,self.obj39)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("connection", new_obj.tag)
    else: new_obj = None
    self.obj39.graphObject_ = new_obj
    rootNode.addNode(self.obj39)
    self.globalAndLocalPostcondition(self.obj39, rootNode)

    self.globalPrecondition( rootNode )

    self.obj40=connection(self)

    self.obj40.server_port.setValue('message')
    self.obj40.graphClass_= graph_connection
    if self.genGraphics:
       from graph_connection import *
       new_obj = graph_connection(137.0,388.5,self.obj40)
       new_obj.DrawObject(self.UMLmodel)
       self.UMLmodel.addtag_withtag("connection", new_obj.tag)
    else: new_obj = None
    self.obj40.graphObject_ = new_obj
    rootNode.addNode(self.obj40)
    self.globalAndLocalPostcondition(self.obj40, rootNode)
    self.drawConnections((self.obj29,self.obj34,[127.0, 173.0, 128.0, 172.0], 0, 2), (self.obj29,self.obj35,[127.0, 191.0, 129.0, 190.0],"bezier", 2), (self.obj29,self.obj36,[136.0, 182.0, 169.0, 221.0], 0, 2), (self.obj30,self.obj37,[274.0, 180.0, 185.0, 166.0, 319.0, 92.0, 286.0, 165.0],"bezier", 4), (self.obj30,self.obj38,[282.0, 189.0, 244.0, 278.0, 381.0, 196.0, 304.0, 184.0],"bezier", 4), (self.obj31,self.obj39,[91.0, 319.0, 141.0, 318.5], 0, 2), (self.obj32,self.obj40,[91.0, 390.0, 137.0, 388.5], 0, 2), (self.obj34,self.obj29,[128.0, 172.0, 115.0, 128.0, 135.0, 113.0, 224.0, 181.0, 136.0, 182.0],"bezier", 5), (self.obj35,self.obj29,[129.0, 190.0, 154.0, 276.0, 30.0, 184.0, 119.0, 182.0],"bezier", 4), (self.obj36,self.obj30,[169.0, 221.0, 228.0, 280.0, 274.0, 180.0],"bezier", 3), (self.obj37,self.obj30,[286.0, 165.0, 282.0, 171.0], 0, 2), (self.obj38,self.obj30,[304.0, 184.0, 291.0, 180.0], 0, 2), (self.obj39,self.obj33,[141.0, 318.5, 160.0, 344.0], 0, 2), (self.obj40,self.obj33,[137.0, 388.5, 160.0, 373.0], 0, 2) )

newfunction = Client

loadedMMName = 'DCharts'
