Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active August 4, 2019 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/3378073 to your computer and use it in GitHub Desktop.
Save kenwebb/3378073 to your computer and use it in GitHub Desktop.
Petri nets - Jensen protocol example
<Network>
<PlacePN roleName="A"/>
<PlacePN roleName="SP"/>
<PlacePN roleName="SA"/>
<PlacePN roleName="C"/>
<TransitionPN roleName="TransmitPacket">
<InputArcs>
<InputArc weight="1" connector="ancestor::Network/PlacePN[@roleName='A']"/>
<InputArc weight="0" connector="ancestor::Network/PlacePN[@roleName='SP']"/>
</InputArcs>
<OutputArcs>
<OutputArc weight="1" connector="ancestor::Network/../Receiver/PlacePN[@roleName='B']"/>
<OutputArc weight="0" connector="ancestor::Network/PlacePN[@roleName='SP']"/>
</OutputArcs>
</TransitionPN>
<TransitionPN roleName="TransmitAck">
<InputArcs>
<InputArc weight="1" connector="ancestor::Network/PlacePN[@roleName='C']"/>
<InputArc weight="0" connector="ancestor::Network/PlacePN[@roleName='SA']"/>
</InputArcs>
<OutputArcs>
<OutputArc weight="1" connector="ancestor::Network/../Sender/PlacePN[@roleName='D']"/>
<OutputArc weight="0" connector="ancestor::Network/PlacePN[@roleName='SA']"/>
</OutputArcs>
</TransitionPN>
</Network>
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/wb/ (C) Ken Webb Fri Aug 17 2012 10:01:24 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Petri nets - Jensen protocol example
Description:
Url: http://www.primordion.com/Xholon/wb/
InternalName:
YoutubeId:
Keywords:
My Notes
--------
see Jensen, Kurt (1996) "An Introduction to the Practical Use of Coloured Petri Nets".
How to run the Java app that's included on this Xholon Workbook page::
(1) Click the "Save locally" button at the top of this page.
This will assemble the contents of the workbook into a separate web browser page.
Position the cursor in the new page and do "Select All" (Ctrl-A).
(2) Click the second "Launch" button further down on this page (http://www.primordion.com/Xholon/jnlp/Chameleon_0.jnlp).
This will start the Chameleon Java application. It's called Chameleon because if can be changed into anything else.
Select "File --> Open".
(3) Drag the contents of the workbook into the Chameleon app.
Just click on the selected text in the new browser window, and drag it anywhere within the Chameleon window.
(4) Click the "Refresh" button in the Chameleon window.
Explore the model to confirm that it has the same structure that's specified on this page.
Click the "Start" button to start the simulation.
If the Java Console is enabled, you may see Sequence Diagram messages there.
Use the "Pause" and "Step" buttons to pause, unpause, and single-step the simulation.
If there are no Sequence Diagram messages::
Right-click any Transition node in the Chameleon app, and select "Attributes".
Change the value of ShouldWriteSequenceDiagram from "false" to "true".
Close the Attributes window.
To view the messages as a graphical Sequence Diagram::
Copy all or some of the messages starting with the "title" line.
Go to "http://www.websequencediagrams.com/", and paste the messages into the textarea on that page.
Example of Sequence Diagram text:
title Xholon Chameleon
sender_41->network_59: SendPacket
network_59->receiver_78: TransmitPacket
receiver_78->network_59: ReceivePacket
network_59->sender_41: TransmitAck
sender_41->sender_41: ReceiveAck
sender_41->network_59: SendPacket
network_59->receiver_78: TransmitPacket
receiver_78->network_59: ReceivePacket
]]></Notes>
<script implName="lang:python:inline:"><![CDATA[
]]></script>
<script implName="lang:javascript:inline:"><![CDATA[
]]></script>
<_-.XholonClass>
<ProtocolSystem/>
<Sender/>
<Network/>
<Receiver/>
</_-.XholonClass>
<xholonClassDetails>
</xholonClassDetails>
<ProtocolSystem xmlns:xi="http://www.w3.org/2001/XInclude">
<Sender>
<PlacePN roleName="Send" token="1"/>
<PlacePN roleName="NextSend" token="1"/>
<PlacePN roleName="D"/>
<TransitionPN roleName="SendPacket">
<InputArcs>
<InputArc weight="1" connector="ancestor::Sender/PlacePN[@roleName='Send']"/>
<InputArc weight="1" connector="ancestor::Sender/PlacePN[@roleName='NextSend']"/>
</InputArcs>
<OutputArcs>
<OutputArc weight="1" connector="ancestor::ProtocolSystem/Network/PlacePN[@roleName='A']"/>
<OutputArc weight="1" connector="ancestor::Sender/PlacePN[@roleName='Send']"/>
<OutputArc weight="0" connector="ancestor::Sender/PlacePN[@roleName='NextSend']"/>
</OutputArcs>
</TransitionPN>
<TransitionPN roleName="ReceiveAck">
<InputArcs>
<InputArc weight="1" connector="ancestor::Sender/PlacePN[@roleName='D']"/>
<InputArc weight="0" connector="ancestor::Sender/PlacePN[@roleName='NextSend']"/>
</InputArcs>
<OutputArcs>
<OutputArc weight="1" connector="ancestor::Sender/PlacePN[@roleName='NextSend']"/>
</OutputArcs>
</TransitionPN>
</Sender>
<!-- treat Network like a CPNTools subpage -->
<!--<xi:include href="https://raw.github.com/gist/3378073/network_csh.xml"/>-->
<xi:include href="https://gist.github.com/kenwebb/3378073/raw/network_csh.xml"/>
<Receiver>
<PlacePN roleName="B"/>
<PlacePN roleName="Received"/>
<PlacePN roleName="NextRec"/>
<TransitionPN roleName="ReceivePacket">
<InputArcs>
<InputArc weight="1" connector="ancestor::Receiver/PlacePN[@roleName='B']"/>
<InputArc weight="0" connector="ancestor::Receiver/PlacePN[@roleName='Received']"/>
<InputArc weight="0" connector="ancestor::Receiver/PlacePN[@roleName='NextRec']"/>
</InputArcs>
<OutputArcs>
<OutputArc weight="1" connector="ancestor::ProtocolSystem/Network/PlacePN[@roleName='C']"/>
<OutputArc weight="0" connector="ancestor::Receiver/PlacePN[@roleName='Received']"/>
<OutputArc weight="0" connector="ancestor::Receiver/PlacePN[@roleName='NextRec']"/>
</OutputArcs>
</TransitionPN>
</Receiver>
<PetriNet roleName="one">
<QueueTransitions connector="ancestor::ProtocolSystem"/>
</PetriNet>
</ProtocolSystem>
<Blockbehavior implName="lang:python:inline:"><![CDATA[
]]></Blockbehavior>
<Blockbehavior implName="lang:javascript:inline:"><![CDATA[
]]></Blockbehavior>
<Blockbehavior implName="lang:webEditionjs:inline:"><![CDATA[
]]></Blockbehavior>
<Blockbehavior implName="lang:bsh:inline:"><![CDATA[
]]></Blockbehavior>
<Blockbehavior implName="lang:jruby:inline:"><![CDATA[
]]></Blockbehavior>
<Blockbehavior implName="lang:groovy:inline:"><![CDATA[
]]></Blockbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Petri nets - Jensen protocol example</title>
<rect id="ProtocolSystem" fill="#98FB98" height="50" width="50" x="25" y="0"/>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment