Пример #1
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Charles Y. Choi

from sequenceplot import SequenceObject, SequenceDiagram

# declare client and server instances
client = SequenceObject('c: client')
server = SequenceObject('s: server')

# declare diagram instance, adding client and server to the diagram.
diagram = SequenceDiagram([client, server])

# configure diagram parameters
diagram.setParam('objectSpacing', 1.75)

# Start a frame named 'Login'
frameName = diagram.beginFrame(client, 'Login')
# Have the client call the method "login(username, password)" on the server with then responds with "sessionID, userInfo".
client.callMethod(server, 'login(username, password)', response='sessionID, userInfo')
# End the previously declared frame
diagram.endFrame(server, frameName)

# Render the diagram into an SVG file named "authentication.svg".
diagram.svg('authentication')


Пример #2
0
# This example is drawn from the example from the UMLGraph documentation
# http://umlgraph.org/doc/uml-appa.html

from sequenceplot import SequenceObject, Placeholder, SequenceDiagram

# declare objects
e = Placeholder()
t = SequenceObject("t:thread")
o = SequenceObject(":Toolkit")
p = Placeholder()

diagram = SequenceDiagram([e, t, o, p])
diagram.setParam('objectSpacing', 1.75)

# use pushMethod() to nest activations
e.pushMethod(t, "a1: run(3)")
t.pushMethod(o, "run()")
o.callMethod(o, "callbackLoop()")

o.createInstance(p, "p:Peer")
o.callMethod(p, "handleExpose()", "", responseSync=True)
o.destroyInstance(p)

t.inactive()
o.inactive()
diagram.step(2)

# Render the diagram into an SVG file named "authentication.svg".
diagram.svg('nestedActivation')
t.inactive()

c.active()
c.createInstance(a1, "a1:TransCheck", sync=False)
a1.active()

c.createInstance(a2, "a2:TransCheck", sync=False)
a2.active()

a1.message(c, "ok")
c.callMethod(c, "all done?")
c.inactive()
a1.delete()

diagram.step()

c.active()
a2.message(c, "ok")
c.callMethod(c, "all done?")
c.inactive()
a2.delete()

c.message(t, "beValid")

t.active()
diagram.step()

# Render the diagram into an SVG file
diagram.svg('concurrentProcessesActivations')

Пример #4
0
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Charles Y. Choi

from sequenceplot import SequenceObject, SequenceDiagram

# declare client and server instances
client = SequenceObject('c: client')
server = SequenceObject('s: server')

# declare diagram instance, adding client and server to the diagram.
diagram = SequenceDiagram([client, server])

# configure diagram parameters
diagram.setParam('objectSpacing', 1.75)

client.callMethod(server, 'login(username, password)', response='sessionID, userInfo')

c1 = diagram.comment(server,
                     'This is an\nexample comment\nconnected to the\nclient and server.',
                     'down 0.35 left 0.5',
                     'wid 1.5 ht 0.7')

diagram.connectToComment(client, c1)
diagram.step(5)

# Render the diagram into an SVG file
diagram.svg('comment')

diagram = SequenceDiagram([s, w, c, r])
diagram.setParam('objectSpacing', 0.5)

diagram.step()
w.active()
diagram.async()

s.message(w, 'liftReceiver')
diagram.sync()
w.message(s, 'setDialTone()')
diagram.async()
s.message(w, '*dialDigit(d)')
w.lconstraint('{dialing.executionTime < 30s}')
w.callMethod(w, 'routeCalls(s,n)')

w.createInstance(c, 'c:Convers')
c.active()
c.pushMethod(r, 'ring()')
diagram.async()
r.message(c, 'liftReceiver')
diagram.sync()
c.message(w, 'connect(r,s)')
w.message(s, 'connect(r)')
w.message(r, '')
w.lconstraint('connect(s)')

diagram.step()

# Render the diagram into an SVG file named "authentication.svg".
diagram.svg('lifelineConstraints')
Пример #6
0
diagram.params.objectSpacing = 0.5

diagram.step()
c.active()
c.createInstance(t, ':Transaction')
diagram.oconstraint('{Transient}')

c.pushMethod(t, "setActions(a,d,o)")

diagram.sync()

t.message(p, 'setValues(d,3,4)')
p.active()
diagram.step()
p.inactive()

t.message(p, 'setValues(a, "CO")')
p.active()
diagram.step()
p.inactive()

c.popMethod(t, "committed")

c.destroyInstance(t)
c.inactive()
diagram.step()

# Render the diagram into an SVG file
diagram.svg('createDestroy')

Пример #7
0
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Charles Y. Choi

# This example is drawn from the example from the UMLGraph documentation
# http://umlgraph.org/doc/uml-appa.html

from sequenceplot import SequenceObject, Actor, SequenceDiagram

# declare objects
a = Actor()
t = SequenceObject(':OTager')
f = SequenceObject(':OFulfill')

diagram = SequenceDiagram([a, t, f])

diagram.step()
a.message(t, 'submitOrder')
t.message(f, 'placeOrder')
f.message(a, 'acknowledgeOrder')
diagram.step()

# Render the diagram into an SVG file
diagram.svg('externalActor')