• Ingen resultater fundet

TCP/IP

Fig.6.Comms/CPNinthecontextofexternalvisualisation.

Theexternalvisualisationpackageiscurrentlyunderdevelopment.Itisbeingimplemented

in Java [10] and consists of two main modules. The AMS Visualisation module is the

mod-ule that provides the visualisation facilities. This module has been implemented using the

Java Swing library [9]. The Java/CPN module is thepeer module of Comms/CPN at the

Java side.The Java/CPN module contains primitivessimilarto those in Comms/CPN to

enable communication, and implementsthe protocol described in Sect. 2.3. We describethe

Java/CPNmodule,theAMS visualisationmodule,andhowitinteractswiththeAMSCPN

modelinmore detail inthefollowingsubsections.

4.1 Java/CPN

The purpose of Java/CPN is to allow Java processes to communicate with Design/CPN

through Comms/CPN. The current implementation of Java/CPN is the minimal

imple-mentation necessary to enable communication. It incorporates the equivalent functionality

of theMessagingandCommunicationlayersfrom Comms/CPN.TheCommunicationLayer

functionalityfromComms/CPN and TCP/IPis already encapsulatedin theSocketobjects

providedbyJavathroughtheuseofSocketmethodsandtheinputandoutputstreams

avail-able from thesocketitself.

NoconnectionmanagementhasbeenimplementedwithinJava/CPNasthisisaminimal

implementation, howevertheimportantthing isthat itimplementsthe sameprotocolasthe

Messaging Layer fromComms/CPN asdescribed inSect. 2.3.The interface ofJava/CPN

is shown in Figure 7. As in Comms/CPN, generic send and receive functions have been

providedat the levelof theMessaging Layer, meaning thatsequences of bytes arepassedto

thesendmethodandreturnedfrom thereceivemethod.Theconnect,accept,anddisconnect

methods have beenprovidedat the level of the CommunicationLayer from Comms/CPN.

The deliberateattempt wasmade to make theinterfaceascloseto that ofComms/CPN as

possible. We describeeach of themethodswithinJava/CPN inmore detailbelow.

TheconnectmethodactsinthesamewayastheconnectmethodfromtheCommunication

Layer of Comms/CPN. It takesa host name and port numberasarguments, and attempts

to establish a connection as a client to the given port on the given host.This method does

not return a value.Once theconnection has been established(i.e. thesocket opened) input

import java.net.*;

import java.io.*;

public interface JavaCPNInterface

{

public void connect(String hostName, int port);

public void accept(int port);

public void send(ByteArrayInputStream sendBytes) throws SocketException;

public ByteArrayOutputStream receive() throws SocketException;

public void disconnect();

}

Fig.7.InterfacetoJava/CPN.

and output streams are extracted from thesocket to enable thetransmission and reception

of bytes.

Theacceptmethodalsoactsinthesamewayastheaccept methodfromthe

Communica-tion Layer ofComms/CPN. It takes aportnumberasan argument and,acting asaserver,

listens on the given port numberfor an incomingconnection request. When received, it

es-tablishes theconnection.Again, oncetheconnection hasbeenestablished,inputand output

streamsareextractedfrom thesocketto enablethetransmissionandreceptionofbytes.This

method doesnotreturna value.

The send method takes a ByteArrayInputStream object (a Java object for holding

se-quences of bytes,acting asinput)astheargument.The segmentationinto packets occursin

a similarwayto that which occursintheMessaging Layerof Comms/CPN. Bytes areread

from theByteArrayInputStreamobject,amaximumof 127at atime, andaheader addedas

described inSect. 2.3.The datapackets formedarethentransmittedto theexternalprocess

throughmethodsactingontheoutputstreamofthesocket.Thesendmethoddoesnotreturn

a value.

Thereceivemethodhasnoarguments.Itusesmethodsthatactontheinputstreamofthe

socketto rstlyreceiveaheaderbyte,and thenreceivethenumberofpayloadbytesspecied

in the header, from the external process. The payload bytes are stored in a

ByteArrayOut-putStream object (a Java object for storing bytes as output) as each segment of payload

data is received. This process is repeated until all data has been received for the current

implementation. Thereceive method returnstheByteArrayOutputStream object.

The disconnectmethodhas no arguments, and returnsno value.It acts inthesame way

as the disconnect function from the Communication Layer of Comms/CPN, except that it

also closes theinputand outputstreamsfrom thesocket before thesocket itself isclosed.

MethodsexternaltotheJava/CPNclassmustbeusedtoconvertfromdata(i.e.astring)

into a ByteArrayInputStream object, and from a ByteArrayOutputStream object backinto

data. This is akin to the encoding and decoding functions passed into the send and receive

functions of theConnectionManagement Layer inComms/CPN.

An Avionics Mission System (AMS) consists of a number of subcomponents connected via

a serialdata bus. The serialdatabus (SDB)is controlledbytheMissionControlComputer

(MCC),andsubcomponentscommunicatebytheexchangeofdataacrosstheSDB.Aninitial

CPNmodelofagenericAMS[16,22]hasbeenconstructed,capturingtheAMSatahighlevel

ofabstraction,includingcommunicationbetweensubcomponents.Inthissectionweshowhow

Comms/CPN can be usedto visualisethiscommunication.

A snapshot from a prototype display of the visualisation package is shown in Figure 8.

The displayshows the varioussubcomponent of theAMS connected to the SDB.Each time

twocomponentscommunicate viatheSDB,theexternalvisualisation package willshow this

communication by highlighting the two subcomponents and the SDB. The simulation will

then blockuntiltheuserclickson theContinue button.

Fig.8.Snapshotfromtheexternalvisualisationpackage.

In orderto provideexternalcommunicationfacilities,theComms/CPN librarymustbe

includedintheCPNmodel.ThisconsistsofloadinganumberofSMLlesusingtheSMLuse

command. FortheAMS CPNmodel,thevisualisationisdone usingcode segments attached

to the transitions.Openingand closing theconnection to theexternalVisualisationPackage

is donebyevaluatingSML code inauxiliaryboxes.

Of particular interest in providing visualisation of SDB communication is the

Serial-DataBus subpage of theAMS CPN model.Thispage isshown inFigure 9.Each

subcompo-nentoftheAMShasauniqueaddressassociatedwithit, andtheTransmittransitionon this

subpagemodelstheactualtransmissionofmessagesacrosstheSDB.Twoauxiliaryboxes

con-tainingComms/CPNprimitiveshavebeenaddedtothetopleftofthispage.Whenevaluated,

the rst opens a connection using the openConnection primitive in the

ConnManagement-Layer structure,and thesecond closestheconnection usingthecloseConnectionprimitivein

the ConnManagementLayer structure which constitutes the Connection Management Layer

of Comms/CPN.

A code segment has been attached to the Transmit transition. This code segment calls

the functionshowninFigure 10.The purposeof thisfunctionisto take theaddressesofthe

sender and receiver, map them to integers, transmit these two integersto theexternal

visu-alisation package, and thenawait a response before continuing the simulation.The external

visualisationpackage interpretsthetwo integersasthecorresponding senderand destination

and updates theanimationto reectthisdatatransfer.The Comms/CPN sendprimitiveis

SDB P I/O

ComponentxSDBMsg

Transmit

[destcomp = (#dest sdbmsg)]