• Ingen resultater fundet

end handle Bind = > CPN’bf() in

65 CPN’bf()

end

fun CPN’bf1() =

let ( B p (x2,y2) binding operator )

val = CPN’BxB pims21.init res(CPN’place4.mark CPN’inst)

70 fun CPN’bf() = let

( Pick random token from place ) val (x2,y2) =

CPN’BxB pims21.random res BindFatalFailure

75 (CPN’place4.mark CPN’inst)

in

( ( B g z2=y2 binding operator ) ( let

val z 2 = y2

80 in

(CPN’bh1::= { z2=z2,y2=y2,x2=x2 } ; ( binding found ) CPN’bf2())

end handle Bind = > raise BindFailure ) handle BindFailure = > CPN’bf())

85 end handle Bind => CPN’bf() in

CPN’bf() end in

90 CPN’bf1() end

( Function for making an enabled binding occur ) fun CPN’occfun ({z2,y2,x2},{y1,x1}) =

95 let

(∗ Remove tokens from input places ∗)

val = (CPN’BxB pims21.delete(CPN’place6.mark CPN’inst,(x1,y1));

CPN’B pims1.delete(CPN’place7.mark CPN’inst,x1);

CPN’BxB pims21.delete(CPN’place4.mark CPN’inst,(x2,y2)));

100 ( Add tokens to output places )

val = (CPN’B pims1.insert(CPN’place5.mark CPN’inst,z2));

in

(CPN’Sim.is executed, ...)

105 end

in ( CPN’transition8 ) if CPN’enough tokens then

(CPN’bindfun();

110 CPN’occfun (CPN’hd(!CPN’bh1),CPN’hd(!CPN’bh2)) ) handle BindFatalFailure = > (CPN’answer,nil) else (CPN’answer,nil)

end

Communication with Design/CPN

GuyGallasch and LarsMichaelKristensen

ComputerSystemsEngineering Centre

SchoolofElectricalandInformationEngineering

UniversityofSouthAustralia

MawsonLakesCampus,SA5095, AUSTRALIA

Email:fgalgy002@students.unisa.edu.au,lars.kristensen@unisa.edu.aug

Abstract. In this paper the development of Comms/CPN is presented. Comms/CPN is a

Standard MLlibrary that augmentsDesign/CPNwiththe necessaryinfrastructureto

estab-lishcommunication between CPNmodelsand external processes. Comms/CPN is potentially

benecialinanumberofareassuchasallowingexternalvisualisationsofsimulations,providing

CPNmodelswiththeirownGraphicalUserInterface,andallowingCPNmodelstointeractwith

thephysicalenvironment.Comms/CPNhasbeensuccessfullyappliedforprovidingexternal

vi-sualisationofthesimulationofaCPNmodelwithintheareaofavionicsmissionsystems.

1 Introduction

ColouredPetriNets(CPNs)[11,13],whenconstructedandsimulatedusingtheDesign/CPN

tool [21], are restricted in their ability to interact with external processes. Extending the

Design/CPN tool by providing a communication infrastructure allows communication to

be established between CPN models and external processes. The Comms/CPN library [6]

presentedinthispaperhasbeendevelopedto extendDesign/CPNwithsuchexternal

com-municationfacilities.

Themotivationbehinddevelopingexternalcommunicationfacilitiescomesfromthedesire

to visualise the simulation of CPN models. As demonstrated in [2,23], it is often benecial

to extendCPN modelswithapplication specic graphics. Thebehaviorof the systemunder

consideration can be visualised using dierent kinds of graphical feedback. This provides a

view of system behavior useful for system developers and analysts, and can also be useful

for conveying knowledge and results about CPN models to people not familiar with CPN

modellingandanalysis.

Currently,Design/CPNprovides visualisationcapabilitiesintwo forms. Therst isthe

token game which displays the simulation of a CPN model in a very detailed fashion. The

second isbyusinghigh-levelapplicationspecicgraphicsthatcanbeaddedontopofaCPN

model. Mimic/CPN [1] and the Message Sequence Chart library [18] provide such

high-level graphics. However these methods are not always satisfactory. The token game is often

too detailed, and the application specic graphics are sometimes limited in capability and

capacity,andaretiedto theGraphicalUserInterface(GUI)of Design/CPN.It istherefore

of interest to conduct visualisationusing an external application. External applications can

bedevelopedwithgreatergraphicalcapabilitiesthanthoseofDesign/CPN,andthereisthe

potential to executetheexternal applicationon a remotemachine.

The Comms/CPN library has been developed to allow communication between

De-sign/CPNandexternalprocessesviaTCP/IP[4].ThemainbenetsthattheComms/CPN

infrastructure willprovideinthecontext ofvisualisationare:

theirsimulation independentlyoftheDesign/CPN GUI.

{ The infrastructure provides exibility, since other graphical libraries and packages are

likelyto providebetter supportforvisualisationthanDesign/CPN.

{ Theinfrastructure makesitpossibletodo thevisualisationon remotemachinesprovided

they supportTCP/IP communication.

It should be stressed that Comms/CPN is not limited to use in external visualisation.

Comms/CPN hasthepotentialtobebenecialinmanyotherareas.Asanexample,itcould

be used to provide CPN modelswith their own GUI. The Design/CPN simulator is built

on theStandardML(SML)[20,27]compilerand Comms/CPNisalsoimplementedinSML.

This means that theDesign/CPN GUI could be separated from thesimulator, and a GUI

specictotheCPNmodelcouldbeusedinstead.Anexamplewherethismaybeusefuliswhen

applying CPN modelsin decisionmaking processes, asshown in [15]. Using Comms/CPN,

it isalso conceivable that CPNmodelscouldinteractwiththephysicalenvironment.

Exam-plesincludetemperatureandlightsensors,keypads,anddisplays(althoughsuchexperiments

have notyetbeenconducted).Situationsmayalso arisewherecomputationallyexpensive

al-gorithmsandproceduresareneededwithinDesign/CPN.WithComms/CPN,thesecanbe

implementedandexecutedon remotemachines,and theresultscanbesentbacktotheCPN

model.An exampleofthiscan be foundin[17] wherethecondensedstate space toolof

De-sign/CPN [12] relied on theGAPprogrammingenviroment [7]foreÆcient manipulationof

algebraicgroups.Moregenerally,Comms/CPN makesitpossibletointegrateDesign/CPN

and external applicationsviaTCP/IP.

Comms/CPN was developed as a Practical Industrial Experience project in Computer

Systems Engineering at theUniversity of SouthAustralia. The development is part of a

re-searchprojectbeingundertakenbytheAirOperationsDivision(AOD) withintheAustralian

Defence ScienceandTechnologyOrganisation(DSTO)[24]andtheComputerSystems

Engi-neeringCentre(CSEC)[3]attheUniversityofSouthAustralia.Itinvolvesthemodellingand

analysis ofAvionics MissionSystems(AMS) fortestingand evaluation.Partofthisresearch

involvesprovidingvisualisationofthesimulationofCPNmodelsbyextendingthem with

ap-plication specic graphics.The externalcommunicationfacilitiesprovidedbyComms/CPN

allow this visualisation to take place using an external visualisation package. The external

visualisation package itself is currently in the process of being developed, but a prototype

demonstrating a proof-of-concept exists.

The development of Comms/CPN is based upon previous work, in particular the

Mas-ter's thesis [19]. The work done in [19] however has some drawbacks as it was primarily

an encapsulation of TCP/IP. Only one connection could be opened, and this connection is

made to a locationxed at compiletime, i.e. it could not be changed without re-switching

the CPN model.Comms/CPN extends the work presented in [19] in several ways. Firstly,

Comms/CPN allows dynamiccreation of connections(also duringthesimulationof a CPN

model),the externalprocessto which connectionsare being made is notxed,and multiple

simultaneous connections are supported. Secondly,Comms/CPN implements a protocol on

top of TCP/IP for passing messages between Design/CPN and the external application.

It is planned to make Comms/CPN available for public use via the Design/CPN home

page [21].

This paper is organised as follows. Section 2 provides a description of the design and

requirements of the Comms/CPN library. Section 3 describes the implementation of the

ulationof an AMS CPN modelis presented inSection 4.Section 5 sumsup the conclusions

and outlines future work in further developing Comms/CPN. The reader is assumed to be

familiarwithCPN modelsand theDesign/CPNtool.

2 Design Overview and Requirements